| // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s |
| // CHECK-NOT: ThreadSanitizer: data race |
| // pthread barriers are not available on OS X |
| volatile int kIter = 10; // prevent unwinding |
| pthread_barrier_t barrier; |
| for (int i = 0; i < kIter; i++) { |
| int *curr = data[(i + 1) % 2]; |
| int left = idx - 1 >= 0 ? prev[idx - 1] : 0; |
| int right = idx + 1 < kSize ? prev[idx + 1] : 0; |
| curr[idx] = (left + right) / 2; |
| pthread_barrier_wait(&barrier); |
| pthread_barrier_init(&barrier, 0, kSize); |
| for (int i = 0; i < kSize; i++) |
| pthread_create(&th[i], 0, thr, (void*)(long)i); |
| for (int i = 0; i < kSize; i++) |
| pthread_barrier_destroy(&barrier); |
| fprintf(stderr, "DONE\n"); |