Fix some spelling errors found by Lintian. Patch from Alessandro Ghedini <ghedo...
[valgrind.git] / drd / tests / annotate_hb_err.c
blob0013eafdfac65f02bca7ebbb73480241e0e9f61d
1 /* Test program that triggers several happens-before usage errors. */
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <pthread.h>
7 #include "unified_annotations.h"
10 int main(int argc, char** argv)
12 pthread_mutex_t m;
13 pthread_cond_t cv;
14 int i[64];
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");
46 return 0;