aboutsummaryrefslogtreecommitdiff
path: root/test/tsan/free_race.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/free_race.c
parentca9211ecdede9bdedb812b2243a4abdb8dacd1b9 (diff)
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/free_race.c')
-rw-r--r--test/tsan/free_race.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/test/tsan/free_race.c b/test/tsan/free_race.c
index 663d7bcf2eb9..63cee8c4adc5 100644
--- a/test/tsan/free_race.c
+++ b/test/tsan/free_race.c
@@ -1,12 +1,8 @@
// RUN: %clang_tsan -O1 %s -o %t
// RUN: %deflake %run %t | FileCheck %s --check-prefix=CHECK-NOZUPP
-// RUN: TSAN_OPTIONS="suppressions=%s.supp print_suppressions=1" %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUPP
+// RUN: TSAN_OPTIONS="suppressions='%s.supp' print_suppressions=1" %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUPP
-#include <pthread.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stddef.h>
-#include <unistd.h>
+#include "test.h"
int *mem;
pthread_mutex_t mtx;
@@ -15,11 +11,12 @@ void *Thread1(void *x) {
pthread_mutex_lock(&mtx);
free(mem);
pthread_mutex_unlock(&mtx);
+ barrier_wait(&barrier);
return NULL;
}
void *Thread2(void *x) {
- sleep(1);
+ barrier_wait(&barrier);
pthread_mutex_lock(&mtx);
mem[0] = 42;
pthread_mutex_unlock(&mtx);
@@ -27,6 +24,7 @@ void *Thread2(void *x) {
}
int main() {
+ barrier_init(&barrier, 2);
mem = (int*)malloc(100);
pthread_mutex_init(&mtx, 0);
pthread_t t;