зеркало из https://github.com/mozilla/pjs.git
fixes bug 308587 "PR_GetPhysicalMemorySize returns garbage on systems with more than 2GB RAM" r=wtc
This commit is contained in:
Родитель
730f1adf2c
Коммит
91bf1447bc
|
@ -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();
|
||||
|
|
Загрузка…
Ссылка в новой задаче