10#ifndef STK_C_SEMAPHORE_H_
11#define STK_C_SEMAPHORE_H_
42#include <stk_config.h>
45#ifndef STK_SYNC_DEBUG_NAMES
46 #if STK_SEGGER_SYSVIEW
47 #define STK_SYNC_DEBUG_NAMES (1)
49 #define STK_SYNC_DEBUG_NAMES (0)
54 #define CLOCK_REALTIME (0)
56#ifndef CLOCK_MONOTONIC
57 #define CLOCK_MONOTONIC (1)
67#define SEM_VALUE_MAX (2147483647)
74#define STK_C_SEM_WORDS (7U + (STK_SYNC_DEBUG_NAMES ? 1U : 0U) + \
75 ((2U * sizeof(uint32_t) + sizeof(uintptr_t) - 1U) / sizeof(uintptr_t)) + 1U)
77#if defined(__GNUC__) || defined(__clang__) || defined(__ICCARM__)
78 #define __stk_sem_aligned __attribute__((aligned(sizeof(uintptr_t))))
80 #define __stk_sem_aligned
int sem_post(sem_t *sem)
Release a token (wakes the first waiter, otherwise increments the count).
#define __stk_sem_aligned
#define STK_C_SEM_WORDS
Size (in machine words) of the opaque storage of a sem_t: the C++ object (7 words + 1 with debug name...
int sem_trywait(sem_t *sem)
Take a token without blocking.
int sem_init(sem_t *sem, int pshared, unsigned int value)
Initialize an unnamed semaphore.
int sem_destroy(sem_t *sem)
Destroy a semaphore.
int sem_getvalue(sem_t *sem, int *sval)
Get the current count.
int sem_timedwait(sem_t *sem, const struct timespec *abstime)
Take a token, waiting until the absolute deadline abstime.
int sem_wait(sem_t *sem)
Take a token, blocking until one is available.
int sem_clockwait(sem_t *sem, clockid_t clock_id, const struct timespec *abstime)
sem_timedwait() with an explicit clock (POSIX.1-2024).
POSIX time extensions for STK: clock_gettime(), clock_getres(), nanosleep(), clock_nanosleep(),...
A POSIX counting semaphore.
void * __handle
NULL until sem_init(), then points into __mem.
uintptr_t data[(7U+((0) ? 1U :0U)+((2U *sizeof(uint32_t)+sizeof(uintptr_t) - 1U)/sizeof(uintptr_t))+1U)]
struct sem_t::@301215357362074031213040000172073175337057334267 __mem
In-place storage of the C++ semaphore.