123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #include <errno.h>
- #include <sysdep.h>
- #include <lowlevellock.h>
- #include <internaltypes.h>
- #include <semaphore.h>
- int
- sem_trywait (sem_t *sem)
- {
- int *futex = (int *) sem;
- int val;
- if (*futex > 0)
- {
- val = atomic_decrement_if_positive (futex);
- if (val > 0)
- return 0;
- }
- __set_errno (EAGAIN);
- return -1;
- }
|