From 347f6784fbf8fc612b418dde804564eb7f06665c Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 3 Mar 2020 15:25:21 +0200 Subject: [PATCH] include: posix: time: Make possible to include with CONFIG_ARCH_POSIX While CONFIG_ARCH_POSIX in general isn't compatible with Zephyr POSIX subsys (because CONFIG_ARCH_POSIX itself is implemented on top of POSIX, so there're obvious conflicts), apply workaround to allow to at least use clock_gettime() and clock_settime() functions. This change is grounded in upcoming support for date manipulation commands for Zephyr shell, which are implemented using functions above. There's no guarantee that CONFIG_ARCH_POSIX and Zephyr POSIX subsys will coexist for any other usecase. (But the change is relatively clean and is definitely in the right direction of prototyping ways of such a coexistance.) Signed-off-by: Paul Sokolovsky (cherry picked from commit 4a05644bce81f4792c018964d29c1158f1982d1e) --- include/posix/posix_types.h | 6 ++++++ include/posix/time.h | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/posix/posix_types.h b/include/posix/posix_types.h index 15b0ba8d2d4..93d0b10aa79 100644 --- a/include/posix/posix_types.h +++ b/include/posix/posix_types.h @@ -17,13 +17,19 @@ extern "C" { #endif +#ifndef __useconds_t_defined typedef unsigned long useconds_t; +#endif /* time related attributes */ #ifndef CONFIG_NEWLIB_LIBC +#ifndef __clockid_t_defined typedef u32_t clockid_t; +#endif #endif /*CONFIG_NEWLIB_LIBC */ +#ifndef __timer_t_defined typedef unsigned long timer_t; +#endif #ifdef CONFIG_PTHREAD_IPC /* Thread attributes */ diff --git a/include/posix/time.h b/include/posix/time.h index ce0648ed68e..65ca722e9a3 100644 --- a/include/posix/time.h +++ b/include/posix/time.h @@ -43,7 +43,12 @@ struct itimerspec { #else /* CONFIG_NEWLIB_LIBC */ /* Not Newlib */ -#include +# ifdef CONFIG_ARCH_POSIX +# include +# include +# else +# include +# endif #endif /* CONFIG_NEWLIB_LIBC */ #include