semaphore.h 771 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2021, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <limits.h>
  8. #include <pthread.h>
  9. #include <sys/cdefs.h>
  10. #include <sys/types.h>
  11. __BEGIN_DECLS
  12. #define SEM_FLAG_PROCESS_SHARED (1 << 0)
  13. #define SEM_FLAG_NAMED (1 << 1)
  14. typedef struct {
  15. uint32_t magic;
  16. uint32_t value;
  17. uint8_t flags;
  18. } sem_t;
  19. int sem_close(sem_t*);
  20. int sem_destroy(sem_t*);
  21. int sem_getvalue(sem_t*, int*);
  22. int sem_init(sem_t*, int, unsigned int);
  23. sem_t* sem_open(char const*, int, ...);
  24. int sem_post(sem_t*);
  25. int sem_trywait(sem_t*);
  26. int sem_unlink(char const*);
  27. int sem_wait(sem_t*);
  28. int sem_timedwait(sem_t*, const struct timespec* abstime);
  29. #define SEM_FAILED ((sem_t*)0)
  30. #define SEM_VALUE_MAX INT_MAX
  31. __END_DECLS