mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +00:00
Fix system memory check
git-svn-id: https://svn.eduke32.com/eduke32@7333 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
af83ff0675
commit
360ee42e0e
1 changed files with 6 additions and 9 deletions
|
@ -574,8 +574,9 @@ typedef BOOL (WINAPI *aGlobalMemoryStatusExType)(LPMEMORYSTATUSEX);
|
|||
|
||||
uint32_t Bgetsysmemsize(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
uint32_t siz = UINT32_MAX;
|
||||
|
||||
#ifdef _WIN32
|
||||
HMODULE lib = LoadLibrary("KERNEL32.DLL");
|
||||
|
||||
if (lib)
|
||||
|
@ -592,7 +593,7 @@ uint32_t Bgetsysmemsize(void)
|
|||
siz = min<decltype(memst.ullTotalPhys)>(UINT32_MAX, memst.ullTotalPhys);
|
||||
}
|
||||
|
||||
if (siz == UINT32_MAX || siz == 0)
|
||||
if (!aGlobalMemoryStatusEx || siz == 0)
|
||||
{
|
||||
initprintf("Bgetsysmemsize(): error determining system memory size!\n");
|
||||
siz = UINT32_MAX;
|
||||
|
@ -601,10 +602,7 @@ uint32_t Bgetsysmemsize(void)
|
|||
FreeLibrary(lib);
|
||||
}
|
||||
else initprintf("Bgetsysmemsize(): unable to load KERNEL32.DLL!\n");
|
||||
|
||||
return siz;
|
||||
#elif (defined(_SC_PAGE_SIZE) || defined(_SC_PAGESIZE)) && defined(_SC_PHYS_PAGES) && !defined(GEKKO)
|
||||
uint32_t siz = UINT32_MAX;
|
||||
#ifdef _SC_PAGE_SIZE
|
||||
int64_t const scpagesiz = sysconf(_SC_PAGE_SIZE);
|
||||
#else
|
||||
|
@ -613,15 +611,14 @@ uint32_t Bgetsysmemsize(void)
|
|||
int64_t const scphyspages = sysconf(_SC_PHYS_PAGES);
|
||||
|
||||
if (scpagesiz >= 0 && scphyspages >= 0)
|
||||
siz = min<uint32_t>(UINT32_MAX, scpagesiz * scphyspages);
|
||||
siz = (uint32_t)min<uint64_t>(UINT32_MAX, scpagesiz * scphyspages);
|
||||
|
||||
//initprintf("Bgetsysmemsize(): %d pages of %d bytes, %d bytes of system memory\n",
|
||||
// scphyspages, scpagesiz, siz);
|
||||
|
||||
return siz;
|
||||
#else
|
||||
return UINT32_MAX;
|
||||
#endif
|
||||
|
||||
return siz;
|
||||
}
|
||||
|
||||
#ifdef GEKKO
|
||||
|
|
Loading…
Reference in a new issue