[libc-commits] [libc] [libc] move src/network to src/arpa/inet (PR #119273)

via libc-commits libc-commits at lists.llvm.org
Mon Dec 9 13:32:13 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Nick Desaulniers (nickdesaulniers)

<details>
<summary>Changes</summary>

So that docgen can find our implementations.

Fixes: #<!-- -->119272


---
Full diff: https://github.com/llvm/llvm-project/pull/119273.diff


22 Files Affected:

- (modified) libc/config/linux/aarch64/entrypoints.txt (+5-5) 
- (modified) libc/config/linux/riscv/entrypoints.txt (+5-5) 
- (modified) libc/config/linux/x86_64/entrypoints.txt (+5-5) 
- (modified) libc/src/CMakeLists.txt (+2-2) 
- (added) libc/src/arpa/CMakeLists.txt (+1) 
- (renamed) libc/src/arpa/inet/CMakeLists.txt () 
- (renamed) libc/src/arpa/inet/htonl.cpp (+1-1) 
- (renamed) libc/src/arpa/inet/htonl.h (+3-3) 
- (renamed) libc/src/arpa/inet/htons.cpp (+1-1) 
- (renamed) libc/src/arpa/inet/htons.h (+3-3) 
- (renamed) libc/src/arpa/inet/ntohl.cpp (+1-1) 
- (renamed) libc/src/arpa/inet/ntohl.h (+3-3) 
- (renamed) libc/src/arpa/inet/ntohs.cpp (+1-1) 
- (renamed) libc/src/arpa/inet/ntohs.h (+3-3) 
- (modified) libc/test/src/CMakeLists.txt (+2-2) 
- (added) libc/test/src/arpa/CMakeLists.txt (+1) 
- (added) libc/test/src/arpa/inet/CMakeLists.txt (+53) 
- (renamed) libc/test/src/arpa/inet/htonl_test.cpp (+2-2) 
- (renamed) libc/test/src/arpa/inet/htons_test.cpp (+2-2) 
- (renamed) libc/test/src/arpa/inet/ntohl_test.cpp (+2-2) 
- (renamed) libc/test/src/arpa/inet/ntohs_test.cpp (+2-2) 
- (removed) libc/test/src/network/CMakeLists.txt (-53) 


``````````diff
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index effa5b12d87ac4..26d2eee1c3542b 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -804,11 +804,11 @@ if(LLVM_LIBC_FULL_BUILD)
     libc.src.dirent.opendir
     libc.src.dirent.readdir
 
-    # network.h entrypoints
-    libc.src.network.htonl
-    libc.src.network.htons
-    libc.src.network.ntohl
-    libc.src.network.ntohs
+    # arpa/inet.h entrypoints
+    libc.src.arpa.inet.htonl
+    libc.src.arpa.inet.htons
+    libc.src.arpa.inet.ntohl
+    libc.src.arpa.inet.ntohs
 
     # pthread.h entrypoints
     libc.src.pthread.pthread_atfork
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 5a48baf104159f..c7d9cc6bd961a0 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -747,11 +747,11 @@ if(LLVM_LIBC_FULL_BUILD)
     libc.src.dirent.opendir
     libc.src.dirent.readdir
 
-    # network.h entrypoints
-    libc.src.network.htonl
-    libc.src.network.htons
-    libc.src.network.ntohl
-    libc.src.network.ntohs
+    # arpa/inet.h entrypoints
+    libc.src.arpa.inet.htonl
+    libc.src.arpa.inet.htons
+    libc.src.arpa.inet.ntohl
+    libc.src.arpa.inet.ntohs
 
     # pthread.h entrypoints
     libc.src.pthread.pthread_atfork
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 1bedc25a9d0291..0cddf72d71fcd9 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -888,11 +888,11 @@ if(LLVM_LIBC_FULL_BUILD)
     libc.src.dirent.opendir
     libc.src.dirent.readdir
 
-    # network.h entrypoints
-    libc.src.network.htonl
-    libc.src.network.htons
-    libc.src.network.ntohl
-    libc.src.network.ntohs
+    # arpa/inet.h entrypoints
+    libc.src.arpa.inet.htonl
+    libc.src.arpa.inet.htons
+    libc.src.arpa.inet.ntohl
+    libc.src.arpa.inet.ntohs
 
     # pthread.h entrypoints
     libc.src.pthread.pthread_atfork
diff --git a/libc/src/CMakeLists.txt b/libc/src/CMakeLists.txt
index dd3b51886edfea..652efcfc32808f 100644
--- a/libc/src/CMakeLists.txt
+++ b/libc/src/CMakeLists.txt
@@ -33,12 +33,12 @@ if(NOT LLVM_LIBC_FULL_BUILD)
   return()
 endif()
 
+add_subdirectory(arpa)
 add_subdirectory(assert)
 add_subdirectory(compiler)
-add_subdirectory(network)
+add_subdirectory(locale)
 add_subdirectory(search)
 add_subdirectory(setjmp)
 add_subdirectory(signal)
 add_subdirectory(spawn)
 add_subdirectory(threads)
-add_subdirectory(locale)
diff --git a/libc/src/arpa/CMakeLists.txt b/libc/src/arpa/CMakeLists.txt
new file mode 100644
index 00000000000000..5c89828860ff87
--- /dev/null
+++ b/libc/src/arpa/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(inet)
diff --git a/libc/src/network/CMakeLists.txt b/libc/src/arpa/inet/CMakeLists.txt
similarity index 100%
rename from libc/src/network/CMakeLists.txt
rename to libc/src/arpa/inet/CMakeLists.txt
diff --git a/libc/src/network/htonl.cpp b/libc/src/arpa/inet/htonl.cpp
similarity index 95%
rename from libc/src/network/htonl.cpp
rename to libc/src/arpa/inet/htonl.cpp
index 681786adea68a7..fb0404a26a2446 100644
--- a/libc/src/network/htonl.cpp
+++ b/libc/src/arpa/inet/htonl.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/network/htonl.h"
+#include "src/arpa/inet/htonl.h"
 #include "src/__support/common.h"
 #include "src/__support/endian_internal.h"
 #include "src/__support/macros/config.h"
diff --git a/libc/src/network/htonl.h b/libc/src/arpa/inet/htonl.h
similarity index 81%
rename from libc/src/network/htonl.h
rename to libc/src/arpa/inet/htonl.h
index 14217310a2271d..e444972c771ea2 100644
--- a/libc/src/network/htonl.h
+++ b/libc/src/arpa/inet/htonl.h
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIBC_SRC_NETWORK_HTONL_H
-#define LLVM_LIBC_SRC_NETWORK_HTONL_H
+#ifndef LLVM_LIBC_SRC_ARPA_INET_HTONL_H
+#define LLVM_LIBC_SRC_ARPA_INET_HTONL_H
 
 #include "src/__support/macros/config.h"
 #include <stdint.h>
@@ -18,4 +18,4 @@ uint32_t htonl(uint32_t hostlong);
 
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LLVM_LIBC_SRC_NETWORK_HTONL_H
+#endif // LLVM_LIBC_SRC_ARPA_INET_HTONL_H
diff --git a/libc/src/network/htons.cpp b/libc/src/arpa/inet/htons.cpp
similarity index 95%
rename from libc/src/network/htons.cpp
rename to libc/src/arpa/inet/htons.cpp
index 675f53cf4a0ad6..1fcbbdf67deb01 100644
--- a/libc/src/network/htons.cpp
+++ b/libc/src/arpa/inet/htons.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/network/htons.h"
+#include "src/arpa/inet/htons.h"
 #include "src/__support/common.h"
 #include "src/__support/endian_internal.h"
 #include "src/__support/macros/config.h"
diff --git a/libc/src/network/htons.h b/libc/src/arpa/inet/htons.h
similarity index 81%
rename from libc/src/network/htons.h
rename to libc/src/arpa/inet/htons.h
index 8f5c68a0a60a88..35c2acdcfae452 100644
--- a/libc/src/network/htons.h
+++ b/libc/src/arpa/inet/htons.h
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIBC_SRC_NETWORK_HTONS_H
-#define LLVM_LIBC_SRC_NETWORK_HTONS_H
+#ifndef LLVM_LIBC_SRC_ARPA_INET_HTONS_H
+#define LLVM_LIBC_SRC_ARPA_INET_HTONS_H
 
 #include "src/__support/macros/config.h"
 #include <stdint.h>
@@ -18,4 +18,4 @@ uint16_t htons(uint16_t hostshort);
 
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LLVM_LIBC_SRC_NETWORK_HTONS_H
+#endif // LLVM_LIBC_SRC_ARPA_INET_HTONS_H
diff --git a/libc/src/network/ntohl.cpp b/libc/src/arpa/inet/ntohl.cpp
similarity index 95%
rename from libc/src/network/ntohl.cpp
rename to libc/src/arpa/inet/ntohl.cpp
index 6a309e97fca79b..d472107a1988cd 100644
--- a/libc/src/network/ntohl.cpp
+++ b/libc/src/arpa/inet/ntohl.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/network/ntohl.h"
+#include "src/arpa/inet/ntohl.h"
 #include "src/__support/common.h"
 #include "src/__support/endian_internal.h"
 #include "src/__support/macros/config.h"
diff --git a/libc/src/network/ntohl.h b/libc/src/arpa/inet/ntohl.h
similarity index 81%
rename from libc/src/network/ntohl.h
rename to libc/src/arpa/inet/ntohl.h
index c325951948062a..40079650d6fd1f 100644
--- a/libc/src/network/ntohl.h
+++ b/libc/src/arpa/inet/ntohl.h
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIBC_SRC_NETWORK_NTOHL_H
-#define LLVM_LIBC_SRC_NETWORK_NTOHL_H
+#ifndef LLVM_LIBC_SRC_ARPA_INET_NTOHL_H
+#define LLVM_LIBC_SRC_ARPA_INET_NTOHL_H
 
 #include "src/__support/macros/config.h"
 #include <stdint.h>
@@ -18,4 +18,4 @@ uint32_t ntohl(uint32_t netlong);
 
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LLVM_LIBC_SRC_NETWORK_NTOHL_H
+#endif // LLVM_LIBC_SRC_ARPA_INET_NTOHL_H
diff --git a/libc/src/network/ntohs.cpp b/libc/src/arpa/inet/ntohs.cpp
similarity index 95%
rename from libc/src/network/ntohs.cpp
rename to libc/src/arpa/inet/ntohs.cpp
index b51ecb93241cac..9082ed928778eb 100644
--- a/libc/src/network/ntohs.cpp
+++ b/libc/src/arpa/inet/ntohs.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/network/ntohs.h"
+#include "src/arpa/inet/ntohs.h"
 #include "src/__support/common.h"
 #include "src/__support/endian_internal.h"
 #include "src/__support/macros/config.h"
diff --git a/libc/src/network/ntohs.h b/libc/src/arpa/inet/ntohs.h
similarity index 81%
rename from libc/src/network/ntohs.h
rename to libc/src/arpa/inet/ntohs.h
index f55591415f764c..5fe3ebcb62520c 100644
--- a/libc/src/network/ntohs.h
+++ b/libc/src/arpa/inet/ntohs.h
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIBC_SRC_NETWORK_NTOHS_H
-#define LLVM_LIBC_SRC_NETWORK_NTOHS_H
+#ifndef LLVM_LIBC_SRC_ARPA_INET_NTOHS_H
+#define LLVM_LIBC_SRC_ARPA_INET_NTOHS_H
 
 #include "src/__support/macros/config.h"
 #include <stdint.h>
@@ -18,4 +18,4 @@ uint16_t ntohs(uint16_t netshort);
 
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LLVM_LIBC_SRC_NETWORK_NTOHS_H
+#endif // LLVM_LIBC_SRC_ARPA_INET_NTOHS_H
diff --git a/libc/test/src/CMakeLists.txt b/libc/test/src/CMakeLists.txt
index 606f6d837e4fe7..a4e62c1e0fb2dd 100644
--- a/libc/test/src/CMakeLists.txt
+++ b/libc/test/src/CMakeLists.txt
@@ -76,14 +76,14 @@ if(NOT LLVM_LIBC_FULL_BUILD)
   return()
 endif()
 
+add_subdirectory(arpa)
 add_subdirectory(assert)
 add_subdirectory(compiler)
 add_subdirectory(dirent)
-add_subdirectory(network)
+add_subdirectory(locale)
 add_subdirectory(setjmp)
 add_subdirectory(signal)
 add_subdirectory(spawn)
-add_subdirectory(locale)
 
 if(${LIBC_TARGET_OS} STREQUAL "linux")
   add_subdirectory(pthread)
diff --git a/libc/test/src/arpa/CMakeLists.txt b/libc/test/src/arpa/CMakeLists.txt
new file mode 100644
index 00000000000000..5c89828860ff87
--- /dev/null
+++ b/libc/test/src/arpa/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(inet)
diff --git a/libc/test/src/arpa/inet/CMakeLists.txt b/libc/test/src/arpa/inet/CMakeLists.txt
new file mode 100644
index 00000000000000..6e78e3a50e6122
--- /dev/null
+++ b/libc/test/src/arpa/inet/CMakeLists.txt
@@ -0,0 +1,53 @@
+add_custom_target(libc_arpa_inet_unittests)
+
+add_libc_unittest(
+  htonl
+  SUITE
+    libc_arpa_inet_unittests
+  SRCS
+    htonl_test.cpp
+  CXX_STANDARD
+    20
+  DEPENDS
+    libc.src.arpa.inet.htonl
+    libc.src.arpa.inet.ntohl
+)
+
+add_libc_unittest(
+  htons
+  SUITE
+    libc_arpa_inet_unittests
+  SRCS
+    htons_test.cpp
+  CXX_STANDARD
+    20
+  DEPENDS
+    libc.src.arpa.inet.htons
+    libc.src.arpa.inet.ntohs
+)
+
+add_libc_unittest(
+  ntohl
+  SUITE
+    libc_arpa_inet_unittests
+  SRCS
+    ntohl_test.cpp
+  CXX_STANDARD
+    20
+  DEPENDS
+    libc.src.arpa.inet.htonl
+    libc.src.arpa.inet.ntohl
+)
+
+add_libc_unittest(
+  ntohs
+  SUITE
+    libc_arpa_inet_unittests
+  SRCS
+    ntohs_test.cpp
+  CXX_STANDARD
+    20
+  DEPENDS
+    libc.src.arpa.inet.htons
+    libc.src.arpa.inet.ntohs
+)
diff --git a/libc/test/src/network/htonl_test.cpp b/libc/test/src/arpa/inet/htonl_test.cpp
similarity index 93%
rename from libc/test/src/network/htonl_test.cpp
rename to libc/test/src/arpa/inet/htonl_test.cpp
index f2e2541312c31a..4cc1e4cb4e8862 100644
--- a/libc/test/src/network/htonl_test.cpp
+++ b/libc/test/src/arpa/inet/htonl_test.cpp
@@ -7,8 +7,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/__support/endian_internal.h"
-#include "src/network/htonl.h"
-#include "src/network/ntohl.h"
+#include "src/arpa/inet/htonl.h"
+#include "src/arpa/inet/ntohl.h"
 #include "test/UnitTest/Test.h"
 
 TEST(LlvmLibcHtonl, SmokeTest) {
diff --git a/libc/test/src/network/htons_test.cpp b/libc/test/src/arpa/inet/htons_test.cpp
similarity index 93%
rename from libc/test/src/network/htons_test.cpp
rename to libc/test/src/arpa/inet/htons_test.cpp
index 9668162523ce5d..6a95ec5587e953 100644
--- a/libc/test/src/network/htons_test.cpp
+++ b/libc/test/src/arpa/inet/htons_test.cpp
@@ -7,8 +7,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/__support/endian_internal.h"
-#include "src/network/htons.h"
-#include "src/network/ntohs.h"
+#include "src/arpa/inet/htons.h"
+#include "src/arpa/inet/ntohs.h"
 #include "test/UnitTest/Test.h"
 
 TEST(LlvmLibcHtons, SmokeTest) {
diff --git a/libc/test/src/network/ntohl_test.cpp b/libc/test/src/arpa/inet/ntohl_test.cpp
similarity index 93%
rename from libc/test/src/network/ntohl_test.cpp
rename to libc/test/src/arpa/inet/ntohl_test.cpp
index b72456b7200e58..42562486d5c00b 100644
--- a/libc/test/src/network/ntohl_test.cpp
+++ b/libc/test/src/arpa/inet/ntohl_test.cpp
@@ -7,8 +7,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/__support/endian_internal.h"
-#include "src/network/htonl.h"
-#include "src/network/ntohl.h"
+#include "src/arpa/inet/htonl.h"
+#include "src/arpa/inet/ntohl.h"
 #include "test/UnitTest/Test.h"
 
 TEST(LlvmLibcNtohl, SmokeTest) {
diff --git a/libc/test/src/network/ntohs_test.cpp b/libc/test/src/arpa/inet/ntohs_test.cpp
similarity index 93%
rename from libc/test/src/network/ntohs_test.cpp
rename to libc/test/src/arpa/inet/ntohs_test.cpp
index 1104356076b94b..38b2c8d8fe40f9 100644
--- a/libc/test/src/network/ntohs_test.cpp
+++ b/libc/test/src/arpa/inet/ntohs_test.cpp
@@ -7,8 +7,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/__support/endian_internal.h"
-#include "src/network/htons.h"
-#include "src/network/ntohs.h"
+#include "src/arpa/inet/htons.h"
+#include "src/arpa/inet/ntohs.h"
 #include "test/UnitTest/Test.h"
 
 TEST(LlvmLibcNtohs, SmokeTest) {
diff --git a/libc/test/src/network/CMakeLists.txt b/libc/test/src/network/CMakeLists.txt
deleted file mode 100644
index 222205dfe247a6..00000000000000
--- a/libc/test/src/network/CMakeLists.txt
+++ /dev/null
@@ -1,53 +0,0 @@
-add_custom_target(libc_network_unittests)
-
-add_libc_unittest(
-  htonl
-  SUITE
-    libc_network_unittests
-  SRCS
-    htonl_test.cpp
-  CXX_STANDARD
-    20
-  DEPENDS
-    libc.src.network.htonl
-    libc.src.network.ntohl
-)
-
-add_libc_unittest(
-  htons
-  SUITE
-    libc_network_unittests
-  SRCS
-    htons_test.cpp
-  CXX_STANDARD
-    20
-  DEPENDS
-    libc.src.network.htons
-    libc.src.network.ntohs
-)
-
-add_libc_unittest(
-  ntohl
-  SUITE
-    libc_network_unittests
-  SRCS
-    ntohl_test.cpp
-  CXX_STANDARD
-    20
-  DEPENDS
-    libc.src.network.htonl
-    libc.src.network.ntohl
-)
-
-add_libc_unittest(
-  ntohs
-  SUITE
-    libc_network_unittests
-  SRCS
-    ntohs_test.cpp
-  CXX_STANDARD
-    20
-  DEPENDS
-    libc.src.network.htons
-    libc.src.network.ntohs
-)

``````````

</details>


https://github.com/llvm/llvm-project/pull/119273


More information about the libc-commits mailing list