Fix macOS code and change "Swapfile" to "Swap"
This commit is contained in:
parent
a67f205cfe
commit
cb8b72069f
@ -65,6 +65,7 @@
|
|||||||
#include "common/logging/filter.h"
|
#include "common/logging/filter.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/logging/text_formatter.h"
|
#include "common/logging/text_formatter.h"
|
||||||
|
#include "common/memory_detect.h"
|
||||||
#include "common/microprofile.h"
|
#include "common/microprofile.h"
|
||||||
#include "common/scm_rev.h"
|
#include "common/scm_rev.h"
|
||||||
#include "common/scope_exit.h"
|
#include "common/scope_exit.h"
|
||||||
|
@ -33,10 +33,13 @@ static MemoryInfo Detect() {
|
|||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
u64 ramsize;
|
u64 ramsize;
|
||||||
struct xsw_usage vmusage;
|
struct xsw_usage vmusage;
|
||||||
|
std::size_t sizeof_ramsize = sizeof(ramsize);
|
||||||
|
std::size_t sizeof_vmusage = sizeof(vmusage);
|
||||||
// hw and vm are defined in sysctl.h
|
// hw and vm are defined in sysctl.h
|
||||||
// https://github.com/apple/darwin-xnu/blob/master/bsd/sys/sysctl.h#L471
|
// https://github.com/apple/darwin-xnu/blob/master/bsd/sys/sysctl.h#L471
|
||||||
sysctlbyname(hw.memsize, &ramsize, sizeof(ramsize), NULL, 0);
|
// sysctlbyname(const char *, void *, size_t *, void *, size_t);
|
||||||
sysctlbyname(vm.swapusage, &vmusage, sizeof(vmusage), NULL, 0);
|
sysctlbyname("hw.memsize", &ramsize, &sizeof_ramsize, NULL, 0);
|
||||||
|
sysctlbyname("vm.swapusage", &vmusage, &sizeof_vmusage, NULL, 0);
|
||||||
mem_info.TotalPhysicalMemory = ramsize;
|
mem_info.TotalPhysicalMemory = ramsize;
|
||||||
mem_info.TotalSwapMemory = vmusage.xsu_total;
|
mem_info.TotalSwapMemory = vmusage.xsu_total;
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user