diff --git a/include/zephyr/posix/dirent.h b/include/zephyr/posix/dirent.h index 2fadf3e52f8..0ffe875606f 100644 --- a/include/zephyr/posix/dirent.h +++ b/include/zephyr/posix/dirent.h @@ -7,7 +7,8 @@ #define ZEPHYR_INCLUDE_POSIX_DIRENT_H_ #include -#include "posix_types.h" + +#include #ifdef CONFIG_POSIX_FILE_SYSTEM #include diff --git a/include/zephyr/posix/mqueue.h b/include/zephyr/posix/mqueue.h index aac03426da4..40db0733374 100644 --- a/include/zephyr/posix/mqueue.h +++ b/include/zephyr/posix/mqueue.h @@ -12,7 +12,7 @@ #include #include #include -#include "posix_types.h" +#include #ifdef __cplusplus extern "C" { diff --git a/include/zephyr/posix/posix_types.h b/include/zephyr/posix/posix_types.h index feb3d9bcbb2..ca8023be831 100644 --- a/include/zephyr/posix/posix_types.h +++ b/include/zephyr/posix/posix_types.h @@ -11,6 +11,18 @@ #include #endif +#if !defined(_CLOCK_T_DECLARED) && !defined(__clock_t_defined) +typedef unsigned long clock_t; +#define _CLOCK_T_DECLARED +#define __clock_t_defined +#endif + +#if !defined(_CLOCKID_T_DECLARED) && !defined(__clockid_t_defined) +typedef unsigned long clockid_t; +#define _CLOCKID_T_DECLARED +#define __clockid_t_defined +#endif + #ifdef CONFIG_NEWLIB_LIBC #include #endif diff --git a/include/zephyr/posix/sched.h b/include/zephyr/posix/sched.h index b337cc2c022..29a3fa93b89 100644 --- a/include/zephyr/posix/sched.h +++ b/include/zephyr/posix/sched.h @@ -7,8 +7,7 @@ #define ZEPHYR_INCLUDE_POSIX_SCHED_H_ #include - -#include "posix_types.h" +#include #include diff --git a/include/zephyr/posix/semaphore.h b/include/zephyr/posix/semaphore.h index 3b0f53b0712..e3f6014cfec 100644 --- a/include/zephyr/posix/semaphore.h +++ b/include/zephyr/posix/semaphore.h @@ -7,7 +7,7 @@ #define ZEPHYR_INCLUDE_POSIX_SEMAPHORE_H_ #include -#include "posix_types.h" +#include #ifdef __cplusplus extern "C" { diff --git a/include/zephyr/posix/signal.h b/include/zephyr/posix/signal.h index 11cbe726dad..e106642f6f1 100644 --- a/include/zephyr/posix/signal.h +++ b/include/zephyr/posix/signal.h @@ -6,7 +6,8 @@ #ifndef ZEPHYR_INCLUDE_POSIX_SIGNAL_H_ #define ZEPHYR_INCLUDE_POSIX_SIGNAL_H_ -#include "posix_types.h" +/* include posix_types.h before posix_features.h (here) to avoid build errors against newlib */ +#include #include "posix_features.h" #ifdef __cplusplus diff --git a/include/zephyr/posix/sys/select.h b/include/zephyr/posix/sys/select.h index ef3e0f5674e..b51ace79828 100644 --- a/include/zephyr/posix/sys/select.h +++ b/include/zephyr/posix/sys/select.h @@ -6,6 +6,7 @@ #ifndef ZEPHYR_INCLUDE_POSIX_SYS_SELECT_H_ #define ZEPHYR_INCLUDE_POSIX_SYS_SELECT_H_ +#include #include #ifdef __cplusplus diff --git a/include/zephyr/posix/time.h b/include/zephyr/posix/time.h index e2815637143..51542f304fa 100644 --- a/include/zephyr/posix/time.h +++ b/include/zephyr/posix/time.h @@ -58,7 +58,7 @@ struct itimerspec { #include #include -#include "posix_types.h" +#include #include #ifdef __cplusplus diff --git a/include/zephyr/posix/unistd.h b/include/zephyr/posix/unistd.h index 96ea52477c9..b7ac069bdc5 100644 --- a/include/zephyr/posix/unistd.h +++ b/include/zephyr/posix/unistd.h @@ -6,7 +6,7 @@ #ifndef ZEPHYR_INCLUDE_POSIX_UNISTD_H_ #define ZEPHYR_INCLUDE_POSIX_UNISTD_H_ -#include "posix_types.h" +#include #ifdef CONFIG_POSIX_API #include diff --git a/tests/posix/net/CMakeLists.txt b/tests/posix/net/CMakeLists.txt index 80433bbd096..9f1e311355a 100644 --- a/tests/posix/net/CMakeLists.txt +++ b/tests/posix/net/CMakeLists.txt @@ -7,3 +7,5 @@ project(posix_net) FILE(GLOB app_sources src/*.c) target_sources(app PRIVATE ${app_sources}) + +target_compile_options(app PRIVATE -U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=200809L)