mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 08:18:30 +00:00
Add sysctlbyname() for MacOS
This commit is contained in:
parent
5c6877b02b
commit
181cd4cbe8
21 changed files with 193 additions and 35 deletions
|
@ -46,7 +46,7 @@ static int64_t GetUptime(void) {
|
|||
struct timeval x;
|
||||
size_t n = sizeof(x);
|
||||
int mib[] = {CTL_KERN, KERN_BOOTTIME};
|
||||
if (sys_sysctl(mib, ARRAYLEN(mib), &x, &n, 0, 0) == -1)
|
||||
if (sysctl(mib, ARRAYLEN(mib), &x, &n, 0, 0) == -1)
|
||||
return 0;
|
||||
return timespec_real().tv_sec - x.tv_sec;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ static int64_t GetPhysmem(void) {
|
|||
uint64_t x = 0;
|
||||
size_t n = sizeof(x);
|
||||
int mib[] = {CTL_HW, HW_PHYSMEM};
|
||||
if (sys_sysctl(mib, ARRAYLEN(mib), &x, &n, 0, 0) == -1)
|
||||
if (sysctl(mib, ARRAYLEN(mib), &x, &n, 0, 0) == -1)
|
||||
return 0;
|
||||
return x;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ static void GetLoads(uint64_t loads[3]) {
|
|||
struct loadavg loadinfo;
|
||||
int mib[2] = {CTL_VM, VM_LOADAVG};
|
||||
size = sizeof(loadinfo);
|
||||
if (sys_sysctl(mib, 2, &loadinfo, &size, 0, 0) != -1) {
|
||||
if (sysctl(mib, 2, &loadinfo, &size, 0, 0) != -1) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
loads[i] = (double)loadinfo.ldavg[i] / loadinfo.fscale * 65536;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue