From 8e1881c3cc799470d3c247a566f049fa72ce14ea Mon Sep 17 00:00:00 2001 From: auronandace Date: Sat, 9 May 2026 07:11:29 +0100 Subject: [PATCH] split out off_t from sys_types_internal --- src/header/bits_off-t/cbindgen.toml | 21 +++++++++++++++++++++ src/header/bits_off-t/mod.rs | 5 +++++ src/header/mod.rs | 2 ++ src/header/sys_types_internal/cbindgen.toml | 2 +- src/header/sys_types_internal/mod.rs | 4 +--- 5 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 src/header/bits_off-t/cbindgen.toml create mode 100644 src/header/bits_off-t/mod.rs diff --git a/src/header/bits_off-t/cbindgen.toml b/src/header/bits_off-t/cbindgen.toml new file mode 100644 index 0000000000..686fa97933 --- /dev/null +++ b/src/header/bits_off-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 off_t: +# - fcntl.h +# - stdio.h +# - sys/mman.h +# - sys/stat.h +# - sys/types.h (where it should be defined) +# - unistd.h +sys_includes = [] +include_guard = "_RELIBC_BITS_OFF_T_H" +language = "C" +style = "type" +no_includes = true +cpp_compat = true +[export] +include = ["off_t"] +[enum] +prefix_with_name = true diff --git a/src/header/bits_off-t/mod.rs b/src/header/bits_off-t/mod.rs new file mode 100644 index 0000000000..1f3eabb72b --- /dev/null +++ b/src/header/bits_off-t/mod.rs @@ -0,0 +1,5 @@ +use crate::platform::types::c_longlong; + +/// Used for file sizes. +#[allow(non_camel_case_types)] +pub type off_t = c_longlong; diff --git a/src/header/mod.rs b/src/header/mod.rs index 55b7be9ca8..458bf9d12b 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -8,6 +8,8 @@ pub mod bits_arpainet; pub mod bits_iovec; #[path = "bits_locale-t/mod.rs"] pub mod bits_locale_t; +#[path = "bits_off-t/mod.rs"] +pub mod bits_off_t; pub mod bits_pthread; #[path = "bits_safamily-t/mod.rs"] pub mod bits_safamily_t; diff --git a/src/header/sys_types_internal/cbindgen.toml b/src/header/sys_types_internal/cbindgen.toml index a8862f8ac2..b13b70703c 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 @@ -23,7 +24,6 @@ include = [ "uid_t", "mode_t", "nlink_t", - "off_t", "pid_t", "id_t", "useconds_t", diff --git a/src/header/sys_types_internal/mod.rs b/src/header/sys_types_internal/mod.rs index 56b3fec7a9..e401f4133d 100644 --- a/src/header/sys_types_internal/mod.rs +++ b/src/header/sys_types_internal/mod.rs @@ -8,7 +8,7 @@ //! for the old specification. pub use crate::header::{ - bits_ssize_t::ssize_t, bits_suseconds_t::suseconds_t, bits_time_t::time_t, + bits_off_t::off_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, @@ -34,8 +34,6 @@ pub type mode_t = c_uint; pub type mode_t = c_int; /// Used for link counts. pub type nlink_t = c_ulong; -/// Used for file sizes. -pub type off_t = c_longlong; /// Used for process IDs and process group IDs. pub type pid_t = c_int; /// Used as a general identifier; can be used to contain at least a pid_t, uid_t, or gid_t.