Merge pull request #15781 from haukepetersen/add_sema_getvalue
sys/sema: add sema_get_value()
This commit is contained in:
commit
ed2e40df63
@ -97,6 +97,18 @@ void sema_create(sema_t *sema, unsigned int value);
|
|||||||
*/
|
*/
|
||||||
void sema_destroy(sema_t *sema);
|
void sema_destroy(sema_t *sema);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get a semaphore's current value
|
||||||
|
*
|
||||||
|
* @param[in] sema A semaphore.
|
||||||
|
*
|
||||||
|
* @return the current value of the semaphore
|
||||||
|
*/
|
||||||
|
static inline unsigned sema_get_value(const sema_t *sema)
|
||||||
|
{
|
||||||
|
return sema->value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Wait for a semaphore, blocking or non-blocking.
|
* @brief Wait for a semaphore, blocking or non-blocking.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -283,7 +283,7 @@ static inline int sem_trywait(sem_t *sem)
|
|||||||
static inline int sem_getvalue(sem_t *sem, int *sval)
|
static inline int sem_getvalue(sem_t *sem, int *sval)
|
||||||
{
|
{
|
||||||
if (sem != NULL) {
|
if (sem != NULL) {
|
||||||
*sval = (int)sem->value;
|
*sval = (int)sema_get_value((sema_t *)sem);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user