1 // RUN: %clangxx_tsan -O1 %s -o %t && %env_tsan_opts=atexit_sleep_ms=0 %run %t 2>&1 | FileCheck %s
10 static void *incrementer(void *arg
) {
12 __sync_fetch_and_add(&counter
, 1);
16 static int cloned(void *arg
) {
17 for (int i
= 0; i
< 1000; i
++)
18 __sync_fetch_and_add(&counter
, 1);
24 barrier_init(&barrier
, 2);
26 pthread_create(&th
, 0, incrementer
, 0);
27 for (int i
= 0; i
< 100; i
++) {
28 char stack
[64 << 10] __attribute__((aligned(64)));
29 int pid
= clone(cloned
, stack
+ sizeof(stack
), SIGCHLD
, 0);
31 fprintf(stderr
, "failed to clone: %d\n", errno
);
34 while (wait(0) != pid
) {
37 fprintf(stderr
, "DONE\n");