diff --git a/src/header/bits_clockid-t/cbindgen.toml b/src/header/bits_clockid-t/cbindgen.toml new file mode 100644 index 0000000000..c4fd0ea378 --- /dev/null +++ b/src/header/bits_clockid-t/cbindgen.toml @@ -0,0 +1,17 @@ +# 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 clockid_t: +# - sys/types.h (where it should be defined) +# - time.h +sys_includes = [] +include_guard = "_RELIBC_BITS_CLOCKID_T_H" +language = "C" +style = "type" +no_includes = true +cpp_compat = true +[export] +include = ["clockid_t"] +[enum] +prefix_with_name = true diff --git a/src/header/bits_clockid-t/mod.rs b/src/header/bits_clockid-t/mod.rs new file mode 100644 index 0000000000..d326b8d62f --- /dev/null +++ b/src/header/bits_clockid-t/mod.rs @@ -0,0 +1,5 @@ +use crate::platform::types::c_int; + +/// Used for clock ID type in the clock and timer functions. +#[allow(non_camel_case_types)] +pub type clockid_t = c_int; diff --git a/src/header/mod.rs b/src/header/mod.rs index 44503976c4..b4238a31c8 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -7,6 +7,8 @@ pub mod assert; pub mod bits_arpainet; #[path = "bits_clock-t/mod.rs"] pub mod bits_clock_t; +#[path = "bits_clockid-t/mod.rs"] +pub mod bits_clockid_t; #[path = "bits_gid-t/mod.rs"] pub mod bits_gid_t; #[path = "bits_id-t/mod.rs"] diff --git a/src/header/sys_types_internal/cbindgen.toml b/src/header/sys_types_internal/cbindgen.toml index b9526a55a6..e587255ff9 100644 --- a/src/header/sys_types_internal/cbindgen.toml +++ b/src/header/sys_types_internal/cbindgen.toml @@ -3,6 +3,7 @@ sys_includes = ["stddef.h"] # TODO: figure out how to export void* type after_includes = """ #include +#include #include #include #include @@ -28,7 +29,6 @@ include = [ "mode_t", "nlink_t", "useconds_t", - "clockid_t", "blkcnt_t", "fsblkcnt_t", "fsfilcnt_t", diff --git a/src/header/sys_types_internal/mod.rs b/src/header/sys_types_internal/mod.rs index ba0093301d..8578d7b7f0 100644 --- a/src/header/sys_types_internal/mod.rs +++ b/src/header/sys_types_internal/mod.rs @@ -8,12 +8,12 @@ //! for the old specification. pub use crate::header::{ - bits_clock_t::clock_t, bits_gid_t::gid_t, bits_id_t::id_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_clockid_t::clockid_t, bits_gid_t::gid_t, bits_id_t::id_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, + c_char, c_long, c_longlong, c_uchar, c_uint, c_ulong, c_ulonglong, c_ushort, }; /// Used for block sizes. @@ -34,9 +34,6 @@ pub type mode_t = c_int; pub type nlink_t = c_ulong; pub type useconds_t = c_uint; -/// Used for clock ID type in the clock and timer functions. -pub type clockid_t = c_int; - // timer_t in cbindgen after_includes (how to export void* type?) /// Used for file block counts.