brintos

brintos / llvm-project-archived public Read only

0
0
Text · 609 B · da83048 Raw
32 lines · cpp
1// RUN: %clangxx_tsan -O1 --std=c++11 %s -o %t && %run %t 2>&1 | FileCheck %s2#include "custom_mutex.h"3 4// Test that custom annotations provide normal mutex synchronization5// (no race reports for properly protected critical sections).6 7Mutex mu(true, 0);8long data;9 10void *thr(void *arg) {11  barrier_wait(&barrier);12  mu.Lock();13  data++;14  mu.Unlock();15  return 0;16}17 18int main() {19  barrier_init(&barrier, 2);20  pthread_t th;21  pthread_create(&th, 0, thr, 0);22  barrier_wait(&barrier);23  mu.Lock();24  data++;25  mu.Unlock();26  pthread_join(th, 0);27  fprintf(stderr, "DONE\n");28  return 0;29}30 31// CHECK: DONE32