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)
33 U_ANNOTATE_HAPPENS_BEFORE(&s_i);
34 pthread_create(&tid[0], 0, thread_func, &result[0]);
35 pthread_create(&tid[1], 0, thread_func, &result[1]);
38 pthread_join(tid[0], NULL);
39 pthread_join(tid[1], NULL);
41 fprintf(stderr, "Done.\n");