Skip to content

Commit

Permalink
replace all other AC-defined platform macro
Browse files Browse the repository at this point in the history
Replaced all other autoconf-defined platform macros (HAVE_LINUX and
HAVE_MACOSX, WIN32 already done) with those ones defined by compiler.

Not yet remove the definitions from autoconf, in case someone will use
the old macros anyways. Remove in future.
  • Loading branch information
MartinPulec committed May 13, 2024
1 parent 56a6dc7 commit 226c17f
Show file tree
Hide file tree
Showing 20 changed files with 61 additions and 60 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ then
fi
fi

# TODO: remove plaform macros definitions
AC_MSG_CHECKING([OS family])
if test "$host_vendor" = "apple"; then
system=MacOSX
Expand Down
4 changes: 2 additions & 2 deletions src/blackmagic_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ char *get_cstr_from_bmd_api_str(BMD_STR bmd_string)
return strdup("(NULL!)");
}
char *cstr;
#ifdef HAVE_MACOSX
#ifdef __APPLE__
size_t len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(bmd_string), kCFStringEncodingUTF8) + 1;
cstr = (char *) malloc(len);
CFStringGetCString(bmd_string, (char *) cstr, len, kCFStringEncodingUTF8);
Expand Down Expand Up @@ -139,7 +139,7 @@ void release_bmd_api_str(BMD_STR string)
if (!string) {
return;
}
#ifdef HAVE_MACOSX
#ifdef __APPLE__
CFRelease(string);
#elif defined _WIN32
SysFreeString(string);
Expand Down
20 changes: 10 additions & 10 deletions src/compat/platform_semaphore.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@

#include "debug.h"

#ifdef HAVE_MACOSX
#ifdef __APPLE__
#include <mach/semaphore.h>
#include <mach/task.h>
#include <mach/mach.h>
#else
#include <semaphore.h>
#endif /* HAVE_MACOSX */
#endif /* __APPLE__ */

#include "compat/platform_semaphore.h"

void platform_sem_init(void *semStructure, int pshared, int initialValue)
{
#ifdef HAVE_MACOSX
#ifdef __APPLE__
UNUSED(pshared);
semaphore_create(mach_task_self(), (semaphore_t *) semStructure,
SYNC_POLICY_FIFO, initialValue);
Expand All @@ -75,37 +75,37 @@ void platform_sem_init(void *semStructure, int pshared, int initialValue)
perror("sem_init");
abort();
}
#endif /* HAVE_MACOSX */
#endif /* __APPLE__ */
}

void platform_sem_post(void *semStructure)
{
#ifdef HAVE_MACOSX
#ifdef __APPLE__
semaphore_signal(*((semaphore_t *) semStructure));
#else
sem_post((sem_t *) semStructure);
#endif /* HAVE_MACOSX */
#endif /* __APPLE__ */
}

void platform_sem_wait(void *semStructure)
{
#ifdef HAVE_MACOSX
#ifdef __APPLE__
semaphore_wait(*((semaphore_t *) semStructure));
#else
int ret = 0;
while ((ret = sem_wait((sem_t *) semStructure)) == -1 && errno == EINTR) { }
if (ret == -1) {
perror("sem_wait");
}
#endif /* HAVE_MACOSX */
#endif /* __APPLE__ */
}

void platform_sem_destroy(void *semStructure)
{
#ifdef HAVE_MACOSX
#ifdef __APPLE__
semaphore_destroy(mach_task_self(), *(semaphore_t *) semStructure);
#else
sem_destroy((sem_t *) semStructure);
#endif /* HAVE_MACOSX */
#endif /* __APPLE__ */
}

4 changes: 2 additions & 2 deletions src/compat/platform_semaphore.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@
#ifndef _PLATFORM_SEMAPHORE_H
#define _PLATFORM_SEMAPHORE_H

#ifdef HAVE_MACOSX
#ifdef __APPLE__
#include <mach/semaphore.h>
#include <mach/task.h>

typedef semaphore_t sem_t;
#else
#include <semaphore.h>
#endif /* HAVE_MACOSX */
#endif /* __APPLE__ */

