|
1 | 1 | #include "memory.h" |
2 | | -#include "common/sysctl.h" |
3 | 2 |
|
4 | 3 | #include <string.h> |
5 | 4 | #include <mach/mach.h> |
| 5 | +#include <sys/sysctl.h> |
6 | 6 |
|
7 | 7 | void ffDetectMemory(FFMemoryStorage* ram) |
8 | 8 | { |
9 | | - ram->bytesTotal = (uint64_t) ffSysctlGetInt64("hw.memsize", 0); |
10 | | - if(ram->bytesTotal == 0) |
| 9 | + size_t length = sizeof(ram->bytesTotal); |
| 10 | + if (sysctl((int[]){ CTL_HW, HW_MEMSIZE }, 2, &ram->bytesTotal, &length, NULL, 0)) |
11 | 11 | { |
12 | 12 | ffStrbufAppendS(&ram->error, "Failed to read hw.memsize"); |
13 | 13 | return; |
14 | 14 | } |
15 | 15 |
|
16 | | - uint32_t pagesize = (uint32_t) ffSysctlGetInt("hw.pagesize", 0); |
17 | | - if(pagesize == 0) |
| 16 | + uint32_t pagesize; |
| 17 | + length = sizeof(pagesize); |
| 18 | + if (sysctl((int[]){ CTL_HW, HW_PAGESIZE }, 2, &pagesize, &length, NULL, 0)) |
18 | 19 | { |
19 | 20 | ffStrbufAppendS(&ram->error, "Failed to read hw.pagesize"); |
20 | 21 | return; |
21 | 22 | } |
22 | 23 |
|
23 | | - mach_msg_type_number_t count = HOST_VM_INFO_COUNT; |
24 | | - vm_statistics_data_t vmstat; |
25 | | - if(host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t) (&vmstat), &count) != KERN_SUCCESS) |
| 24 | + mach_msg_type_number_t count = HOST_VM_INFO64_COUNT; |
| 25 | + vm_statistics64_data_t vmstat; |
| 26 | + if(host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info64_t) (&vmstat), &count) != KERN_SUCCESS) |
26 | 27 | { |
27 | | - ffStrbufAppendS(&ram->error, "Failed to read vm statistics"); |
| 28 | + ffStrbufAppendS(&ram->error, "Failed to read host_statistics64"); |
28 | 29 | return; |
29 | 30 | } |
30 | 31 |
|
|
0 commit comments