diff --git a/src/header/bits_uid-t/cbindgen.toml b/src/header/bits_uid-t/cbindgen.toml new file mode 100644 index 0000000000..f692c4bdca --- /dev/null +++ b/src/header/bits_uid-t/cbindgen.toml @@ -0,0 +1,21 @@ +# 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 uid_t: +# - pwd.h +# - signal.h +# - sys/ipc.h (TODO not present in relibc) +# - sys/stat.h +# - sys/types.h (where it should be defined) +# - unistd.h +sys_includes = [] +include_guard = "_RELIBC_BITS_UID_T_H" +language = "C" +style = "type" +no_includes = true +cpp_compat = true +[export] +include = ["uid_t"] +[enum] +prefix_with_name = true diff --git a/src/header/bits_uid-t/mod.rs b/src/header/bits_uid-t/mod.rs new file mode 100644 index 0000000000..2ddcf0df03 --- /dev/null +++ b/src/header/bits_uid-t/mod.rs @@ -0,0 +1,5 @@ +use crate::platform::types::c_int; + +/// Used for user IDs. +#[allow(non_camel_case_types)] +pub type uid_t = c_int; diff --git a/src/header/mod.rs b/src/header/mod.rs index a12397c5bc..f8fa4f816b 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -31,6 +31,8 @@ pub mod bits_suseconds_t; pub mod bits_time_t; pub mod bits_timespec; pub mod bits_timeval; +#[path = "bits_uid-t/mod.rs"] +pub mod bits_uid_t; // complex.h implemented in C (currently through openlibm) pub mod cpio; pub mod crypt; diff --git a/src/header/sys_types_internal/cbindgen.toml b/src/header/sys_types_internal/cbindgen.toml index e76a0a5724..896755be07 100644 --- a/src/header/sys_types_internal/cbindgen.toml +++ b/src/header/sys_types_internal/cbindgen.toml @@ -8,6 +8,7 @@ after_includes = """ #include #include #include +#include typedef void* timer_t; """ @@ -22,7 +23,6 @@ include = [ "dev_t", "ino_t", "reclen_t", - "uid_t", "mode_t", "nlink_t", "id_t", diff --git a/src/header/sys_types_internal/mod.rs b/src/header/sys_types_internal/mod.rs index 201da2f264..f6444cc215 100644 --- a/src/header/sys_types_internal/mod.rs +++ b/src/header/sys_types_internal/mod.rs @@ -9,7 +9,7 @@ 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_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, @@ -23,8 +23,6 @@ pub type dev_t = c_ulonglong; pub type ino_t = c_ulonglong; /// Used for directory entry lengths. pub type reclen_t = c_ushort; -/// Used for user IDs. -pub type uid_t = c_int; /// Used for some file attributes. #[cfg(target_os = "linux")] pub type mode_t = c_uint;