mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-08-13 17:26:00 +00:00
Modifies several functions that are causing wrong behaviour. * semaphore.h: add missing restrict keyword. * sem_destroy(): check that nobody is waiting before destroying the object. * sem_timedwait(): simpify function logic and fix a bug when abstime > currtime, that passed ticks instead of ms to k_sem_take(). * sem_wait(): avoid unnecessary checks. * sem_init(): add pshared value assertion. Signed-off-by: Juan Manuel Torres Palma <j.m.torrespalma@gmail.com>
29 lines
633 B
C
29 lines
633 B
C
/*
|
|
* Copyright (c) 2018 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
#ifndef _POSIX_SEMAPHORE_H
|
|
#define _POSIX_SEMAPHORE_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "sys/types.h"
|
|
#include <time.h>
|
|
|
|
int sem_destroy(sem_t *semaphore);
|
|
int sem_getvalue(sem_t *restrict semaphore, int *restrict value);
|
|
int sem_init(sem_t *semaphore, int pshared, unsigned int value);
|
|
int sem_post(sem_t *semaphore);
|
|
int sem_timedwait(sem_t *restrict semaphore, struct timespec *restrict abstime);
|
|
int sem_trywait(sem_t *semaphore);
|
|
int sem_wait(sem_t *semaphore);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* POSIX_SEMAPHORE_H */
|