6 #include <internaltypes.h>
18 if (sem_init (&u
.s
, 0, 0) != 0)
20 puts ("sem_init failed");
24 struct timespec ts
= { 0, 1000000001 }; /* Invalid. */
26 if (sem_timedwait (&u
.s
, &ts
) >= 0)
28 puts ("sem_timedwait did not fail");
33 perror ("sem_timedwait did not fail with EINVAL");
36 #if __HAVE_64B_ATOMICS
37 unsigned int nwaiters
= (u
.ns
.data
>> SEM_NWAITERS_SHIFT
);
39 unsigned int nwaiters
= u
.ns
.nwaiters
;
43 printf ("sem_timedwait modified nwaiters: %d\n", nwaiters
);
47 ts
.tv_sec
= /* Invalid. */ -2;
50 if (sem_timedwait (&u
.s
, &ts
) >= 0)
52 puts ("2nd sem_timedwait did not fail");
55 if (errno
!= ETIMEDOUT
)
57 perror ("2nd sem_timedwait did not fail with ETIMEDOUT");
60 #if __HAVE_64B_ATOMICS
61 nwaiters
= (u
.ns
.data
>> SEM_NWAITERS_SHIFT
);
63 nwaiters
= u
.ns
.nwaiters
;
67 printf ("2nd sem_timedwait modified nwaiters: %d\n", nwaiters
);
74 #define TEST_FUNCTION do_test ()
75 #include "../test-skeleton.c"