fixes bug 308587 "PR_GetPhysicalMemorySize returns garbage on systems with more than 2GB RAM" r=wtc a=asa MOZILLA_1_8_BRANCH FIREFOX_1_5b2_RELEASE MOZILLA_1_8b5_RELEASE THUNDERBIRD_1_5b2_RELEASE
authordarin%meer.net
Mon, 19 Sep 2005 17:59:52 +0000
branchMOZILLA_1_8_BRANCH
changeset 3467 6fc6909652e15eaef19a010603e77b9ca1d464a6
parent 3461 f8c5ea0326a9da6d4e516083fd28ae2b99ac214f
child 3481 d17dd1306d3b59b86ec28ffb69dedeb3cdf0417e
push idunknown
push userunknown
push dateunknown
reviewerswtc, asa
bugs308587
fixes bug 308587 "PR_GetPhysicalMemorySize returns garbage on systems with more than 2GB RAM" r=wtc a=asa
pr/src/misc/prsystem.c
--- a/pr/src/misc/prsystem.c
+++ b/pr/src/misc/prsystem.c
@@ -273,87 +273,85 @@ PR_IMPLEMENT(PRInt32) PR_GetNumberOfProc
 **     bytes is the returned value.
 **   for each platform's "if defined" section
 **     declare your local variable
 **     do your thing, assign to bytes.
 ** 
 */
 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)
 
     struct host_basic_info hInfo;
     mach_msg_type_number_t count;
 
     int result = host_info(mach_host_self(),
                            HOST_BASIC_INFO,
                            (host_info_t) &hInfo,
                            &count);
     if (result == KERN_SUCCESS)
-        LL_I2L(bytes, hInfo.memory_size);
+        bytes = hInfo.memory_size;
 
 #elif defined(WIN32)
 
     /* Try to use the newer GlobalMemoryStatusEx API for Windows 2000+. */
     GlobalMemoryStatusExFn globalMemory = (GlobalMemoryStatusExFn) NULL;
     HMODULE module = GetModuleHandle("kernel32.dll");
 
     if (module) {
         globalMemory = (GlobalMemoryStatusExFn)GetProcAddress(module, "GlobalMemoryStatusEx");
 
         if (globalMemory) {
             PR_MEMORYSTATUSEX memStat;
             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)
 
     ULONG ulPhysMem;
     DosQuerySysInfo(QSV_TOTPHYSMEM,
                     QSV_TOTPHYSMEM,
                     &ulPhysMem,
                     sizeof(ulPhysMem));
-    LL_I2L(bytes, ulPhysMem);
+    bytes = ulPhysMem;
 
 #elif defined(AIX)
 
     if (odm_initialize() == 0) {
         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();
     }
 
 #else
 
     PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);