2 /* Check that a child thread doesn't inherit its parent's disablement
9 #include <unistd.h> // sleep
11 #include "../include/valgrind.h"
15 __attribute__((noinline
)) void usechar ( char c
)
17 // Spook gcc into believing mysterious bad things are
18 // happening behind its back, and that 'c' is definitely
19 // used in some (unknown) way.
20 __asm__
__volatile__("" : : "r"(c
) : "memory","cc");
23 __attribute__((noinline
)) void err ( void )
28 void* child_fn ( void* arg
)
30 fprintf(stderr
, "\n--------- c: start (expect 1) ---------\n\n");
32 fprintf(stderr
, "\n--------- c: end ---------\n\n");
44 fprintf(stderr
, "\n--------- p: disabling errors (expect 0) ---------\n\n");
46 VALGRIND_DISABLE_ERROR_REPORTING
;
49 fprintf(stderr
, "\n--------- p: creating child ---------\n\n");
51 r
= pthread_create(&child
, NULL
, child_fn
, NULL
);
53 sleep(1); // let the child run first (determinism fix)
54 fprintf(stderr
, "\n--------- p: join child ---------\n\n");
55 r
= pthread_join(child
, NULL
);
58 fprintf(stderr
, "\n--------- p: re_enabled (expect 1) ---------\n\n");
59 VALGRIND_ENABLE_ERROR_REPORTING
;