posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
semaphore.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
17#ifndef ZEPHYR_INCLUDE_POSIX_SEMAPHORE_H_
18#define ZEPHYR_INCLUDE_POSIX_SEMAPHORE_H_
19
20#include <time.h>
21
22#include <zephyr/kernel.h>
23#include <zephyr/sys/sem.h>
24#include <zephyr/toolchain.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
31#define SEM_FAILED ((sem_t *) 0)
32
33#if !(defined(_SEM_T_DECLARED) || defined(__sem_t_defined)) || defined(__DOXYGEN__)
44typedef struct sys_sem sem_t;
45#define _SEM_T_DECLARED
46#define __sem_t_defined
47#endif
48
56int sem_destroy(sem_t *semaphore);
57
66int sem_getvalue(sem_t *ZRESTRICT semaphore, int *ZRESTRICT value);
67
77int sem_init(sem_t *semaphore, int pshared, unsigned int value);
78
86int sem_post(sem_t *semaphore);
87
88#if defined(_POSIX_TIMEOUTS) || defined(__DOXYGEN__)
98int sem_timedwait(sem_t *ZRESTRICT semaphore, struct timespec *ZRESTRICT abstime);
99#endif
100
109int sem_trywait(sem_t *semaphore);
110
118int sem_wait(sem_t *semaphore);
119
129sem_t *sem_open(const char *name, int oflags, ...);
130
138int sem_unlink(const char *name);
139
147int sem_close(sem_t *sem);
148
149
150#ifdef __cplusplus
151}
152#endif
153
154#endif /* ZEPHYR_INCLUDE_POSIX_SEMAPHORE_H_ */
struct sys_sem sem_t
Semaphore object type.
Definition semaphore.h:44
sem_t * sem_open(const char *name, int oflags,...)
Open or create a named semaphore.
int sem_trywait(sem_t *semaphore)
Try to lock a semaphore without blocking.
int sem_init(sem_t *semaphore, int pshared, unsigned int value)
Initialise an unnamed semaphore.
int sem_post(sem_t *semaphore)
Unlock a semaphore (increment its count).
int sem_wait(sem_t *semaphore)
Lock a semaphore, blocking until it becomes available.
int sem_destroy(sem_t *semaphore)
Destroy an unnamed semaphore.
int sem_close(sem_t *sem)
Close a named semaphore.
int sem_unlink(const char *name)
Remove a named semaphore.
int sem_timedwait(sem_t *ZRESTRICT semaphore, struct timespec *ZRESTRICT abstime)
Lock a semaphore with an absolute timeout.
int sem_getvalue(sem_t *ZRESTRICT semaphore, int *ZRESTRICT value)
Get the current value of a semaphore.
Time value with nanosecond resolution.
Definition aio.h:65
POSIX time-of-day types and functions (<sys/time.h>)