summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan/lit_tests
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2013-10-29 10:30:39 +0000
committerDmitry Vyukov <dvyukov@google.com>2013-10-29 10:30:39 +0000
commit3e8432ee6c93bb5645ca85c8daab03a35b41eead (patch)
treec7b8407a701cc379f6b73b524c732a1320f7d408 /compiler-rt/lib/tsan/lit_tests
parentda797048d9dac2b34880c9858a393c5af08e817b (diff)
downloadbcm5719-llvm-3e8432ee6c93bb5645ca85c8daab03a35b41eead.tar.gz
bcm5719-llvm-3e8432ee6c93bb5645ca85c8daab03a35b41eead.zip
tsan/asan: support pthread_setname_np to set thread names
llvm-svn: 193602
Diffstat (limited to 'compiler-rt/lib/tsan/lit_tests')
-rw-r--r--compiler-rt/lib/tsan/lit_tests/thread_name2.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/compiler-rt/lib/tsan/lit_tests/thread_name2.cc b/compiler-rt/lib/tsan/lit_tests/thread_name2.cc
new file mode 100644
index 00000000000..8c5cb741f61
--- /dev/null
+++ b/compiler-rt/lib/tsan/lit_tests/thread_name2.cc
@@ -0,0 +1,32 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && not %t 2>&1 | FileCheck %s
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+
+int Global;
+
+void *Thread1(void *x) {
+ sleep(1);
+ Global++;
+ return 0;
+}
+
+void *Thread2(void *x) {
+ pthread_setname_np(pthread_self(), "foobar2");
+ Global--;
+ return 0;
+}
+
+int main() {
+ pthread_t t[2];
+ pthread_create(&t[0], 0, Thread1, 0);
+ pthread_create(&t[1], 0, Thread2, 0);
+ pthread_setname_np(t[0], "foobar1");
+ pthread_join(t[0], NULL);
+ pthread_join(t[1], NULL);
+}
+
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK: Thread T1 'foobar1'
+// CHECK: Thread T2 'foobar2'
+
OpenPOWER on IntegriCloud