From 29cd880ab5d5e3f8ebf31da1204037c81dab2489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 16 Feb 2026 15:07:18 +0100 Subject: [PATCH] macOS: Clarify separation between Cocoa and macOS The timer code uses no part of Cocoa and is in turn used by other backends than Cocoa on macOS. The macOS timer code is now labeled macOS. Cocoa-specific files are now consistently labeled Cocoa, not macOS. --- src/CMakeLists.txt | 2 +- src/cocoa_init.m | 2 +- src/cocoa_monitor.m | 2 +- src/cocoa_platform.h | 2 +- src/cocoa_window.m | 2 +- src/{cocoa_time.c => macos_time.c} | 8 ++++---- src/{cocoa_time.h => macos_time.h} | 8 ++++---- src/platform.h | 10 +++++----- 8 files changed, 18 insertions(+), 18 deletions(-) rename src/{cocoa_time.c => macos_time.c} (90%) rename src/{cocoa_time.h => macos_time.h} (89%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2cbe8a73..942e2799 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,7 +10,7 @@ add_library(glfw ${GLFW_LIBRARY_TYPE} # The time, thread and module code is shared between all backends on a given OS, # including the null backend, which still needs those bits to be functional if (APPLE) - target_sources(glfw PRIVATE cocoa_time.h cocoa_time.c posix_thread.h + target_sources(glfw PRIVATE macos_time.h macos_time.c posix_thread.h posix_module.c posix_thread.c) elseif (WIN32) target_sources(glfw PRIVATE win32_time.h win32_thread.h win32_module.c diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 531d8b45..4b2094ca 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.5 macOS - www.glfw.org +// GLFW 3.5 Cocoa - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 6495e1f3..620a8cfb 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.5 macOS - www.glfw.org +// GLFW 3.5 Cocoa - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 4d1d66ae..a25d1b2b 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.5 macOS - www.glfw.org +// GLFW 3.5 Cocoa - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 2bff22a6..1769f79b 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.5 macOS - www.glfw.org +// GLFW 3.5 Cocoa - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // diff --git a/src/cocoa_time.c b/src/macos_time.c similarity index 90% rename from src/cocoa_time.c rename to src/macos_time.c index a153edb3..c66ea3c9 100644 --- a/src/cocoa_time.c +++ b/src/macos_time.c @@ -26,7 +26,7 @@ #include "internal.h" -#if defined(GLFW_BUILD_COCOA_TIMER) +#if defined(GLFW_BUILD_MACOS_TIMER) #include @@ -40,7 +40,7 @@ void _glfwPlatformInitTimer(void) mach_timebase_info_data_t info; mach_timebase_info(&info); - _glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer; + _glfw.timer.macos.frequency = (info.denom * 1e9) / info.numer; } uint64_t _glfwPlatformGetTimerValue(void) @@ -50,8 +50,8 @@ uint64_t _glfwPlatformGetTimerValue(void) uint64_t _glfwPlatformGetTimerFrequency(void) { - return _glfw.timer.ns.frequency; + return _glfw.timer.macos.frequency; } -#endif // GLFW_BUILD_COCOA_TIMER +#endif // GLFW_BUILD_MACOS_TIMER diff --git a/src/cocoa_time.h b/src/macos_time.h similarity index 89% rename from src/cocoa_time.h rename to src/macos_time.h index 8463cbb6..77bf119a 100644 --- a/src/cocoa_time.h +++ b/src/macos_time.h @@ -24,12 +24,12 @@ // //======================================================================== -#define GLFW_COCOA_LIBRARY_TIMER_STATE _GLFWtimerNS ns; +#define GLFW_MACOS_LIBRARY_TIMER_STATE _GLFWtimerMacOS macos; -// Cocoa-specific global timer data +// macOS-specific global timer data // -typedef struct _GLFWtimerNS +typedef struct _GLFWtimerMacOS { uint64_t frequency; -} _GLFWtimerNS; +} _GLFWtimerMacOS; diff --git a/src/platform.h b/src/platform.h index 7ce4e015..e196e387 100644 --- a/src/platform.h +++ b/src/platform.h @@ -28,7 +28,7 @@ #if defined(GLFW_BUILD_WIN32_TIMER) || \ defined(GLFW_BUILD_WIN32_MODULE) || \ defined(GLFW_BUILD_WIN32_THREAD) || \ - defined(GLFW_BUILD_COCOA_TIMER) || \ + defined(GLFW_BUILD_MACOS_TIMER) || \ defined(GLFW_BUILD_POSIX_TIMER) || \ defined(GLFW_BUILD_POSIX_MODULE) || \ defined(GLFW_BUILD_POSIX_THREAD) || \ @@ -184,7 +184,7 @@ #if defined(_WIN32) #define GLFW_BUILD_WIN32_TIMER #elif defined(__APPLE__) - #define GLFW_BUILD_COCOA_TIMER + #define GLFW_BUILD_MACOS_TIMER #else #define GLFW_BUILD_POSIX_TIMER #endif @@ -192,9 +192,9 @@ #if defined(GLFW_BUILD_WIN32_TIMER) #include "win32_time.h" #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_WIN32_LIBRARY_TIMER_STATE -#elif defined(GLFW_BUILD_COCOA_TIMER) - #include "cocoa_time.h" - #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_COCOA_LIBRARY_TIMER_STATE +#elif defined(GLFW_BUILD_MACOS_TIMER) + #include "macos_time.h" + #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_MACOS_LIBRARY_TIMER_STATE #elif defined(GLFW_BUILD_POSIX_TIMER) #include "posix_time.h" #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_POSIX_LIBRARY_TIMER_STATE