[compiler-rt] r317834 - [sanitizer] Revert rL317822
Kostya Kortchinsky via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 9 13:26:07 PST 2017
Author: cryptoad
Date: Thu Nov 9 13:26:07 2017
New Revision: 317834
URL: http://llvm.org/viewvc/llvm-project?rev=317834&view=rev
Log:
[sanitizer] Revert rL317822
Summary:
This reverts D39490.
For toolchains generated with older NDKs (<=r13b as far as we tested),
`cpu_set_t` doesn't exist in `sched.h`.
We have to figure out another way to get the number of CPUs without this.
Reviewers: rnk
Reviewed By: rnk
Subscribers: kubamracek, llvm-commits, krytarowski
Differential Revision: https://reviews.llvm.org/D39867
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_fuchsia.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
compiler-rt/trunk/lib/scudo/scudo_tsd_shared.cpp
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=317834&r1=317833&r2=317834&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h Thu Nov 9 13:26:07 2017
@@ -933,9 +933,6 @@ void CheckNoDeepBind(const char *filenam
// 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,
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_fuchsia.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_fuchsia.cc?rev=317834&r1=317833&r2=317834&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_fuchsia.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_fuchsia.cc Thu Nov 9 13:26:07 2017
@@ -520,10 +520,6 @@ bool GetRandom(void *buffer, uptr length
return true;
}
-u32 GetNumberOfCPUs() {
- return zx_system_get_num_cpus();
-}
-
} // namespace __sanitizer
using namespace __sanitizer; // NOLINT
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc?rev=317834&r1=317833&r2=317834&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc Thu Nov 9 13:26:07 2017
@@ -30,7 +30,6 @@
#include <dlfcn.h> // for dlsym()
#include <link.h>
#include <pthread.h>
-#include <sched.h>
#include <signal.h>
#include <sys/resource.h>
#include <syslog.h>
@@ -38,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
@@ -544,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.
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc?rev=317834&r1=317833&r2=317834&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc Thu Nov 9 13:26:07 2017
@@ -1000,11 +1000,6 @@ bool GetRandom(void *buffer, uptr length
UNIMPLEMENTED();
}
-// FIXME: implement on this platform.
-u32 GetNumberOfCPUs() {
- UNIMPLEMENTED();
-}
-
} // namespace __sanitizer
#endif // SANITIZER_MAC
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc?rev=317834&r1=317833&r2=317834&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc Thu Nov 9 13:26:07 2017
@@ -1093,11 +1093,6 @@ bool GetRandom(void *buffer, uptr length
UNIMPLEMENTED();
}
-// FIXME: implement on this platform.
-u32 GetNumberOfCPUs() {
- UNIMPLEMENTED();
-}
-
} // namespace __sanitizer
#endif // _WIN32
Modified: compiler-rt/trunk/lib/scudo/scudo_tsd_shared.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/scudo_tsd_shared.cpp?rev=317834&r1=317833&r2=317834&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/scudo_tsd_shared.cpp (original)
+++ compiler-rt/trunk/lib/scudo/scudo_tsd_shared.cpp Thu Nov 9 13:26:07 2017
@@ -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"));
More information about the llvm-commits
mailing list