| OLD | NEW |
| 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 /* This Source Code Form is subject to the terms of the Mozilla Public | 2 /* This Source Code Form is subject to the terms of the Mozilla Public |
| 3 * License, v. 2.0. If a copy of the MPL was not distributed with this | 3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 5 | 5 |
| 6 #include "primpl.h" | 6 #include "primpl.h" |
| 7 #include "prsystem.h" | 7 #include "prsystem.h" |
| 8 #include "prprf.h" | 8 #include "prprf.h" |
| 9 #include "prlong.h" | 9 #include "prlong.h" |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include <string.h> | 49 #include <string.h> |
| 50 #include <ctype.h> | 50 #include <ctype.h> |
| 51 #define MAX_LINE 512 | 51 #define MAX_LINE 512 |
| 52 #endif | 52 #endif |
| 53 | 53 |
| 54 #if defined(AIX) | 54 #if defined(AIX) |
| 55 #include <cf.h> | 55 #include <cf.h> |
| 56 #include <sys/cfgodm.h> | 56 #include <sys/cfgodm.h> |
| 57 #endif | 57 #endif |
| 58 | 58 |
| 59 #if defined(WIN32) | |
| 60 /* This struct is not present in VC6 headers, so declare it here */ | |
| 61 typedef struct { | |
| 62 DWORD dwLength; | |
| 63 DWORD dwMemoryLoad; | |
| 64 DWORDLONG ullTotalPhys; | |
| 65 DWORDLONG ullAvailPhys; | |
| 66 DWORDLONG ullToalPageFile; | |
| 67 DWORDLONG ullAvailPageFile; | |
| 68 DWORDLONG ullTotalVirtual; | |
| 69 DWORDLONG ullAvailVirtual; | |
| 70 DWORDLONG ullAvailExtendedVirtual; | |
| 71 } PR_MEMORYSTATUSEX; | |
| 72 | |
| 73 /* Typedef for dynamic lookup of GlobalMemoryStatusEx(). */ | |
| 74 typedef BOOL (WINAPI *GlobalMemoryStatusExFn)(PR_MEMORYSTATUSEX *); | |
| 75 #endif | |
| 76 | |
| 77 PR_IMPLEMENT(char) PR_GetDirectorySeparator(void) | 59 PR_IMPLEMENT(char) PR_GetDirectorySeparator(void) |
| 78 { | 60 { |
| 79 return PR_DIRECTORY_SEPARATOR; | 61 return PR_DIRECTORY_SEPARATOR; |
| 80 } /* PR_GetDirectorySeparator */ | 62 } /* PR_GetDirectorySeparator */ |
| 81 | 63 |
| 82 /* | 64 /* |
| 83 ** OBSOLETE -- the function name is misspelled. | 65 ** OBSOLETE -- the function name is misspelled. |
| 84 */ | 66 */ |
| 85 PR_IMPLEMENT(char) PR_GetDirectorySepartor(void) | 67 PR_IMPLEMENT(char) PR_GetDirectorySepartor(void) |
| 86 { | 68 { |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 302 |
| 321 int result = host_info(mach_host_self(), | 303 int result = host_info(mach_host_self(), |
| 322 HOST_BASIC_INFO, | 304 HOST_BASIC_INFO, |
| 323 (host_info_t) &hInfo, | 305 (host_info_t) &hInfo, |
| 324 &count); | 306 &count); |
| 325 if (result == KERN_SUCCESS) | 307 if (result == KERN_SUCCESS) |
| 326 bytes = hInfo.max_mem; | 308 bytes = hInfo.max_mem; |
| 327 | 309 |
| 328 #elif defined(WIN32) | 310 #elif defined(WIN32) |
| 329 | 311 |
| 330 /* Try to use the newer GlobalMemoryStatusEx API for Windows 2000+. */ | 312 MEMORYSTATUSEX memStat; |
| 331 GlobalMemoryStatusExFn globalMemory = (GlobalMemoryStatusExFn) NULL; | 313 memStat.dwLength = sizeof(memStat); |
| 332 HMODULE module = GetModuleHandleW(L"kernel32.dll"); | 314 if (GlobalMemoryStatusEx(&memStat)) |
| 333 | 315 bytes = memStat.ullTotalPhys; |
| 334 if (module) { | |
| 335 globalMemory = (GlobalMemoryStatusExFn)GetProcAddress(module, "GlobalMem
oryStatusEx"); | |
| 336 | |
| 337 if (globalMemory) { | |
| 338 PR_MEMORYSTATUSEX memStat; | |
| 339 memStat.dwLength = sizeof(memStat); | |
| 340 | |
| 341 if (globalMemory(&memStat)) | |
| 342 bytes = memStat.ullTotalPhys; | |
| 343 } | |
| 344 } | |
| 345 | |
| 346 if (!bytes) { | |
| 347 /* Fall back to the older API. */ | |
| 348 MEMORYSTATUS memStat; | |
| 349 memset(&memStat, 0, sizeof(memStat)); | |
| 350 GlobalMemoryStatus(&memStat); | |
| 351 bytes = memStat.dwTotalPhys; | |
| 352 } | |
| 353 | 316 |
| 354 #elif defined(OS2) | 317 #elif defined(OS2) |
| 355 | 318 |
| 356 ULONG ulPhysMem; | 319 ULONG ulPhysMem; |
| 357 DosQuerySysInfo(QSV_TOTPHYSMEM, | 320 DosQuerySysInfo(QSV_TOTPHYSMEM, |
| 358 QSV_TOTPHYSMEM, | 321 QSV_TOTPHYSMEM, |
| 359 &ulPhysMem, | 322 &ulPhysMem, |
| 360 sizeof(ulPhysMem)); | 323 sizeof(ulPhysMem)); |
| 361 bytes = ulPhysMem; | 324 bytes = ulPhysMem; |
| 362 | 325 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 373 } | 336 } |
| 374 | 337 |
| 375 #else | 338 #else |
| 376 | 339 |
| 377 PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); | 340 PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); |
| 378 | 341 |
| 379 #endif | 342 #endif |
| 380 | 343 |
| 381 return bytes; | 344 return bytes; |
| 382 } /* end PR_GetPhysicalMemorySize() */ | 345 } /* end PR_GetPhysicalMemorySize() */ |
| OLD | NEW |