From 72642ea0d1f3ad75f503bd90b9ba740a274e0422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 9 Nov 2021 19:41:34 +0100 Subject: [PATCH] Simplify struct stitching for sync primitives There will not currently be more than one set of threading or timer APIs selected regardless of how many window systems are enabled, so there is no need for this extra complexity. --- src/platform.h | 58 ++++++++++++++++++-------------------------------- 1 file changed, 21 insertions(+), 37 deletions(-) diff --git a/src/platform.h b/src/platform.h index cc842eb8..0c593676 100644 --- a/src/platform.h +++ b/src/platform.h @@ -92,30 +92,6 @@ #define GLFW_LINUX_LIBRARY_JOYSTICK_STATE #endif -#if defined(_WIN32) - #include "win32_thread.h" - #define GLFW_POSIX_TLS_STATE - #define GLFW_POSIX_MUTEX_STATE -#else - #include "posix_thread.h" - #define GLFW_WIN32_TLS_STATE - #define GLFW_WIN32_MUTEX_STATE -#endif - -#if defined(_WIN32) - #include "win32_time.h" - #define GLFW_POSIX_LIBRARY_TIMER_STATE - #define GLFW_COCOA_LIBRARY_TIMER_STATE -#elif defined(__APPLE__) - #include "cocoa_time.h" - #define GLFW_WIN32_LIBRARY_TIMER_STATE - #define GLFW_POSIX_LIBRARY_TIMER_STATE -#else - #include "posix_time.h" - #define GLFW_WIN32_LIBRARY_TIMER_STATE - #define GLFW_COCOA_LIBRARY_TIMER_STATE -#endif - #define GLFW_PLATFORM_WINDOW_STATE \ GLFW_WIN32_WINDOW_STATE \ GLFW_COCOA_WINDOW_STATE \ @@ -142,14 +118,6 @@ GLFW_COCOA_JOYSTICK_STATE \ GLFW_LINUX_JOYSTICK_STATE -#define GLFW_PLATFORM_TLS_STATE \ - GLFW_WIN32_TLS_STATE \ - GLFW_POSIX_TLS_STATE \ - -#define GLFW_PLATFORM_MUTEX_STATE \ - GLFW_WIN32_MUTEX_STATE \ - GLFW_POSIX_MUTEX_STATE \ - #define GLFW_PLATFORM_LIBRARY_WINDOW_STATE \ GLFW_WIN32_LIBRARY_WINDOW_STATE \ GLFW_COCOA_LIBRARY_WINDOW_STATE \ @@ -162,11 +130,6 @@ GLFW_COCOA_LIBRARY_JOYSTICK_STATE \ GLFW_LINUX_LIBRARY_JOYSTICK_STATE -#define GLFW_PLATFORM_LIBRARY_TIMER_STATE \ - GLFW_WIN32_LIBRARY_TIMER_STATE \ - GLFW_COCOA_LIBRARY_TIMER_STATE \ - GLFW_POSIX_LIBRARY_TIMER_STATE \ - #define GLFW_PLATFORM_CONTEXT_STATE \ GLFW_WGL_CONTEXT_STATE \ GLFW_NSGL_CONTEXT_STATE \ @@ -177,3 +140,24 @@ GLFW_NSGL_LIBRARY_CONTEXT_STATE \ GLFW_GLX_LIBRARY_CONTEXT_STATE +#if defined(_WIN32) + #include "win32_thread.h" + #define GLFW_PLATFORM_TLS_STATE GLFW_WIN32_TLS_STATE + #define GLFW_PLATFORM_MUTEX_STATE GLFW_WIN32_MUTEX_STATE +#else + #include "posix_thread.h" + #define GLFW_PLATFORM_TLS_STATE GLFW_POSIX_TLS_STATE + #define GLFW_PLATFORM_MUTEX_STATE GLFW_POSIX_MUTEX_STATE +#endif + +#if defined(_WIN32) + #include "win32_time.h" + #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_WIN32_LIBRARY_TIMER_STATE +#elif defined(__APPLE__) + #include "cocoa_time.h" + #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_COCOA_LIBRARY_TIMER_STATE +#else + #include "posix_time.h" + #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_POSIX_LIBRARY_TIMER_STATE +#endif +