2014-05-30 22:08:51 +08:00
|
|
|
// RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
|
2015-01-21 21:50:02 +08:00
|
|
|
#include "test.h"
|
2013-06-25 00:28:02 +08:00
|
|
|
|
2012-05-16 15:48:16 +08:00
|
|
|
int Global;
|
2013-06-25 00:28:02 +08:00
|
|
|
|
2012-05-16 15:48:16 +08:00
|
|
|
void *Thread1(void *x) {
|
2015-01-21 21:50:02 +08:00
|
|
|
barrier_wait(&barrier);
|
2012-05-16 15:48:16 +08:00
|
|
|
Global = 42;
|
|
|
|
return x;
|
|
|
|
}
|
2013-06-25 00:28:02 +08:00
|
|
|
|
2012-05-16 15:48:16 +08:00
|
|
|
int main() {
|
2015-01-21 21:50:02 +08:00
|
|
|
barrier_init(&barrier, 2);
|
2012-05-16 15:48:16 +08:00
|
|
|
pthread_t t;
|
2013-06-25 00:28:02 +08:00
|
|
|
pthread_create(&t, 0, Thread1, 0);
|
2012-05-16 15:48:16 +08:00
|
|
|
Global = 43;
|
2015-01-21 21:50:02 +08:00
|
|
|
barrier_wait(&barrier);
|
2013-06-25 00:28:02 +08:00
|
|
|
pthread_join(t, 0);
|
2012-05-16 15:48:16 +08:00
|
|
|
return Global;
|
|
|
|
}
|
2013-06-25 00:28:02 +08:00
|
|
|
|
2012-05-16 15:48:16 +08:00
|
|
|
// CHECK: WARNING: ThreadSanitizer: data race
|