[libc-commits] [libc] 8acfc36 - [libc] Add the htons function family to netinet/in.h (#203028)
via libc-commits
libc-commits at lists.llvm.org
Thu Jun 11 03:14:41 PDT 2026
Author: Pavel Labath
Date: 2026-06-11T12:14:36+02:00
New Revision: 8acfc364e9f788367ff0beab5c76a3527a689a0b
URL: https://github.com/llvm/llvm-project/commit/8acfc364e9f788367ff0beab5c76a3527a689a0b
DIFF: https://github.com/llvm/llvm-project/commit/8acfc364e9f788367ff0beab5c76a3527a689a0b.diff
LOG: [libc] Add the htons function family to netinet/in.h (#203028)
As required by POSIX.
I've used the merge_yaml_files functionality to avoid duplication.
Assisted by Gemini.
Added:
libc/include/htons-family.yaml
Modified:
libc/include/arpa/inet.yaml
libc/include/netinet/in.yaml
libc/utils/docgen/netinet/in.yaml
Removed:
################################################################################
diff --git a/libc/include/arpa/inet.yaml b/libc/include/arpa/inet.yaml
index ab7b2e52dd127..38e975c3dfbfd 100644
--- a/libc/include/arpa/inet.yaml
+++ b/libc/include/arpa/inet.yaml
@@ -1,6 +1,8 @@
header: arpa/inet.h
standards:
- posix
+merge_yaml_files:
+ - ../htons-family.yaml
macros:
- macro_name: INET_ADDRSTRLEN
macro_header: inet-address-macros.h
@@ -12,18 +14,6 @@ types:
enums: []
objects: []
functions:
- - name: htonl
- standards:
- - posix
- return_type: uint32_t
- arguments:
- - type: uint32_t
- - name: htons
- standards:
- - posix
- return_type: uint16_t
- arguments:
- - type: uint16_t
- name: inet_addr
standards:
- posix
@@ -37,15 +27,3 @@ functions:
arguments:
- type: const char *
- type: struct in_addr *
- - name: ntohl
- standards:
- - posix
- return_type: uint32_t
- arguments:
- - type: uint32_t
- - name: ntohs
- standards:
- - posix
- return_type: uint16_t
- arguments:
- - type: uint16_t
diff --git a/libc/include/htons-family.yaml b/libc/include/htons-family.yaml
new file mode 100644
index 0000000000000..f6b2ecccf3646
--- /dev/null
+++ b/libc/include/htons-family.yaml
@@ -0,0 +1,25 @@
+functions:
+ - name: htonl
+ standards:
+ - posix
+ return_type: uint32_t
+ arguments:
+ - type: uint32_t
+ - name: htons
+ standards:
+ - posix
+ return_type: uint16_t
+ arguments:
+ - type: uint16_t
+ - name: ntohl
+ standards:
+ - posix
+ return_type: uint32_t
+ arguments:
+ - type: uint32_t
+ - name: ntohs
+ standards:
+ - posix
+ return_type: uint16_t
+ arguments:
+ - type: uint16_t
diff --git a/libc/include/netinet/in.yaml b/libc/include/netinet/in.yaml
index 26e3a7c037c60..c5f24200b72ac 100644
--- a/libc/include/netinet/in.yaml
+++ b/libc/include/netinet/in.yaml
@@ -1,6 +1,8 @@
header: netinet/in.h
standards:
- posix
+merge_yaml_files:
+ - ../htons-family.yaml
macros:
- macro_name: IPPROTO_IP
macro_header: netinet-in-macros.h
diff --git a/libc/utils/docgen/netinet/in.yaml b/libc/utils/docgen/netinet/in.yaml
index 215451858dc15..dd575dcb0f181 100644
--- a/libc/utils/docgen/netinet/in.yaml
+++ b/libc/utils/docgen/netinet/in.yaml
@@ -59,3 +59,12 @@ macros:
in-latest-posix: ''
IN6_IS_ADDR_MC_GLOBAL:
in-latest-posix: ''
+functions:
+ htonl:
+ in-latest-posix: ''
+ htons:
+ in-latest-posix: ''
+ ntohl:
+ in-latest-posix: ''
+ ntohs:
+ in-latest-posix: ''
More information about the libc-commits
mailing list