From 430aa6f584e2f5cba6446b25d676c867022cefc5 Mon Sep 17 00:00:00 2001 From: auronandace Date: Mon, 18 May 2026 08:38:10 +0100 Subject: [PATCH] split out useconds_t from sys_types header --- src/header/bits_useconds-t/cbindgen.toml | 18 ++++++++++++++++++ src/header/bits_useconds-t/mod.rs | 6 ++++++ src/header/mod.rs | 2 ++ src/header/sys_types/cbindgen.toml | 11 +++-------- src/header/sys_types_internal/cbindgen.toml | 3 ++- src/header/sys_types_internal/mod.rs | 4 ++-- 6 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 src/header/bits_useconds-t/cbindgen.toml create mode 100644 src/header/bits_useconds-t/mod.rs diff --git a/src/header/bits_useconds-t/cbindgen.toml b/src/header/bits_useconds-t/cbindgen.toml new file mode 100644 index 0000000000..f77a7a2fb9 --- /dev/null +++ b/src/header/bits_useconds-t/cbindgen.toml @@ -0,0 +1,18 @@ +# POSIX header spec: https://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/types.h.html +# +# This type is split out to prevent importing all of sys/types.h into other headers. +# +# useconds_t was defined in sys/types.h in an older POSIX standard. +# relibc currently only uses it in unistd.h for ualarm and usleep. +# +# features.h required for deprecated annotation. +sys_includes = ["features.h"] +include_guard = "_RELIBC_BITS_USECONDS_T_H" +language = "C" +style = "type" +no_includes = true +cpp_compat = true +[export] +include = ["useconds_t"] +[enum] +prefix_with_name = true diff --git a/src/header/bits_useconds-t/mod.rs b/src/header/bits_useconds-t/mod.rs new file mode 100644 index 0000000000..74cb8e1e0c --- /dev/null +++ b/src/header/bits_useconds-t/mod.rs @@ -0,0 +1,6 @@ +use crate::platform::types::c_uint; + +/// Used for time in microseconds. +#[allow(non_camel_case_types)] +#[deprecated] +pub type useconds_t = c_uint; diff --git a/src/header/mod.rs b/src/header/mod.rs index 74f18749b1..dcb457754e 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -53,6 +53,8 @@ pub mod bits_timespec; pub mod bits_timeval; #[path = "bits_uid-t/mod.rs"] pub mod bits_uid_t; +#[path = "bits_useconds-t/mod.rs"] +pub mod bits_useconds_t; // complex.h implemented in C (currently through openlibm) pub mod cpio; pub mod crypt; diff --git a/src/header/sys_types/cbindgen.toml b/src/header/sys_types/cbindgen.toml index f0a2d8c655..cd00479de9 100644 --- a/src/header/sys_types/cbindgen.toml +++ b/src/header/sys_types/cbindgen.toml @@ -2,21 +2,16 @@ # # There are no spec quotations relating to includes # -# - sys/types_internal.h are fundamental C types (which includes stddef.h) +# - sys/types/internal.h are fundamental C types (which includes stddef.h) +# - sys/types/internal.h brings in features.h for deprecated annotations for useconds_t # - bits/pthread.h is separate for convenience -# - features.h saves importing separately for any header that imports sys/types.h -# -# no default C includes - they cause recursive dependencies and do weird stuff -no_includes = true sys_includes = [ # Import most necessary, internal types first "sys/types/internal.h", - "bits/pthread.h", - "features.h", ] - include_guard = "_SYS_TYPES_H" +no_includes = true language = "C" style = "Tag" diff --git a/src/header/sys_types_internal/cbindgen.toml b/src/header/sys_types_internal/cbindgen.toml index eb5a0744c0..0f992450c3 100644 --- a/src/header/sys_types_internal/cbindgen.toml +++ b/src/header/sys_types_internal/cbindgen.toml @@ -1,4 +1,5 @@ # stddef.h brings in size_t +# bits/useconds-t.h brings in features.h for deprecated annotation sys_includes = ["stddef.h"] after_includes = """ #include @@ -19,6 +20,7 @@ after_includes = """ #include #include #include +#include // from older POSIX """ include_guard = "_RELIBC_SYS_TYPES_INTERNAL_H" language = "C" @@ -27,7 +29,6 @@ no_includes = true [export] include = [ - "useconds_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 eded3a79f5..d235d53910 100644 --- a/src/header/sys_types_internal/mod.rs +++ b/src/header/sys_types_internal/mod.rs @@ -28,10 +28,10 @@ pub use crate::header::{ bits_timer_t::timer_t, bits_uid_t::uid_t, }; +#[expect(deprecated)] +pub use crate::header::bits_useconds_t::useconds_t; use crate::platform::types::{c_char, c_longlong, c_uchar, c_uint, c_ulong, c_ulonglong, c_ushort}; -pub type useconds_t = c_uint; - pub type u_char = c_uchar; pub type uchar = c_uchar; pub type u_short = c_ushort;