diff --git a/src/header/bits_ssize-t/cbindgen.toml b/src/header/bits_ssize-t/cbindgen.toml new file mode 100644 index 0000000000..d02adad767 --- /dev/null +++ b/src/header/bits_ssize-t/cbindgen.toml @@ -0,0 +1,25 @@ +# 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 ssize_t: +# - aio.h +# - dirent.h +# - monetary.h +# - mqueue.h +# - stdio.h +# - sys/msg.h +# - sys/socket.h +# - sys/types.h (where it should be defined) +# - sys/uio.h +# - unistd.h +sys_includes = [] +include_guard = "_RELIBC_BITS_SSIZE_T_H" +language = "C" +style = "type" +no_includes = true +cpp_compat = true +[export] +include = ["ssize_t"] +[enum] +prefix_with_name = true diff --git a/src/header/bits_ssize-t/mod.rs b/src/header/bits_ssize-t/mod.rs new file mode 100644 index 0000000000..a8b518bf0b --- /dev/null +++ b/src/header/bits_ssize-t/mod.rs @@ -0,0 +1,5 @@ +use crate::platform::types::c_long; + +/// Used for a count of bytes or an error indication. +#[allow(non_camel_case_types)] +pub type ssize_t = c_long; diff --git a/src/header/mod.rs b/src/header/mod.rs index 7f82b7915f..9ef9953492 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -15,6 +15,8 @@ pub mod bits_safamily_t; pub mod bits_sigset_t; #[path = "bits_socklen-t/mod.rs"] pub mod bits_socklen_t; +#[path = "bits_ssize-t/mod.rs"] +pub mod bits_ssize_t; #[path = "bits_suseconds-t/mod.rs"] pub mod bits_suseconds_t; #[path = "bits_time-t/mod.rs"] diff --git a/src/header/sys_types_internal/cbindgen.toml b/src/header/sys_types_internal/cbindgen.toml index 41b3d0a724..4e253f3ba4 100644 --- a/src/header/sys_types_internal/cbindgen.toml +++ b/src/header/sys_types_internal/cbindgen.toml @@ -1,6 +1,7 @@ sys_includes = ["stddef.h"] # TODO: figure out how to export void* type after_includes = """ +#include #include #include @@ -24,7 +25,6 @@ include = [ "off_t", "pid_t", "id_t", - "ssize_t", "useconds_t", "clock_t", "clockid_t", diff --git a/src/header/sys_types_internal/mod.rs b/src/header/sys_types_internal/mod.rs index bd8ab3be9c..56b3fec7a9 100644 --- a/src/header/sys_types_internal/mod.rs +++ b/src/header/sys_types_internal/mod.rs @@ -7,7 +7,9 @@ //! //! for the old specification. -pub use crate::header::{bits_suseconds_t::suseconds_t, bits_time_t::time_t}; +pub use crate::header::{ + bits_ssize_t::ssize_t, bits_suseconds_t::suseconds_t, bits_time_t::time_t, +}; use crate::platform::types::{ c_char, c_int, c_long, c_longlong, c_uchar, c_uint, c_ulong, c_ulonglong, c_ushort, }; @@ -38,8 +40,6 @@ pub type off_t = c_longlong; pub type pid_t = c_int; /// Used as a general identifier; can be used to contain at least a pid_t, uid_t, or gid_t. pub type id_t = c_uint; -/// Used for a count of bytes or an error indication. -pub type ssize_t = c_long; pub type useconds_t = c_uint; /// Used for system times in clock ticks or CLOCKS_PER_SEC.