From 74ca9e661a91383a79779e44177f189a243f45b6 Mon Sep 17 00:00:00 2001 From: auronandace Date: Mon, 11 May 2026 15:20:20 +0100 Subject: [PATCH] split out id_t from sys_types --- src/header/bits_id-t/cbindgen.toml | 18 ++++++++++++++++++ src/header/bits_id-t/mod.rs | 5 +++++ src/header/mod.rs | 2 ++ src/header/sys_types_internal/cbindgen.toml | 2 +- src/header/sys_types_internal/mod.rs | 7 +++---- 5 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 src/header/bits_id-t/cbindgen.toml create mode 100644 src/header/bits_id-t/mod.rs diff --git a/src/header/bits_id-t/cbindgen.toml b/src/header/bits_id-t/cbindgen.toml new file mode 100644 index 0000000000..005335f44f --- /dev/null +++ b/src/header/bits_id-t/cbindgen.toml @@ -0,0 +1,18 @@ +# POSIX header spec: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_types.h.html +# +# This type is split out to prevent importing all of sys/types.h into other headers. +# +# POSIX headers that require id_t: +# - sys/resource.h +# - sys/types.h (where it should be defined) +# - sys/wait.h +sys_includes = [] +include_guard = "_RELIBC_BITS_ID_T_H" +language = "C" +style = "type" +no_includes = true +cpp_compat = true +[export] +include = ["id_t"] +[enum] +prefix_with_name = true diff --git a/src/header/bits_id-t/mod.rs b/src/header/bits_id-t/mod.rs new file mode 100644 index 0000000000..f0db91cfbd --- /dev/null +++ b/src/header/bits_id-t/mod.rs @@ -0,0 +1,5 @@ +use crate::platform::types::c_uint; + +/// Used as a general identifier; can be used to contain at least a pid_t, uid_t, or gid_t. +#[allow(non_camel_case_types)] +pub type id_t = c_uint; diff --git a/src/header/mod.rs b/src/header/mod.rs index 261e45c45c..44503976c4 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -9,6 +9,8 @@ pub mod bits_arpainet; pub mod bits_clock_t; #[path = "bits_gid-t/mod.rs"] pub mod bits_gid_t; +#[path = "bits_id-t/mod.rs"] +pub mod bits_id_t; pub mod bits_iovec; #[path = "bits_locale-t/mod.rs"] pub mod bits_locale_t; diff --git a/src/header/sys_types_internal/cbindgen.toml b/src/header/sys_types_internal/cbindgen.toml index e37705e19d..b9526a55a6 100644 --- a/src/header/sys_types_internal/cbindgen.toml +++ b/src/header/sys_types_internal/cbindgen.toml @@ -4,6 +4,7 @@ sys_includes = ["stddef.h"] after_includes = """ #include #include +#include #include #include #include @@ -26,7 +27,6 @@ include = [ "reclen_t", "mode_t", "nlink_t", - "id_t", "useconds_t", "clockid_t", "blkcnt_t", diff --git a/src/header/sys_types_internal/mod.rs b/src/header/sys_types_internal/mod.rs index e6579d058d..ba0093301d 100644 --- a/src/header/sys_types_internal/mod.rs +++ b/src/header/sys_types_internal/mod.rs @@ -8,8 +8,9 @@ //! for the old specification. pub use crate::header::{ - bits_clock_t::clock_t, bits_gid_t::gid_t, bits_off_t::off_t, bits_pid_t::pid_t, - bits_ssize_t::ssize_t, bits_suseconds_t::suseconds_t, bits_time_t::time_t, bits_uid_t::uid_t, + bits_clock_t::clock_t, bits_gid_t::gid_t, bits_id_t::id_t, bits_off_t::off_t, + bits_pid_t::pid_t, bits_ssize_t::ssize_t, bits_suseconds_t::suseconds_t, bits_time_t::time_t, + bits_uid_t::uid_t, }; use crate::platform::types::{ c_char, c_int, c_long, c_longlong, c_uchar, c_uint, c_ulong, c_ulonglong, c_ushort, @@ -31,8 +32,6 @@ pub type mode_t = c_uint; pub type mode_t = c_int; /// Used for link counts. pub type nlink_t = c_ulong; -/// Used as a general identifier; can be used to contain at least a pid_t, uid_t, or gid_t. -pub type id_t = c_uint; pub type useconds_t = c_uint; /// Used for clock ID type in the clock and timer functions.