diff options
author | Kostya Kortchinsky <kostyak@google.com> | 2017-10-13 20:55:31 +0000 |
---|---|---|
committer | Kostya Kortchinsky <kostyak@google.com> | 2017-10-13 20:55:31 +0000 |
commit | e972b4cb282b92b0c15356660c4a95593066ef8c (patch) | |
tree | 8b947d7341e5ac451b910e8fc0e2514351059879 /lib/scudo/scudo_platform.h | |
parent | cb11821c26e019476a12f31757083c2cde4f3262 (diff) |
[scudo] Allow for non-Android Shared TSD platforms, part 2
Summary:
Follow up to D38826.
We introduce `pthread_{get,set}specific` versions of `{get,set}CurrentTSD` to
allow for non Android platforms to use the Shared TSD model.
We now allow `SCUDO_TSD_EXCLUSIVE` to be defined at compile time.
A couple of things:
- I know that `#if SANITIZER_ANDROID` is not ideal within a function, but in
the end I feel it looks more compact and clean than going the .inc route; I
am open to an alternative if anyone has one;
- `SCUDO_TSD_EXCLUSIVE=1` requires ELF TLS support (and not emutls as this uses
malloc). I haven't found anything to enforce that, so it's currently not
checked.
Reviewers: alekseyshl
Reviewed By: alekseyshl
Subscribers: srhines, llvm-commits
Differential Revision: https://reviews.llvm.org/D38854
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@315751 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/scudo/scudo_platform.h')
-rw-r--r-- | lib/scudo/scudo_platform.h | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/scudo/scudo_platform.h b/lib/scudo/scudo_platform.h index 86ddc1a25..095d6ef19 100644 --- a/lib/scudo/scudo_platform.h +++ b/lib/scudo/scudo_platform.h @@ -20,15 +20,25 @@ # error "The Scudo hardened allocator is not supported on this platform." #endif -#if SANITIZER_ANDROID || SANITIZER_FUCHSIA +#define SCUDO_TSD_EXCLUSIVE_SUPPORTED (!SANITIZER_ANDROID && !SANITIZER_FUCHSIA) + +#ifndef SCUDO_TSD_EXCLUSIVE +// SCUDO_TSD_EXCLUSIVE wasn't defined, use a default TSD model for the platform. +# if SANITIZER_ANDROID || SANITIZER_FUCHSIA // Android and Fuchsia use a pool of TSDs shared between threads. -# define SCUDO_TSD_EXCLUSIVE 0 -#elif SANITIZER_LINUX && !SANITIZER_ANDROID +# define SCUDO_TSD_EXCLUSIVE 0 +# elif SANITIZER_LINUX && !SANITIZER_ANDROID // Non-Android Linux use an exclusive TSD per thread. -# define SCUDO_TSD_EXCLUSIVE 1 -#else -# error "No default TSD model defined for this platform." -#endif // SANITIZER_ANDROID || SANITIZER_FUCHSIA +# define SCUDO_TSD_EXCLUSIVE 1 +# else +# error "No default TSD model defined for this platform." +# endif // SANITIZER_ANDROID || SANITIZER_FUCHSIA +#endif // SCUDO_TSD_EXCLUSIVE + +// If the exclusive TSD model is chosen, make sure the platform supports it. +#if SCUDO_TSD_EXCLUSIVE && !SCUDO_TSD_EXCLUSIVE_SUPPORTED +# error "The exclusive TSD model is not supported on this platform." +#endif namespace __scudo { |