@@ -174,6 +174,22 @@ pub type c_ptrdiff_t = isize;
174174#[ unstable( feature = "c_size_t" , issue = "88345" ) ]
175175pub type c_ssize_t = isize ;
176176
177+ /// Equivalent to C's `intptr_t` type.
178+ ///
179+ /// This type have the same size with a pointer. The C standard technically only
180+ /// requires that this type be a signed integer type just capable of holding a
181+ /// pointer.
182+ #[ unstable( feature = "c_size_t" , issue = "88345" ) ]
183+ pub type c_intptr_t = c_intptr_definition:: c_intptr_t ;
184+
185+ /// Equivalent to C's `uintptr_t` type.
186+ ///
187+ /// This type have the same size with a pointer. The C standard technically only
188+ /// requires that this type be an unsigned integer type just capable of holding
189+ /// a pointer.
190+ #[ unstable( feature = "c_size_t" , issue = "88345" ) ]
191+ pub type c_uintptr_t = c_intptr_definition:: c_uintptr_t ;
192+
177193mod c_int_definition {
178194 crate :: cfg_select! {
179195 any( target_arch = "avr" , target_arch = "msp430" ) => {
@@ -187,6 +203,31 @@ mod c_int_definition {
187203 }
188204}
189205
206+ mod c_intptr_definition {
207+ crate :: cfg_select! {
208+ target_pointer_width = "16" => {
209+ pub ( super ) type c_intptr_t = i16 ;
210+ pub ( super ) type c_uintptr_t = u16 ;
211+ }
212+ target_pointer_width = "32" => {
213+ pub ( super ) type c_intptr_t = i32 ;
214+ pub ( super ) type c_uintptr_t = u32 ;
215+ }
216+ target_pointer_width = "64" => {
217+ pub ( super ) type c_intptr_t = i64 ;
218+ pub ( super ) type c_uintptr_t = u64 ;
219+ }
220+ _ => {
221+ /// 128-bit width pointer.
222+ ///
223+ /// The C standard only requires that these types be large enough to hold a pointer,
224+ /// so we'll use the i128/u128 integer types in Rust.
225+ pub ( super ) type c_intptr_t = i128 ;
226+ pub ( super ) type c_uintptr_t = u128 ;
227+ }
228+ }
229+ }
230+
190231mod c_double_definition {
191232 crate :: cfg_select! {
192233 target_arch = "avr" => {
0 commit comments