Index: lib/sanitizer_common/sanitizer_linux_libcdep.cc =================================================================== --- lib/sanitizer_common/sanitizer_linux_libcdep.cc +++ lib/sanitizer_common/sanitizer_linux_libcdep.cc @@ -316,7 +316,7 @@ } #endif // (x86_64 || i386 || MIPS) && SANITIZER_LINUX -#if SANITIZER_FREEBSD +#if SANITIZER_FREEBSD || SANITIZER_NETBSD static void **ThreadSelfSegbase() { void **segbase = 0; # if defined(__i386__) @@ -326,7 +326,7 @@ // 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; } @@ -334,9 +334,7 @@ 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) { @@ -354,7 +352,7 @@ *addr = 0; *size = 0; # endif -#elif SANITIZER_FREEBSD +#elif SANITIZER_FREEBSD || SANITIZER_NETBSD void** segbase = ThreadSelfSegbase(); *addr = 0; *size = 0; @@ -367,7 +365,7 @@ *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 Index: test/tsan/tls_race.cc =================================================================== --- test/tsan/tls_race.cc +++ test/tsan/tls_race.cc @@ -20,4 +20,5 @@ // 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 Index: test/tsan/tls_race2.cc =================================================================== --- test/tsan/tls_race2.cc +++ test/tsan/tls_race2.cc @@ -27,4 +27,5 @@ // 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