summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2017-11-08 01:33:15 +0000
committerReid Kleckner <rnk@google.com>2017-11-08 01:33:15 +0000
commit3806f9ea105f0e9554d87862d81caeadb81d44f6 (patch)
treeef7f32f4eb63c256d6fed8307dfded142465578d /lib
parent644af7779f086cb428b7b76da5509348e3a2358f (diff)
Revert "[scudo] Make getNumberOfCPUs Fuchsia compliant"
This reverts commit r317604. Android doesn't have cpu_set_t. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317655 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/sanitizer_common/sanitizer_common.h3
-rw-r--r--lib/sanitizer_common/sanitizer_fuchsia.cc4
-rw-r--r--lib/sanitizer_common/sanitizer_linux_libcdep.cc22
-rw-r--r--lib/sanitizer_common/sanitizer_mac.cc5
-rw-r--r--lib/sanitizer_common/sanitizer_win.cc5
-rw-r--r--lib/scudo/scudo_tsd_shared.cpp9
6 files changed, 8 insertions, 40 deletions
diff --git a/lib/sanitizer_common/sanitizer_common.h b/lib/sanitizer_common/sanitizer_common.h
index b322f4712..d64d3e153 100644
--- a/lib/sanitizer_common/sanitizer_common.h
+++ b/lib/sanitizer_common/sanitizer_common.h
@@ -933,9 +933,6 @@ void CheckNoDeepBind(const char *filename, int flag);
// be used to seed a PRNG. Defaults to blocking like the underlying syscall.
bool GetRandom(void *buffer, uptr length, bool blocking = true);
-// Returns the number of logical processors on the system.
-u32 GetNumberOfCPUs();
-
} // namespace __sanitizer
inline void *operator new(__sanitizer::operator_new_size_type size,
diff --git a/lib/sanitizer_common/sanitizer_fuchsia.cc b/lib/sanitizer_common/sanitizer_fuchsia.cc
index 45104e5bc..97dff0d8b 100644
--- a/lib/sanitizer_common/sanitizer_fuchsia.cc
+++ b/lib/sanitizer_common/sanitizer_fuchsia.cc
@@ -520,10 +520,6 @@ bool GetRandom(void *buffer, uptr length, bool blocking) {
return true;
}
-u32 GetNumberOfCPUs() {
- return zx_system_get_num_cpus();
-}
-
} // namespace __sanitizer
using namespace __sanitizer; // NOLINT
diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
index 495fa255d..0dc437585 100644
--- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc
+++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc
@@ -37,14 +37,9 @@
#if SANITIZER_FREEBSD
#include <pthread_np.h>
#include <osreldate.h>
-#include <sys/sysctl.h>
#define pthread_getattr_np pthread_attr_get_np
#endif
-#if SANITIZER_NETBSD
-#include <sys/sysctl.h>
-#endif
-
#if SANITIZER_LINUX
#include <sys/prctl.h>
#endif
@@ -543,23 +538,6 @@ uptr GetRSS() {
return rss * GetPageSizeCached();
}
-// sysconf(_SC_NPROCESSORS_{CONF,ONLN}) cannot be used as they allocate memory.
-u32 GetNumberOfCPUs() {
-#if SANITIZER_FREEBSD || SANITIZER_NETBSD
- u32 ncpu;
- int req[2];
- size_t len = sizeof(ncpu);
- req[0] = CTL_HW;
- req[1] = HW_NCPU;
- CHECK_EQ(sysctl(req, 2, &ncpu, &len, NULL, 0), 0);
- return ncpu;
-#else
- cpu_set_t CPUs;
- CHECK_EQ(sched_getaffinity(0, sizeof(cpu_set_t), &CPUs), 0);
- return CPU_COUNT(&CPUs);
-#endif
-}
-
// 64-bit Android targets don't provide the deprecated __android_log_write.
// Starting with the L release, syslog() works and is preferable to
// __android_log_write.
diff --git a/lib/sanitizer_common/sanitizer_mac.cc b/lib/sanitizer_common/sanitizer_mac.cc
index fbc8cdd1f..7a93c112b 100644
--- a/lib/sanitizer_common/sanitizer_mac.cc
+++ b/lib/sanitizer_common/sanitizer_mac.cc
@@ -1000,11 +1000,6 @@ bool GetRandom(void *buffer, uptr length, bool blocking) {
UNIMPLEMENTED();
}
-// FIXME: implement on this platform.
-u32 GetNumberOfCPUs() {
- UNIMPLEMENTED();
-}
-
} // namespace __sanitizer
#endif // SANITIZER_MAC
diff --git a/lib/sanitizer_common/sanitizer_win.cc b/lib/sanitizer_common/sanitizer_win.cc
index 7a9a94780..1186971f7 100644
--- a/lib/sanitizer_common/sanitizer_win.cc
+++ b/lib/sanitizer_common/sanitizer_win.cc
@@ -1093,11 +1093,6 @@ bool GetRandom(void *buffer, uptr length, bool blocking) {
UNIMPLEMENTED();
}
-// FIXME: implement on this platform.
-u32 GetNumberOfCPUs() {
- UNIMPLEMENTED();
-}
-
} // namespace __sanitizer
#endif // _WIN32
diff --git a/lib/scudo/scudo_tsd_shared.cpp b/lib/scudo/scudo_tsd_shared.cpp
index 25575afcb..191c9ff13 100644
--- a/lib/scudo/scudo_tsd_shared.cpp
+++ b/lib/scudo/scudo_tsd_shared.cpp
@@ -24,10 +24,17 @@ static atomic_uint32_t CurrentIndex;
static ScudoTSD *TSDs;
static u32 NumberOfTSDs;
+// sysconf(_SC_NPROCESSORS_{CONF,ONLN}) cannot be used as they allocate memory.
+static u32 getNumberOfCPUs() {
+ cpu_set_t CPUs;
+ CHECK_EQ(sched_getaffinity(0, sizeof(cpu_set_t), &CPUs), 0);
+ return CPU_COUNT(&CPUs);
+}
+
static void initOnce() {
CHECK_EQ(pthread_key_create(&PThreadKey, NULL), 0);
initScudo();
- NumberOfTSDs = Min(Max(1U, GetNumberOfCPUs()),
+ NumberOfTSDs = Min(Max(1U, getNumberOfCPUs()),
static_cast<u32>(SCUDO_SHARED_TSD_POOL_SIZE));
TSDs = reinterpret_cast<ScudoTSD *>(
MmapOrDie(sizeof(ScudoTSD) * NumberOfTSDs, "ScudoTSDs"));