This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit b82188fd5002ba3339e29e805a217c7f402c2197 Author: buxiasen <[email protected]> AuthorDate: Fri Aug 15 11:47:38 2025 +0800 libs/libc/assert: add LIBC_ASSERT_CUSTOM Some images contain code that runs outside of NuttX, e.g. the code of a second core that is compiled and linked together with NuttX but not managed by it. When that code calls __assert(), the NuttX implementation must not handle it. Add LIBC_ASSERT_CUSTOM to leave __assert() out of libc, so that a custom implementation can be provided instead. Signed-off-by: buxiasen <[email protected]> --- libs/libc/Kconfig | 1 + libs/libc/assert/Kconfig | 15 +++++++++++++++ libs/libc/assert/lib_assert.c | 2 ++ 3 files changed, 18 insertions(+) diff --git a/libs/libc/Kconfig b/libs/libc/Kconfig index 076fd961b6e..067b7cfe225 100644 --- a/libs/libc/Kconfig +++ b/libs/libc/Kconfig @@ -56,3 +56,4 @@ source "libs/libc/regex/Kconfig" source "libs/libc/gnssutils/Kconfig" source "libs/libc/fdt/Kconfig" source "libs/libc/queue/Kconfig" +source "libs/libc/assert/Kconfig" diff --git a/libs/libc/assert/Kconfig b/libs/libc/assert/Kconfig new file mode 100644 index 00000000000..bd3798f7ff4 --- /dev/null +++ b/libs/libc/assert/Kconfig @@ -0,0 +1,15 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +menu "lib_assert custom options" + +config LIBC_ASSERT_CUSTOM + bool "use custom implementation of __assert" + default n + ---help--- + If the default implementation of __assert cannot match requirements, + Possible remove the default implementation and use a custom one. + +endmenu #lib_assert custom options diff --git a/libs/libc/assert/lib_assert.c b/libs/libc/assert/lib_assert.c index 4a71163d55a..307e3ac0d56 100644 --- a/libs/libc/assert/lib_assert.c +++ b/libs/libc/assert/lib_assert.c @@ -33,8 +33,10 @@ * Public Functions ****************************************************************************/ +#ifndef CONFIG_LIBC_ASSERT_CUSTOM void __assert(FAR const char *filename, int linenum, FAR const char *msg) { _assert(filename, linenum, msg, NULL); abort(); } +#endif
