Add DRD suppression patterns for races triggered by std::ostream
[valgrind.git] / drd / tests / annotate_static.cpp
blob25ffd47e6cc24d50a162b811b86af2369abf7fd5
1 // Test for ANNOTATE_BENIGN_RACE_STATIC() and ANNOTATE_UNPROTECTED_READ().
4 #include <pthread.h> /* pthread_create() */
5 #include <stdio.h> /* fprintf() */
6 #include "../../drd/drd.h"
9 /* Local variables. */
11 static int s_i;
12 static volatile int s_j;
14 ANNOTATE_BENIGN_RACE_STATIC(s_i, "Benign because duplicate assignment.");
17 /* Local functions. */
19 static inline void AnnotateIgnoreReadsBegin() { ANNOTATE_IGNORE_READS_BEGIN(); }
20 static inline void AnnotateIgnoreReadsEnd() { ANNOTATE_IGNORE_READS_END(); }
22 static void* thread_func(void*)
24 #if defined(__powerpc__) && __GNUC__ -0 == 4 && __GNUC_MINOR__ -0 == 3 \
25 && __GNUC_PATCHLEVEL__ -0 == 0
26 AnnotateIgnoreReadsBegin();
27 int i = s_j;
28 AnnotateIgnoreReadsEnd();
29 s_i = i;
30 #else
31 s_i = ANNOTATE_UNPROTECTED_READ(s_j);
32 #endif
33 return 0;
36 int main(int argc, char** argv)
38 pthread_t tid;
40 pthread_create(&tid, 0, thread_func, NULL);
41 s_j++;
42 s_i = s_j;
43 pthread_join(tid, NULL);
45 fprintf(stderr, "Done.\n");
47 return 0;