diff --git a/src/header/bits_timer-t/cbindgen.toml b/src/header/bits_timer-t/cbindgen.toml new file mode 100644 index 0000000000..33f6a4ccd1 --- /dev/null +++ b/src/header/bits_timer-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 timer_t: +# - sys/types.h (where it should be defined) +# - time.h +sys_includes = [] +include_guard = "_RELIBC_BITS_TIMER_T_H" +language = "C" +style = "type" +no_includes = true +cpp_compat = true +[export] +include = ["timer_t"] +[enum] +prefix_with_name = true diff --git a/src/header/bits_timer-t/mod.rs b/src/header/bits_timer-t/mod.rs new file mode 100644 index 0000000000..84324346e1 --- /dev/null +++ b/src/header/bits_timer-t/mod.rs @@ -0,0 +1,5 @@ +use crate::platform::types::c_void; + +/// Used for timer ID returned by timer_create() +#[allow(non_camel_case_types)] +pub type timer_t = *mut c_void; diff --git a/src/header/mod.rs b/src/header/mod.rs index 5c58b3a09b..e85a4dc560 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -40,6 +40,8 @@ pub mod bits_suseconds_t; pub mod bits_sys_statvfs; #[path = "bits_time-t/mod.rs"] pub mod bits_time_t; +#[path = "bits_timer-t/mod.rs"] +pub mod bits_timer_t; pub mod bits_timespec; pub mod bits_timeval; #[path = "bits_uid-t/mod.rs"] diff --git a/src/header/sys_types_internal/cbindgen.toml b/src/header/sys_types_internal/cbindgen.toml index a79f81b163..21a4a58751 100644 --- a/src/header/sys_types_internal/cbindgen.toml +++ b/src/header/sys_types_internal/cbindgen.toml @@ -1,6 +1,5 @@ # stddef.h brings in size_t sys_includes = ["stddef.h"] -# TODO: figure out how to export void* type after_includes = """ #include #include @@ -14,9 +13,8 @@ after_includes = """ #include #include // for fsblkcnt_t and fsfilcnt_t #include +#include #include - -typedef void* timer_t; """ include_guard = "_RELIBC_SYS_TYPES_INTERNAL_H" language = "C" diff --git a/src/header/sys_types_internal/mod.rs b/src/header/sys_types_internal/mod.rs index aa499b3c72..3c0cc9cd45 100644 --- a/src/header/sys_types_internal/mod.rs +++ b/src/header/sys_types_internal/mod.rs @@ -20,6 +20,7 @@ pub use crate::header::{ bits_suseconds_t::suseconds_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::{ @@ -36,8 +37,6 @@ pub type reclen_t = c_ushort; pub type nlink_t = c_ulong; pub type useconds_t = c_uint; -// timer_t in cbindgen after_includes (how to export void* type?) - /// Used for file block counts. pub type blkcnt_t = c_longlong;