diff --git a/src/header/bits_mode-t/cbindgen.toml b/src/header/bits_mode-t/cbindgen.toml new file mode 100644 index 0000000000..614acf95e4 --- /dev/null +++ b/src/header/bits_mode-t/cbindgen.toml @@ -0,0 +1,22 @@ +# 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 mode_t: +# - fcntl.h +# - ndbm.h (TODO not present in relibc) +# - spawn.h (TODO not present in relibc) +# - sys/ipc.h (TODO not present in relibc) +# - sys/mman.h +# - sys/stat.h +# - sys/types.h (where it should be defined) +sys_includes = [] +include_guard = "_RELIBC_BITS_MODE_T_H" +language = "C" +style = "type" +no_includes = true +cpp_compat = true +[export] +include = ["mode_t"] +[enum] +prefix_with_name = true diff --git a/src/header/bits_mode-t/mod.rs b/src/header/bits_mode-t/mod.rs new file mode 100644 index 0000000000..f2d48bae81 --- /dev/null +++ b/src/header/bits_mode-t/mod.rs @@ -0,0 +1,14 @@ +#[cfg(target_os = "linux")] +use crate::platform::types::c_uint; + +#[cfg(not(target_os = "linux"))] +use crate::platform::types::c_int; + +/// Used for some file attributes. +#[allow(non_camel_case_types)] +#[cfg(target_os = "linux")] +pub type mode_t = c_uint; +/// Used for some file attributes. +#[allow(non_camel_case_types)] +#[cfg(not(target_os = "linux"))] +pub type mode_t = c_int; diff --git a/src/header/mod.rs b/src/header/mod.rs index b4238a31c8..05d18ba711 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -16,6 +16,8 @@ pub mod bits_id_t; pub mod bits_iovec; #[path = "bits_locale-t/mod.rs"] pub mod bits_locale_t; +#[path = "bits_mode-t/mod.rs"] +pub mod bits_mode_t; #[path = "bits_off-t/mod.rs"] pub mod bits_off_t; #[path = "bits_pid-t/mod.rs"] diff --git a/src/header/sys_types_internal/cbindgen.toml b/src/header/sys_types_internal/cbindgen.toml index e587255ff9..f9ee2bffa4 100644 --- a/src/header/sys_types_internal/cbindgen.toml +++ b/src/header/sys_types_internal/cbindgen.toml @@ -6,6 +6,7 @@ after_includes = """ #include #include #include +#include #include #include #include @@ -26,7 +27,6 @@ include = [ "dev_t", "ino_t", "reclen_t", - "mode_t", "nlink_t", "useconds_t", "blkcnt_t", diff --git a/src/header/sys_types_internal/mod.rs b/src/header/sys_types_internal/mod.rs index 6bd3b63b7c..89dacc4f87 100644 --- a/src/header/sys_types_internal/mod.rs +++ b/src/header/sys_types_internal/mod.rs @@ -9,11 +9,9 @@ pub use crate::header::{ 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, + bits_mode_t::mode_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, }; -#[cfg(not(target_os = "linux"))] -use crate::platform::types::c_int; use crate::platform::types::{ c_char, c_long, c_longlong, c_uchar, c_uint, c_ulong, c_ulonglong, c_ushort, }; @@ -26,12 +24,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 some file attributes. -#[cfg(target_os = "linux")] -pub type mode_t = c_uint; -/// Used for some file attributes. -#[cfg(not(target_os = "linux"))] -pub type mode_t = c_int; /// Used for link counts. pub type nlink_t = c_ulong; pub type useconds_t = c_uint;