1 /* 2 * Copyright (C) 2015-2021 Alibaba Group Holding Limited 3 */ 4 5 #ifndef _SEMAPHORE_H 6 #define _SEMAPHORE_H 7 8 #include <time.h> 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 14 #define SEM_FAILED ((sem_t *)0) 15 #define SEM_VALUE_MAX 32767 16 17 typedef struct { 18 void *aos_sem; 19 } sem_t; 20 21 int sem_init(sem_t *sem, int pshared, unsigned int value); 22 sem_t *sem_open(const char *name, int oflag, ...); 23 int sem_post(sem_t *sem); 24 int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout); 25 int sem_trywait(sem_t *sem); 26 int sem_unlink(const char *name); 27 int sem_wait(sem_t *sem); 28 int sem_getvalue(sem_t *sem, int *sval); 29 int sem_close(sem_t *sem); 30 int sem_destroy(sem_t *sem); 31 32 #ifdef __cplusplus 33 } 34 #endif 35 36 #endif /* _SEMAPHORE_H */ 37