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.
This commit is contained in:
parent
d1775169d2
commit
10554eb5b1
@ -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
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files (the
|
* 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 memorySize = 0;
|
||||||
size_t len = sizeof(memorySize);
|
size_t len = sizeof(memorySize);
|
||||||
// Argh, the API doesn't seem to be const-correct
|
// Argh, the API doesn't seem to be const-correct
|
||||||
/*const*/ int mib[2] = { CTL_HW, HW_PHYSMEM };
|
/*const*/ int mib[2] = { CTL_HW, HW_MEMSIZE };
|
||||||
sysctl(mib, 2, &memorySize, &len, 0, 0);
|
sysctl(mib, 2, &memorySize, &len, nullptr, 0);
|
||||||
memorySize /= MiB;
|
memorySize /= MiB;
|
||||||
return memorySize;
|
return memorySize;
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ size_t os_cpu_MemoryAvailable()
|
|||||||
size_t len = sizeof(memoryAvailable);
|
size_t len = sizeof(memoryAvailable);
|
||||||
// Argh, the API doesn't seem to be const-correct
|
// Argh, the API doesn't seem to be const-correct
|
||||||
/*const*/ int mib[2] = { CTL_HW, HW_USERMEM };
|
/*const*/ int mib[2] = { CTL_HW, HW_USERMEM };
|
||||||
sysctl(mib, 2, &memoryAvailable, &len, 0, 0);
|
sysctl(mib, 2, &memoryAvailable, &len, nullptr, 0);
|
||||||
memoryAvailable /= MiB;
|
memoryAvailable /= MiB;
|
||||||
return memoryAvailable;
|
return memoryAvailable;
|
||||||
}
|
}
|
||||||
|
@ -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
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
* a copy of this software and associated documentation files (the
|
* 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 memorySize = 0;
|
||||||
size_t len = sizeof(memorySize);
|
size_t len = sizeof(memorySize);
|
||||||
// Argh, the API doesn't seem to be const-correct
|
// Argh, the API doesn't seem to be const-correct
|
||||||
/*const*/ int mib[2] = { CTL_HW, HW_PHYSMEM };
|
/*const*/ int mib[2] = { CTL_HW, HW_MEMSIZE };
|
||||||
sysctl(mib, 2, &memorySize, &len, 0, 0);
|
sysctl(mib, 2, &memorySize, &len, nullptr, 0);
|
||||||
memorySize /= MiB;
|
memorySize /= MiB;
|
||||||
return memorySize;
|
return memorySize;
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ size_t os_cpu_MemoryAvailable()
|
|||||||
size_t len = sizeof(memoryAvailable);
|
size_t len = sizeof(memoryAvailable);
|
||||||
// Argh, the API doesn't seem to be const-correct
|
// Argh, the API doesn't seem to be const-correct
|
||||||
/*const*/ int mib[2] = { CTL_HW, HW_USERMEM };
|
/*const*/ int mib[2] = { CTL_HW, HW_USERMEM };
|
||||||
sysctl(mib, 2, &memoryAvailable, &len, 0, 0);
|
sysctl(mib, 2, &memoryAvailable, &len, nullptr, 0);
|
||||||
memoryAvailable /= MiB;
|
memoryAvailable /= MiB;
|
||||||
return memoryAvailable;
|
return memoryAvailable;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user