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 /* ***** BEGIN LICENSE BLOCK ***** | 2 /* ***** BEGIN LICENSE BLOCK ***** |
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
4 * | 4 * |
5 * The contents of this file are subject to the Mozilla Public License Version | 5 * The contents of this file are subject to the Mozilla Public License Version |
6 * 1.1 (the "License"); you may not use this file except in compliance with | 6 * 1.1 (the "License"); you may not use this file except in compliance with |
7 * the License. You may obtain a copy of the License at | 7 * the License. You may obtain a copy of the License at |
8 * http://www.mozilla.org/MPL/ | 8 * http://www.mozilla.org/MPL/ |
9 * | 9 * |
10 * Software distributed under the License is distributed on an "AS IS" basis, | 10 * Software distributed under the License is distributed on an "AS IS" basis, |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 PR_IMPLEMENT(PRUint64) PR_GetPhysicalMemorySize(void) | 277 PR_IMPLEMENT(PRUint64) PR_GetPhysicalMemorySize(void) |
278 { | 278 { |
279 PRUint64 bytes = 0; | 279 PRUint64 bytes = 0; |
280 | 280 |
281 #if defined(LINUX) || defined(SOLARIS) | 281 #if defined(LINUX) || defined(SOLARIS) |
282 | 282 |
283 long pageSize = sysconf(_SC_PAGESIZE); | 283 long pageSize = sysconf(_SC_PAGESIZE); |
284 long pageCount = sysconf(_SC_PHYS_PAGES); | 284 long pageCount = sysconf(_SC_PHYS_PAGES); |
285 bytes = (PRUint64) pageSize * pageCount; | 285 bytes = (PRUint64) pageSize * pageCount; |
286 | 286 |
| 287 #elif defined(NETBSD) |
| 288 |
| 289 int mib[2]; |
| 290 int rc; |
| 291 uint64_t memSize; |
| 292 size_t len = sizeof(memSize); |
| 293 |
| 294 mib[0] = CTL_HW; |
| 295 mib[1] = HW_PHYSMEM64; |
| 296 rc = sysctl(mib, 2, &memSize, &len, NULL, 0); |
| 297 if (-1 != rc) { |
| 298 bytes = memSize; |
| 299 } |
| 300 |
287 #elif defined(HPUX) | 301 #elif defined(HPUX) |
288 | 302 |
289 struct pst_static info; | 303 struct pst_static info; |
290 int result = pstat_getstatic(&info, sizeof(info), 1, 0); | 304 int result = pstat_getstatic(&info, sizeof(info), 1, 0); |
291 if (result == 1) | 305 if (result == 1) |
292 bytes = (PRUint64) info.physical_memory * info.page_size; | 306 bytes = (PRUint64) info.physical_memory * info.page_size; |
293 | 307 |
294 #elif defined(DARWIN) | 308 #elif defined(DARWIN) |
295 | 309 |
296 struct host_basic_info hInfo; | 310 struct host_basic_info hInfo; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 } | 365 } |
352 | 366 |
353 #else | 367 #else |
354 | 368 |
355 PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); | 369 PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); |
356 | 370 |
357 #endif | 371 #endif |
358 | 372 |
359 return bytes; | 373 return bytes; |
360 } /* end PR_GetPhysicalMemorySize() */ | 374 } /* end PR_GetPhysicalMemorySize() */ |
OLD | NEW |