#ifdef __cplusplus
extern "C" {
Expand Down
4 changes: 2 additions & 2 deletions src/deltacast_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include <map>
#include <string>
#include <unordered_map>
#ifdef HAVE_MACOSX
#ifdef __APPLE__
#include <VideoMasterHD/VideoMasterHD_Core.h>
#ifdef ENUMBASE_DV
#include <VideoMasterHD/VideoMasterHD_Dv.h>
Expand Down Expand Up @@ -79,7 +79,7 @@
#define DELTA_DVI_DEPRECATED 1
#endif

#ifdef HAVE_MACOSX
#ifdef __APPLE__
#include <VideoMasterHD/VideoMasterHD_Ip_Board.h>
#else
#include <VideoMasterHD_Ip_Board.h>
Expand Down
16 changes: 8 additions & 8 deletions src/gl_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@

#include <stdio.h>

#ifdef HAVE_MACOSX
#ifdef __APPLE__
#include "mac_gl_common.h"
#elif defined HAVE_LINUX
#elif defined __linux__
#include "x11_common.h"
#include "glx_common.h"
#else // _WIN32
Expand All @@ -68,7 +68,7 @@
*/
bool init_gl_context(struct gl_context *context, int which) {
context->context = NULL;
#ifdef HAVE_LINUX
#ifdef __linux__
if(which == GL_CONTEXT_ANY) {
debug_msg("Trying OpenGL 3.1 first.\n");
context->context = glx_init(MK_OPENGL_VERSION(3,1));
Expand All @@ -84,7 +84,7 @@ bool init_gl_context(struct gl_context *context, int which) {
if(context->context) {
glx_validate(context->context);
}
#elif defined HAVE_MACOSX
#elif defined __APPLE__
if(which == GL_CONTEXT_ANY) {
if(get_mac_kernel_version_major() >= 11) {
debug_msg("Mac 10.7 or latter detected. Trying OpenGL 3.2 Core profile first.\n");
Expand Down Expand Up @@ -224,9 +224,9 @@ void destroy_gl_context(struct gl_context *context) {
if (context == NULL || context->context == NULL) {
return;
}
#ifdef HAVE_MACOSX
#ifdef __APPLE__
mac_gl_free(context->context);
#elif defined HAVE_LINUX
#elif defined __linux__
glx_free(context->context);
#else
win32_context_free(context->context);
Expand All @@ -239,9 +239,9 @@ void gl_context_make_current(struct gl_context *context)
if(context) {
context_state = context->context;
}
#ifdef HAVE_LINUX
#ifdef __linux__
glx_make_current(context_state);
#elif defined HAVE_MACOSX
#elif defined __APPLE__
mac_gl_make_current(context_state);
#else
win32_context_make_current(context_state);
Expand Down
2 changes: 1 addition & 1 deletion src/gl_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include <GL/glew.h>
#else
#include <OpenGL/GL.h>
#endif /* HAVE_LINUX */
#endif /* __linux__ */

#ifdef __APPLE__
#include <Availability.h>
Expand Down
2 changes: 1 addition & 1 deletion src/pdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ struct pdb {

#ifdef DEBUG
static
#ifndef HAVE_MACOSX
#ifndef __APPLE__
__thread
#endif
int pdb_count;
Expand Down
4 changes: 2 additions & 2 deletions src/pixfmt_conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ static void vc_copylineDVS10toV210(unsigned char * __restrict dst, const unsigne
/* convert 10bits Cb Y Cr A Y Cb Y A to 8bits Cb Y Cr Y Cb Y */

/* TODO: undo it - currently this decoder is broken */
#if 0 /* !(HAVE_MACOSX || HAVE_32B_LINUX) */
#if 0 /* !(__APPLE__ || HAVE_32B_LINUX) */

void vc_copylineDVS10(unsigned char *dst, unsigned char *src, int src_len)
{
Expand Down Expand Up @@ -690,7 +690,7 @@ static void vc_copylineDVS10(unsigned char * __restrict dst, const unsigned char
}
}

#endif /* !(HAVE_MACOSX || HAVE_32B_LINUX) */
#endif /* !(__APPLE__ || HAVE_32B_LINUX) */

/**
* @brief Changes color order of an RGB
Expand Down
2 changes: 1 addition & 1 deletion src/video_capture/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ static void *video_reader_callback(void *arg)
flags |= O_BINARY;
#endif
if (data->o_direct) {
#ifdef HAVE_LINUX
#ifdef __linux__
flags |= O_DIRECT;
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion src/video_decompress/libavcodec.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ static enum AVPixelFormat get_format_callback(struct AVCodecContext *s, const en
#ifdef HWACC_VAAPI
{AV_PIX_FMT_VAAPI, vaapi_init},
#endif
#ifdef HAVE_MACOSX
#ifdef __APPLE__
{AV_PIX_FMT_VIDEOTOOLBOX, videotoolbox_init},
#endif
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(55, 75, 100)
Expand Down
4 changes: 2 additions & 2 deletions src/video_display/gl_vdpau.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

#ifdef HWACC_VDPAU

#ifdef HAVE_MACOSX
#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/OpenGL.h> // CGL
#include <OpenGL/glext.h>
#else
#include <GL/glew.h>
#endif /* HAVE_MACOSX */
#endif /* __APPLE__ */

#include "hwaccel_vdpau.h"
typedef GLintptr vdpauSurfaceNV;
Expand Down
6 changes: 3 additions & 3 deletions src/video_display/opengl_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@
# include "config.h"
#endif //HAVE_CONFIG_H

#ifdef HAVE_MACOSX
#ifdef __APPLE__
# include <OpenGL/OpenGL.h> // CGL
# include <OpenGL/gl3.h>
# include <OpenGL/glext.h>
#elif defined HAVE_LINUX
#elif defined __linux__
# include <X11/Xlib.h>
# include <GL/glew.h>
# include <GL/glx.h>
#else // _WIN32
# include <GL/glew.h>
#endif //HAVE_MACOSX
#endif //__APPLE__

#include <SDL2/SDL.h>
//#include <SDL2/SDL_opengl.h>
Expand Down
6 changes: 3 additions & 3 deletions src/video_display/openxr_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include <queue>

#include <assert.h>
#ifdef HAVE_LINUX
#ifdef __linux__
# include <X11/Xlib.h>
# include <GL/glew.h>
# include <GL/glx.h>
Expand Down Expand Up @@ -617,7 +617,7 @@ static void display_xrgl_run(void *state){

std::thread worker_thread(worker, s);

#ifdef HAVE_LINUX
#ifdef __linux__
XrGraphicsBindingOpenGLXlibKHR graphics_binding_gl = {};
graphics_binding_gl.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_XLIB_KHR;
graphics_binding_gl.xDisplay = nullptr;
Expand Down Expand Up @@ -647,7 +647,7 @@ static void display_xrgl_run(void *state){
//TODO: Implement GL OpenXR binding for other platforms
log_msg(LOG_LEVEL_ERROR, "OpenXR and OpenGL binding not implemented on this platform!\n");
return;
#endif //HAVE_LINUX
#endif // defined __linux__

std::vector<XrViewConfigurationView> config_views = get_views(s->xr_state);

Expand Down
2 changes: 1 addition & 1 deletion src/video_display/sage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ static bool display_sage_putf(void *state, struct video_frame *frame, long long
pthread_mutex_unlock(&s->buffer_writable_lock);

sem_post(&s->semaphore);
#ifndef HAVE_MACOSX
#ifndef __APPLE__
sem_getvalue(&s->semaphore, &tmp);
if (tmp > 1)
printf("frame drop!\n");
Expand Down
16 changes: 8 additions & 8 deletions src/video_display/sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@
#include "utils/ring_buffer.h"
#include "video.h"

#ifdef HAVE_MACOSX
#ifdef __APPLE__
#include "utils/autorelease_pool.h"
extern "C" void NSApplicationLoad();
#elif defined HAVE_LINUX
#elif defined __linux__
#include "x11_common.h"
#endif /* HAVE_MACOSX */
#endif /* __APPLE__ */

#include <math.h>

Expand Down Expand Up @@ -109,7 +109,7 @@ struct state_sdl {
mutex lock;
condition_variable frame_consumed_cv;

#ifdef HAVE_MACOSX
#ifdef __APPLE__
void *autorelease_pool;
#endif
uint32_t sdl_flags_win, sdl_flags_fs;
Expand All @@ -121,7 +121,7 @@ struct state_sdl {
fixed_w(0), fixed_h(0),
screen_w(0), screen_h(0), audio_buffer(nullptr), audio_frame(), play_audio(false), buffered_frames_count(0),
current_desc(), current_display_desc(),
#ifdef HAVE_MACOSX
#ifdef __APPLE__
autorelease_pool(nullptr),
#endif
sdl_flags_win(0), sdl_flags_fs(0)
Expand Down Expand Up @@ -489,7 +489,7 @@ static void *display_sdl_init(struct module *parent, const char *fmt, unsigned i
free (tmp);
}

#ifdef HAVE_MACOSX
#ifdef __APPLE__
/* Startup function to call when running Cocoa code from a Carbon application.
* Whatever the fuck that means.
* Avoids uncaught exception (1002) when creating CGSWindow */
Expand All @@ -512,7 +512,7 @@ static void *display_sdl_init(struct module *parent, const char *fmt, unsigned i
SDL_SysWMinfo info;
memset(&info, 0, sizeof(SDL_SysWMinfo));
ret = SDL_GetWMInfo(&info);
#ifdef HAVE_LINUX
#ifdef __linux__
if (ret == 1) {
x11_set_display(info.info.x11.display);
} else if (ret == 0) {
Expand Down Expand Up @@ -569,7 +569,7 @@ static void display_sdl_done(void *state)

SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
SDL_Quit();
#ifdef HAVE_MACOSX
#ifdef __APPLE__
autorelease_pool_destroy(s->autorelease_pool);
#endif

Expand Down
Loading

0 comments on commit 226c17f

Please sign in to comment.