blob: 5bc9c2f1287eb14a433285bbbf8eb375bbdb246b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include "system_memory.h"
#include <stdint.h>
#if __APPLE__
#include <mach/mach.h>
#include <sys/resource.h>
#include <sys/sysctl.h>
#include <unistd.h>
extern "C" uint64_t getFreeMemoryDarwin_B() {
vm_statistics_data_t info;
mach_msg_type_number_t count = sizeof(info) / sizeof(integer_t);
if (host_statistics(mach_host_self(), HOST_VM_INFO,
(host_info_t)&info, &count) != KERN_SUCCESS) {
return 0;
}
return (uint64_t) info.free_count * sysconf(_SC_PAGESIZE);
}
#else
// Implemented in zig
extern "C" uint64_t getFreeMemoryDarwin_B() {
return (uint64_t) 0;
}
#endif
|