Merge branch 'split-ucred' into 'master'

split out ucred to a bits header

See merge request redox-os/relibc!1467
This commit is contained in:
Mathew John Roberts
2026-06-16 10:47:50 +01:00
6 changed files with 40 additions and 25 deletions
+17
View File
@@ -0,0 +1,17 @@
# Non-POSIX spec: https://www.man7.org/linux/man-pages/man7/unix.7.html
#
# This type is split out to avoid namespace pollution in sys/socket.h.
after_includes = """
#include <bits/gid-t.h> // for gid_t from sys/types.h
#include <bits/pid-t.h> // for pid_t from sys/types.h
#include <bits/uid-t.h> // for uid_t from sys/types.h
"""
include_guard = "_RELIBC_BITS_UCRED_H"
language = "C"
style = "Tag"
no_includes = true
cpp_compat = true
[export]
include = ["ucred"]
[enum]
prefix_with_name = true
+16
View File
@@ -0,0 +1,16 @@
use crate::platform::types::{gid_t, pid_t, uid_t};
/// Non-POSIX, see <https://www.man7.org/linux/man-pages/man7/unix.7.html>.
///
/// Represents UNIX credentials.
#[repr(C)]
#[derive(Clone, Debug)]
// FIXME: CheckVsLibcCrate
pub struct ucred {
/// Process ID of the sending process.
pub pid: pid_t,
/// User ID of the sending process.
pub uid: uid_t,
/// Group ID of the sending process.
pub gid: gid_t,
}
+1
View File
@@ -57,6 +57,7 @@ pub mod bits_time_t;
pub mod bits_timer_t;
pub mod bits_timespec;
pub mod bits_timeval;
pub mod bits_ucred;
#[path = "bits_uid-t/mod.rs"]
pub mod bits_uid_t;
#[path = "bits_useconds-t/mod.rs"]
+3 -5
View File
@@ -16,10 +16,9 @@ after_includes = """
#include <bits/socklen-t.h> // for socklen_t
#include <bits/ssize-t.h> // for ssize_t from sys/types.h
// Below required for Non-POSIX ucred struct
#include <bits/gid-t.h> // for gid_t from sys/types.h
#include <bits/pid-t.h> // for pid_t from sys/types.h
#include <bits/uid-t.h> // for uid_t from sys/types.h
#if defined(_GNU_SOURCE)
#include <bits/ucred.h> // for Non-POSIX ucred struct
#endif
"""
trailer = """
#ifndef _RELIBC_BITS_SYS_SOCKET_H
@@ -61,7 +60,6 @@ prefix_with_name = true
include = [
"linger",
"cmsghdr",
"ucred"
]
[export.rename]
+1 -19
View File
@@ -9,9 +9,7 @@ use crate::{
header::{bits_safamily_t::sa_family_t, sys_uio::iovec},
platform::{
PalSocket, Sys,
types::{
c_char, c_int, c_long, c_uchar, c_uint, c_void, gid_t, pid_t, size_t, ssize_t, uid_t,
},
types::{c_char, c_int, c_long, c_uchar, c_uint, c_void, size_t, ssize_t},
},
};
@@ -61,22 +59,6 @@ pub struct cmsghdr {
pub cmsg_type: c_int,
}
// TODO: `ucred` should be behind _GNU_SOURCE include guard
/// Non-POSIX, see <https://www.man7.org/linux/man-pages/man7/unix.7.html>.
///
/// Represents UNIX credentials.
#[repr(C)]
#[derive(Clone, Debug)]
// FIXME: CheckVsLibcCrate
pub struct ucred {
/// Process ID of the sending process.
pub pid: pid_t,
/// User ID of the sending process.
pub uid: uid_t,
/// Group ID of the sending process.
pub gid: gid_t,
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_socket.h.html>.
#[repr(C)]
#[derive(Default, CheckVsLibcCrate)]
+2 -1
View File
@@ -14,6 +14,7 @@ use crate::{
header::{
arpa_inet::inet_aton,
bits_safamily_t::sa_family_t,
bits_ucred::ucred,
errno::{
EAFNOSUPPORT, EDOM, EFAULT, EINVAL, EMSGSIZE, ENOMEM, ENOSYS, ENOTSOCK, EOPNOTSUPP,
EPROTONOSUPPORT,
@@ -23,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, socklen_t, ucred,
constants::*, msghdr, sockaddr, socklen_t,
},
sys_uio::iovec,
sys_un::sockaddr_un,