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-02-01 22:41:58 +08:00
|
|
|
|
|
|
|
void *Thread(void *x) {
|
|
|
|
pthread_mutex_lock((pthread_mutex_t*)x);
|
|
|
|
pthread_mutex_unlock((pthread_mutex_t*)x);
|
2015-01-21 21:50:02 +08:00
|
|
|
barrier_wait(&barrier);
|
2013-02-01 22:41:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
2015-01-21 21:50:02 +08:00
|
|
|
barrier_init(&barrier, 2);
|
2013-02-01 22:41:58 +08:00
|
|
|
pthread_mutex_t Mtx;
|
|
|
|
pthread_mutex_init(&Mtx, 0);
|
|
|
|
pthread_t t;
|
|
|
|
pthread_create(&t, 0, Thread, &Mtx);
|
2015-01-21 21:50:02 +08:00
|
|
|
barrier_wait(&barrier);
|
2013-02-01 22:41:58 +08:00
|
|
|
pthread_mutex_destroy(&Mtx);
|
|
|
|
pthread_join(t, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: WARNING: ThreadSanitizer: data race
|