Skip to content

Commit 65306d3

Browse files
committed
core: Add core::ffi::c_intptr_t and core::ffi::c_uintptr_t
This is a complement to c_ptrdiff_t Tracking issue: #88345 Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
1 parent d7f14d3 commit 65306d3

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

library/core/src/ffi/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub use self::primitives::{
3838
c_ulong, c_ulonglong, c_ushort,
3939
};
4040
#[unstable(feature = "c_size_t", issue = "88345")]
41-
pub use self::primitives::{c_ptrdiff_t, c_size_t, c_ssize_t};
41+
pub use self::primitives::{c_ptrdiff_t, c_size_t, c_ssize_t, c_intptr_t, c_uintptr_t};
4242

4343
// N.B., for LLVM to recognize the void pointer type and by extension
4444
// functions like malloc(), we need to have it represented as i8* in

library/core/src/ffi/primitives.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,24 @@ pub type c_ptrdiff_t = isize;
174174
#[unstable(feature = "c_size_t", issue = "88345")]
175175
pub type c_ssize_t = isize;
176176

177+
/// Equivalent to C's `intptr_t` type.
178+
///
179+
/// This type is currently always [`isize`], however in the future there may be
180+
/// platforms where this is not the case. The C standard technically only
181+
/// requires that this type be a signed integer type just capable of holding a
182+
/// pointer.
183+
#[unstable(feature = "c_size_t", issue = "88345")]
184+
pub type c_intptr_t = isize;
185+
186+
/// Equivalent to C's `uintptr_t` type.
187+
///
188+
/// This type is currently always [`usize`], however in the future there may be
189+
/// platforms where this is not the case. The C standard technically only
190+
/// requires that this type be an unsigned integer type just capable of holding a
191+
/// pointer.
192+
#[unstable(feature = "c_size_t", issue = "88345")]
193+
pub type c_uintptr_t = usize;
194+
177195
mod c_int_definition {
178196
crate::cfg_select! {
179197
any(target_arch = "avr", target_arch = "msp430") => {

0 commit comments

Comments
 (0)