lib: posix: clock: Turn clock_gettime into system call

Fix thread fault, on user mode, when reading variable rt_clock_base.
For the moment, clock_settime is left without system call:
we don't want to expose clock_settime without figuring out access
control

Signed-off-by: Julien D'Ascenzio <julien.dascenzio@paratronic.fr>
This commit is contained in:
Julien D'Ascenzio 2020-03-24 08:10:56 +01:00 committed by Anas Nashif
commit e689277dd5
2 changed files with 19 additions and 1 deletions

View file

@ -79,7 +79,11 @@ static inline s32_t _ts_to_ms(const struct timespec *to)
return (to->tv_sec * MSEC_PER_SEC) + (to->tv_nsec / NSEC_PER_MSEC);
}
#ifdef CONFIG_ARCH_POSIX
int clock_gettime(clockid_t clock_id, struct timespec *ts);
#else
__syscall int clock_gettime(clockid_t clock_id, struct timespec *ts);
#endif /* CONFIG_ARCH_POSIX */
int clock_settime(clockid_t clock_id, const struct timespec *ts);
/* Timer APIs */
int timer_create(clockid_t clockId, struct sigevent *evp, timer_t *timerid);
@ -92,4 +96,8 @@ int timer_settime(timer_t timerid, int flags, const struct itimerspec *value,
}
#endif
#ifndef CONFIG_ARCH_POSIX
#include <syscalls/time.h>
#endif /* CONFIG_ARCH_POSIX */
#endif /* ZEPHYR_INCLUDE_POSIX_TIME_H_ */