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");
37 #if __HAVE_64B_ATOMICS
38 if ((u
.ns
.data
>> SEM_NWAITERS_SHIFT
) != 0)
40 if (u
.ns
.nwaiters
!= 0)
43 puts ("nwaiters not initialized");
47 if (pthread_create (&th
, NULL
, tf
, &u
.s
) != 0)
49 puts ("pthread_create failed");
55 if (pthread_cancel (th
) != 0)
57 puts ("pthread_cancel failed");
62 if (pthread_join (th
, &r
) != 0)
64 puts ("pthread_join failed");
67 if (r
!= PTHREAD_CANCELED
&& --tries
> 0)
69 /* Maybe we get the scheduling right the next time. */
74 #if __HAVE_64B_ATOMICS
75 if ((u
.ns
.data
>> SEM_NWAITERS_SHIFT
) != 0)
77 if (u
.ns
.nwaiters
!= 0)
80 puts ("nwaiters not reset");