diff --git a/source/lib/config2.h b/source/lib/config2.h index ca6a4dd80c..879c7ab68f 100644 --- a/source/lib/config2.h +++ b/source/lib/config2.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -36,12 +36,6 @@ # define CONFIG2_DAP_INTERFACE 1 #endif // !CONFIG2_DAP_INTERFACE -// allow use of RDTSC for raw tick counts (otherwise, the slower but -// more reliable on MP systems wall-clock will be used). -#ifndef CONFIG2_TIMER_ALLOW_RDTSC -# define CONFIG2_TIMER_ALLOW_RDTSC 1 -#endif - // this enables/disables the actual checking done by OverrunProtector // (quite slow, entailing mprotect() before/after each access). // define to 1 here or in the relevant module if you suspect mem corruption. diff --git a/source/lib/sysdep/arch/x86_x64/x86_x64.cpp b/source/lib/sysdep/arch/x86_x64/x86_x64.cpp index 1ae9cf7050..43031fa935 100644 --- a/source/lib/sysdep/arch/x86_x64/x86_x64.cpp +++ b/source/lib/sysdep/arch/x86_x64/x86_x64.cpp @@ -44,7 +44,7 @@ #include #if MSC_VERSION -# include // __rdtsc +# include // __cpuidex #endif namespace x86_x64 { @@ -156,16 +156,6 @@ bool Cap(Caps cap) return IsBitSet(caps[index], bit); } -void GetCapBits(std::uint32_t* d0, std::uint32_t* d1, std::uint32_t* d2, std::uint32_t* d3) -{ - ModuleInit(&capsInitState, InitCaps); - - *d0 = caps[0]; - *d1 = caps[1]; - *d2 = caps[2]; - *d3 = caps[3]; -} - //----------------------------------------------------------------------------- // vendor @@ -372,19 +362,6 @@ static const char* IdentifierString() //----------------------------------------------------------------------------- // miscellaneous stateless functions -#if !MSC_VERSION // ensure not already defined in header -std::uint64_t rdtsc() -{ -#if GCC_VERSION - // GCC supports "portable" assembly for both x86 and x64 - volatile std::uint32_t lo, hi; - __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); - return u64_from_u32(hi, lo); -#endif -} -#endif - - void DebugBreak() { #if MSC_VERSION diff --git a/source/lib/sysdep/arch/x86_x64/x86_x64.h b/source/lib/sysdep/arch/x86_x64/x86_x64.h index bf29405cd0..cd34b3347a 100644 --- a/source/lib/sysdep/arch/x86_x64/x86_x64.h +++ b/source/lib/sysdep/arch/x86_x64/x86_x64.h @@ -36,10 +36,6 @@ #error "including x86_x64.h without ARCH_X86_X64=1" #endif -#if MSC_VERSION -#include // __rdtsc -#endif - namespace x86_x64 { /** @@ -146,27 +142,10 @@ enum Caps **/ bool Cap(Caps cap); -void GetCapBits(std::uint32_t* d0, std::uint32_t* d1, std::uint32_t* d2, std::uint32_t* d3); - //----------------------------------------------------------------------------- // stateless -/** - * @return the current value of the TimeStampCounter (a counter of - * CPU cycles since power-on, which is useful for high-resolution timing - * but potentially differs between multiple CPUs) - * - * notes: - * - a macro avoids call overhead, which is important for TIMER_ACCRUE. - * - x64 RDTSC writes to edx:eax and clears the upper halves of rdx and rax. - **/ -#if MSC_VERSION -static inline std::uint64_t rdtsc() { return __rdtsc(); } -#else -std::uint64_t rdtsc(); -#endif - /** * trigger a breakpoint inside this function when it is called. **/ diff --git a/source/lib/sysdep/os/bsd/bcpu.cpp b/source/lib/sysdep/os/bsd/bcpu.cpp index 5eb49b3269..4502dfa8a2 100644 --- a/source/lib/sysdep/os/bsd/bcpu.cpp +++ b/source/lib/sysdep/os/bsd/bcpu.cpp @@ -88,18 +88,6 @@ size_t os_cpu_LargePageSize() } -size_t os_cpu_QueryMemorySize() -{ - size_t memorySize = 0; - size_t len = sizeof(memorySize); - // Argh, the API doesn't seem to be const-correct - /*const*/ int mib[2] = { CTL_HW, HW_PHYSMEM }; - sysctl(mib, 2, &memorySize, &len, nullptr, 0); - memorySize /= MiB; - return memorySize; -} - - size_t os_cpu_MemoryAvailable() { size_t memoryAvailable = 0; diff --git a/source/lib/sysdep/os/linux/lcpu.cpp b/source/lib/sysdep/os/linux/lcpu.cpp index 0ffe349cdf..88120d3294 100644 --- a/source/lib/sysdep/os/linux/lcpu.cpp +++ b/source/lib/sysdep/os/linux/lcpu.cpp @@ -97,13 +97,6 @@ size_t os_cpu_LargePageSize() } -size_t os_cpu_QueryMemorySize() -{ - const uint64_t memorySize = (uint64_t)sysconf(_SC_PHYS_PAGES) * os_cpu_PageSize(); - return size_t(memorySize / MiB); -} - - size_t os_cpu_MemoryAvailable() { const uint64_t memoryAvailableBytes = (uint64_t)sysconf(_SC_AVPHYS_PAGES) * os_cpu_PageSize(); diff --git a/source/lib/sysdep/os/osx/ocpu.cpp b/source/lib/sysdep/os/osx/ocpu.cpp index 0a68b3a08a..65fd6aa8b0 100644 --- a/source/lib/sysdep/os/osx/ocpu.cpp +++ b/source/lib/sysdep/os/osx/ocpu.cpp @@ -76,18 +76,6 @@ size_t os_cpu_LargePageSize() } -size_t os_cpu_QueryMemorySize() -{ - size_t memorySize = 0; - size_t len = sizeof(memorySize); - // Argh, the API doesn't seem to be const-correct - /*const*/ int mib[2] = { CTL_HW, HW_MEMSIZE }; - sysctl(mib, 2, &memorySize, &len, nullptr, 0); - memorySize /= MiB; - return memorySize; -} - - size_t os_cpu_MemoryAvailable() { size_t memoryAvailable = 0; diff --git a/source/lib/sysdep/os/win/tests/test_ia32.h b/source/lib/sysdep/os/win/tests/test_ia32.h index 47a87e1ee0..739283ef71 100644 --- a/source/lib/sysdep/os/win/tests/test_ia32.h +++ b/source/lib/sysdep/os/win/tests/test_ia32.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -31,15 +31,6 @@ class TestIA32: public CxxTest::TestSuite { public: - void test_rdtsc() - { - // must increase monotonously - const std::uint64_t c1 = x86_x64::rdtsc(); - const std::uint64_t c2 = x86_x64::rdtsc(); - const std::uint64_t c3 = x86_x64::rdtsc(); - TS_ASSERT(c1 < c2 && c2 < c3); - } - void test_ia32_cap() { // make sure the really common/basic caps end up reported as true diff --git a/source/lib/sysdep/os/win/wcpu.cpp b/source/lib/sysdep/os/win/wcpu.cpp index 09903142cf..f1f27ab173 100644 --- a/source/lib/sysdep/os/win/wcpu.cpp +++ b/source/lib/sysdep/os/win/wcpu.cpp @@ -115,22 +115,6 @@ static void GetMemoryStatus(MEMORYSTATUSEX& mse) WARN_IF_FALSE(ok); } -size_t os_cpu_QueryMemorySize() -{ - MEMORYSTATUSEX mse; - GetMemoryStatus(mse); - DWORDLONG memorySize = mse.ullTotalPhys; - - // Richter, "Programming Applications for Windows": the reported - // value doesn't include non-paged pool reserved during boot; - // it's not considered available to the kernel. (the amount is - // 528 KiB on a 512 MiB WinXP/Win2k machine). we'll round up - // to the nearest megabyte to fix this. - memorySize = round_up(memorySize, DWORDLONG(1*MiB)); // (Align<> cannot compute DWORDLONG) - - return size_t(memorySize / MiB); -} - size_t os_cpu_MemoryAvailable() { MEMORYSTATUSEX mse; diff --git a/source/lib/sysdep/os_cpu.cpp b/source/lib/sysdep/os_cpu.cpp deleted file mode 100644 index 7ad1ca7fe0..0000000000 --- a/source/lib/sysdep/os_cpu.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2026 Wildfire Games. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * OS-specific support functions relating to CPU and memory - */ - -#include "precompiled.h" - -#include "lib/sysdep/os_cpu.h" - -#include "lib/alignment.h" -#include "lib/code_annotation.h" -#include "lib/sysdep/os.h" - -size_t os_cpu_MemorySize() -{ - static size_t memorySize; - if(memorySize != 0) // already initialized - return memorySize; - - memorySize = os_cpu_QueryMemorySize(); - return memorySize; -} diff --git a/source/lib/sysdep/os_cpu.h b/source/lib/sysdep/os_cpu.h index b5b4f5f8ac..eb86cca548 100644 --- a/source/lib/sysdep/os_cpu.h +++ b/source/lib/sysdep/os_cpu.h @@ -79,18 +79,6 @@ size_t os_cpu_PageSize(); **/ size_t os_cpu_LargePageSize(); -/** - * @return the size [MB] of physical memory as reported by the OS; - * no caching/validation is performed. - **/ -size_t os_cpu_QueryMemorySize(); - -/** - * @return the size [MB] of physical memory; caches the result of - * os_cpu_QueryMemorySize. - **/ -size_t os_cpu_MemorySize(); - /** * @return the current amount [MB] of available memory. **/ diff --git a/source/lib/timer.h b/source/lib/timer.h index 98009c0c16..3564126278 100644 --- a/source/lib/timer.h +++ b/source/lib/timer.h @@ -27,14 +27,6 @@ #ifndef INCLUDED_TIMER #define INCLUDED_TIMER -#include "lib/code_annotation.h" -#include "lib/config2.h" // CONFIG2_TIMER_ALLOW_RDTSC -#include "lib/debug.h" -#include "lib/sysdep/arch.h" - -#include -#include - /** * timer_Time will subsequently return values relative to the current time. **/