|
@@ -48,6 +48,15 @@
|
|
#include <mach/mach_time.h>
|
|
#include <mach/mach_time.h>
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+/* Use CLOCK_MONOTONIC_RAW, if available, which is not subject to adjustment by NTP */
|
|
|
|
+#if HAVE_CLOCK_GETTIME
|
|
|
|
+#ifdef CLOCK_MONOTONIC_RAW
|
|
|
|
+#define SDL_MONOTONIC_CLOCK CLOCK_MONOTONIC_RAW
|
|
|
|
+#else
|
|
|
|
+#define SDL_MONOTONIC_CLOCK CLOCK_MONOTONIC
|
|
|
|
+#endif
|
|
|
|
+#endif
|
|
|
|
+
|
|
/* The first ticks value of the application */
|
|
/* The first ticks value of the application */
|
|
#if HAVE_CLOCK_GETTIME
|
|
#if HAVE_CLOCK_GETTIME
|
|
static struct timespec start_ts;
|
|
static struct timespec start_ts;
|
|
@@ -69,7 +78,7 @@ SDL_TicksInit(void)
|
|
|
|
|
|
/* Set first ticks value */
|
|
/* Set first ticks value */
|
|
#if HAVE_CLOCK_GETTIME
|
|
#if HAVE_CLOCK_GETTIME
|
|
- if (clock_gettime(CLOCK_MONOTONIC, &start_ts) == 0) {
|
|
|
|
|
|
+ if (clock_gettime(SDL_MONOTONIC_CLOCK, &start_ts) == 0) {
|
|
has_monotonic_time = SDL_TRUE;
|
|
has_monotonic_time = SDL_TRUE;
|
|
} else
|
|
} else
|
|
#elif defined(__APPLE__)
|
|
#elif defined(__APPLE__)
|
|
@@ -101,7 +110,7 @@ SDL_GetTicks(void)
|
|
if (has_monotonic_time) {
|
|
if (has_monotonic_time) {
|
|
#if HAVE_CLOCK_GETTIME
|
|
#if HAVE_CLOCK_GETTIME
|
|
struct timespec now;
|
|
struct timespec now;
|
|
- clock_gettime(CLOCK_MONOTONIC, &now);
|
|
|
|
|
|
+ clock_gettime(SDL_MONOTONIC_CLOCK, &now);
|
|
ticks = (now.tv_sec - start_ts.tv_sec) * 1000 + (now.tv_nsec -
|
|
ticks = (now.tv_sec - start_ts.tv_sec) * 1000 + (now.tv_nsec -
|
|
start_ts.tv_nsec) / 1000000;
|
|
start_ts.tv_nsec) / 1000000;
|
|
#elif defined(__APPLE__)
|
|
#elif defined(__APPLE__)
|
|
@@ -132,7 +141,7 @@ SDL_GetPerformanceCounter(void)
|
|
#if HAVE_CLOCK_GETTIME
|
|
#if HAVE_CLOCK_GETTIME
|
|
struct timespec now;
|
|
struct timespec now;
|
|
|
|
|
|
- clock_gettime(CLOCK_MONOTONIC, &now);
|
|
|
|
|
|
+ clock_gettime(SDL_MONOTONIC_CLOCK, &now);
|
|
ticks = now.tv_sec;
|
|
ticks = now.tv_sec;
|
|
ticks *= 1000000000;
|
|
ticks *= 1000000000;
|
|
ticks += now.tv_nsec;
|
|
ticks += now.tv_nsec;
|