diff --git a/include/stdint.h b/include/stdint.h index 963b8e9b5d..989c7ca6fa 100644 --- a/include/stdint.h +++ b/include/stdint.h @@ -87,9 +87,7 @@ typedef __UINT_FAST64_TYPE__ uint_fast64_t; /* 7.8.1.4 Integer types capable of holding object pointers */ -#ifdef __INTPTR_TYPE__ -typedef __INTPTR_TYPE__ intptr_t; -#endif +#include // for intptr_t #ifdef __UINTPTR_TYPE__ typedef __UINTPTR_TYPE__ uintptr_t; #endif diff --git a/src/header/bits_intptr-t/cbindgen.toml b/src/header/bits_intptr-t/cbindgen.toml new file mode 100644 index 0000000000..09634daab2 --- /dev/null +++ b/src/header/bits_intptr-t/cbindgen.toml @@ -0,0 +1,19 @@ +# POSIX header spec: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/stdint.h.html +# +# This type is split out to prevent importing all of stdint.h in other headers. +# +# POSIX headers that require intptr_t: +# - stdint.h (where it should be defined) +# - sys/shm.h +# - unistd.h (permitted to include all of stdint.h) +include_guard = "_RELIBC_BITS_INTPTR_T_H" +after_includes = """ +#ifdef __INTPTR_TYPE__ +typedef __INTPTR_TYPE__ intptr_t; +#endif +""" +language = "C" +no_includes = true +cpp_compat = true +[enum] +prefix_with_name = true diff --git a/src/header/bits_intptr-t/mod.rs b/src/header/bits_intptr-t/mod.rs new file mode 100644 index 0000000000..475584e727 --- /dev/null +++ b/src/header/bits_intptr-t/mod.rs @@ -0,0 +1,5 @@ +//! `intptr_t` implementation for `stdint.h` +//! +//! See . +//! +//! Implemented via typedef in cbindgen. diff --git a/src/header/mod.rs b/src/header/mod.rs index f89397d71e..3df1f0c776 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -18,6 +18,8 @@ pub mod bits_gid_t; pub mod bits_id_t; #[path = "bits_ino-t/mod.rs"] pub mod bits_ino_t; +#[path = "bits_intptr-t/mod.rs"] +pub mod bits_intptr_t; pub mod bits_iovec; #[path = "bits_key-t/mod.rs"] pub mod bits_key_t; diff --git a/src/header/sys_shm/cbindgen.toml b/src/header/sys_shm/cbindgen.toml index e199598ffe..c49aca2117 100644 --- a/src/header/sys_shm/cbindgen.toml +++ b/src/header/sys_shm/cbindgen.toml @@ -4,14 +4,13 @@ # - "The header shall define the type intptr_t as described in ." # - "The header shall define the pid_t, size_t, and time_t types as described in ." # - "In addition, the header shall include the header." -# -# TODO split out intptr_t from stdint.h -sys_includes = ["sys/ipc.h", "stdint.h"] +sys_includes = ["sys/ipc.h"] include_guard = "_RELIBC_SYS_SHM_H" after_includes = """ -#include // for pid_t from sys/types.h -#include // for size_t from sys/types.h -#include // for time_t from sys/types.h +#include // for intptr_t from stdint.h +#include // for pid_t from sys/types.h +#include // for size_t from sys/types.h +#include // for time_t from sys/types.h """ language = "C" style = "Tag"