summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordarin%meer.net <devnull@localhost>2005-09-19 17:59:52 +0000
committerdarin%meer.net <devnull@localhost>2005-09-19 17:59:52 +0000
commit863914758e7375ee660b6d8ab101fe401cbf19e8 (patch)
tree4f65f645a62b28259673dc979cdb8aab456bcfb6
parent407cf4c14606e9051ed7c3d6197c379a550b78e1 (diff)
downloadnspr-hg-FIREFOX_1_5b2_RELEASE.tar.gz
fixes bug 308587 "PR_GetPhysicalMemorySize returns garbage on systems with more than 2GB RAM" r=wtc a=asaTHUNDERBIRD_1_5b2_RELEASEMOZILLA_1_8b5_RELEASEFIREFOX_1_5b2_RELEASE
-rw-r--r--pr/src/misc/prsystem.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/pr/src/misc/prsystem.c b/pr/src/misc/prsystem.c
index f931e3af..40c6eaac 100644
--- a/pr/src/misc/prsystem.c
+++ b/pr/src/misc/prsystem.c
@@ -278,20 +278,20 @@ PR_IMPLEMENT(PRInt32) PR_GetNumberOfProcessors( void )
*/
PR_IMPLEMENT(PRUint64) PR_GetPhysicalMemorySize(void)
{
- PRUint64 bytes = LL_ZERO;
+ PRUint64 bytes = 0;
#if defined(LINUX) || defined(SOLARIS)
long pageSize = sysconf(_SC_PAGESIZE);
long pageCount = sysconf(_SC_PHYS_PAGES);
- LL_I2L(bytes, pageSize * pageCount);
+ bytes = (PRUint64) pageSize * pageCount;
#elif defined(HPUX)
struct pst_static info;
int result = pstat_getstatic(&info, sizeof(info), 1, 0);
if (result == 1)
- LL_I2L(bytes, info.physical_memory * info.page_size);
+ bytes = (PRUint64) info.physical_memory * info.page_size;
#elif defined(DARWIN)
@@ -303,7 +303,7 @@ PR_IMPLEMENT(PRUint64) PR_GetPhysicalMemorySize(void)
(host_info_t) &hInfo,
&count);
if (result == KERN_SUCCESS)
- LL_I2L(bytes, hInfo.memory_size);
+ bytes = hInfo.memory_size;
#elif defined(WIN32)
@@ -319,16 +319,16 @@ PR_IMPLEMENT(PRUint64) PR_GetPhysicalMemorySize(void)
memStat.dwLength = sizeof(memStat);
if (globalMemory(&memStat))
- LL_UI2L(bytes, memStat.ullTotalPhys);
+ bytes = memStat.ullTotalPhys;
}
}
- if (LL_EQ(bytes, LL_ZERO)) {
+ if (!bytes) {
/* Fall back to the older API. */
MEMORYSTATUS memStat;
memset(&memStat, 0, sizeof(memStat));
GlobalMemoryStatus(&memStat);
- LL_I2L(bytes, memStat.dwTotalPhys);
+ bytes = memStat.dwTotalPhys;
}
#elif defined(OS2)
@@ -338,7 +338,7 @@ PR_IMPLEMENT(PRUint64) PR_GetPhysicalMemorySize(void)
QSV_TOTPHYSMEM,
&ulPhysMem,
sizeof(ulPhysMem));
- LL_I2L(bytes, ulPhysMem);
+ bytes = ulPhysMem;
#elif defined(AIX)
@@ -346,9 +346,7 @@ PR_IMPLEMENT(PRUint64) PR_GetPhysicalMemorySize(void)
int how_many;
struct CuAt *obj = getattr("sys0", "realmem", 0, &how_many);
if (obj != NULL) {
- PRUint64 kbytes;
- LL_I2L(kbytes, atoi(obj->value));
- LL_MUL(bytes, kbytes, 1024);
+ bytes = (PRUint64) atoi(obj->value) * 1024;
free(obj);
}
odm_terminate();