POSIX: Remove use of deprecated gettimeofday

POSIX.1-2008 deprecated gettimeofday, which we used as a fallback if the
monotonic clock was unavailable.

This replaces that fallback with the non-monotonic real-time clock.

Because of the Gordian knot of feature test macros across Unices, this
also includes the shift from some platform source files defining
_POSIX_C_SOURCE to various values to _DEFAULT_SOURCE being defined for
all source files on Linux.  This is because -std=c99 on Linux disables
_DEFAULT_SOURCE (POSIX 2008 and extensions).

Once runtime platform selection comes in, this kind of platform-specific
preprocessor logic can be moved into the platform glue files and won't
need to be replicated by third-party build setups, but for now, sorry.
This commit is contained in:
Camilla Löwy
2021-06-21 22:14:40 +02:00
parent 58b48a3a00
commit 111c02d74e
6 changed files with 22 additions and 39 deletions
+7
View File
@@ -190,6 +190,13 @@ if (MSVC90)
endif()
endif()
# Workaround for -std=c99 on Linux disabling _DEFAULT_SOURCE (POSIX 2008 and more)
if (_GLFW_X11 OR _GLFW_WAYLAND OR _GLFW_OSMESA)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_compile_definitions(glfw PRIVATE _DEFAULT_SOURCE)
endif()
endif()
if (BUILD_SHARED_LIBS)
if (WIN32)
if (MINGW)