From bd505d34512480f89a5bfc00ddbe90e7762d3332 Mon Sep 17 00:00:00 2001 From: auronandace Date: Mon, 11 May 2026 14:03:16 +0100 Subject: [PATCH] split out clock_t from sys_types --- src/header/bits_clock-t/cbindgen.toml | 18 ++++++++++++++++++ src/header/bits_clock-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, 28 insertions(+), 5 deletions(-) create mode 100644 src/header/bits_clock-t/cbindgen.toml create mode 100644 src/header/bits_clock-t/mod.rs diff --git a/src/header/bits_clock-t/cbindgen.toml b/src/header/bits_clock-t/cbindgen.toml new file mode 100644 index 0000000000..7d773fd54b --- /dev/null +++ b/src/header/bits_clock-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 clock_t: +# - sys/times.h +# - sys/types.h (where it should be defined) +# - time.h +sys_includes = [] +include_guard = "_RELIBC_BITS_CLOCK_T_H" +language = "C" +style = "type" +no_includes = true +cpp_compat = true +[export] +include = ["clock_t"] +[enum] +prefix_with_name = true diff --git a/src/header/bits_clock-t/mod.rs b/src/header/bits_clock-t/mod.rs new file mode 100644 index 0000000000..59e023b15a --- /dev/null +++ b/src/header/bits_clock-t/mod.rs @@ -0,0 +1,5 @@ +use crate::platform::types::c_long; + +/// Used for system times in clock ticks or CLOCKS_PER_SEC. +#[allow(non_camel_case_types)] +pub type clock_t = c_long; diff --git a/src/header/mod.rs b/src/header/mod.rs index e8a877127e..261e45c45c 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_clock-t/mod.rs"] +pub mod bits_clock_t; #[path = "bits_gid-t/mod.rs"] pub mod bits_gid_t; pub mod bits_iovec; diff --git a/src/header/sys_types_internal/cbindgen.toml b/src/header/sys_types_internal/cbindgen.toml index 896755be07..e37705e19d 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 @@ -27,7 +28,6 @@ include = [ "nlink_t", "id_t", "useconds_t", - "clock_t", "clockid_t", "blkcnt_t", "fsblkcnt_t", diff --git a/src/header/sys_types_internal/mod.rs b/src/header/sys_types_internal/mod.rs index f6444cc215..e6579d058d 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_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_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, @@ -35,8 +35,6 @@ pub type nlink_t = c_ulong; pub type id_t = c_uint; pub type useconds_t = c_uint; -/// Used for system times in clock ticks or CLOCKS_PER_SEC. -pub type clock_t = c_long; /// Used for clock ID type in the clock and timer functions. pub type clockid_t = c_int;