import socklen_t from sys_socket instead of bits

This commit is contained in:
auronandace
2026-05-03 16:54:46 +01:00
parent 9fd1da5d92
commit 8cec0c2280
8 changed files with 20 additions and 21 deletions
+1 -2
View File
@@ -11,10 +11,9 @@ use crate::{
c_str::CStr,
header::{
bits_arpainet::ntohl,
bits_socklen_t::socklen_t,
errno::{EAFNOSUPPORT, ENOSPC},
netinet_in::{INADDR_NONE, in_addr, in_addr_t},
sys_socket::constants::AF_INET,
sys_socket::{constants::AF_INET, socklen_t},
},
platform::{
self,
+9 -3
View File
@@ -1,3 +1,11 @@
# POSIX header spec: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_socket.h.html
#
# This type is split out to prevent importing all of sys/socket.h to other headers.
#
# POSIX headers that require socklen_t:
# - arpa/inet.h
# - netdb.h
# - sys/socket.h (where it should be defined)
sys_includes = []
include_guard = "_RELIBC_BITS_SOCKLEN_T_H"
language = "C"
@@ -5,8 +13,6 @@ style = "type"
no_includes = true
cpp_compat = true
[export]
include = [
"socklen_t"
]
include = ["socklen_t"]
[enum]
prefix_with_name = true
+1 -2
View File
@@ -11,13 +11,12 @@ use crate::{
use crate::header::{
bits_arpainet::htons,
bits_socklen_t::socklen_t,
errno::*,
netinet_in::{IPPROTO_UDP, in_addr, sockaddr_in},
sys_socket::{
self,
constants::{AF_INET, SOCK_DGRAM},
sockaddr,
sockaddr, socklen_t,
},
time::{self, timespec},
};
+1 -2
View File
@@ -15,13 +15,12 @@ use crate::{
arpa_inet::inet_aton,
bits_arpainet::{htons, ntohl},
bits_safamily_t::sa_family_t,
bits_socklen_t::socklen_t,
errno::*,
fcntl::O_RDONLY,
netinet_in::{in_addr, sockaddr_in, sockaddr_in6},
stdlib::atoi,
strings::strcasecmp,
sys_socket::{constants::AF_INET, sockaddr},
sys_socket::{constants::AF_INET, sockaddr, socklen_t},
unistd::SEEK_SET,
},
platform::{
+5 -2
View File
@@ -6,7 +6,7 @@ use core::{mem, ptr};
use crate::{
error::ResultExt,
header::{bits_iovec::iovec, bits_safamily_t::sa_family_t, bits_socklen_t::socklen_t},
header::{bits_iovec::iovec, bits_safamily_t::sa_family_t},
platform::{
PalSocket, Sys,
types::{
@@ -15,6 +15,8 @@ use crate::{
},
};
pub use crate::header::bits_socklen_t::socklen_t;
pub mod constants;
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_socket.h.html>.
@@ -89,9 +91,10 @@ const _SS_PADDING: usize = _SS_MAXSIZE - mem::size_of::<sa_family_t>() - mem::si
/// * [`usize`] is used because it's the width of a pointer for a given platform
/// * The order of the fields is important because the bytes in the padding will be cast to and
/// from protocol structs in C
///
/// cbindgen:ignore
#[repr(C)]
//#[derive(CheckVsLibcCrate)] FIXME: can't ignore private fields yet
/// cbindgen:ignore
pub struct sockaddr_storage {
pub ss_family: sa_family_t,
__ss_pad2: [u8; _SS_PADDING],
+1 -4
View File
@@ -1,10 +1,7 @@
use super::{Sys, e_raw};
use crate::{
error::Result,
header::{
bits_socklen_t::socklen_t,
sys_socket::{msghdr, sockaddr},
},
header::sys_socket::{msghdr, sockaddr, socklen_t},
platform::{
PalSocket,
types::{c_int, c_void, size_t},
+1 -4
View File
@@ -1,9 +1,6 @@
use crate::{
error::Result,
header::{
bits_socklen_t::socklen_t,
sys_socket::{msghdr, sockaddr},
},
header::sys_socket::{msghdr, sockaddr, socklen_t},
platform::{
Pal,
types::{c_int, c_void, size_t},
+1 -2
View File
@@ -15,7 +15,6 @@ use crate::{
arpa_inet::inet_aton,
bits_iovec::iovec,
bits_safamily_t::sa_family_t,
bits_socklen_t::socklen_t,
errno::{
EAFNOSUPPORT, EDOM, EFAULT, EINVAL, EMSGSIZE, ENOMEM, ENOSYS, ENOTSOCK, EOPNOTSUPP,
EPROTONOSUPPORT,
@@ -25,7 +24,7 @@ use crate::{
sys_select::timeval,
sys_socket::{
CMSG_ALIGN, CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_NXTHDR, CMSG_SPACE, cmsghdr,
constants::*, msghdr, sockaddr, ucred,
constants::*, msghdr, sockaddr, socklen_t, ucred,
},
sys_un::sockaddr_un,
},