5 #include <internaltypes.h>
8 # define SEM_WAIT(s) sem_wait (s)
32 if (sem_init (&u
.s
, 0, 0) != 0)
34 puts ("sem_init failed");
38 if (u
.ns
.nwaiters
!= 0)
40 puts ("nwaiters not initialized");
44 if (pthread_create (&th
, NULL
, tf
, &u
.s
) != 0)
46 puts ("pthread_create failed");
52 if (pthread_cancel (th
) != 0)
54 puts ("pthread_cancel failed");
59 if (pthread_join (th
, &r
) != 0)
61 puts ("pthread_join failed");
64 if (r
!= PTHREAD_CANCELED
&& --tries
> 0)
66 /* Maybe we get the scheduling right the next time. */
71 if (u
.ns
.nwaiters
!= 0)
73 puts ("nwaiters not reset");