From 71ab39f9e6f8c06e1458918f0d7c1243cb3fbc0a Mon Sep 17 00:00:00 2001 From: auronandace Date: Sat, 9 May 2026 18:30:35 +0100 Subject: [PATCH] split out gid_t from sys_types --- src/header/bits_gid-t/cbindgen.toml | 21 +++++++++++++++++++++ src/header/bits_gid-t/mod.rs | 5 +++++ src/header/mod.rs | 2 ++ src/header/sys_types_internal/cbindgen.toml | 2 +- src/header/sys_types_internal/mod.rs | 6 ++---- 5 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 src/header/bits_gid-t/cbindgen.toml create mode 100644 src/header/bits_gid-t/mod.rs diff --git a/src/header/bits_gid-t/cbindgen.toml b/src/header/bits_gid-t/cbindgen.toml new file mode 100644 index 0000000000..22609fbb71 --- /dev/null +++ b/src/header/bits_gid-t/cbindgen.toml @@ -0,0 +1,21 @@ +# 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 gid_t: +# - grp.h +# - pwd.h +# - sys/ipc.h (TODO not present in relibc) +# - sys/stat.h +# - sys/types.h (where it should be defined) +# - unistd.h +sys_includes = [] +include_guard = "_RELIBC_BITS_GID_T_H" +language = "C" +style = "type" +no_includes = true +cpp_compat = true +[export] +include = ["gid_t"] +[enum] +prefix_with_name = true diff --git a/src/header/bits_gid-t/mod.rs b/src/header/bits_gid-t/mod.rs new file mode 100644 index 0000000000..8a3bfd4d6d --- /dev/null +++ b/src/header/bits_gid-t/mod.rs @@ -0,0 +1,5 @@ +use crate::platform::types::c_int; + +/// Used for group IDs. +#[allow(non_camel_case_types)] +pub type gid_t = c_int; diff --git a/src/header/mod.rs b/src/header/mod.rs index bdfb84e6e9..a12397c5bc 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -5,6 +5,8 @@ pub mod _fenv; pub mod arpa_inet; pub mod assert; pub mod bits_arpainet; +#[path = "bits_gid-t/mod.rs"] +pub mod bits_gid_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 dd83e05aa1..e76a0a5724 100644 --- a/src/header/sys_types_internal/cbindgen.toml +++ b/src/header/sys_types_internal/cbindgen.toml @@ -2,6 +2,7 @@ sys_includes = ["stddef.h"] # TODO: figure out how to export void* type after_includes = """ +#include #include #include #include @@ -21,7 +22,6 @@ include = [ "dev_t", "ino_t", "reclen_t", - "gid_t", "uid_t", "mode_t", "nlink_t", diff --git a/src/header/sys_types_internal/mod.rs b/src/header/sys_types_internal/mod.rs index 1fc2b6369f..201da2f264 100644 --- a/src/header/sys_types_internal/mod.rs +++ b/src/header/sys_types_internal/mod.rs @@ -8,8 +8,8 @@ //! for the old specification. pub use crate::header::{ - 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_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, }; use crate::platform::types::{ c_char, c_int, c_long, c_longlong, c_uchar, c_uint, c_ulong, c_ulonglong, c_ushort, @@ -23,8 +23,6 @@ pub type dev_t = c_ulonglong; pub type ino_t = c_ulonglong; /// Used for directory entry lengths. pub type reclen_t = c_ushort; -/// Used for group IDs. -pub type gid_t = c_int; /// Used for user IDs. pub type uid_t = c_int; /// Used for some file attributes.