[compiler-rt] e777317 - [tsan] Make pthread_mutex_clocklock Linux only

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 18 15:01:30 PST 2023


Author: Fangrui Song
Date: 2023-12-18T15:01:25-08:00
New Revision: e77731722755f8b397c0fd9e3bf574128af6c137

URL: https://github.com/llvm/llvm-project/commit/e77731722755f8b397c0fd9e3bf574128af6c137
DIFF: https://github.com/llvm/llvm-project/commit/e77731722755f8b397c0fd9e3bf574128af6c137.diff

LOG: [tsan] Make pthread_mutex_clocklock Linux only

Many systems (glibc<2.30, Bionic before 2019, musl, macOS, etc) do not have the function.

Added: 
    

Modified: 
    compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
    compiler-rt/test/tsan/pthread_mutex_clocklock.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
index da0ad8eb42ab4a..fdcba6e8ca7398 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
@@ -1380,6 +1380,7 @@ TSAN_INTERCEPTOR(int, pthread_mutex_unlock, void *m) {
   return res;
 }
 
+#if SANITIZER_LINUX
 TSAN_INTERCEPTOR(int, pthread_mutex_clocklock, void *m,
                  __sanitizer_clockid_t clock, void *abstime) {
   SCOPED_TSAN_INTERCEPTOR(pthread_mutex_clocklock, m, clock, abstime);
@@ -1393,6 +1394,7 @@ TSAN_INTERCEPTOR(int, pthread_mutex_clocklock, void *m,
     MutexInvalidAccess(thr, pc, (uptr)m);
   return res;
 }
+#endif
 
 #if SANITIZER_GLIBC
 #  if !__GLIBC_PREREQ(2, 34)

diff  --git a/compiler-rt/test/tsan/pthread_mutex_clocklock.cpp b/compiler-rt/test/tsan/pthread_mutex_clocklock.cpp
index dbca0b42039181..63d329928080de 100644
--- a/compiler-rt/test/tsan/pthread_mutex_clocklock.cpp
+++ b/compiler-rt/test/tsan/pthread_mutex_clocklock.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
-// UNSUPPORTED: darwin
+// REQUIRES: glibc-2.30
 #include <pthread.h>
 #include <stdio.h>
 
@@ -26,4 +26,4 @@ int main() {
 }
 
 // CHECK-NOT: WARNING: ThreadSanitizer: unlock of an unlocked mutex
-// CHECK: PASS
\ No newline at end of file
+// CHECK: PASS


        


More information about the llvm-commits mailing list