12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #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;
- }
|