[libc-commits] [libc] f7f911f - [libc] Add some types to netinet/in.h (#196932)

via libc-commits libc-commits at lists.llvm.org
Tue May 12 03:59:57 PDT 2026


Author: Pavel Labath
Date: 2026-05-12T12:59:52+02:00
New Revision: f7f911f72f050f2a796590f415fe738f21246d73

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

LOG: [libc] Add some types to netinet/in.h (#196932)

Not including more types because I need to fix in_addr definition first.

This exposes stdint macros and types through the header, but POSIX
permits that behavior (and explicitly requires that we define uint8_t
and uint32_t).

No test as this is just adding a typedef, and I don't *think* we have
tests for that, but I can add a "check that type is defined" test if
that is desirable.

Added: 
    libc/include/llvm-libc-types/in_port_t.h

Modified: 
    libc/include/CMakeLists.txt
    libc/include/llvm-libc-types/CMakeLists.txt
    libc/include/netinet/in.yaml

Removed: 
    


################################################################################
diff  --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index b1b4a4fd20982..5f836e0f480e1 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -216,8 +216,11 @@ add_header_macro(
   ../libc/include/netinet/in.yaml
   netinet/in.h
   DEPENDS
-    .llvm_libc_common_h
     .llvm-libc-macros.netinet_in_macros
+    .llvm-libc-types.in_addr_t
+    .llvm-libc-types.in_port_t
+    .llvm-libc-types.sa_family_t
+    .llvm_libc_common_h
 )
 
 add_header_macro(

diff  --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index e967b43d81df0..aad6650d90428 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -57,6 +57,7 @@ add_header(gid_t HDR gid_t.h)
 add_header(uid_t HDR uid_t.h)
 add_header(imaxdiv_t HDR imaxdiv_t.h)
 add_header(in_addr_t HDR in_addr_t.h)
+add_header(in_port_t HDR in_port_t.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
 add_header(struct_in_addr HDR struct_in_addr.h DEPENDS .in_addr_t)
 add_header(ino_t HDR ino_t.h)
 add_header(key_t HDR key_t.h)

diff  --git a/libc/include/llvm-libc-types/in_port_t.h b/libc/include/llvm-libc-types/in_port_t.h
new file mode 100644
index 0000000000000..daf33f91d95af
--- /dev/null
+++ b/libc/include/llvm-libc-types/in_port_t.h
@@ -0,0 +1,16 @@
+//===-- Definition of in_port_t type --------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_IN_PORT_T_H
+#define LLVM_LIBC_TYPES_IN_PORT_T_H
+
+#include "../llvm-libc-types/stdint-macros.h"
+
+typedef uint16_t in_port_t;
+
+#endif // LLVM_LIBC_TYPES_IN_PORT_T_H

diff  --git a/libc/include/netinet/in.yaml b/libc/include/netinet/in.yaml
index e7b33dc87334f..8d9749f36ab78 100644
--- a/libc/include/netinet/in.yaml
+++ b/libc/include/netinet/in.yaml
@@ -14,7 +14,10 @@ macros:
     macro_header: netinet-in-macros.h
   - macro_name: IPPROTO_RAW
     macro_header: netinet-in-macros.h
-types: []
+types:
+  - type_name: in_port_t
+  - type_name: in_addr_t
+  - type_name: sa_family_t
 enums: []
 objects: []
 functions: []


        


More information about the libc-commits mailing list