1
0

sem_init.c 240 B

1234567891011121314
  1. #include <semaphore.h>
  2. #include <limits.h>
  3. #include <errno.h>
  4. int sem_init(sem_t *sem, int pshared, unsigned value)
  5. {
  6. if (value > SEM_VALUE_MAX) {
  7. errno = EINVAL;
  8. return -1;
  9. }
  10. sem->__val[0] = value;
  11. sem->__val[1] = 0;
  12. return 0;
  13. }