diff options
author | Jan Beich <jbeich@FreeBSD.org> | 2020-06-30 00:39:31 +0200 |
---|---|---|
committer | Jan Beich <jbeich@FreeBSD.org> | 2020-06-30 00:41:22 +0200 |
commit | e6085ea35f0b2579a1df40ee4e24d02e47ee85bc (patch) | |
tree | 0cf573d257ff95817201adf6d2998c31e45bc65e /src/common/memory_detect.cpp | |
parent | Merge pull request #4140 from ReinUsesLisp/validation-layers (diff) | |
download | yuzu-e6085ea35f0b2579a1df40ee4e24d02e47ee85bc.tar yuzu-e6085ea35f0b2579a1df40ee4e24d02e47ee85bc.tar.gz yuzu-e6085ea35f0b2579a1df40ee4e24d02e47ee85bc.tar.bz2 yuzu-e6085ea35f0b2579a1df40ee4e24d02e47ee85bc.tar.lz yuzu-e6085ea35f0b2579a1df40ee4e24d02e47ee85bc.tar.xz yuzu-e6085ea35f0b2579a1df40ee4e24d02e47ee85bc.tar.zst yuzu-e6085ea35f0b2579a1df40ee4e24d02e47ee85bc.zip |
Diffstat (limited to '')
-rw-r--r-- | src/common/memory_detect.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/common/memory_detect.cpp b/src/common/memory_detect.cpp index 3fdc309a2..e981b9a2a 100644 --- a/src/common/memory_detect.cpp +++ b/src/common/memory_detect.cpp @@ -9,10 +9,12 @@ // clang-format on #else #include <sys/types.h> -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__FreeBSD__) #include <sys/sysctl.h> -#else +#elif defined(__linux__) #include <sys/sysinfo.h> +#else +#include <unistd.h> #endif #endif @@ -42,11 +44,22 @@ static MemoryInfo Detect() { sysctlbyname("vm.swapusage", &vmusage, &sizeof_vmusage, NULL, 0); mem_info.TotalPhysicalMemory = ramsize; mem_info.TotalSwapMemory = vmusage.xsu_total; -#else +#elif defined(__FreeBSD__) + u_long physmem, swap_total; + std::size_t sizeof_u_long = sizeof(u_long); + // sysctlbyname(const char *, void *, size_t *, const void *, size_t); + sysctlbyname("hw.physmem", &physmem, &sizeof_u_long, NULL, 0); + sysctlbyname("vm.swap_total", &swap_total, &sizeof_u_long, NULL, 0); + mem_info.TotalPhysicalMemory = physmem; + mem_info.TotalSwapMemory = swap_total; +#elif defined(__linux__) struct sysinfo meminfo; sysinfo(&meminfo); mem_info.TotalPhysicalMemory = meminfo.totalram; mem_info.TotalSwapMemory = meminfo.totalswap; +#else + mem_info.TotalPhysicalMemory = sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGE_SIZE); + mem_info.TotalSwapMemory = 0; #endif return mem_info; |