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 | 13007b2220cde5084e3b5e8bb7f0df4e0273eebd (patch) | |
tree | c62e4d0b3076165fc7478cffc7f669d74f518a66 | |
parent | cc318be68d46c405cce0e3a0725fa4bd8d295708 (diff) | |
download | llvm-13007b2220cde5084e3b5e8bb7f0df4e0273eebd.zip llvm-13007b2220cde5084e3b5e8bb7f0df4e0273eebd.tar.gz llvm-13007b2220cde5084e3b5e8bb7f0df4e0273eebd.tar.bz2 |
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
llvm-svn: 318431
-rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc | 12 | ||||
-rw-r--r-- | compiler-rt/test/tsan/tls_race.cc | 1 | ||||
-rw-r--r-- | compiler-rt/test/tsan/tls_race2.cc | 1 |
3 files changed, 7 insertions, 7 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc index 3e64e90..33f1dfb 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc +++ b/compiler-rt/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 diff --git a/compiler-rt/test/tsan/tls_race.cc b/compiler-rt/test/tsan/tls_race.cc index b43a514..dd37ff0 100644 --- a/compiler-rt/test/tsan/tls_race.cc +++ b/compiler-rt/test/tsan/tls_race.cc @@ -20,4 +20,5 @@ int main() { // CHECK: WARNING: ThreadSanitizer: data race // CHECK-Linux: Location is TLS of main thread. // CHECK-FreeBSD: Location is TLS of main thread. +// CHECK-NetBSD: Location is TLS of main thread. // CHECK-Darwin: Location is heap block of size 4 diff --git a/compiler-rt/test/tsan/tls_race2.cc b/compiler-rt/test/tsan/tls_race2.cc index b04ff67..f3139b6 100644 --- a/compiler-rt/test/tsan/tls_race2.cc +++ b/compiler-rt/test/tsan/tls_race2.cc @@ -27,4 +27,5 @@ int main() { // CHECK: WARNING: ThreadSanitizer: data race // CHECK-Linux: Location is TLS of thread T1. // CHECK-FreeBSD: Location is TLS of thread T1. +// CHECK-NetBSD: Location is TLS of thread T1. // CHECK-Darwin: Location is heap block of size 4 |