aboutsummaryrefslogtreecommitdiff
path: root/test/tsan/cond_cancel.c
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-02-10 07:45:43 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-02-10 07:45:43 +0000
commit476c4db3dc56bee43df384704c75ccc71cfa7a1d (patch)
tree5d0dcec3cc12fc53532fc84029892b98711a2596 /test/tsan/cond_cancel.c
parentca9211ecdede9bdedb812b2243a4abdb8dacd1b9 (diff)
downloadsrc-476c4db3dc56bee43df384704c75ccc71cfa7a1d.tar.gz
src-476c4db3dc56bee43df384704c75ccc71cfa7a1d.zip
Import compiler-rt trunk r228651.vendor/compiler-rt/compiler-rt-r228651
Notes
Notes: svn path=/vendor/compiler-rt/dist/; revision=278497 svn path=/vendor/compiler-rt/compiler-rt-r228651/; revision=278498; tag=vendor/compiler-rt/compiler-rt-r228651
Diffstat (limited to 'test/tsan/cond_cancel.c')
-rw-r--r--test/tsan/cond_cancel.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/test/tsan/cond_cancel.c b/test/tsan/cond_cancel.c
index 397cad4b1838..e744570b12fc 100644
--- a/test/tsan/cond_cancel.c
+++ b/test/tsan/cond_cancel.c
@@ -2,10 +2,7 @@
// CHECK-NOT: WARNING
// CHECK: OK
-#include <stdio.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <unistd.h>
+#include "test.h"
pthread_mutex_t m;
pthread_cond_t c;
@@ -14,6 +11,7 @@ int x;
void *thr1(void *p) {
pthread_mutex_lock(&m);
pthread_cleanup_push((void(*)(void *arg))pthread_mutex_unlock, &m);
+ barrier_wait(&barrier);
while (x == 0)
pthread_cond_wait(&c, &m);
pthread_cleanup_pop(1);
@@ -21,12 +19,15 @@ void *thr1(void *p) {
}
int main() {
+ barrier_init(&barrier, 2);
+
pthread_t th;
pthread_mutex_init(&m, 0);
pthread_cond_init(&c, 0);
pthread_create(&th, 0, thr1, 0);
+ barrier_wait(&barrier);
sleep(1); // let it block on cond var
pthread_cancel(th);