Skip to content

Commit 3fd186e

Browse files
asemjonovscfriedt
authored andcommitted
newlib: allow limits to be defined externally
Downstream toolchains may already define these macros, add guard to prevent macro redefined errors. Signed-off-by: Al Semjonovs <[email protected]>
1 parent b69b750 commit 3fd186e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/libc/newlib/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,14 @@ config NEWLIB_LIBC_CUSTOM_SBRK
7070
Allow user to define custom version of the _sbrk function. Some application
7171
may need to use the remaining RAM for also other purposes than heap.
7272

73+
config NEWLIB_LIBC_USE_POSIX_LIMITS_H
74+
bool "Use Zephyr's posix_limits.h header"
75+
default y
76+
help
77+
The newlib provided by the Zephyr SDK does not include all mandatory POSIX limits.
78+
However, some external newlib-based toolchains do.
79+
80+
Disable this option if your toolchain's newlib already includes all mandatory POSIX
81+
limits.
82+
7383
endif # NEWLIB_LIBC

lib/libc/newlib/include/limits.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_LIMITS_H_
99

1010
#include_next <limits.h>
11+
#ifdef CONFIG_NEWLIB_LIBC_USE_POSIX_LIMITS_H
1112
#include <zephyr/posix/posix_limits.h>
13+
#endif
1214

1315
#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_LIMITS_H_ */

0 commit comments

Comments
 (0)