1 /* Test program that triggers several happens-before usage errors. */
7 #include "unified_annotations.h"
10 int main(int argc
, char** argv
)
16 pthread_mutex_init(&m
, NULL
);
17 pthread_cond_init(&cv
, NULL
);
19 /* happens-after without preceding happens-before. */
20 U_ANNOTATE_HAPPENS_AFTER(&i
);
22 /* happens-after on a mutex. */
23 U_ANNOTATE_HAPPENS_BEFORE(&m
);
25 /* happens-after on a condition variable. */
26 U_ANNOTATE_HAPPENS_BEFORE(&cv
);
28 /* condition variable operation on a h.b. annotated object. */
29 U_ANNOTATE_HAPPENS_BEFORE(&i
);
30 pthread_cond_init((pthread_cond_t
*)&i
, NULL
);
32 /* The sequence below is fine. */
33 U_ANNOTATE_NEW_MEMORY(&i
, sizeof(i
));
34 U_ANNOTATE_HAPPENS_BEFORE(&i
);
35 U_ANNOTATE_HAPPENS_AFTER(&i
);
36 U_ANNOTATE_NEW_MEMORY(&i
, sizeof(i
));
37 U_ANNOTATE_HAPPENS_BEFORE(&i
);
38 U_ANNOTATE_NEW_MEMORY(&i
, sizeof(i
));
40 /* happens-before after happens-after. */
41 U_ANNOTATE_HAPPENS_BEFORE(&i
);
42 U_ANNOTATE_HAPPENS_AFTER(&i
);
43 U_ANNOTATE_HAPPENS_BEFORE(&i
);
45 fprintf(stderr
, "Done.\n");