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 1c7a946deeea5918b683a58168122e0f8d1a2313 Author: zhangyu117 <[email protected]> AuthorDate: Thu Aug 13 22:15:48 2026 +0800 nuttx/include/atomic.h: add __has_include fallback and simplify guards Add a fallback macro in compiler.h that defines __has_include(x) as 0 when the compiler does not natively support it. This allows simplifying the guards in atomic.h by removing the defined(__has_include) check and the __has_include(<stdatomic.h>) check, since __has_include is now always defined and __STDC_NO_ATOMICS__ is sufficient to determine atomic support. The NEED_ATOMIC_MACROS logic is kept unchanged to preserve the C++ conflict fix from commit cd8ba3377ca. Signed-off-by: zhangyu117 <[email protected]> --- include/nuttx/atomic.h | 5 ++--- include/nuttx/compiler.h | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/nuttx/atomic.h b/include/nuttx/atomic.h index 2a6ff228a12..65456d60382 100644 --- a/include/nuttx/atomic.h +++ b/include/nuttx/atomic.h @@ -36,7 +36,7 @@ # endif #endif -#if defined(__has_include) && !defined(CONFIG_LIBC_ARCH_ATOMIC) +#if !defined(CONFIG_LIBC_ARCH_ATOMIC) # if __has_include(<atomic>) && defined(__cplusplus) extern "C++" { @@ -57,8 +57,7 @@ extern "C++" typedef volatile int32_t atomic_t; typedef volatile int64_t atomic64_t; } -# elif __has_include(<stdatomic.h>) && \ - ((defined(__cplusplus) && __cplusplus >= 201103L) || \ +# elif ((defined(__cplusplus) && __cplusplus >= 201103L) || \ (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)) && \ !defined(__STDC_NO_ATOMICS__) # if !defined(__clang__) && defined(__cplusplus) diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h index fbf04775dbe..0c2af726c15 100644 --- a/include/nuttx/compiler.h +++ b/include/nuttx/compiler.h @@ -1426,6 +1426,12 @@ # define osentry_function #endif +/* Micro about __has_include */ + +#ifndef __has_include +# define __has_include(x) 0 +#endif + /**************************************************************************** * Public Function Prototypes ****************************************************************************/
