| 84 | } |
| 85 | |
| 86 | uint64 Plat_RelativeTicks() |
| 87 | { |
| 88 | if ( g_TickBase == 0 ) |
| 89 | InitTicks(); |
| 90 | |
| 91 | uint64 Ticks; |
| 92 | |
| 93 | #if defined(_WIN32) |
| 94 | LARGE_INTEGER Large; |
| 95 | QueryPerformanceCounter(&Large); |
| 96 | Ticks = Large.QuadPart; |
| 97 | // On WinXP w/ multi-core CPU, ticks can go slightly backwards. Fixed in Vista+ |
| 98 | if ( Ticks < g_TickLastReturned_XPWorkaround ) |
| 99 | { |
| 100 | Ticks = g_TickLastReturned_XPWorkaround; |
| 101 | } |
| 102 | else |
| 103 | { |
| 104 | g_TickLastReturned_XPWorkaround = Ticks; |
| 105 | } |
| 106 | #elif IsOSX() |
| 107 | Ticks = mach_absolute_time(); |
| 108 | #elif IsNintendoSwitch() |
| 109 | Ticks = PlatformTime_GetRawTickCounter(); |
| 110 | #elif IsPosix() |
| 111 | timespec TimeSpec; |
| 112 | clock_gettime( CLOCK_MONOTONIC, &TimeSpec ); |
| 113 | Ticks = (uint64)TimeSpec.tv_sec * 1000000000 + TimeSpec.tv_nsec; |
| 114 | #else |
| 115 | #error Unknown platform |
| 116 | #endif |
| 117 | |
| 118 | return Ticks; |
| 119 | } |
| 120 | |
| 121 | double Plat_FloatTime() |
| 122 | { |
no test coverage detected