Files
0ad/source/lib/sysdep/osx/ocpu.cpp
T
janwas b776e58c67 use (newly added) cpu_PageSize instead of sysconf (avoids a critical order dependency on windows)
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.
2007-09-23 08:05:38 +00:00

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;
}