mcst-linux-kernel/patches-2024.06.26/RBDOOM-3-BFG-1.4.0/0003-rdtsc_on_e2k.patch

67 lines
2.0 KiB
Diff

diff --git a/neo/idlib/math/Simd.cpp b/neo/idlib/math/Simd.cpp
index 127458a..fd0871d 100644
--- a/neo/idlib/math/Simd.cpp
+++ b/neo/idlib/math/Simd.cpp
@@ -183,6 +183,16 @@ double ticksPerNanosecond;
#define StopRecordTime( end ) \
end = mach_absolute_time();
+#elif defined( __e2k__ )
+
+#define TIME_TYPE uint64_t
+
+#define StartRecordTime( start ) \
+ asm volatile("rrd %%clkr, %0" : "=r"(start));
+
+#define StopRecordTime( end ) \
+ asm volatile("rrd %%clkr, %0" : "=r"(end));
+
#else // not _MSC_VER and _M_IX86 or __APPLE__
// FIXME: meaningful values/functions here for Linux?
#define TIME_TYPE int
diff --git a/neo/sys/posix/posix_main.cpp b/neo/sys/posix/posix_main.cpp
index a243b0d..271e659 100644
--- a/neo/sys/posix/posix_main.cpp
+++ b/neo/sys/posix/posix_main.cpp
@@ -261,6 +261,10 @@ double Sys_GetClockTicks()
"pop %%ebx\n"
: "=r"( lo ), "=r"( hi ) );
return ( double ) lo + ( double ) 0xFFFFFFFF * hi;
+#elif defined( __e2k__ )
+ uint64_t c64;
+ asm volatile("rrd %%clkr, %0" : "=r"(c64));
+ return (double) c64;
// RB begin
#elif defined( __x86_64__ )
uint32_t lo, hi;
diff --git a/neo/sys/sdl/sdl_cpu.cpp b/neo/sys/sdl/sdl_cpu.cpp
index a64bb57..2a93c5b 100644
--- a/neo/sys/sdl/sdl_cpu.cpp
+++ b/neo/sys/sdl/sdl_cpu.cpp
@@ -88,6 +88,10 @@ double Sys_GetClockTicks()
"pop %%ebx\n"
: "=r"( lo ), "=r"( hi ) );
return ( double ) lo + ( double ) 0xFFFFFFFF * hi;
+#elif defined( __e2k__ )
+ uint64_t c64;
+ asm volatile("rrd %%clkr, %0" : "=r"(c64));
+ return (double)c64;
#else
#error unsupported CPU
#endif
diff --git a/neo/sys/win32/win_cpu.cpp b/neo/sys/win32/win_cpu.cpp
index e38a3ad..d890534 100644
--- a/neo/sys/win32/win_cpu.cpp
+++ b/neo/sys/win32/win_cpu.cpp
@@ -87,6 +87,10 @@ double Sys_GetClockTicks()
"pop %%ebx\n"
: "=r"( lo ), "=r"( hi ) );
return ( double ) lo + ( double ) 0xFFFFFFFF * hi;
+#elif defined( __e2k__ )
+ uint64_t c64;
+ asm volatile("rrd %%clkr, %0" : "=r"(c64));
+ return (double)c64;
#else
#error unsupported CPU
#endif