[libcxx-commits] [libcxx] 8deaa4a - [libc++] Move checks for newlib to actually work

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Apr 12 11:21:20 PDT 2021


Author: Mara Sophie Grosch
Date: 2021-04-12T14:20:36-04:00
New Revision: 8deaa4a1471dac19c717a320eec9956843a8c479

URL: https://github.com/llvm/llvm-project/commit/8deaa4a1471dac19c717a320eec9956843a8c479
DIFF: https://github.com/llvm/llvm-project/commit/8deaa4a1471dac19c717a320eec9956843a8c479.diff

LOG: [libc++] Move checks for newlib to actually work

The checks did not work in __config, since no header defining
`_NEWLIB_VERSION` was included before. This patch moves the two
checks for newlib to the headers that actually need it - and after
they already include relevant headers.

Differential Revision: https://reviews.llvm.org/D79888

Added: 
    

Modified: 
    libcxx/include/__config
    libcxx/include/fstream
    libcxx/include/locale

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__config b/libcxx/include/__config
index 3acb17f05c09..7b6a08c2202a 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -934,13 +934,6 @@ typedef unsigned int   char32_t;
 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
 #endif
 
-#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
-// Most unix variants have catopen.  These are the specific ones that don't.
-#  if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
-#    define _LIBCPP_HAS_CATOPEN 1
-#  endif
-#endif
-
 #ifdef __FreeBSD__
 #define _DECLARE_C99_LDBL_MATH 1
 #endif
@@ -1312,12 +1305,6 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
 #define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
 #endif
 
-#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
-#  if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
-#    define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
-#  endif
-#endif
-
 #if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
 #  define _LIBCPP_DIAGNOSE_WARNING(...) \
      __attribute__((diagnose_if(__VA_ARGS__, "warning")))

diff  --git a/libcxx/include/fstream b/libcxx/include/fstream
index d7d6b46c32d9..51b26ecf79e4 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -198,6 +198,9 @@ typedef basic_fstream<wchar_t> wfstream;
 _LIBCPP_PUSH_MACROS
 #include <__undef_macros>
 
+#if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
+#  define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
+#endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 

diff  --git a/libcxx/include/locale b/libcxx/include/locale
index 9a705c77cfab..ad002227b36b 100644
--- a/libcxx/include/locale
+++ b/libcxx/include/locale
@@ -203,8 +203,13 @@ template <class charT> class messages_byname;
 #include <cstdlib>
 #include <ctime>
 #include <cstdio>
-#ifdef _LIBCPP_HAS_CATOPEN
-#include <nl_types.h>
+
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+// Most unix variants have catopen.  These are the specific ones that don't.
+#  if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
+#    define _LIBCPP_HAS_CATOPEN 1
+#    include <nl_types.h>
+#  endif
 #endif
 
 #ifdef _LIBCPP_LOCALE__L_EXTENSIONS


        


More information about the libcxx-commits mailing list