This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 970fb51ad679f50b9c03be830443dc432554a138
Author: Marco Casaroli <[email protected]>
AuthorDate: Wed Oct 28 00:34:29 2026 +0100

    include/nuttx/compiler.h: Hide builtin_function() with NUTTX_NO_EXTENSIONS.
    
    When a program is compiled with optimisation, <nuttx/compiler.h> (which
    every public header includes) defines builtin_function(fn) and
    builtin_original(fn) for the inline versions of memcpy() and other
    functions in <string.h>.  These names are not reserved: a program that
    uses them for its own code does not compile (vim declares a function
    builtin_function(): "macro passed 2 arguments").
    
    With NUTTX_NO_EXTENSIONS, the header does not define them, and
    <string.h> declares the plain functions.  The compiler can still use
    its own built-in functions for them.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 include/nuttx/compiler.h | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h
index ecb133b4e61..34d17a180eb 100644
--- a/include/nuttx/compiler.h
+++ b/include/nuttx/compiler.h
@@ -226,7 +226,8 @@
                                  extern __inline__ no_builtin(#fn) \
                                  __attribute__((__always_inline__, \
                                                 __gnu_inline__, 
__artificial__))
-#  elif defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 && defined(__has_builtin)
+#  elif defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 && \
+         defined(__has_builtin) && !defined(NUTTX_NO_EXTENSIONS)
 #    define builtin_original(fn)  __typeof__(fn)  __orig_##fn __asm__(#fn)
 #    define builtin_function(fn)  builtin_original(fn); \
                                   extern __inline__ no_builtin(#fn) \
@@ -1623,11 +1624,12 @@
  * and lutimens() (sys/stat.h), the file system types *_MAGIC
  * (sys/statfs.h), PANIC(), PANIC_WITH_REGS(), ASSERT(), VERIFY(),
  * COMPILE_TIME_ASSERT() and BUILD_BUG_ON_ZERO() (assert.h), crypt_r()
- * (unistd.h), the types unchar and s_char (sys/types.h) and the helper
- * macros of this file below, such as memory_barrier() and UNUSED().  The
- * headers that a program includes do not use these names.  A definition
- * that the program made before is restored (saved at the start of this
- * file).
+ * (unistd.h), the types unchar and s_char (sys/types.h),
+ * builtin_function() and builtin_original() (above: string.h then declares
+ * the plain functions) and the helper macros of this file below, such as
+ * memory_barrier() and UNUSED().  The headers that a program includes do
+ * not use these names.  A definition that the program made before is
+ * restored (saved at the start of this file).
  */
 
 #ifdef NUTTX_NO_EXTENSIONS

Reply via email to