From 10554eb5b164682dab7b54a518496e0cea44704c Mon Sep 17 00:00:00 2001 From: Stan Date: Tue, 17 May 2022 08:08:14 +0000 Subject: [PATCH] Fix RAM amount detection on BSD and macOS. Tested by: @Mastoras Comments by: @vladislavbelov Differential Revision: https://code.wildfiregames.com/D4651 This was SVN commit r26888. --- source/lib/sysdep/os/bsd/bcpu.cpp | 8 ++++---- source/lib/sysdep/os/osx/ocpu.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/lib/sysdep/os/bsd/bcpu.cpp b/source/lib/sysdep/os/bsd/bcpu.cpp index e17f71e9a5..d5b87a2ee5 100644 --- a/source/lib/sysdep/os/bsd/bcpu.cpp +++ b/source/lib/sysdep/os/bsd/bcpu.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -93,8 +93,8 @@ size_t os_cpu_QueryMemorySize() size_t memorySize = 0; size_t len = sizeof(memorySize); // Argh, the API doesn't seem to be const-correct - /*const*/ int mib[2] = { CTL_HW, HW_PHYSMEM }; - sysctl(mib, 2, &memorySize, &len, 0, 0); + /*const*/ int mib[2] = { CTL_HW, HW_MEMSIZE }; + sysctl(mib, 2, &memorySize, &len, nullptr, 0); memorySize /= MiB; return memorySize; } @@ -106,7 +106,7 @@ size_t os_cpu_MemoryAvailable() size_t len = sizeof(memoryAvailable); // Argh, the API doesn't seem to be const-correct /*const*/ int mib[2] = { CTL_HW, HW_USERMEM }; - sysctl(mib, 2, &memoryAvailable, &len, 0, 0); + sysctl(mib, 2, &memoryAvailable, &len, nullptr, 0); memoryAvailable /= MiB; return memoryAvailable; } diff --git a/source/lib/sysdep/os/osx/ocpu.cpp b/source/lib/sysdep/os/osx/ocpu.cpp index 2aa1d3c226..f7eeee2871 100644 --- a/source/lib/sysdep/os/osx/ocpu.cpp +++ b/source/lib/sysdep/os/osx/ocpu.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -81,8 +81,8 @@ size_t os_cpu_QueryMemorySize() size_t memorySize = 0; size_t len = sizeof(memorySize); // Argh, the API doesn't seem to be const-correct - /*const*/ int mib[2] = { CTL_HW, HW_PHYSMEM }; - sysctl(mib, 2, &memorySize, &len, 0, 0); + /*const*/ int mib[2] = { CTL_HW, HW_MEMSIZE }; + sysctl(mib, 2, &memorySize, &len, nullptr, 0); memorySize /= MiB; return memorySize; } @@ -94,7 +94,7 @@ size_t os_cpu_MemoryAvailable() size_t len = sizeof(memoryAvailable); // Argh, the API doesn't seem to be const-correct /*const*/ int mib[2] = { CTL_HW, HW_USERMEM }; - sysctl(mib, 2, &memoryAvailable, &len, 0, 0); + sysctl(mib, 2, &memoryAvailable, &len, nullptr, 0); memoryAvailable /= MiB; return memoryAvailable; }