From 9447d2c3ff87cfca6585ac3049f555d65d3fecca Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 25 Oct 2018 23:31:49 +0000 Subject: [PATCH] Fix issue with Bgetsysmemsize() on some platforms after the changeover to ::min and ::max. git-svn-id: https://svn.eduke32.com/eduke32@7113 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/src/compat.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/source/build/src/compat.cpp b/source/build/src/compat.cpp index d69d5ad32..6aaad03a7 100644 --- a/source/build/src/compat.cpp +++ b/source/build/src/compat.cpp @@ -604,16 +604,15 @@ uint32_t Bgetsysmemsize(void) return siz; #elif (defined(_SC_PAGE_SIZE) || defined(_SC_PAGESIZE)) && defined(_SC_PHYS_PAGES) && !defined(GEKKO) uint32_t siz = UINT32_MAX; - int64_t scpagesiz, scphyspages; - #ifdef _SC_PAGE_SIZE - scpagesiz = sysconf(_SC_PAGE_SIZE); + int64_t const scpagesiz = sysconf(_SC_PAGE_SIZE); #else - scpagesiz = sysconf(_SC_PAGESIZE); + int64_t const scpagesiz = sysconf(_SC_PAGESIZE); #endif - scphyspages = sysconf(_SC_PHYS_PAGES); + int64_t const scphyspages = sysconf(_SC_PHYS_PAGES); + if (scpagesiz >= 0 && scphyspages >= 0) - siz = (uint32_t)min(UINT32_MAX, (int64_t)scpagesiz * (int64_t)scphyspages); + siz = min(UINT32_MAX, scpagesiz * scphyspages); //initprintf("Bgetsysmemsize(): %d pages of %d bytes, %d bytes of system memory\n", // scphyspages, scpagesiz, siz);