summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan/output_tests/static_init1.cc
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2012-05-10 14:18:22 +0000
committerKostya Serebryany <kcc@google.com>2012-05-10 14:18:22 +0000
commitff15ef0c506e65a7ecff95f52356320a96a89e4b (patch)
tree0778e5bfd36a80473a7970eb42e692e51c002c79 /compiler-rt/lib/tsan/output_tests/static_init1.cc
parentdf68b67f067a1e762eb045a6ebef3cb1ef8b8cbe (diff)
downloadbcm5719-llvm-ff15ef0c506e65a7ecff95f52356320a96a89e4b.tar.gz
bcm5719-llvm-ff15ef0c506e65a7ecff95f52356320a96a89e4b.zip
[tsan] ThreadSanitizer tests and micro benchmarks. No makefiles yet.
llvm-svn: 156545
Diffstat (limited to 'compiler-rt/lib/tsan/output_tests/static_init1.cc')
-rw-r--r--compiler-rt/lib/tsan/output_tests/static_init1.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/compiler-rt/lib/tsan/output_tests/static_init1.cc b/compiler-rt/lib/tsan/output_tests/static_init1.cc
new file mode 100644
index 00000000000..75d281954e1
--- /dev/null
+++ b/compiler-rt/lib/tsan/output_tests/static_init1.cc
@@ -0,0 +1,25 @@
+#include <pthread.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+struct P {
+ int x;
+ int y;
+};
+
+void *Thread(void *x) {
+ static P p = {rand(), rand()};
+ if (p.x > RAND_MAX || p.y > RAND_MAX)
+ exit(1);
+ return 0;
+}
+
+int main() {
+ pthread_t t[2];
+ pthread_create(&t[0], 0, Thread, 0);
+ pthread_create(&t[1], 0, Thread, 0);
+ pthread_join(t[0], 0);
+ pthread_join(t[1], 0);
+}
+
+// CHECK-NOT: WARNING: ThreadSanitizer: data race
OpenPOWER on IntegriCloud