Skip to content

Commit

Permalink
backport high-resolution clock fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-cellier-aka-nice committed Jan 3, 2019
1 parent 87a2f3b commit e2cc141
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions platforms/minheadless/windows/sqWin32Heartbeat.c
Expand Up @@ -56,8 +56,23 @@ static DWORD timerID = 0;
sqLong
ioHighResClock(void) {
sqLong value = 0;
#ifdef __GNUC__
__asm__ __volatile__ ("rdtsc" : "=A" (value));

#if defined(__GNUC__) && (defined(i386) || defined(__i386) || defined(__i386__))
__asm__ __volatile__ ("rdtsc" : "=A"(value));
#elif defined(__GNUC__) && (defined(x86_64) || defined(__x86_64) || defined (__x86_64__))
__asm__ __volatile__ ("rdtsc\n\t" // Returns the time in EDX:EAX.
"shl $32, %%rdx\n\t" // Shift the upper bits left.
"or %%rdx, %0" // 'Or' in the lower bits.
: "=a" (value)
:
: "rdx");
#elif defined(_MSC_VER)
LARGE_INTEGER aux;
aux.QuadPart = 0;
QueryPerformanceCounter(&aux);
value = aux.QuadPart;
#else
# error "no high res clock defined"
#endif
return value;
}
Expand Down

0 comments on commit e2cc141

Please sign in to comment.