mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-03-20 17:51:02 +00:00
Mac: Fix RAM detection for >2GB
Sys_GetSystemRam() for OSX used some deprecated MacOS function from 1989 that used int32 for the amount of bytes. Now using sysctl() instead, should be supported since at least 10.2.8 at least it's in https://github.com/phracker/MacOSX-SDKs/blob/master/MacOSX10.2.8.sdk/usr/include/sys/sysctl.h
This commit is contained in:
parent
5becb2d14d
commit
df0916ecf8
1 changed files with 14 additions and 4 deletions
|
@ -36,6 +36,10 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include <SDL_main.h>
|
||||
|
||||
#include "sys/platform.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include "idlib/Str.h"
|
||||
#include "framework/Common.h"
|
||||
|
||||
|
@ -91,10 +95,16 @@ returns in megabytes
|
|||
================
|
||||
*/
|
||||
int Sys_GetSystemRam( void ) {
|
||||
SInt32 ramSize;
|
||||
|
||||
if ( Gestalt( gestaltPhysicalRAMSize, &ramSize ) == noErr ) {
|
||||
return ramSize / (1024*1024);
|
||||
// from https://discussions.apple.com/thread/1775836?answerId=8396559022#8396559022
|
||||
// should work (at least) from the Mac OSX 10.2.8 SDK on
|
||||
int mib[2];
|
||||
uint64_t memsize;
|
||||
size_t len;
|
||||
mib[0] = CTL_HW;
|
||||
mib[1] = HW_MEMSIZE; /* uint64_t: physical ram size */
|
||||
len = sizeof(memsize);
|
||||
if(sysctl(mib, 2, &memsize, &len, NULL, 0) == 0) {
|
||||
return (int)(memsize / (1024*1024));
|
||||
}
|
||||
else
|
||||
return 1024;
|
||||
|
|
Loading…
Reference in a new issue