[libcxx-commits] [PATCH] D134591: [libcxx] Make stdatomic.h work when included from a C source file

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 27 10:13:40 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGafec0f0ec38a: [libcxx] Make stdatomic.h work when included from a C source file (authored by ngg, committed by ldionne).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134591/new/

https://reviews.llvm.org/D134591

Files:
  libcxx/include/__config
  libcxx/include/stdatomic.h
  libcxx/test/libcxx/include_as_c.sh.cpp


Index: libcxx/test/libcxx/include_as_c.sh.cpp
===================================================================
--- libcxx/test/libcxx/include_as_c.sh.cpp
+++ libcxx/test/libcxx/include_as_c.sh.cpp
@@ -34,6 +34,7 @@
 #endif
 #include <math.h>
 #include <setjmp.h>
+#include <stdatomic.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdint.h>
Index: libcxx/include/stdatomic.h
===================================================================
--- libcxx/include/stdatomic.h
+++ libcxx/include/stdatomic.h
@@ -121,7 +121,7 @@
 #  pragma GCC system_header
 #endif
 
-#if _LIBCPP_STD_VER > 20
+#if defined(__cplusplus) && _LIBCPP_STD_VER > 20
 
 #include <atomic>
 #include <version>
@@ -230,6 +230,6 @@
 #   include_next <stdatomic.h>
 # endif
 
-#endif // _LIBCPP_STD_VER > 20
+#endif // defined(__cplusplus) && _LIBCPP_STD_VER > 20
 
 #endif // _LIBCPP_STDATOMIC_H
Index: libcxx/include/__config
===================================================================
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -22,6 +22,16 @@
 #  pragma GCC system_header
 #endif
 
+#if defined(__apple_build_version__)
+#  define _LIBCPP_COMPILER_CLANG_BASED
+#  define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000)
+#elif defined(__clang__)
+#  define _LIBCPP_COMPILER_CLANG_BASED
+#  define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
+#elif defined(__GNUC__)
+#  define _LIBCPP_COMPILER_GCC
+#endif
+
 #ifdef __cplusplus
 
 // _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM.
@@ -202,16 +212,6 @@
 #    define __has_include(...) 0
 #  endif
 
-#  if defined(__apple_build_version__)
-#    define _LIBCPP_COMPILER_CLANG_BASED
-#    define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000)
-#  elif defined(__clang__)
-#    define _LIBCPP_COMPILER_CLANG_BASED
-#    define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
-#  elif defined(__GNUC__)
-#    define _LIBCPP_COMPILER_GCC
-#  endif
-
 #  if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L
 #    error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
 #  endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134591.463273.patch
Type: text/x-patch
Size: 2159 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220927/2daff1fc/attachment.bin>


More information about the libcxx-commits mailing list