aports/testing/fceux/01-rdtsc.patch
2023-10-22 08:37:29 +00:00

76 lines
2 KiB
Diff

https://github.com/TASEmulators/fceux/issues/663
--- a/src/utils/timeStamp.cpp
+++ b/src/utils/timeStamp.cpp
@@ -14,6 +14,7 @@
//-------------------------------------------------------------------------
//---- Time Stamp Record
//-------------------------------------------------------------------------
+#ifdef __QT_DRIVER__
#if defined(WIN32)
#include <intrin.h>
#pragma intrinsic(__rdtsc)
@@ -25,6 +26,7 @@ static uint64_t rdtsc()
{
return __rdtsc();
}
+#endif
namespace FCEU
{
@@ -36,12 +38,15 @@ uint64_t timeStampRecord::qpcFreq = 0;
void timeStampRecord::readNew(void)
{
-#if defined(__linux__) || defined(__APPLE__) || defined(__unix__)
- clock_gettime( CLOCK_REALTIME, &ts );
-#else
- QueryPerformanceCounter((LARGE_INTEGER*)&ts);
-#endif
- tsc = rdtsc();
+ #ifdef __QT_DRIVER__
+ tsc = rdtsc();
+ #else
+ #if defined(__linux__) || defined(__APPLE__) || defined(__unix__)
+ clock_gettime( CLOCK_REALTIME, &ts );
+ #else
+ QueryPerformanceCounter((LARGE_INTEGER*)&ts);
+ #endif
+ #endif
}
#if defined(WIN32)
void timeStampRecord::qpcCalibrate(void)
--- a/src/utils/timeStamp.cpp
+++ b/src/utils/timeStamp.cpp
@@ -14,7 +14,7 @@
//-------------------------------------------------------------------------
//---- Time Stamp Record
//-------------------------------------------------------------------------
-#ifdef __QT_DRIVER__
+#ifdef __FCEU_X86_TSC_ENABLE
#if defined(WIN32)
#include <intrin.h>
#pragma intrinsic(__rdtsc)
@@ -38,14 +38,14 @@ uint64_t timeStampRecord::qpcFreq = 0;
void timeStampRecord::readNew(void)
{
- #ifdef __QT_DRIVER__
+ #ifdef __FCEU_X86_TSC_ENABLE
tsc = rdtsc();
+ #endif
+
+ #if defined(__linux__) || defined(__APPLE__) || defined(__unix__)
+ clock_gettime( CLOCK_REALTIME, &ts );
#else
- #if defined(__linux__) || defined(__APPLE__) || defined(__unix__)
- clock_gettime( CLOCK_REALTIME, &ts );
- #else
- QueryPerformanceCounter((LARGE_INTEGER*)&ts);
- #endif
+ QueryPerformanceCounter((LARGE_INTEGER*)&ts);
#endif
}
#if defined(WIN32)