split out uint32_t for socklen_t for sys_socket header

This commit is contained in:
auronandace
2026-06-17 09:18:37 +01:00
parent 6c49b9acac
commit 7315ad5155
6 changed files with 31 additions and 12 deletions
+1 -6
View File
@@ -50,12 +50,7 @@ typedef __UINT8_TYPE__ u_int8_t;
typedef __UINT16_TYPE__ uint16_t;
typedef __UINT16_TYPE__ u_int16_t;
#endif
#ifdef __UINT32_TYPE__
typedef __UINT32_TYPE__ uint32_t;
typedef __UINT32_TYPE__ u_int32_t;
// Required by openlibm
typedef __UINT32_TYPE__ __uint32_t;
#endif
#include <bits/uint32-t.h> // for uint32_t
#ifdef __UINT64_TYPE__
typedef __UINT64_TYPE__ uint64_t;
typedef __UINT64_TYPE__ u_int64_t;
+3 -3
View File
@@ -7,9 +7,9 @@
# - netdb.h
# - sys/socket.h (where it should be defined)
#
# TODO split out uint32_t to prevent including all of stdint.h
# stdint needed for uint32_t for socklen_t
sys_includes = ["stdint.h"]
# sys/socket.h spec states socklen_t must be at least 32bit wide.
# Application usage section recommends socklen_t value should not be larger than 2^31 -1.
sys_includes = ["bits/uint32-t.h"]
include_guard = "_RELIBC_BITS_SOCKLEN_T_H"
language = "C"
no_includes = true
+19
View File
@@ -0,0 +1,19 @@
# POSIX header spec: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/stdint.h.html
#
# This type is split out to prevent importing all of stdint.h in other headers.
#
# socklen_t from sys/socket.h requires a 32bit integer even though the spec doesn't state uint32_t specifically
include_guard = "_RELIBC_BITS_UINT32_T_H"
after_includes = """
#ifdef __UINT32_TYPE__
typedef __UINT32_TYPE__ uint32_t;
typedef __UINT32_TYPE__ u_int32_t;
// Required by openlibm
typedef __UINT32_TYPE__ __uint32_t;
#endif
"""
language = "C"
no_includes = true
cpp_compat = true
[enum]
prefix_with_name = true
+5
View File
@@ -0,0 +1,5 @@
//! `uint32_t` implementation for `stdint.h`.
//!
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/stdint.h.html>.
//!
//! Implemented via typedef in cbindgen.
+2
View File
@@ -62,6 +62,8 @@ pub mod bits_timeval;
pub mod bits_ucred;
#[path = "bits_uid-t/mod.rs"]
pub mod bits_uid_t;
#[path = "bits_uint32-t/mod.rs"]
pub mod bits_uint32_t;
#[path = "bits_useconds-t/mod.rs"]
pub mod bits_useconds_t;
pub mod bits_valist;
+1 -3
View File
@@ -5,10 +5,8 @@
# - "The <sys/socket.h> header shall define the size_t and ssize_t types as described in <sys/types.h>."
# - "Inclusion of <sys/socket.h> may also make visible all symbols from <sys/uio.h>."
#
# TODO split out uint32_t from stdint.h in bits/socklen-t.h
#
# bits/iovec.h brings in size_t
# bits/socklen_t brings in stdint.h for uint32_t for socklen_t
# bits/socklen_t brings in bits/uint32-t.h for uint32_t for socklen_t
include_guard = "_RELIBC_SYS_SOCKET_H"
after_includes = """
#include <bits/iovec.h> // for iovec from sys/uio.h