aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreyVK_D3D <geecandrey@gmail.com>2025-09-09 20:49:33 +0300
committerSpencer Fricke <115671160+spencer-lunarg@users.noreply.github.com>2025-12-15 17:52:08 -0500
commit1e62683bc7b7a46895843b6d67f72cb56b4ba42f (patch)
treee2a8a3a539eeb109f8091410a947248649610aa3
parented33199cca325fe3fec3d667d4556dda27356ba0 (diff)
downloadusermoji-1e62683bc7b7a46895843b6d67f72cb56b4ba42f.tar.xz
Use the clock_gettime() function instead of the obsolescent gettimeofday() function.
clock_gettime() can be used for macos since MacOS 10.12 Sierra, instaead of instead of the obsolescent gettimeofday() function. see POSIX documenation https://pubs.opengroup.org/onlinepubs/9699919799/functions/gettimeofday.html
-rw-r--r--cube/gettime.h13
1 files changed, 2 insertions, 11 deletions
diff --git a/cube/gettime.h b/cube/gettime.h
index 5eae98fd..0a697b42 100644
--- a/cube/gettime.h
+++ b/cube/gettime.h
@@ -26,14 +26,10 @@
#include <windows.h>
-#elif defined(__unix__) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__ANDROID__) || defined(__EPOC32__) || defined(__QNX__)
+#elif defined(__unix__) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__ANDROID__) || defined(__EPOC32__) || defined(__QNX__) || defined(__APPLE__)
#include <time.h>
-#elif defined(__APPLE__)
-
-#include <sys/time.h>
-
#endif
uint64_t getTimeInNanoseconds(void) {
@@ -55,7 +51,7 @@ uint64_t getTimeInNanoseconds(void) {
return count.QuadPart / (freq.QuadPart / ns_in_s);
}
-#elif defined(__unix__) || defined(__linux) || defined(__linux__) || defined(__ANDROID__) || defined(__QNX__)
+#elif defined(__unix__) || defined(__linux) || defined(__linux__) || defined(__ANDROID__) || defined(__QNX__) || defined(__APPLE__)
struct timespec currTime;
clock_gettime(CLOCK_MONOTONIC, &currTime);
return (uint64_t)currTime.tv_sec * ns_in_s + (uint64_t)currTime.tv_nsec;
@@ -66,11 +62,6 @@ uint64_t getTimeInNanoseconds(void) {
clock_gettime(CLOCK_REALTIME, &currTime);
return (uint64_t)currTime.tv_sec * ns_in_s + (uint64_t)currTime.tv_nsec;
-#elif defined(__APPLE__)
- struct timeval currTime;
- gettimeofday(&currTime, NULL);
- return (uint64_t)currTime.tv_sec * ns_in_s + (uint64_t)currTime.tv_usec * ns_in_us;
-
#else
#error getTimeInNanoseconds Not implemented for target OS
#endif