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

via libc-commits libc-commits at lists.llvm.org
Wed Nov 13 10:28:12 PST 2024


Author: Daniel Thornburgh
Date: 2024-11-13T10:28:07-08:00
New Revision: 95b680e4c353d479fbfb96adb39696042c005e99

URL: https://github.com/llvm/llvm-project/commit/95b680e4c353d479fbfb96adb39696042c005e99
DIFF: https://github.com/llvm/llvm-project/commit/95b680e4c353d479fbfb96adb39696042c005e99.diff

LOG: [libc] Rename libc/src/__support/endian.h to endian_internal.h (#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.

Added: 
    libc/src/__support/endian_internal.h
    libc/test/src/__support/endian_internal_test.cpp

Modified: 
    libc/src/__support/CMakeLists.txt
    libc/src/__support/HashTable/generic/bitmask_impl.inc
    libc/src/network/htonl.cpp
    libc/src/network/htons.cpp
    libc/src/network/ntohl.cpp
    libc/src/network/ntohs.cpp
    libc/src/string/memory_utils/op_generic.h
    libc/src/string/memory_utils/utils.h
    libc/test/src/__support/CMakeLists.txt
    libc/test/src/network/htonl_test.cpp
    libc/test/src/network/htons_test.cpp
    libc/test/src/network/ntohl_test.cpp
    libc/test/src/network/ntohs_test.cpp
    utils/bazel/llvm-project-overlay/libc/BUILD.bazel
    utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel

Removed: 
    libc/src/__support/endian.h
    libc/test/src/__support/endian_test.cpp


################################################################################
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 dc66bc5c71dd67..c3a7d87d8281f9 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"

diff  --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 69a0dada23b4cd..2573788658d59b 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -425,7 +425,7 @@ libc_support_library(
     name = "__support_common",
     hdrs = [
         "src/__support/common.h",
-        "src/__support/endian.h",
+        "src/__support/endian_internal.h",
     ],
     deps = [
         ":__support_macros_attributes",

diff  --git a/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel
index fae0482e7f3a55..0698f45ceabc9a 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel
@@ -30,8 +30,8 @@ libc_test(
 # )
 
 libc_test(
-    name = "endian_test",
-    srcs = ["endian_test.cpp"],
+    name = "endian_internal_test",
+    srcs = ["endian_internal_test.cpp"],
     deps = ["//libc:__support_common"],
 )
 


        


More information about the libc-commits mailing list