diff options
author | Kamil Rytarowski <n54@gmx.com> | 2017-11-16 17:54:14 +0000 |
---|---|---|
committer | Kamil Rytarowski <n54@gmx.com> | 2017-11-16 17:54:14 +0000 |
commit | 6692a59458ab016453e89a6b4a7f559335c14293 (patch) | |
tree | 6e537a74e5feda850f4bc57dda2fee554627dd89 /lib | |
parent | 871a521d0c3232a89e9f33e6d55f84154bbf9d39 (diff) |
Implement GetTls() for NetBSD
Summary:
Reuse the existing code for FreeBSD that is compatible with NetBSD.
Add NetBSD support in tests: tls_race.cc and tls_race2.cc.
Sponsored by <The NetBSD Foundation>
Reviewers: joerg, dvyukov, vitalybuka, kcc, eugenis
Reviewed By: dvyukov
Subscribers: srhines, emaste, kubamracek, llvm-commits, #sanitizers
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D40105
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@318431 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sanitizer_common/sanitizer_linux_libcdep.cc | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/lib/sanitizer_common/sanitizer_linux_libcdep.cc index 3e64e90b5..33f1dfb58 100644 --- a/lib/sanitizer_common/sanitizer_linux_libcdep.cc +++ b/lib/sanitizer_common/sanitizer_linux_libcdep.cc @@ -312,7 +312,7 @@ uptr ThreadSelf() { } #endif // (x86_64 || i386 || MIPS) && SANITIZER_LINUX -#if SANITIZER_FREEBSD +#if SANITIZER_FREEBSD || SANITIZER_NETBSD static void **ThreadSelfSegbase() { void **segbase = 0; # if defined(__i386__) @@ -322,7 +322,7 @@ static void **ThreadSelfSegbase() { // sysarch(AMD64_GET_FSBASE, segbase); __asm __volatile("movq %%fs:0, %0" : "=r" (segbase)); # else -# error "unsupported CPU arch for FreeBSD platform" +# error "unsupported CPU arch" # endif return segbase; } @@ -330,9 +330,7 @@ static void **ThreadSelfSegbase() { uptr ThreadSelf() { return (uptr)ThreadSelfSegbase()[2]; } -#elif SANITIZER_NETBSD -uptr ThreadSelf() { return (uptr)pthread_self(); } -#endif // SANITIZER_NETBSD +#endif // SANITIZER_FREEBSD || SANITIZER_NETBSD #if !SANITIZER_GO static void GetTls(uptr *addr, uptr *size) { @@ -350,7 +348,7 @@ static void GetTls(uptr *addr, uptr *size) { *addr = 0; *size = 0; # endif -#elif SANITIZER_FREEBSD +#elif SANITIZER_FREEBSD || SANITIZER_NETBSD void** segbase = ThreadSelfSegbase(); *addr = 0; *size = 0; @@ -363,7 +361,7 @@ static void GetTls(uptr *addr, uptr *size) { *addr = (uptr) dtv[2]; *size = (*addr == 0) ? 0 : ((uptr) segbase[0] - (uptr) dtv[2]); } -#elif SANITIZER_ANDROID || SANITIZER_NETBSD +#elif SANITIZER_ANDROID *addr = 0; *size = 0; #else |