23 #include "precompiled.h"
31 #include <sys/param.h>
32 #include <sys/sysctl.h>
36 static size_t numProcessors;
38 if(numProcessors == 0)
43 if (RUNNING_ON_VALGRIND)
47 long res = sysconf(_SC_NPROCESSORS_CONF);
49 numProcessors = (size_t)res;
59 static uintptr_t processorMask;
73 pageSize = (size_t)sysconf(_SC_PAGESIZE);
88 size_t memorySize = 0;
89 size_t len =
sizeof(memorySize);
91 int mib[2] = { CTL_HW, HW_PHYSMEM };
92 sysctl(mib, 2, &memorySize, &len, 0, 0);
100 size_t memoryAvailable = 0;
101 size_t len =
sizeof(memoryAvailable);
103 int mib[2] = { CTL_HW, HW_USERMEM };
104 sysctl(mib, 2, &memoryAvailable, &len, 0, 0);
105 memoryAvailable /=
MiB;
106 return memoryAvailable;
119 const uintptr_t processorMask = uintptr_t(1) << processor;
121 cb(processor, cbData);
size_t os_cpu_QueryMemorySize()
static const size_t pageSize
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning. ...
Status os_cpu_CallByEachCPU(OsCpuCallback cb, uintptr_t cbData)
execute the specified function once on each processor.
size_t os_cpu_NumProcessors()
size_t os_cpu_LargePageSize()
uintptr_t os_cpu_SetThreadAffinityMask(uintptr_t processorMask)
restrict the current thread to a set of processors.
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
size_t os_cpu_MemoryAvailable()
i64 Status
Error handling system.
uintptr_t os_cpu_ProcessorMask()
void(* OsCpuCallback)(size_t processor, uintptr_t cbData)
called by os_cpu_CallByEachCPU.