diff --git a/include/net/socket_select.h b/include/net/socket_select.h index 98c59a13d72f..15c8f5ed0873 100644 --- a/include/net/socket_select.h +++ b/include/net/socket_select.h @@ -16,15 +16,36 @@ #include +#ifdef CONFIG_POSIX_API +#ifdef __NEWLIB__ +#include +#else +#include +#endif /* __NEWLIB__ */ +#endif /* CONFIG_POSIX_API */ + #ifdef __cplusplus extern "C" { #endif +#ifdef CONFIG_POSIX_API +/* Rely on the underlying libc definition */ +#ifdef __NEWLIB__ +#define zsock_timeval timeval +#else +/* workaround for older Newlib 2.x, as it lacks sys/_timeval.h */ +struct zsock_timeval { + time_t tv_sec; + suseconds_t tv_usec; +}; +#endif /* __NEWLIB__ */ +#else struct zsock_timeval { /* Using longs, as many (?) implementations seem to use it. */ long tv_sec; long tv_usec; }; +#endif /* CONFIG_POSIX_API */ typedef struct zsock_fd_set { uint32_t bitset[(CONFIG_POSIX_MAX_FDS + 31) / 32];