mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-11-08 10:09:16 +00:00
Removes unused sysdep functions and macro
Removed: * os_cpu_QueryMemorySize * os_cpu_MemorySize * GetCapBits * rdtsc * CONFIG2_TIMER_ALLOW_RDTSC
This commit is contained in:
11 files changed
+3
-172
No files matched your search
@@ -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.
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <vector>
|
||||
|
||||
#if MSC_VERSION
|
||||
# include <intrin.h> // __rdtsc
|
||||
# include <intrin.h> // __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
|
||||
|
||||
@@ -36,10 +36,6 @@
|
||||
#error "including x86_x64.h without ARCH_X86_X64=1"
|
||||
#endif
|
||||
|
||||
#if MSC_VERSION
|
||||
#include <intrin.h> // __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.
|
||||
**/
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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.
|
||||
**/
|
||||
|
||||
@@ -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 <cstdint>
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* timer_Time will subsequently return values relative to the current time.
|
||||
**/
|
||||
|
||||
Reference in new issue
Block a user