37typedef struct semaphore {
44#define SEM_INITIALIZER(value) { 1, value }
179static inline void __sem_scoped_cleanup(
semaphore_t **sm) {
184#define ___sem_wait_scoped(sm, l) \
185 semaphore_t *__scoped_sem_##l __attribute__((cleanup(__sem_scoped_cleanup))) = sem_wait(sm) ? NULL : (sm)
187#define __sem_wait_scoped(sm, l) ___sem_wait_scoped(sm, l)
198#define sem_wait_scoped(sm) __sem_wait_scoped((sm), __LINE__)
Various common macros used throughout the codebase.
static __nonnull_all int sem_wait(semaphore_t *sm)
Wait on a semaphore.
Definition sem.h:111
int sem_count(const semaphore_t *sm) __nonnull_all
Retrieve the number of available resources.
int sem_destroy(semaphore_t *sm) __nonnull_all
Destroy a semaphore.
int sem_wait_timed(semaphore_t *sm, unsigned int timeout) __nonnull_all
Wait on a semaphore (with a timeout).
int sem_init(semaphore_t *sm, int count)
Initialize a semaphore for use.
int sem_wait_irqsafe(semaphore_t *sm) __nonnull_all
Wait on a semaphore.
int sem_trywait(semaphore_t *sm) __nonnull_all
"Wait" on a semaphore without blocking.
int sem_signal(semaphore_t *sm) __nonnull_all
Signal a semaphore.
Semaphore type.
Definition sem.h:37
int initialized
Are we initialized?
Definition sem.h:38
int count
The semaphore count.
Definition sem.h:39