Merge branch 'bits-safamilyt' into 'master'

split out sa_family_t to a bits header

See merge request redox-os/relibc!1191
This commit is contained in:
Jeremy Soller
2026-04-14 07:12:43 -06:00
9 changed files with 32 additions and 7 deletions
+21
View File
@@ -0,0 +1,21 @@
# POSIX header spec: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_socket.h.html
#
# The sys/socket header should define this type.
# It is split out to avoid other headers from including all of sys/socket.
#
# POSIX headers that require sa_family_t:
# - netinet/in.h
# - sys/socket.h
# - sys/un.h
sys_includes = []
include_guard = "_RELIBC_BITS_SA_FAMILY_T_H"
language = "C"
style = "type"
no_includes = true
cpp_compat = true
[export]
include = ["sa_family_t"]
[enum]
prefix_with_name = true
+1
View File
@@ -0,0 +1 @@
pub type sa_family_t = u16;
+2
View File
@@ -9,6 +9,8 @@ pub mod bits_iovec;
#[path = "bits_locale-t/mod.rs"]
pub mod bits_locale_t;
pub mod bits_pthread;
#[path = "bits_safamily-t/mod.rs"]
pub mod bits_safamily_t;
#[path = "bits_socklen-t/mod.rs"]
pub mod bits_socklen_t;
pub mod bits_timespec;
+2 -1
View File
@@ -14,13 +14,14 @@ use crate::{
header::{
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, sa_family_t, sockaddr},
sys_socket::{constants::AF_INET, sockaddr},
unistd::SEEK_SET,
},
platform::{
+1 -1
View File
@@ -5,7 +5,7 @@
#![allow(non_camel_case_types)]
use crate::{
header::sys_socket::{sa_family_t, sockaddr_storage},
header::{bits_safamily_t::sa_family_t, sys_socket::sockaddr_storage},
platform::types::{c_char, c_int},
};
+1
View File
@@ -2,6 +2,7 @@ sys_includes = ["stddef.h", "stdint.h", "sys/types.h"]
include_guard = "_RELIBC_SYS_SOCKET_H"
after_includes = """
#include <bits/iovec.h> // for iovec from sys/uio.h
#include <bits/safamily-t.h> // for sa_family_t
#include <bits/socklen-t.h> // for socklen_t
"""
trailer = """
+1 -3
View File
@@ -6,7 +6,7 @@ use core::{mem, ptr};
use crate::{
error::ResultExt,
header::{bits_iovec::iovec, bits_socklen_t::socklen_t},
header::{bits_iovec::iovec, bits_safamily_t::sa_family_t, bits_socklen_t::socklen_t},
platform::{
PalSocket, Sys,
types::{
@@ -17,8 +17,6 @@ use crate::{
pub mod constants;
pub type sa_family_t = u16;
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_socket.h.html>.
#[repr(C)]
#[derive(Default, CheckVsLibcCrate)]
+1 -1
View File
@@ -2,7 +2,7 @@
//!
//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_un.h.html>.
use crate::{header::sys_socket::sa_family_t, platform::types::c_char};
use crate::{header::bits_safamily_t::sa_family_t, platform::types::c_char};
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_un.h.html>.
#[repr(C)]
+2 -1
View File
@@ -14,6 +14,7 @@ use crate::{
header::{
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,
@@ -24,7 +25,7 @@ use crate::{
sys_select::timeval,
sys_socket::{
CMSG_ALIGN, CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_NXTHDR, CMSG_SPACE, cmsghdr,
constants::*, msghdr, sa_family_t, sockaddr, ucred,
constants::*, msghdr, sockaddr, ucred,
},
sys_un::sockaddr_un,
},