diff options
| author | Kostya Kortchinsky <kostyak@google.com> | 2017-11-09 21:26:07 +0000 |
|---|---|---|
| committer | Kostya Kortchinsky <kostyak@google.com> | 2017-11-09 21:26:07 +0000 |
| commit | 5604ad1c9b6af40e28e7172cea637854273ac8bb (patch) | |
| tree | fae05b720af5784b9a3fc636a76db4a4b8c64457 /compiler-rt/lib/scudo/scudo_tsd_shared.cpp | |
| parent | 41856684c143d96631ca60614830e8b9a075f8e4 (diff) | |
| download | bcm5719-llvm-5604ad1c9b6af40e28e7172cea637854273ac8bb.tar.gz bcm5719-llvm-5604ad1c9b6af40e28e7172cea637854273ac8bb.zip | |
[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
llvm-svn: 317834
Diffstat (limited to 'compiler-rt/lib/scudo/scudo_tsd_shared.cpp')
| -rw-r--r-- | compiler-rt/lib/scudo/scudo_tsd_shared.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler-rt/lib/scudo/scudo_tsd_shared.cpp b/compiler-rt/lib/scudo/scudo_tsd_shared.cpp index 25575afcb3e..191c9ff13bb 100644 --- a/compiler-rt/lib/scudo/scudo_tsd_shared.cpp +++ b/compiler-rt/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")); |

