|
@@ -27,13 +27,10 @@
|
|
// It is fine to use C99 in this file because it will not be built with VS
|
|
// It is fine to use C99 in this file because it will not be built with VS
|
|
//========================================================================
|
|
//========================================================================
|
|
|
|
|
|
-#define _POSIX_C_SOURCE 199309L
|
|
|
|
-
|
|
|
|
#include "internal.h"
|
|
#include "internal.h"
|
|
|
|
|
|
#include <unistd.h>
|
|
#include <unistd.h>
|
|
#include <sys/time.h>
|
|
#include <sys/time.h>
|
|
-#include <time.h>
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////
|
|
@@ -44,20 +41,14 @@
|
|
//
|
|
//
|
|
void _glfwInitTimerPOSIX(void)
|
|
void _glfwInitTimerPOSIX(void)
|
|
{
|
|
{
|
|
-#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
|
|
|
|
- struct timespec ts;
|
|
|
|
|
|
+ _glfw.timer.posix.clock = CLOCK_REALTIME;
|
|
|
|
+ _glfw.timer.posix.frequency = 1000000000;
|
|
|
|
|
|
|
|
+#if defined(_POSIX_MONOTONIC_CLOCK)
|
|
|
|
+ struct timespec ts;
|
|
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
|
|
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
|
|
- {
|
|
|
|
- _glfw.timer.posix.monotonic = GLFW_TRUE;
|
|
|
|
- _glfw.timer.posix.frequency = 1000000000;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
|
|
+ _glfw.timer.posix.clock = CLOCK_MONOTONIC;
|
|
#endif
|
|
#endif
|
|
- {
|
|
|
|
- _glfw.timer.posix.monotonic = GLFW_FALSE;
|
|
|
|
- _glfw.timer.posix.frequency = 1000000;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -67,20 +58,9 @@ void _glfwInitTimerPOSIX(void)
|
|
|
|
|
|
uint64_t _glfwPlatformGetTimerValue(void)
|
|
uint64_t _glfwPlatformGetTimerValue(void)
|
|
{
|
|
{
|
|
-#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
|
|
|
|
- if (_glfw.timer.posix.monotonic)
|
|
|
|
- {
|
|
|
|
- struct timespec ts;
|
|
|
|
- clock_gettime(CLOCK_MONOTONIC, &ts);
|
|
|
|
- return (uint64_t) ts.tv_sec * (uint64_t) 1000000000 + (uint64_t) ts.tv_nsec;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
-#endif
|
|
|
|
- {
|
|
|
|
- struct timeval tv;
|
|
|
|
- gettimeofday(&tv, NULL);
|
|
|
|
- return (uint64_t) tv.tv_sec * (uint64_t) 1000000 + (uint64_t) tv.tv_usec;
|
|
|
|
- }
|
|
|
|
|
|
+ struct timespec ts;
|
|
|
|
+ clock_gettime(_glfw.timer.posix.clock, &ts);
|
|
|
|
+ return (uint64_t) ts.tv_sec * (uint64_t) 1000000000 + (uint64_t) ts.tv_nsec;
|
|
}
|
|
}
|
|
|
|
|
|
uint64_t _glfwPlatformGetTimerFrequency(void)
|
|
uint64_t _glfwPlatformGetTimerFrequency(void)
|