From eca687759abe298dcf5561c2d7a9ab502aa9ace5 Mon Sep 17 00:00:00 2001 From: auronandace Date: Fri, 15 May 2026 13:49:10 +0100 Subject: [PATCH] split out blkcnt_t and blksize_t from sys_types header --- src/header/bits_sys_stat/cbindgen.toml | 20 ++++++++++++++++++++ src/header/bits_sys_stat/mod.rs | 9 +++++++++ src/header/mod.rs | 1 + src/header/sys_types_internal/cbindgen.toml | 3 +-- src/header/sys_types_internal/mod.rs | 10 ++-------- 5 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 src/header/bits_sys_stat/cbindgen.toml create mode 100644 src/header/bits_sys_stat/mod.rs diff --git a/src/header/bits_sys_stat/cbindgen.toml b/src/header/bits_sys_stat/cbindgen.toml new file mode 100644 index 0000000000..c02d31b93f --- /dev/null +++ b/src/header/bits_sys_stat/cbindgen.toml @@ -0,0 +1,20 @@ +# POSIX header spec: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_types.h.html +# +# These types are split out to prevent importing all of sys/types.h into sys/statvfs.h. +# +# POSIX headers that require blkcnt_t and blksize_t: +# - sys/stat.h +# - sys/types.h (where they should be defined) +sys_includes = [] +include_guard = "_RELIBC_BITS_SYS_STAT_H" +language = "C" +style = "type" +no_includes = true +cpp_compat = true +[export] +include = [ + "blkcnt_t", + "blksize_t" +] +[enum] +prefix_with_name = true diff --git a/src/header/bits_sys_stat/mod.rs b/src/header/bits_sys_stat/mod.rs new file mode 100644 index 0000000000..d2b1a88234 --- /dev/null +++ b/src/header/bits_sys_stat/mod.rs @@ -0,0 +1,9 @@ +use crate::platform::types::{c_long, c_longlong}; + +/// Used for file block counts. +#[allow(non_camel_case_types)] +pub type blkcnt_t = c_longlong; + +/// Used for block sizes. +#[allow(non_camel_case_types)] +pub type blksize_t = c_long; diff --git a/src/header/mod.rs b/src/header/mod.rs index e85a4dc560..8f1bf27426 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -37,6 +37,7 @@ pub mod bits_socklen_t; pub mod bits_ssize_t; #[path = "bits_suseconds-t/mod.rs"] pub mod bits_suseconds_t; +pub mod bits_sys_stat; pub mod bits_sys_statvfs; #[path = "bits_time-t/mod.rs"] pub mod bits_time_t; diff --git a/src/header/sys_types_internal/cbindgen.toml b/src/header/sys_types_internal/cbindgen.toml index 21a4a58751..18dd0fa138 100644 --- a/src/header/sys_types_internal/cbindgen.toml +++ b/src/header/sys_types_internal/cbindgen.toml @@ -11,6 +11,7 @@ after_includes = """ #include #include #include +#include // for blkcnt_t and blksize_t #include // for fsblkcnt_t and fsfilcnt_t #include #include @@ -23,12 +24,10 @@ no_includes = true [export] include = [ - "blksize_t", "dev_t", "reclen_t", "nlink_t", "useconds_t", - "blkcnt_t", "u_char", "uchar", "u_short", diff --git a/src/header/sys_types_internal/mod.rs b/src/header/sys_types_internal/mod.rs index 3c0cc9cd45..cc3b33081d 100644 --- a/src/header/sys_types_internal/mod.rs +++ b/src/header/sys_types_internal/mod.rs @@ -18,17 +18,14 @@ pub use crate::header::{ bits_pid_t::pid_t, bits_ssize_t::ssize_t, bits_suseconds_t::suseconds_t, + bits_sys_stat::{blkcnt_t, blksize_t}, bits_sys_statvfs::{fsblkcnt_t, fsfilcnt_t}, bits_time_t::time_t, bits_timer_t::timer_t, bits_uid_t::uid_t, }; -use crate::platform::types::{ - c_char, c_long, c_longlong, c_uchar, c_uint, c_ulong, c_ulonglong, c_ushort, -}; +use crate::platform::types::{c_char, c_longlong, c_uchar, c_uint, c_ulong, c_ulonglong, c_ushort}; -/// Used for block sizes. -pub type blksize_t = c_long; /// Used for device IDs. pub type dev_t = c_ulonglong; /// Used for directory entry lengths. @@ -37,9 +34,6 @@ pub type reclen_t = c_ushort; pub type nlink_t = c_ulong; pub type useconds_t = c_uint; -/// Used for file block counts. -pub type blkcnt_t = c_longlong; - pub type u_char = c_uchar; pub type uchar = c_uchar; pub type u_short = c_ushort;