9 static pthread_key_t keys
[NKEYS
];
10 static pthread_barrier_t b
;
17 for (int i
= 0; i
< NKEYS
; ++i
)
19 void *p
= pthread_getspecific (keys
[i
]);
20 /* Use an arbitrary but valid pointer as the value. */
21 pthread_setspecific (keys
[i
], (void *) keys
);
27 pthread_barrier_wait (arg
);
28 pthread_barrier_wait (arg
);
37 pthread_barrier_init (&b
, NULL
, 2);
39 for (int i
= 0; i
< NKEYS
; ++i
)
40 if (pthread_key_create (&keys
[i
], NULL
) != 0)
42 puts ("cannot create keys");
47 if (pthread_create (&th
, NULL
, tf
, &b
) != 0)
49 puts ("cannot create thread in parent");
53 pthread_barrier_wait (&b
);
58 if (pthread_create (&th
, NULL
, tf
, NULL
) != 0)
60 puts ("cannot create thread in child");
65 pthread_join (th
, &res
);
71 puts ("cannot create child process");
76 if (TEMP_FAILURE_RETRY (waitpid (pid
, &s
, 0)) != pid
)
78 puts ("failing to wait for child process");
82 pthread_barrier_wait (&b
);
83 pthread_join (th
, NULL
);
85 return !WIFEXITED (s
) ? 2 : WEXITSTATUS (s
);
89 #define TEST_FUNCTION do_test ()
90 #include "../test-skeleton.c"