semaphore.h 816 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef _SEMAPHORE_H
  2. #define _SEMAPHORE_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #if __STDC_VERSION__ >= 199901L
  7. #define __restrict restrict
  8. #elif !defined(__GNUC__)
  9. #define __restrict
  10. #endif
  11. #define __NEED_time_t
  12. #define __NEED_struct_timespec
  13. #include <bits/alltypes.h>
  14. #include <fcntl.h>
  15. #define SEM_FAILED ((sem_t *)0)
  16. typedef struct {
  17. int __val[4*sizeof(long)/sizeof(int)];
  18. } sem_t;
  19. int sem_close(sem_t *);
  20. int sem_destroy(sem_t *);
  21. int sem_getvalue(sem_t *__restrict, int *__restrict);
  22. int sem_init(sem_t *, int, unsigned);
  23. sem_t *sem_open(const char *, int, ...);
  24. int sem_post(sem_t *);
  25. int sem_timedwait(sem_t *__restrict, const struct timespec *__restrict);
  26. int sem_trywait(sem_t *);
  27. int sem_unlink(const char *);
  28. int sem_wait(sem_t *);
  29. #ifdef __cplusplus
  30. }
  31. #endif
  32. #endif