| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 University of Szeged. All rights reserved. | 2 * Copyright (C) 2012 University of Szeged. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "NumberOfCores.h" | 27 #include "NumberOfCores.h" |
| 28 | 28 |
| 29 #if OS(DARWIN) || OS(OPENBSD) || OS(NETBSD) || OS(FREEBSD) | 29 #if OS(DARWIN) || OS(OPENBSD) || OS(NETBSD) || OS(FREEBSD) |
| 30 #include <sys/param.h> | 30 #include <sys/param.h> |
| 31 // sys/types.h must come before sys/sysctl.h because the latter uses | 31 // sys/types.h must come before sys/sysctl.h because the latter uses |
| 32 // data types defined in the former. See sysctl(3) and style(9). | 32 // data types defined in the former. See sysctl(3) and style(9). |
| 33 #include <sys/types.h> | 33 #include <sys/types.h> |
| 34 #include <sys/sysctl.h> | 34 #include <sys/sysctl.h> |
| 35 #elif OS(LINUX) || OS(AIX) || OS(SOLARIS) | 35 #elif OS(LINUX) || OS(AIX) || OS(SOLARIS) |
| 36 #include <unistd.h> | 36 #include <unistd.h> |
| 37 #elif OS(WINDOWS) || OS(QNX) | 37 #elif OS(WINDOWS) |
| 38 #include <wtf/UnusedParam.h> | 38 #include <wtf/UnusedParam.h> |
| 39 #if OS(WINDOWS) | 39 #if OS(WINDOWS) |
| 40 #include <windows.h> | 40 #include <windows.h> |
| 41 #elif OS(QNX) | |
| 42 #include <sys/syspage.h> | |
| 43 #endif | 41 #endif |
| 44 #endif | 42 #endif |
| 45 | 43 |
| 46 namespace WTF { | 44 namespace WTF { |
| 47 | 45 |
| 48 int numberOfProcessorCores() | 46 int numberOfProcessorCores() |
| 49 { | 47 { |
| 50 const int defaultIfUnavailable = 1; | 48 const int defaultIfUnavailable = 1; |
| 51 static int s_numberOfCores = -1; | 49 static int s_numberOfCores = -1; |
| 52 | 50 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 66 #elif OS(LINUX) || OS(AIX) || OS(SOLARIS) | 64 #elif OS(LINUX) || OS(AIX) || OS(SOLARIS) |
| 67 long sysconfResult = sysconf(_SC_NPROCESSORS_ONLN); | 65 long sysconfResult = sysconf(_SC_NPROCESSORS_ONLN); |
| 68 | 66 |
| 69 s_numberOfCores = sysconfResult < 0 ? defaultIfUnavailable : static_cast<int
>(sysconfResult); | 67 s_numberOfCores = sysconfResult < 0 ? defaultIfUnavailable : static_cast<int
>(sysconfResult); |
| 70 #elif OS(WINDOWS) | 68 #elif OS(WINDOWS) |
| 71 UNUSED_PARAM(defaultIfUnavailable); | 69 UNUSED_PARAM(defaultIfUnavailable); |
| 72 SYSTEM_INFO sysInfo; | 70 SYSTEM_INFO sysInfo; |
| 73 GetSystemInfo(&sysInfo); | 71 GetSystemInfo(&sysInfo); |
| 74 | 72 |
| 75 s_numberOfCores = sysInfo.dwNumberOfProcessors; | 73 s_numberOfCores = sysInfo.dwNumberOfProcessors; |
| 76 #elif OS(QNX) | |
| 77 UNUSED_PARAM(defaultIfUnavailable); | |
| 78 | |
| 79 s_numberOfCores = _syspage_ptr->num_cpu; | |
| 80 #else | 74 #else |
| 81 s_numberOfCores = defaultIfUnavailable; | 75 s_numberOfCores = defaultIfUnavailable; |
| 82 #endif | 76 #endif |
| 83 return s_numberOfCores; | 77 return s_numberOfCores; |
| 84 } | 78 } |
| 85 | 79 |
| 86 } | 80 } |
| OLD | NEW |