[libc-commits] [libc] Rename libc/src/__support/endian.h to endian_internal.h (PR #115950)

Daniel Thornburgh via libc-commits libc-commits at lists.llvm.org
Tue Nov 12 14:29:07 PST 2024


https://github.com/mysterymath created https://github.com/llvm/llvm-project/pull/115950

This prevents a conflict with the Linux system endian.h when built in overlay mode for CPP files in __support.

This issue appeared in PR #106259.

>From 7d2e3b7c80a83694216ef5ee52daaaa5c368a161 Mon Sep 17 00:00:00 2001
From: Daniel Thornburgh <dthorn at google.com>
Date: Tue, 12 Nov 2024 13:49:37 -0800
Subject: [PATCH] Rename libc/src/__support/endian.h to endian_internal.h

This prevents a conflict with the Linux system endian.h when built in
overlay mode for CPP files in __support.

This issue appeared in PR #106259.
---
 libc/src/__support/CMakeLists.txt                           | 2 +-
 libc/src/__support/HashTable/generic/bitmask_impl.inc       | 2 +-
 libc/src/__support/{endian.h => endian_internal.h}          | 6 +++---
 libc/src/network/htonl.cpp                                  | 2 +-
 libc/src/network/htons.cpp                                  | 2 +-
 libc/src/network/ntohl.cpp                                  | 2 +-
 libc/src/network/ntohs.cpp                                  | 2 +-
 libc/src/string/memory_utils/op_generic.h                   | 2 +-
 libc/src/string/memory_utils/utils.h                        | 2 +-
 libc/test/src/__support/CMakeLists.txt                      | 4 ++--
 .../__support/{endian_test.cpp => endian_internal_test.cpp} | 2 +-
 libc/test/src/network/htonl_test.cpp                        | 2 +-
 libc/test/src/network/htons_test.cpp                        | 2 +-
 libc/test/src/network/ntohl_test.cpp                        | 2 +-
 libc/test/src/network/ntohs_test.cpp                        | 2 +-
 15 files changed, 18 insertions(+), 18 deletions(-)
 rename libc/src/__support/{endian.h => endian_internal.h} (96%)
 rename libc/test/src/__support/{endian_test.cpp => endian_internal_test.cpp} (97%)

diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt
index c44e333645e22e..6637ff9d56f4bc 100644
--- a/libc/src/__support/CMakeLists.txt
+++ b/libc/src/__support/CMakeLists.txt
@@ -55,7 +55,7 @@ add_header_library(
   common
   HDRS
     common.h
-    endian.h
+    endian_internal.h
     macros/properties/architectures.h
     macros/attributes.h
     macros/properties/cpu_features.h
diff --git a/libc/src/__support/HashTable/generic/bitmask_impl.inc b/libc/src/__support/HashTable/generic/bitmask_impl.inc
index 6266ac3c84a900..469ddeeed8a859 100644
--- a/libc/src/__support/HashTable/generic/bitmask_impl.inc
+++ b/libc/src/__support/HashTable/generic/bitmask_impl.inc
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/__support/common.h"
-#include "src/__support/endian.h"
+#include "src/__support/endian_internal.h"
 #include "src/__support/macros/config.h"
 
 namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/__support/endian.h b/libc/src/__support/endian_internal.h
similarity index 96%
rename from libc/src/__support/endian.h
rename to libc/src/__support/endian_internal.h
index 8c443fefab5e8f..77839ad75455ba 100644
--- a/libc/src/__support/endian.h
+++ b/libc/src/__support/endian_internal.h
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIBC_SRC___SUPPORT_ENDIAN_H
-#define LLVM_LIBC_SRC___SUPPORT_ENDIAN_H
+#ifndef LLVM_LIBC_SRC___SUPPORT_ENDIAN_INTERNAL_H
+#define LLVM_LIBC_SRC___SUPPORT_ENDIAN_INTERNAL_H
 
 #include "common.h"
 #include "src/__support/macros/config.h"
@@ -143,4 +143,4 @@ using Endian = internal::Endian<__BYTE_ORDER__>;
 
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LLVM_LIBC_SRC___SUPPORT_ENDIAN_H
+#endif // LLVM_LIBC_SRC___SUPPORT_ENDIAN_INTERNAL_H
diff --git a/libc/src/network/htonl.cpp b/libc/src/network/htonl.cpp
index ec3c02e2894f2f..681786adea68a7 100644
--- a/libc/src/network/htonl.cpp
+++ b/libc/src/network/htonl.cpp
@@ -8,7 +8,7 @@
 
 #include "src/network/htonl.h"
 #include "src/__support/common.h"
-#include "src/__support/endian.h"
+#include "src/__support/endian_internal.h"
 #include "src/__support/macros/config.h"
 
 namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/network/htons.cpp b/libc/src/network/htons.cpp
index 78416b3a7d1f0a..675f53cf4a0ad6 100644
--- a/libc/src/network/htons.cpp
+++ b/libc/src/network/htons.cpp
@@ -8,7 +8,7 @@
 
 #include "src/network/htons.h"
 #include "src/__support/common.h"
-#include "src/__support/endian.h"
+#include "src/__support/endian_internal.h"
 #include "src/__support/macros/config.h"
 
 namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/network/ntohl.cpp b/libc/src/network/ntohl.cpp
index 974b574432ff3d..6a309e97fca79b 100644
--- a/libc/src/network/ntohl.cpp
+++ b/libc/src/network/ntohl.cpp
@@ -8,7 +8,7 @@
 
 #include "src/network/ntohl.h"
 #include "src/__support/common.h"
-#include "src/__support/endian.h"
+#include "src/__support/endian_internal.h"
 #include "src/__support/macros/config.h"
 
 namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/network/ntohs.cpp b/libc/src/network/ntohs.cpp
index bb1779f3dcb30c..b51ecb93241cac 100644
--- a/libc/src/network/ntohs.cpp
+++ b/libc/src/network/ntohs.cpp
@@ -8,7 +8,7 @@
 
 #include "src/network/ntohs.h"
 #include "src/__support/common.h"
-#include "src/__support/endian.h"
+#include "src/__support/endian_internal.h"
 #include "src/__support/macros/config.h"
 
 namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/string/memory_utils/op_generic.h b/libc/src/string/memory_utils/op_generic.h
index 89bbea8a2bdd2b..da20a84dede4d1 100644
--- a/libc/src/string/memory_utils/op_generic.h
+++ b/libc/src/string/memory_utils/op_generic.h
@@ -26,7 +26,7 @@
 #include "src/__support/CPP/array.h"
 #include "src/__support/CPP/type_traits.h"
 #include "src/__support/common.h"
-#include "src/__support/endian.h"
+#include "src/__support/endian_internal.h"
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/optimization.h"
 #include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT64
diff --git a/libc/src/string/memory_utils/utils.h b/libc/src/string/memory_utils/utils.h
index 5e5fe593cce773..cae65bddd92f6e 100644
--- a/libc/src/string/memory_utils/utils.h
+++ b/libc/src/string/memory_utils/utils.h
@@ -12,7 +12,7 @@
 #include "src/__support/CPP/bit.h"
 #include "src/__support/CPP/cstddef.h"
 #include "src/__support/CPP/type_traits.h"
-#include "src/__support/endian.h"
+#include "src/__support/endian_internal.h"
 #include "src/__support/macros/attributes.h" // LIBC_INLINE
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/properties/architectures.h"
diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index 7ad262d5f1f300..e7ab85906a94f6 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -57,11 +57,11 @@ add_libc_test(
 )
 
 add_libc_test(
-  endian_test
+  endian_internal_test
   SUITE
     libc-support-tests
   SRCS
-    endian_test.cpp
+    endian_internal_test.cpp
   DEPENDS
     libc.src.__support.common
 )
diff --git a/libc/test/src/__support/endian_test.cpp b/libc/test/src/__support/endian_internal_test.cpp
similarity index 97%
rename from libc/test/src/__support/endian_test.cpp
rename to libc/test/src/__support/endian_internal_test.cpp
index 758c13b686946a..eab0f376e74956 100644
--- a/libc/test/src/__support/endian_test.cpp
+++ b/libc/test/src/__support/endian_internal_test.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/endian.h"
+#include "src/__support/endian_internal.h"
 #include "src/__support/macros/config.h"
 #include "test/UnitTest/Test.h"
 
diff --git a/libc/test/src/network/htonl_test.cpp b/libc/test/src/network/htonl_test.cpp
index d3b930d0b1ea24..f2e2541312c31a 100644
--- a/libc/test/src/network/htonl_test.cpp
+++ b/libc/test/src/network/htonl_test.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/endian.h"
+#include "src/__support/endian_internal.h"
 #include "src/network/htonl.h"
 #include "src/network/ntohl.h"
 #include "test/UnitTest/Test.h"
diff --git a/libc/test/src/network/htons_test.cpp b/libc/test/src/network/htons_test.cpp
index d38fab8153b97c..9668162523ce5d 100644
--- a/libc/test/src/network/htons_test.cpp
+++ b/libc/test/src/network/htons_test.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/endian.h"
+#include "src/__support/endian_internal.h"
 #include "src/network/htons.h"
 #include "src/network/ntohs.h"
 #include "test/UnitTest/Test.h"
diff --git a/libc/test/src/network/ntohl_test.cpp b/libc/test/src/network/ntohl_test.cpp
index b06f8e19e4f45b..b72456b7200e58 100644
--- a/libc/test/src/network/ntohl_test.cpp
+++ b/libc/test/src/network/ntohl_test.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/endian.h"
+#include "src/__support/endian_internal.h"
 #include "src/network/htonl.h"
 #include "src/network/ntohl.h"
 #include "test/UnitTest/Test.h"
diff --git a/libc/test/src/network/ntohs_test.cpp b/libc/test/src/network/ntohs_test.cpp
index 654a39662ac9ce..1104356076b94b 100644
--- a/libc/test/src/network/ntohs_test.cpp
+++ b/libc/test/src/network/ntohs_test.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/endian.h"
+#include "src/__support/endian_internal.h"
 #include "src/network/htons.h"
 #include "src/network/ntohs.h"
 #include "test/UnitTest/Test.h"



More information about the libc-commits mailing list