2014-05-30 22:08:51 +08:00
|
|
|
// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
|
2015-01-21 21:50:02 +08:00
|
|
|
#include "test.h"
|
2012-05-10 22:18:22 +08:00
|
|
|
|
2013-12-24 15:49:33 +08:00
|
|
|
volatile int X;
|
2012-05-10 22:18:22 +08:00
|
|
|
|
|
|
|
void *Thread1(void *x) {
|
2015-01-21 21:50:02 +08:00
|
|
|
barrier_wait(&barrier);
|
2012-05-10 22:18:22 +08:00
|
|
|
X = 42;
|
|
|
|
X = 66;
|
|
|
|
X = 78;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *Thread2(void *x) {
|
|
|
|
X = 11;
|
|
|
|
X = 99;
|
|
|
|
X = 73;
|
2015-01-21 21:50:02 +08:00
|
|
|
barrier_wait(&barrier);
|
2012-05-10 22:18:22 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
2015-01-21 21:50:02 +08:00
|
|
|
barrier_init(&barrier, 2);
|
2012-05-10 22:18:22 +08:00
|
|
|
pthread_t t;
|
|
|
|
pthread_create(&t, 0, Thread1, 0);
|
|
|
|
Thread2(0);
|
|
|
|
pthread_join(t, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: ThreadSanitizer: reported 1 warnings
|