Add DRD suppression patterns for races triggered by std::ostream
[valgrind.git] / helgrind / tests / tc02_simple_tls.c
bloba23b14c172537d95079b8fa6d257fc9c918743a2
2 #include <pthread.h>
3 #include <stdio.h>
4 #include <stdlib.h>
6 /* Simple test program, no race: parent only modified x after child
7 has modified it and then joined with the parent. Tests simple
8 thread lifetime segment handling. */
10 int x = 0;
12 void* child_fn ( void* arg )
14 /* Unprotected relative to parent, but in child's segment only */
15 x++;
16 return NULL;
19 int main ( void )
21 pthread_t child;
23 x++; /* happens in parent's segment */
25 if (pthread_create(&child, NULL, child_fn, NULL)) {
26 perror("pthread_create");
27 exit(1);
30 if (pthread_join(child, NULL)) {
31 perror("pthread join");
32 exit(1);
35 /* Now back in parent's segment */
36 x++;
38 return 0;