| 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 |
| 11 #if defined(BEOS) | 11 #if defined(BEOS) |
| 12 #include <kernel/OS.h> | 12 #include <kernel/OS.h> |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 #if defined(OS2) | 15 #if defined(OS2) |
| 16 #define INCL_DOS | 16 #define INCL_DOS |
| 17 #define INCL_DOSMISC | 17 #define INCL_DOSMISC |
| 18 #include <os2.h> | 18 #include <os2.h> |
| 19 /* define the required constant if it is not already defined in the headers */ | 19 /* define the required constant if it is not already defined in the headers */ |
| 20 #ifndef QSV_NUMPROCESSORS | 20 #ifndef QSV_NUMPROCESSORS |
| 21 #define QSV_NUMPROCESSORS 26 | 21 #define QSV_NUMPROCESSORS 26 |
| 22 #endif | 22 #endif |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 /* BSD-derived systems use sysctl() to get the number of processors */ | 25 /* BSD-derived systems use sysctl() to get the number of processors */ |
| 26 #if defined(BSDI) || defined(FREEBSD) || defined(NETBSD) \ | 26 #if defined(BSDI) || defined(FREEBSD) || defined(NETBSD) \ |
| 27 || defined(OPENBSD) || defined(DARWIN) | 27 || defined(OPENBSD) || defined(DRAGONFLY) || defined(DARWIN) |
| 28 #define _PR_HAVE_SYSCTL | 28 #define _PR_HAVE_SYSCTL |
| 29 #include <sys/param.h> | 29 #include <sys/param.h> |
| 30 #include <sys/sysctl.h> | 30 #include <sys/sysctl.h> |
| 31 #endif | 31 #endif |
| 32 | 32 |
| 33 #if defined(DARWIN) | 33 #if defined(DARWIN) |
| 34 #include <mach/mach_init.h> | 34 #include <mach/mach_init.h> |
| 35 #include <mach/mach_host.h> | 35 #include <mach/mach_host.h> |
| 36 #include <mach/mach_port.h> | 36 #include <mach/mach_port.h> |
| 37 #endif | 37 #endif |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 { | 268 { |
| 269 PRUint64 bytes = 0; | 269 PRUint64 bytes = 0; |
| 270 | 270 |
| 271 #if defined(LINUX) || defined(SOLARIS) | 271 #if defined(LINUX) || defined(SOLARIS) |
| 272 | 272 |
| 273 long pageSize = sysconf(_SC_PAGESIZE); | 273 long pageSize = sysconf(_SC_PAGESIZE); |
| 274 long pageCount = sysconf(_SC_PHYS_PAGES); | 274 long pageCount = sysconf(_SC_PHYS_PAGES); |
| 275 if (pageSize >= 0 && pageCount >= 0) | 275 if (pageSize >= 0 && pageCount >= 0) |
| 276 bytes = (PRUint64) pageSize * pageCount; | 276 bytes = (PRUint64) pageSize * pageCount; |
| 277 | 277 |
| 278 #elif defined(NETBSD) || defined(OPENBSD) | 278 #elif defined(NETBSD) || defined(OPENBSD) \ |
| 279 || defined(FREEBSD) || defined(DRAGONFLY) |
| 279 | 280 |
| 280 int mib[2]; | 281 int mib[2]; |
| 281 int rc; | 282 int rc; |
| 283 #ifdef HW_PHYSMEM64 |
| 282 uint64_t memSize; | 284 uint64_t memSize; |
| 285 #else |
| 286 unsigned long memSize; |
| 287 #endif |
| 283 size_t len = sizeof(memSize); | 288 size_t len = sizeof(memSize); |
| 284 | 289 |
| 285 mib[0] = CTL_HW; | 290 mib[0] = CTL_HW; |
| 291 #ifdef HW_PHYSMEM64 |
| 286 mib[1] = HW_PHYSMEM64; | 292 mib[1] = HW_PHYSMEM64; |
| 293 #else |
| 294 mib[1] = HW_PHYSMEM; |
| 295 #endif |
| 287 rc = sysctl(mib, 2, &memSize, &len, NULL, 0); | 296 rc = sysctl(mib, 2, &memSize, &len, NULL, 0); |
| 288 if (-1 != rc) { | 297 if (-1 != rc) { |
| 289 bytes = memSize; | 298 bytes = memSize; |
| 290 } | 299 } |
| 291 | 300 |
| 292 #elif defined(HPUX) | 301 #elif defined(HPUX) |
| 293 | 302 |
| 294 struct pst_static info; | 303 struct pst_static info; |
| 295 int result = pstat_getstatic(&info, sizeof(info), 1, 0); | 304 int result = pstat_getstatic(&info, sizeof(info), 1, 0); |
| 296 if (result == 1) | 305 if (result == 1) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 } | 348 } |
| 340 | 349 |
| 341 #else | 350 #else |
| 342 | 351 |
| 343 PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); | 352 PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); |
| 344 | 353 |
| 345 #endif | 354 #endif |
| 346 | 355 |
| 347 return bytes; | 356 return bytes; |
| 348 } /* end PR_GetPhysicalMemorySize() */ | 357 } /* end PR_GetPhysicalMemorySize() */ |
| OLD | NEW |