[compiler-rt] r318431 - Implement GetTls() for NetBSD
Kamil Rytarowski via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 16 09:54:14 PST 2017
Author: kamil
Date: Thu Nov 16 09:54:14 2017
New Revision: 318431
URL: http://llvm.org/viewvc/llvm-project?rev=318431&view=rev
Log:
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
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc
compiler-rt/trunk/test/tsan/tls_race.cc
compiler-rt/trunk/test/tsan/tls_race2.cc
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=318431&r1=318430&r2=318431&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 16 09:54:14 2017
@@ -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 *siz
*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 *siz
*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
Modified: compiler-rt/trunk/test/tsan/tls_race.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/tls_race.cc?rev=318431&r1=318430&r2=318431&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/tls_race.cc (original)
+++ compiler-rt/trunk/test/tsan/tls_race.cc Thu Nov 16 09:54:14 2017
@@ -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
Modified: compiler-rt/trunk/test/tsan/tls_race2.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/tls_race2.cc?rev=318431&r1=318430&r2=318431&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/tls_race2.cc (original)
+++ compiler-rt/trunk/test/tsan/tls_race2.cc Thu Nov 16 09:54:14 2017
@@ -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
More information about the llvm-commits
mailing list