From 3500e4722d2a3f2d8fb8e5ebb2ce1217f41ee6a8 Mon Sep 17 00:00:00 2001 From: Chen-Yuanmeng <2784841400@qq.com> Date: Sun, 5 Jul 2026 16:10:32 +0800 Subject: [PATCH] bugfix: fix clock_t issue when compiling with newlib --- .../libc/compilers/common/include/sys/select.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/components/libc/compilers/common/include/sys/select.h b/components/libc/compilers/common/include/sys/select.h index 32ce39c287e..182ccc03dea 100644 --- a/components/libc/compilers/common/include/sys/select.h +++ b/components/libc/compilers/common/include/sys/select.h @@ -9,6 +9,18 @@ * 2021-12-25 Meco Man Handle newlib 2.2.0 or lower version */ +/* + * Newlib's includes before it defines clock_t. + * If this wrapper is picked up at that point, including RT-Thread's + * below pulls in too early and newlib sees an undefined + * clock_t. In that specific in-progress newlib include, keep using newlib's + * own select definitions first. + */ +#if defined(__GNUC__) && !defined(__ARMCC_VERSION) && defined(_SYS_TYPES_H) && \ + !defined(__clock_t_defined) && !defined(_CLOCK_T_DECLARED) +#include_next +#else + #ifndef __SYS_SELECT_H__ #define __SYS_SELECT_H__ @@ -58,3 +70,5 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struc #endif #endif /* __SYS_SELECT_H__ */ + +#endif