Use clock_gettime on macOS

Is a Posix function and available on macOS since version 10.12, has better
granularity than gettimeofday. Add missing header <time.h> where
clock_gettime is specified.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser 2025-07-16 11:32:18 +02:00
parent a03268ebae
commit 2e6f62dcf9
No known key found for this signature in database

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2024 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -43,6 +43,7 @@
#endif
#if OS_UNIX
# include <unistd.h>
# include <time.h>
#endif
#if OS_UNIX || OS_WIN
@ -51,7 +52,7 @@
# define HAVE_GETTIMEOFDAY 0
#endif
#if (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0)
#if (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) || OS_MACOSX
# define HAVE_CLOCK_GETTIME 1
#else
# define HAVE_CLOCK_GETTIME 0