[libcxx-commits] [libcxx] [libc++] Don't rely on a transitively included BYTE_ORDER in ctype_base (PR #213032)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 30 07:26:59 PDT 2026


https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/213032

Use libc++'s own _LIBCPP_BIG_ENDIAN macro instead of BYTE_ORDER, which was relied upon from a transitive <endian.h> include on Glibc.

>From d4030cdec76b6760c07b09b22553f704c0354b17 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 30 Jul 2026 09:40:01 -0400
Subject: [PATCH] [libc++] Don't rely on a transitively included BYTE_ORDER in
 ctype_base

Use libc++'s own _LIBCPP_BIG_ENDIAN macro instead of BYTE_ORDER, which
was relied upon from a transitive <endian.h> include on Glibc.
---
 libcxx/include/__locale | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libcxx/include/__locale b/libcxx/include/__locale
index 28bc17f8368a6..f6458d80fbbdc 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -12,6 +12,7 @@
 
 #include <__config>
 #include <__configuration/availability.h>
+#include <__configuration/platform.h>
 
 #if _LIBCPP_HAS_LOCALIZATION
 
@@ -345,7 +346,7 @@ public:
   static const mask xdigit = _ISxdigit;
   static const mask blank  = _ISblank;
   _LIBCPP_DIAGNOSTIC_POP
-#    if defined(__mips__) || (BYTE_ORDER == BIG_ENDIAN)
+#    if defined(__mips__) || defined(_LIBCPP_BIG_ENDIAN)
   static const mask __regex_word = static_cast<mask>(_ISbit(15));
 #    else
   static const mask __regex_word = 0x80;



More information about the libcxx-commits mailing list