aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/c-c++-common/tsan/simple_stack.c
diff options
context:
space:
mode:
authorYiran Wang <yiran@google.com>2015-06-23 15:33:17 -0700
committerYiran Wang <yiran@google.com>2015-06-29 10:56:28 -0700
commit1d9fec7937f45dde5e04cac966a2d9a12f2fc15a (patch)
tree3fbcd18a379a05fd6d43491a107e1f36bc61b185 /gcc-4.9/gcc/testsuite/c-c++-common/tsan/simple_stack.c
parentf378ebf14df0952eae870c9865bab8326aa8f137 (diff)
downloadtoolchain_gcc-1d9fec7937f45dde5e04cac966a2d9a12f2fc15a.tar.gz
toolchain_gcc-1d9fec7937f45dde5e04cac966a2d9a12f2fc15a.tar.bz2
toolchain_gcc-1d9fec7937f45dde5e04cac966a2d9a12f2fc15a.zip
Synchronize with google/gcc-4_9 to r224707 (from r214835)
Change-Id: I3d6f06fc613c8f8b6a82143dc44b7338483aac5d
Diffstat (limited to 'gcc-4.9/gcc/testsuite/c-c++-common/tsan/simple_stack.c')
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/tsan/simple_stack.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/tsan/simple_stack.c b/gcc-4.9/gcc/testsuite/c-c++-common/tsan/simple_stack.c
index b66a67085..a4d0aba69 100644
--- a/gcc-4.9/gcc/testsuite/c-c++-common/tsan/simple_stack.c
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/tsan/simple_stack.c
@@ -1,9 +1,10 @@
/* { dg-shouldfail "tsan" } */
+/* { dg-additional-options "-ldl" } */
#include <pthread.h>
-#include <stdio.h>
-#include <unistd.h>
+#include "tsan_barrier.h"
+static pthread_barrier_t barrier;
int Global;
void __attribute__((noinline)) foo1() {
@@ -25,13 +26,14 @@ void __attribute__((noinline)) bar2() {
}
void *Thread1(void *x) {
- sleep(1);
+ barrier_wait(&barrier);
bar1();
return NULL;
}
void *Thread2(void *x) {
bar2();
+ barrier_wait(&barrier);
return NULL;
}
@@ -40,6 +42,7 @@ void StartThread(pthread_t *t, void *(*f)(void*)) {
}
int main() {
+ barrier_init(&barrier, 2);
pthread_t t[2];
StartThread(&t[0], Thread1);
StartThread(&t[1], Thread2);
@@ -50,16 +53,16 @@ int main() {
/* { dg-output "WARNING: ThreadSanitizer: data race.*" } */
/* { dg-output " Write of size 4 at .* by thread T1:(\n|\r\n|\r)" } */
-/* { dg-output " #0 foo1.* .*(simple_stack.c:10|\\?{2}:0) (.*)" } */
-/* { dg-output " #1 bar1.* .*(simple_stack.c:15|\\?{2}:0) (.*)" } */
-/* { dg-output " #2 Thread1.* .*(simple_stack.c:29|\\?{2}:0) (.*)" } */
+/* { dg-output " #0 foo1.* .*(simple_stack.c:11|\\?{2}:0) (.*)" } */
+/* { dg-output " #1 bar1.* .*(simple_stack.c:16|\\?{2}:0) (.*)" } */
+/* { dg-output " #2 Thread1.* .*(simple_stack.c:30|\\?{2}:0) (.*)" } */
/* { dg-output " Previous read of size 4 at .* by thread T2:(\n|\r\n|\r)" } */
-/* { dg-output " #0 foo2.* .*(simple_stack.c:19|\\?{2}:0) (.*)" } */
-/* { dg-output " #1 bar2.* .*(simple_stack.c:24|\\?{2}:0) (.*)" } */
-/* { dg-output " #2 Thread2.* .*(simple_stack.c:34|\\?{2}:0) (.*)" } */
+/* { dg-output " #0 foo2.* .*(simple_stack.c:20|\\?{2}:0) (.*)" } */
+/* { dg-output " #1 bar2.* .*(simple_stack.c:25|\\?{2}:0) (.*)" } */
+/* { dg-output " #2 Thread2.* .*(simple_stack.c:35|\\?{2}:0) (.*)" } */
/* { dg-output " Thread T1 \\(tid=.*, running\\) created by main thread at:(\n|\r\n|\r)" } */
/* { dg-output " #0 pthread_create .* (.*)" } */
-/* { dg-output " #1 StartThread.* .*(simple_stack.c:39|\\?{2}:0) (.*)" } */
+/* { dg-output " #1 StartThread.* .*(simple_stack.c:41|\\?{2}:0) (.*)" } */
/* { dg-output " Thread T2 (.*) created by main thread at:(\n|\r\n|\r)" } */
/* { dg-output " #0 pthread_create .* (.*)" } */
-/* { dg-output " #1 StartThread.* .*(simple_stack.c:39|\\?{2}:0) (.*)" } */
+/* { dg-output " #1 StartThread.* .*(simple_stack.c:41|\\?{2}:0) (.*)" } */