MCPcopy Create free account
hub / github.com/ValveSoftware/GameNetworkingSockets / Plat_RelativeTicks

Function Plat_RelativeTicks

src/tier0/platformtime.cpp:86–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86uint64 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
121double Plat_FloatTime()
122{

Callers 2

Plat_FloatTimeFunction · 0.85
Plat_USTimeFunction · 0.85

Calls 1

InitTicksFunction · 0.85

Tested by

no test coverage detected