mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-13 23:35:19 +00:00
53bcba3368
IGUIObject: Cache the JSObject*, to prevent some frequent allocation while running GUI scripts. JSInterface_IGUIObject: Fixed garbage collection issues. JSInterface_IGUIObject, ScriptGlue: Changed to the JS_THREADSAFE form of JS_GetClass. Util: Avoid startup warnings on Linux caused by using unimplemented cpu_* functions that aren't needed for anything important yet. sysdep/unix: Changed to native line endings. This was SVN commit r5154.
31 lines
574 B
C++
31 lines
574 B
C++
#include "precompiled.h"
|
|
#include "bsd.h"
|
|
|
|
#if OS_BSD
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
static int SysctlFromMemType(CpuMemoryIndicators mem_type)
|
|
{
|
|
switch(mem_type)
|
|
{
|
|
case CPU_MEM_TOTAL:
|
|
return HW_PHYSMEM;
|
|
case CPU_MEM_AVAILABLE:
|
|
return HW_USERMEM;
|
|
}
|
|
UNREACHABLE;
|
|
}
|
|
|
|
size_t bsd_MemorySize(CpuMemoryIndicators mem_type)
|
|
{
|
|
size_t memory_size = 0;
|
|
size_t len = sizeof(memory_size);
|
|
// Argh, the API doesn't seem to be const-correct
|
|
/*const*/ int mib[2] = { CTL_HW, SysctlFromMemType(mem_type) };
|
|
sysctl(mib, 2, &memory_size, &len, 0, 0);
|
|
return memory_size;
|
|
}
|
|
|
|
#endif
|