mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-12 23:54:17 +00:00
Proper RDTSC implementation for x86_64 targets
Higher 32 bits of Time Stamp Counter were ignored in non-MSVC Windows and macOS builds
This commit is contained in:
parent
47faaa87fc
commit
3d147a032c
1 changed files with 7 additions and 3 deletions
10
src/stats.h
10
src/stats.h
|
@ -102,7 +102,7 @@ private:
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// Windows
|
// Windows and macOS
|
||||||
#include "x86.h"
|
#include "x86.h"
|
||||||
|
|
||||||
extern double PerfToSec, PerfToMillisec;
|
extern double PerfToSec, PerfToMillisec;
|
||||||
|
@ -126,15 +126,19 @@ inline unsigned __int64 rdtsc()
|
||||||
#else
|
#else
|
||||||
inline unsigned long long rdtsc()
|
inline unsigned long long rdtsc()
|
||||||
{
|
{
|
||||||
#ifndef __amd64__
|
#ifdef __amd64__
|
||||||
|
unsigned long long tsc;
|
||||||
|
asm volatile ("rdtsc; shlq $32, %%rdx; orq %%rdx, %%rax" : "=a" (tsc) :: "%rdx");
|
||||||
|
return tsc;
|
||||||
|
#else // i386
|
||||||
if (CPU.bRDTSC)
|
if (CPU.bRDTSC)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
unsigned long long tsc;
|
unsigned long long tsc;
|
||||||
asm volatile ("\trdtsc\n" : "=A" (tsc));
|
asm volatile ("\trdtsc\n" : "=A" (tsc));
|
||||||
return tsc;
|
return tsc;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif // __amd64__
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue