[llvm] [libc][bazel] Add missing arpa/inet functions and tests (PR #210310)
Pavel Labath via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 17 04:41:25 PDT 2026
https://github.com/labath created https://github.com/llvm/llvm-project/pull/210310
Add bazel build targets for the remaining arpa/inet functions (inet_addr, inet_aton, inet_ntoa, and inet_ntop) along with their unit tests and supporting targets (__support_net_address, headers, and proxy types).
Assisted by Gemini.
>From ef5903b5fba763ff74f02d96b7d8551e1993ce50 Mon Sep 17 00:00:00 2001
From: Pavel Labath <pavel at labath.sk>
Date: Fri, 17 Jul 2026 11:39:44 +0000
Subject: [PATCH] [libc][bazel] Add missing arpa/inet functions and tests
Add bazel build targets for the remaining arpa/inet functions (inet_addr,
inet_aton, inet_ntoa, and inet_ntop) along with their unit tests and supporting
targets (__support_net_address, headers, and proxy types).
Assisted by Gemini.
---
.../llvm-project-overlay/libc/BUILD.bazel | 110 ++++++++++++++++++
.../libc/test/src/arpa/inet/BUILD.bazel | 43 +++++++
2 files changed, 153 insertions(+)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 0c4b759e331d9..d8f4cfc546acd 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -505,6 +505,19 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "llvm_libc_macros_inet_address_macros",
+ hdrs = ["include/llvm-libc-macros/inet-address-macros.h"],
+)
+
+libc_support_library(
+ name = "hdr_inet_address_macros",
+ hdrs = ["hdr/inet-address-macros.h"],
+ deps = [
+ ":llvm_libc_macros_inet_address_macros",
+ ],
+)
+
libc_support_library(
name = "hdr_errno_macros",
hdrs = ["hdr/errno_macros.h"],
@@ -783,6 +796,21 @@ libc_support_library(
hdrs = ["hdr/types/socklen_t.h"],
)
+libc_support_library(
+ name = "types_in_addr_t",
+ hdrs = ["hdr/types/in_addr_t.h"],
+)
+
+libc_support_library(
+ name = "types_struct_in_addr",
+ hdrs = ["hdr/types/struct_in_addr.h"],
+)
+
+libc_support_library(
+ name = "types_struct_in6_addr",
+ hdrs = ["hdr/types/struct_in6_addr.h"],
+)
+
libc_support_library(
name = "types_struct_sockaddr",
hdrs = ["hdr/types/struct_sockaddr.h"],
@@ -3546,6 +3574,66 @@ libc_function(
],
)
+libc_function(
+ name = "inet_addr",
+ srcs = ["src/arpa/inet/inet_addr.cpp"],
+ hdrs = ["src/arpa/inet/inet_addr.h"],
+ deps = [
+ ":__support_common",
+ ":__support_cpp_optional",
+ ":__support_macros_config",
+ ":__support_net_address",
+ ":hdr_netinet_in_macros",
+ ":types_in_addr_t",
+ ],
+)
+
+libc_function(
+ name = "inet_aton",
+ srcs = ["src/arpa/inet/inet_aton.cpp"],
+ hdrs = ["src/arpa/inet/inet_aton.h"],
+ deps = [
+ ":__support_common",
+ ":__support_cpp_optional",
+ ":__support_macros_config",
+ ":__support_net_address",
+ ":types_struct_in_addr",
+ ],
+)
+
+libc_function(
+ name = "inet_ntoa",
+ srcs = ["src/arpa/inet/inet_ntoa.cpp"],
+ hdrs = ["src/arpa/inet/inet_ntoa.h"],
+ deps = [
+ ":__support_common",
+ ":__support_cpp_span",
+ ":__support_macros_config",
+ ":__support_net_address",
+ ":hdr_inet_address_macros",
+ ":types_struct_in_addr",
+ ],
+)
+
+libc_function(
+ name = "inet_ntop",
+ srcs = ["src/arpa/inet/inet_ntop.cpp"],
+ hdrs = ["src/arpa/inet/inet_ntop.h"],
+ deps = [
+ ":__support_common",
+ ":__support_cpp_span",
+ ":__support_libc_errno",
+ ":__support_macros_config",
+ ":__support_macros_null_check",
+ ":__support_net_address",
+ ":hdr_errno_macros",
+ ":hdr_sys_socket_macros",
+ ":types_socklen_t",
+ ":types_struct_in6_addr",
+ ":types_struct_in_addr",
+ ],
+)
+
libc_function(
name = "ntohl",
srcs = ["src/arpa/inet/ntohl.cpp"],
@@ -9862,6 +9950,28 @@ libc_support_library(
],
)
+############################### __support/net #################################
+
+libc_support_library(
+ name = "__support_net_address",
+ srcs = ["src/__support/net/address.cpp"],
+ hdrs = ["src/__support/net/address.h"],
+ deps = [
+ ":__support_common",
+ ":__support_cpp_optional",
+ ":__support_cpp_span",
+ ":__support_ctype_utils",
+ ":__support_libc_assert",
+ ":__support_macros_config",
+ ":__support_str_to_integer",
+ ":hdr_inet_address_macros",
+ ":string_memory_utils",
+ ":types_in_addr_t",
+ ":types_struct_in6_addr",
+ ":types_struct_in_addr",
+ ],
+)
+
############################### complex targets ################################
libc_function(
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/arpa/inet/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/arpa/inet/BUILD.bazel
index 2f1bcd23ae0a7..29ef2cf4b1fc4 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/arpa/inet/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/arpa/inet/BUILD.bazel
@@ -30,6 +30,49 @@ libc_test(
],
)
+libc_test(
+ name = "inet_addr_test",
+ srcs = ["inet_addr_test.cpp"],
+ deps = [
+ "//libc:__support_common",
+ "//libc:htonl",
+ "//libc:inet_addr",
+ ],
+)
+
+libc_test(
+ name = "inet_aton_test",
+ srcs = ["inet_aton_test.cpp"],
+ deps = [
+ "//libc:__support_common",
+ "//libc:htonl",
+ "//libc:inet_aton",
+ ],
+)
+
+libc_test(
+ name = "inet_ntoa_test",
+ srcs = ["inet_ntoa_test.cpp"],
+ deps = [
+ "//libc:__support_common",
+ "//libc:inet_ntoa",
+ "//libc:types_struct_in_addr",
+ ],
+)
+
+libc_test(
+ name = "inet_ntop_test",
+ srcs = ["inet_ntop_test.cpp"],
+ deps = [
+ "//libc:__support_common",
+ "//libc:hdr_errno_macros",
+ "//libc:hdr_sys_socket_macros",
+ "//libc:inet_ntop",
+ "//libc:types_struct_in6_addr",
+ "//libc:types_struct_in_addr",
+ ],
+)
+
libc_test(
name = "ntohl_test",
srcs = ["ntohl_test.cpp"],
More information about the llvm-commits
mailing list