mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-11 03:16:53 +00:00
b776e58c67
refactored sysdep code: - avoid many #if OS_xxx. - remove bsd.cpp, merge its contents with osx - move linux-specific parts of unix/ into linux/ This was SVN commit r5363.
56 lines
1.0 KiB
C++
56 lines
1.0 KiB
C++
#include "precompiled.h"
|
|
|
|
#include "ocpu.h"
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
int ocpu_IsThrottlingPossible()
|
|
{
|
|
return -1; // don't know
|
|
}
|
|
|
|
int ocpu_NumPackages()
|
|
{
|
|
int mib[]={CTL_HW, HW_NCPU};
|
|
int ncpus;
|
|
size_t len = sizeof(ncpus);
|
|
if (sysctl(mib, 2, &ncpus, &len, NULL, 0) == -1)
|
|
return -1; // don't know
|
|
else
|
|
return ncpus;
|
|
}
|
|
|
|
double ocpu_ClockFrequency()
|
|
{
|
|
return -1; // don't know
|
|
}
|
|
|
|
LibError ocpu_CallByEachCPU(CpuCallback cb, void* param)
|
|
{
|
|
// TODO: implement
|
|
return ERR::NOT_IMPLEMENTED;
|
|
}
|
|
|
|
|
|
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 ocpu_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;
|
|
}
|