2 * Test program with happens-before / happens-after annotations that triggers
3 * a data race. The data race will only be reported if happens-after
4 * annotations that occur in different threads are not totally ordered. Or:
5 * this is a test for the implementation of ordering annotations.
11 #include "unified_annotations.h"
17 static void* thread_func(void* arg
)
21 U_ANNOTATE_HAPPENS_AFTER(&s_i
);
23 U_ANNOTATE_HAPPENS_AFTER(&s_i
);
28 int main(int argc
, char** argv
)
30 const struct timespec delay
= { 0, 100 * 1000 * 1000 };
34 U_ANNOTATE_HAPPENS_BEFORE(&s_i
);
35 pthread_create(&tid
[0], 0, thread_func
, &result
[0]);
36 pthread_create(&tid
[1], 0, thread_func
, &result
[1]);
42 pthread_join(tid
[0], NULL
);
43 pthread_join(tid
[1], NULL
);
45 fprintf(stderr
, "Done.\n");