From 226c17f02d8fc9d1096d880d17d876971b9e4bb4 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Mon, 13 May 2024 11:03:36 +0200 Subject: [PATCH] replace all other AC-defined platform macro 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. --- configure.ac | 1 + src/blackmagic_common.cpp | 4 ++-- src/compat/platform_semaphore.c | 20 ++++++++++---------- src/compat/platform_semaphore.h | 4 ++-- src/deltacast_common.hpp | 4 ++-- src/gl_context.c | 16 ++++++++-------- src/gl_context.h | 2 +- src/pdb.c | 2 +- src/pixfmt_conv.c | 4 ++-- src/video_capture/import.c | 2 +- src/video_decompress/libavcodec.c | 2 +- src/video_display/gl_vdpau.hpp | 4 ++-- src/video_display/opengl_utils.hpp | 6 +++--- src/video_display/openxr_gl.cpp | 6 +++--- src/video_display/sage.cpp | 2 +- src/video_display/sdl.cpp | 16 ++++++++-------- src/video_display/sdl_window.cpp | 8 ++++---- src/video_display/sdl_window.hpp | 10 +++++----- src/video_rxtx/rtp.cpp | 6 +++--- src/video_rxtx/rtp.hpp | 2 +- 20 files changed, 61 insertions(+), 60 deletions(-) diff --git a/configure.ac b/configure.ac index 7576642bc8..7590ac00fb 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/src/blackmagic_common.cpp b/src/blackmagic_common.cpp index a2e5589450..0924a3cd17 100644 --- a/src/blackmagic_common.cpp +++ b/src/blackmagic_common.cpp @@ -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); @@ -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); diff --git a/src/compat/platform_semaphore.c b/src/compat/platform_semaphore.c index 740c67ffb6..d223bd37bc 100644 --- a/src/compat/platform_semaphore.c +++ b/src/compat/platform_semaphore.c @@ -54,19 +54,19 @@ #include "debug.h" -#ifdef HAVE_MACOSX +#ifdef __APPLE__ #include #include #include #else #include -#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); @@ -75,21 +75,21 @@ 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; @@ -97,15 +97,15 @@ void platform_sem_wait(void *semStructure) 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__ */ } diff --git a/src/compat/platform_semaphore.h b/src/compat/platform_semaphore.h index 1c71ded7dd..2c1227137b 100644 --- a/src/compat/platform_semaphore.h +++ b/src/compat/platform_semaphore.h @@ -53,14 +53,14 @@ #ifndef _PLATFORM_SEMAPHORE_H #define _PLATFORM_SEMAPHORE_H -#ifdef HAVE_MACOSX +#ifdef __APPLE__ #include #include typedef semaphore_t sem_t; #else #include -#endif /* HAVE_MACOSX */ +#endif /* __APPLE__ */ #ifdef __cplusplus extern "C" { diff --git a/src/deltacast_common.hpp b/src/deltacast_common.hpp index 9bd27a47d1..d46553bb68 100644 --- a/src/deltacast_common.hpp +++ b/src/deltacast_common.hpp @@ -42,7 +42,7 @@ #include #include #include -#ifdef HAVE_MACOSX +#ifdef __APPLE__ #include #ifdef ENUMBASE_DV #include @@ -79,7 +79,7 @@ #define DELTA_DVI_DEPRECATED 1 #endif -#ifdef HAVE_MACOSX +#ifdef __APPLE__ #include #else #include diff --git a/src/gl_context.c b/src/gl_context.c index b5c8df3c60..42c2e899ad 100644 --- a/src/gl_context.c +++ b/src/gl_context.c @@ -43,9 +43,9 @@ #include -#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 @@ -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)); @@ -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"); @@ -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); @@ -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); diff --git a/src/gl_context.h b/src/gl_context.h index fd426468d2..302e4f5ad6 100644 --- a/src/gl_context.h +++ b/src/gl_context.h @@ -42,7 +42,7 @@ #include #else #include -#endif /* HAVE_LINUX */ +#endif /* __linux__ */ #ifdef __APPLE__ #include diff --git a/src/pdb.c b/src/pdb.c index 086b66891f..0e352c1577 100644 --- a/src/pdb.c +++ b/src/pdb.c @@ -97,7 +97,7 @@ struct pdb { #ifdef DEBUG static -#ifndef HAVE_MACOSX +#ifndef __APPLE__ __thread #endif int pdb_count; diff --git a/src/pixfmt_conv.c b/src/pixfmt_conv.c index e10f62f386..5d2ad7c128 100644 --- a/src/pixfmt_conv.c +++ b/src/pixfmt_conv.c @@ -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) { @@ -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 diff --git a/src/video_capture/import.c b/src/video_capture/import.c index 348e7a3557..30ed3a332f 100644 --- a/src/video_capture/import.c +++ b/src/video_capture/import.c @@ -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 } diff --git a/src/video_decompress/libavcodec.c b/src/video_decompress/libavcodec.c index 35f81e7cb5..aacd4c240f 100644 --- a/src/video_decompress/libavcodec.c +++ b/src/video_decompress/libavcodec.c @@ -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) diff --git a/src/video_display/gl_vdpau.hpp b/src/video_display/gl_vdpau.hpp index 085cd76630..d46bf20f56 100644 --- a/src/video_display/gl_vdpau.hpp +++ b/src/video_display/gl_vdpau.hpp @@ -3,13 +3,13 @@ #ifdef HWACC_VDPAU -#ifdef HAVE_MACOSX +#ifdef __APPLE__ #include #include // CGL #include #else #include -#endif /* HAVE_MACOSX */ +#endif /* __APPLE__ */ #include "hwaccel_vdpau.h" typedef GLintptr vdpauSurfaceNV; diff --git a/src/video_display/opengl_utils.hpp b/src/video_display/opengl_utils.hpp index 1298d6aea7..d386672447 100644 --- a/src/video_display/opengl_utils.hpp +++ b/src/video_display/opengl_utils.hpp @@ -41,17 +41,17 @@ # include "config.h" #endif //HAVE_CONFIG_H -#ifdef HAVE_MACOSX +#ifdef __APPLE__ # include // CGL # include # include -#elif defined HAVE_LINUX +#elif defined __linux__ # include # include # include #else // _WIN32 # include -#endif //HAVE_MACOSX +#endif //__APPLE__ #include //#include diff --git a/src/video_display/openxr_gl.cpp b/src/video_display/openxr_gl.cpp index abc0dfd4a4..ccde9ab0b6 100644 --- a/src/video_display/openxr_gl.cpp +++ b/src/video_display/openxr_gl.cpp @@ -47,7 +47,7 @@ #include #include -#ifdef HAVE_LINUX +#ifdef __linux__ # include # include # include @@ -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; @@ -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 config_views = get_views(s->xr_state); diff --git a/src/video_display/sage.cpp b/src/video_display/sage.cpp index 2e63294d0e..b9e0ec90de 100644 --- a/src/video_display/sage.cpp +++ b/src/video_display/sage.cpp @@ -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"); diff --git a/src/video_display/sdl.cpp b/src/video_display/sdl.cpp index f68b077e68..fb219c2a70 100644 --- a/src/video_display/sdl.cpp +++ b/src/video_display/sdl.cpp @@ -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 @@ -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; @@ -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) @@ -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 */ @@ -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) { @@ -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 diff --git a/src/video_display/sdl_window.cpp b/src/video_display/sdl_window.cpp index e51d7af94f..2a29971ba4 100644 --- a/src/video_display/sdl_window.cpp +++ b/src/video_display/sdl_window.cpp @@ -76,13 +76,13 @@ Sdl_window::Sdl_window(const char *title, throw std::runtime_error("Failed to create gl context!"); } -#ifndef HAVE_MACOSX +#ifndef __APPLE__ glewExperimental = GL_TRUE; GLenum glewError = glewInit(); if(glewError != GLEW_OK){ throw std::runtime_error("Failed to initialize gl context!"); } -#endif //HAVE_MACOSX +#endif //__APPLE__ glClearColor(0,0,0,1); glClear(GL_COLOR_BUFFER_BIT); @@ -96,7 +96,7 @@ Sdl_window::~Sdl_window(){ SDL_QuitSubSystem(SDL_INIT_VIDEO); } -#ifdef HAVE_LINUX +#ifdef __linux__ void Sdl_window::getXlibHandles(Display **xDisplay, GLXContext *glxContext, GLXDrawable *glxDrawable) @@ -106,7 +106,7 @@ void Sdl_window::getXlibHandles(Display **xDisplay, *glxContext = glXGetCurrentContext(); *glxDrawable = glXGetCurrentDrawable(); } -#endif //HAVE_LINUX +#endif // defined __linux__ void Sdl_window::make_render_context_current(){ SDL_GL_MakeCurrent(sdl_window, sdl_gl_context); diff --git a/src/video_display/sdl_window.hpp b/src/video_display/sdl_window.hpp index 9641197bb0..1886be5b1d 100644 --- a/src/video_display/sdl_window.hpp +++ b/src/video_display/sdl_window.hpp @@ -41,17 +41,17 @@ # include "config.h" #endif //HAVE_CONFIG_H -#ifdef HAVE_MACOSX +#ifdef __APPLE__ # include // CGL # include # include -#elif defined HAVE_LINUX +#elif defined __linux__ # include # include # include #else // _WIN32 # include -#endif //HAVE_MACOSX +#endif //__APPLE__ @@ -95,14 +95,14 @@ struct Sdl_window{ Sdl_window& operator=(const Sdl_window&) = delete; Sdl_window& operator=(Sdl_window&& o) { swap(o); return *this; } -#ifdef HAVE_LINUX +#ifdef __linux__ /** * Used to obtain Xlib window handles */ void getXlibHandles(Display **xDisplay, GLXContext *glxContext, GLXDrawable *glxDrawable); -#endif //HAVE_LINUX +#endif // defined __linux__ /** * Sets window title diff --git a/src/video_rxtx/rtp.cpp b/src/video_rxtx/rtp.cpp index 9ecd9bc9ce..c164962206 100644 --- a/src/video_rxtx/rtp.cpp +++ b/src/video_rxtx/rtp.cpp @@ -247,7 +247,7 @@ void rtp_video_rxtx::display_buf_increase_warning(int size) #else "Please set net.core.rmem_max value to %d or greater (see also\n" "https://github.com/CESNET/UltraGrid/wiki/OS-Setup-UltraGrid):\n" -#ifdef HAVE_MACOSX +#ifdef __APPLE__ "\tsysctl -w kern.ipc.maxsockbuf=%d\n" "\tsysctl -w net.inet.udp.recvspace=%d\n" #else @@ -256,9 +256,9 @@ void rtp_video_rxtx::display_buf_increase_warning(int size) "To make this persistent, add these options (key=value) to /etc/sysctl.conf\n" "\n***\n\n", size, size, -#ifdef HAVE_MACOSX +#ifdef __APPLE__ size * 4, -#endif /* HAVE_MACOSX */ +#endif /* __APPLE__ */ #endif /* ! defined _WIN32 */ size); diff --git a/src/video_rxtx/rtp.hpp b/src/video_rxtx/rtp.hpp index 0b19d41a6b..6c0a65e28d 100644 --- a/src/video_rxtx/rtp.hpp +++ b/src/video_rxtx/rtp.hpp @@ -44,7 +44,7 @@ #include #include -#ifdef HAVE_MACOSX +#ifdef __APPLE__ #define INITIAL_VIDEO_RECV_BUFFER_SIZE 5944320 #else #define INITIAL_VIDEO_RECV_BUFFER_SIZE ((4*1920*1080)*110/100)