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

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

commit a5536cde46e10b2f9ec7b9057ac2348771ff514f
Author: Bowen Wang <[email protected]>
AuthorDate: Tue Nov 24 13:07:00 2026 +0800

    openamp: skip atomic_wchar_t in libmetal when libc++ lacks it
    
    libc++ declares std::atomic_wchar_t only with wide character support,
    which NuttX leaves off by default, so a C++ file including
    metal/atomic.h fails:
    
      include/metal/atomic.h:50:12: error: 'atomic_wchar_t' has not been
      declared in 'std'
    
    Add a libmetal patch that exports it only when libc++ provides it. The
    next patch includes metal/atomic.h from openamp/rpmsg.h.
    
    Signed-off-by: Bowen Wang <[email protected]>
---
 ...h-skip-atomic_wchar_t-when-libc-has-no-wi.patch | 41 ++++++++++++++++++++++
 openamp/libmetal.cmake                             |  2 ++
 openamp/libmetal.defs                              |  1 +
 3 files changed, 44 insertions(+)

diff --git 
a/openamp/0004-lib-atomic.h-skip-atomic_wchar_t-when-libc-has-no-wi.patch 
b/openamp/0004-lib-atomic.h-skip-atomic_wchar_t-when-libc-has-no-wi.patch
new file mode 100644
index 00000000000..91e641ef5c3
--- /dev/null
+++ b/openamp/0004-lib-atomic.h-skip-atomic_wchar_t-when-libc-has-no-wi.patch
@@ -0,0 +1,41 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Bowen Wang <[email protected]>
+Date: Wed, 14 Oct 2026 21:35:23 +0800
+Subject: [PATCH] lib/atomic.h: skip atomic_wchar_t when libc++ has no wide
+ characters
+
+libc++ declares std::atomic_wchar_t only with wide character support,
+which NuttX leaves off by default, so any C++ file including
+metal/atomic.h fails:
+
+  include/metal/atomic.h:50:12: error: 'atomic_wchar_t' has not been
+  declared in 'std'
+
+Export it only when libc++ provides it. libc++ 17 spells the switch
+_LIBCPP_HAS_NO_WIDE_CHARACTERS and libc++ 21 _LIBCPP_HAS_WIDE_CHARACTERS,
+so both are checked.
+
+Signed-off-by: Bowen Wang <[email protected]>
+---
+ lib/atomic.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/lib/atomic.h libmetal/lib/atomic.h
+index 7f38a08..a017b09 100644
+--- a/lib/atomic.h
++++ libmetal/lib/atomic.h
+@@ -47,7 +47,11 @@ using std::atomic_llong;
+ using std::atomic_ullong;
+ using std::atomic_char16_t;
+ using std::atomic_char32_t;
++/* libc++ leaves atomic_wchar_t out when wide character support is off */
++#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) && \
++    (!defined(_LIBCPP_HAS_WIDE_CHARACTERS) || _LIBCPP_HAS_WIDE_CHARACTERS)
+ using std::atomic_wchar_t;
++#endif
+ using std::atomic_int_least8_t;
+ using std::atomic_uint_least8_t;
+ using std::atomic_int_least16_t;
+-- 
+2.34.1
+
diff --git a/openamp/libmetal.cmake b/openamp/libmetal.cmake
index c2093280d81..f68c1440dcc 100644
--- a/openamp/libmetal.cmake
+++ b/openamp/libmetal.cmake
@@ -42,6 +42,8 @@ if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libmetal)
       
${CMAKE_CURRENT_LIST_DIR}/0002-libmetal-atomic-enable-64-bit-atomic-by-toolchain-bu.patch
       && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
       
${CMAKE_CURRENT_LIST_DIR}/0003-mutex-make-the-libmetal-nuttx-mutex-a-recursive-spinlock.patch
+      && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
+      
${CMAKE_CURRENT_LIST_DIR}/0004-lib-atomic.h-skip-atomic_wchar_t-when-libc-has-no-wi.patch
     DOWNLOAD_NO_PROGRESS true
     TIMEOUT 30)
 
diff --git a/openamp/libmetal.defs b/openamp/libmetal.defs
index e10a7a295cf..389da8d5c30 100644
--- a/openamp/libmetal.defs
+++ b/openamp/libmetal.defs
@@ -85,6 +85,7 @@ libmetal.zip:
        $(Q) patch -p0 < 
0001-libmetal-cmake-set-HAVE_STDATOMIC_H-default-true-in-.patch
        $(Q) patch -p0 < 
0002-libmetal-atomic-enable-64-bit-atomic-by-toolchain-bu.patch
        $(Q) patch -p0 < 
0003-mutex-make-the-libmetal-nuttx-mutex-a-recursive-spinlock.patch
+       $(Q) patch -p0 < 
0004-lib-atomic.h-skip-atomic_wchar_t-when-libc-has-no-wi.patch
 
 .libmetal_headers: libmetal.zip
 else

Reply via email to