• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //! Platform-specific types, as defined by C.
2 //!
3 //! Code that interacts via FFI will almost certainly be using the
4 //! base types provided by C, which aren't nearly as nicely defined
5 //! as Rust's primitive types. This module provides types which will
6 //! match those defined by C, so that code that interacts with C will
7 //! refer to the correct types.
8 
9 #![stable(feature = "", since = "1.30.0")]
10 #![allow(non_camel_case_types)]
11 
12 use crate::fmt;
13 use crate::marker::PhantomData;
14 use crate::num::*;
15 use crate::ops::{Deref, DerefMut};
16 
17 #[stable(feature = "core_c_str", since = "1.64.0")]
18 pub use self::c_str::{CStr, FromBytesUntilNulError, FromBytesWithNulError};
19 
20 mod c_str;
21 
22 macro_rules! type_alias_no_nz {
23     {
24       $Docfile:tt, $Alias:ident = $Real:ty;
25       $( $Cfg:tt )*
26     } => {
27         #[doc = include_str!($Docfile)]
28         $( $Cfg )*
29         #[stable(feature = "core_ffi_c", since = "1.64.0")]
30         pub type $Alias = $Real;
31     }
32 }
33 
34 // To verify that the NonZero types in this file's macro invocations correspond
35 //
36 //  perl -n < library/std/src/os/raw/mod.rs -e 'next unless m/type_alias\!/; die "$_ ?" unless m/, (c_\w+) = (\w+), NonZero_(\w+) = NonZero(\w+)/; die "$_ ?" unless $3 eq $1 and $4 eq ucfirst $2'
37 //
38 // NB this does not check that the main c_* types are right.
39 
40 macro_rules! type_alias {
41     {
42       $Docfile:tt, $Alias:ident = $Real:ty, $NZAlias:ident = $NZReal:ty;
43       $( $Cfg:tt )*
44     } => {
45         type_alias_no_nz! { $Docfile, $Alias = $Real; $( $Cfg )* }
46 
47         #[doc = concat!("Type alias for `NonZero` version of [`", stringify!($Alias), "`]")]
48         #[unstable(feature = "raw_os_nonzero", issue = "82363")]
49         $( $Cfg )*
50         pub type $NZAlias = $NZReal;
51     }
52 }
53 
54 type_alias! { "c_char.md", c_char = c_char_definition::c_char, NonZero_c_char = c_char_definition::NonZero_c_char;
55 // Make this type alias appear cfg-dependent so that Clippy does not suggest
56 // replacing `0 as c_char` with `0_i8`/`0_u8`. This #[cfg(all())] can be removed
57 // after the false positive in https://github.com/rust-lang/rust-clippy/issues/8093
58 // is fixed.
59 #[cfg(all())]
60 #[doc(cfg(all()))] }
61 
62 type_alias! { "c_schar.md", c_schar = i8, NonZero_c_schar = NonZeroI8; }
63 type_alias! { "c_uchar.md", c_uchar = u8, NonZero_c_uchar = NonZeroU8; }
64 type_alias! { "c_short.md", c_short = i16, NonZero_c_short = NonZeroI16; }
65 type_alias! { "c_ushort.md", c_ushort = u16, NonZero_c_ushort = NonZeroU16; }
66 
67 type_alias! { "c_int.md", c_int = c_int_definition::c_int, NonZero_c_int = c_int_definition::NonZero_c_int;
68 #[doc(cfg(all()))] }
69 type_alias! { "c_uint.md", c_uint = c_int_definition::c_uint, NonZero_c_uint = c_int_definition::NonZero_c_uint;
70 #[doc(cfg(all()))] }
71 
72 type_alias! { "c_long.md", c_long = c_long_definition::c_long, NonZero_c_long = c_long_definition::NonZero_c_long;
73 #[doc(cfg(all()))] }
74 type_alias! { "c_ulong.md", c_ulong = c_long_definition::c_ulong, NonZero_c_ulong = c_long_definition::NonZero_c_ulong;
75 #[doc(cfg(all()))] }
76 
77 type_alias! { "c_longlong.md", c_longlong = i64, NonZero_c_longlong = NonZeroI64; }
78 type_alias! { "c_ulonglong.md", c_ulonglong = u64, NonZero_c_ulonglong = NonZeroU64; }
79 
80 type_alias_no_nz! { "c_float.md", c_float = f32; }
81 type_alias_no_nz! { "c_double.md", c_double = f64; }
82 
83 /// Equivalent to C's `size_t` type, from `stddef.h` (or `cstddef` for C++).
84 ///
85 /// This type is currently always [`usize`], however in the future there may be
86 /// platforms where this is not the case.
87 #[unstable(feature = "c_size_t", issue = "88345")]
88 pub type c_size_t = usize;
89 
90 /// Equivalent to C's `ptrdiff_t` type, from `stddef.h` (or `cstddef` for C++).
91 ///
92 /// This type is currently always [`isize`], however in the future there may be
93 /// platforms where this is not the case.
94 #[unstable(feature = "c_size_t", issue = "88345")]
95 pub type c_ptrdiff_t = isize;
96 
97 /// Equivalent to C's `ssize_t` (on POSIX) or `SSIZE_T` (on Windows) type.
98 ///
99 /// This type is currently always [`isize`], however in the future there may be
100 /// platforms where this is not the case.
101 #[unstable(feature = "c_size_t", issue = "88345")]
102 pub type c_ssize_t = isize;
103 
104 mod c_char_definition {
105     cfg_if! {
106         // These are the targets on which c_char is unsigned.
107         if #[cfg(any(
108             all(
109                 target_os = "linux",
110                 any(
111                     target_arch = "aarch64",
112                     target_arch = "arm",
113                     target_arch = "hexagon",
114                     target_arch = "powerpc",
115                     target_arch = "powerpc64",
116                     target_arch = "s390x",
117                     target_arch = "riscv64",
118                     target_arch = "riscv32"
119                 )
120             ),
121             all(target_os = "android", any(target_arch = "aarch64", target_arch = "arm")),
122             all(target_os = "l4re", target_arch = "x86_64"),
123             all(
124                 any(target_os = "freebsd", target_os = "openbsd"),
125                 any(
126                     target_arch = "aarch64",
127                     target_arch = "arm",
128                     target_arch = "powerpc",
129                     target_arch = "powerpc64",
130                     target_arch = "riscv64"
131                 )
132             ),
133             all(
134                 target_os = "netbsd",
135                 any(
136                     target_arch = "aarch64",
137                     target_arch = "arm",
138                     target_arch = "powerpc",
139                     target_arch = "riscv64"
140                 )
141             ),
142             all(
143                 target_os = "vxworks",
144                 any(
145                     target_arch = "aarch64",
146                     target_arch = "arm",
147                     target_arch = "powerpc64",
148                     target_arch = "powerpc"
149                 )
150             ),
151             all(
152                 target_os = "fuchsia",
153                 any(target_arch = "aarch64", target_arch = "riscv64")
154             ),
155             all(target_os = "nto", target_arch = "aarch64"),
156             target_os = "horizon"
157         ))] {
158             pub type c_char = u8;
159             pub type NonZero_c_char = crate::num::NonZeroU8;
160         } else {
161             // On every other target, c_char is signed.
162             pub type c_char = i8;
163             pub type NonZero_c_char = crate::num::NonZeroI8;
164         }
165     }
166 }
167 
168 mod c_int_definition {
169     cfg_if! {
170         if #[cfg(any(target_arch = "avr", target_arch = "msp430"))] {
171             pub type c_int = i16;
172             pub type NonZero_c_int = crate::num::NonZeroI16;
173             pub type c_uint = u16;
174             pub type NonZero_c_uint = crate::num::NonZeroU16;
175         } else {
176             pub type c_int = i32;
177             pub type NonZero_c_int = crate::num::NonZeroI32;
178             pub type c_uint = u32;
179             pub type NonZero_c_uint = crate::num::NonZeroU32;
180         }
181     }
182 }
183 
184 mod c_long_definition {
185     cfg_if! {
186         if #[cfg(all(target_pointer_width = "64", not(windows)))] {
187             pub type c_long = i64;
188             pub type NonZero_c_long = crate::num::NonZeroI64;
189             pub type c_ulong = u64;
190             pub type NonZero_c_ulong = crate::num::NonZeroU64;
191         } else {
192             // The minimal size of `long` in the C standard is 32 bits
193             pub type c_long = i32;
194             pub type NonZero_c_long = crate::num::NonZeroI32;
195             pub type c_ulong = u32;
196             pub type NonZero_c_ulong = crate::num::NonZeroU32;
197         }
198     }
199 }
200 
201 // N.B., for LLVM to recognize the void pointer type and by extension
202 //     functions like malloc(), we need to have it represented as i8* in
203 //     LLVM bitcode. The enum used here ensures this and prevents misuse
204 //     of the "raw" type by only having private variants. We need two
205 //     variants, because the compiler complains about the repr attribute
206 //     otherwise and we need at least one variant as otherwise the enum
207 //     would be uninhabited and at least dereferencing such pointers would
208 //     be UB.
209 #[doc = include_str!("c_void.md")]
210 #[lang = "c_void"]
211 #[cfg_attr(not(doc), repr(u8))] // work around https://github.com/rust-lang/rust/issues/90435
212 #[stable(feature = "core_c_void", since = "1.30.0")]
213 pub enum c_void {
214     #[unstable(
215         feature = "c_void_variant",
216         reason = "temporary implementation detail",
217         issue = "none"
218     )]
219     #[doc(hidden)]
220     __variant1,
221     #[unstable(
222         feature = "c_void_variant",
223         reason = "temporary implementation detail",
224         issue = "none"
225     )]
226     #[doc(hidden)]
227     __variant2,
228 }
229 
230 #[stable(feature = "std_debug", since = "1.16.0")]
231 impl fmt::Debug for c_void {
fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result232     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
233         f.debug_struct("c_void").finish()
234     }
235 }
236 
237 /// Basic implementation of a `va_list`.
238 // The name is WIP, using `VaListImpl` for now.
239 #[cfg(any(
240     all(
241         not(target_arch = "aarch64"),
242         not(target_arch = "powerpc"),
243         not(target_arch = "s390x"),
244         not(target_arch = "x86_64")
245     ),
246     all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios", target_os = "tvos")),
247     target_family = "wasm",
248     target_arch = "asmjs",
249     target_os = "uefi",
250     windows,
251 ))]
252 #[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/90435
253 #[unstable(
254     feature = "c_variadic",
255     reason = "the `c_variadic` feature has not been properly tested on \
256               all supported platforms",
257     issue = "44930"
258 )]
259 #[lang = "va_list"]
260 pub struct VaListImpl<'f> {
261     ptr: *mut c_void,
262 
263     // Invariant over `'f`, so each `VaListImpl<'f>` object is tied to
264     // the region of the function it's defined in
265     _marker: PhantomData<&'f mut &'f c_void>,
266 }
267 
268 #[cfg(any(
269     all(
270         not(target_arch = "aarch64"),
271         not(target_arch = "powerpc"),
272         not(target_arch = "s390x"),
273         not(target_arch = "x86_64")
274     ),
275     all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios", target_os = "tvos")),
276     target_family = "wasm",
277     target_arch = "asmjs",
278     target_os = "uefi",
279     windows,
280 ))]
281 #[unstable(
282     feature = "c_variadic",
283     reason = "the `c_variadic` feature has not been properly tested on \
284               all supported platforms",
285     issue = "44930"
286 )]
287 impl<'f> fmt::Debug for VaListImpl<'f> {
fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result288     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
289         write!(f, "va_list* {:p}", self.ptr)
290     }
291 }
292 
293 /// AArch64 ABI implementation of a `va_list`. See the
294 /// [AArch64 Procedure Call Standard] for more details.
295 ///
296 /// [AArch64 Procedure Call Standard]:
297 /// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055b/IHI0055B_aapcs64.pdf
298 #[cfg(all(
299     target_arch = "aarch64",
300     not(any(target_os = "macos", target_os = "ios", target_os = "tvos")),
301     not(target_os = "uefi"),
302     not(windows),
303 ))]
304 #[cfg_attr(not(doc), repr(C))] // work around https://github.com/rust-lang/rust/issues/66401
305 #[derive(Debug)]
306 #[unstable(
307     feature = "c_variadic",
308     reason = "the `c_variadic` feature has not been properly tested on \
309               all supported platforms",
310     issue = "44930"
311 )]
312 #[lang = "va_list"]
313 pub struct VaListImpl<'f> {
314     stack: *mut c_void,
315     gr_top: *mut c_void,
316     vr_top: *mut c_void,
317     gr_offs: i32,
318     vr_offs: i32,
319     _marker: PhantomData<&'f mut &'f c_void>,
320 }
321 
322 /// PowerPC ABI implementation of a `va_list`.
323 #[cfg(all(target_arch = "powerpc", not(target_os = "uefi"), not(windows)))]
324 #[cfg_attr(not(doc), repr(C))] // work around https://github.com/rust-lang/rust/issues/66401
325 #[derive(Debug)]
326 #[unstable(
327     feature = "c_variadic",
328     reason = "the `c_variadic` feature has not been properly tested on \
329               all supported platforms",
330     issue = "44930"
331 )]
332 #[lang = "va_list"]
333 pub struct VaListImpl<'f> {
334     gpr: u8,
335     fpr: u8,
336     reserved: u16,
337     overflow_arg_area: *mut c_void,
338     reg_save_area: *mut c_void,
339     _marker: PhantomData<&'f mut &'f c_void>,
340 }
341 
342 /// s390x ABI implementation of a `va_list`.
343 #[cfg(target_arch = "s390x")]
344 #[cfg_attr(not(doc), repr(C))] // work around https://github.com/rust-lang/rust/issues/66401
345 #[derive(Debug)]
346 #[unstable(
347     feature = "c_variadic",
348     reason = "the `c_variadic` feature has not been properly tested on \
349               all supported platforms",
350     issue = "44930"
351 )]
352 #[lang = "va_list"]
353 pub struct VaListImpl<'f> {
354     gpr: i64,
355     fpr: i64,
356     overflow_arg_area: *mut c_void,
357     reg_save_area: *mut c_void,
358     _marker: PhantomData<&'f mut &'f c_void>,
359 }
360 
361 /// x86_64 ABI implementation of a `va_list`.
362 #[cfg(all(target_arch = "x86_64", not(target_os = "uefi"), not(windows)))]
363 #[cfg_attr(not(doc), repr(C))] // work around https://github.com/rust-lang/rust/issues/66401
364 #[derive(Debug)]
365 #[unstable(
366     feature = "c_variadic",
367     reason = "the `c_variadic` feature has not been properly tested on \
368               all supported platforms",
369     issue = "44930"
370 )]
371 #[lang = "va_list"]
372 pub struct VaListImpl<'f> {
373     gp_offset: i32,
374     fp_offset: i32,
375     overflow_arg_area: *mut c_void,
376     reg_save_area: *mut c_void,
377     _marker: PhantomData<&'f mut &'f c_void>,
378 }
379 
380 /// A wrapper for a `va_list`
381 #[cfg_attr(not(doc), repr(transparent))] // work around https://github.com/rust-lang/rust/issues/90435
382 #[derive(Debug)]
383 #[unstable(
384     feature = "c_variadic",
385     reason = "the `c_variadic` feature has not been properly tested on \
386               all supported platforms",
387     issue = "44930"
388 )]
389 pub struct VaList<'a, 'f: 'a> {
390     #[cfg(any(
391         all(
392             not(target_arch = "aarch64"),
393             not(target_arch = "powerpc"),
394             not(target_arch = "s390x"),
395             not(target_arch = "x86_64")
396         ),
397         all(
398             target_arch = "aarch64",
399             any(target_os = "macos", target_os = "ios", target_os = "tvos")
400         ),
401         target_family = "wasm",
402         target_arch = "asmjs",
403         target_os = "uefi",
404         windows,
405     ))]
406     inner: VaListImpl<'f>,
407 
408     #[cfg(all(
409         any(
410             target_arch = "aarch64",
411             target_arch = "powerpc",
412             target_arch = "s390x",
413             target_arch = "x86_64"
414         ),
415         any(
416             not(target_arch = "aarch64"),
417             not(any(target_os = "macos", target_os = "ios", target_os = "tvos"))
418         ),
419         not(target_family = "wasm"),
420         not(target_arch = "asmjs"),
421         not(target_os = "uefi"),
422         not(windows),
423     ))]
424     inner: &'a mut VaListImpl<'f>,
425 
426     _marker: PhantomData<&'a mut VaListImpl<'f>>,
427 }
428 
429 #[cfg(any(
430     all(
431         not(target_arch = "aarch64"),
432         not(target_arch = "powerpc"),
433         not(target_arch = "s390x"),
434         not(target_arch = "x86_64")
435     ),
436     all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios", target_os = "tvos")),
437     target_family = "wasm",
438     target_arch = "asmjs",
439     target_os = "uefi",
440     windows,
441 ))]
442 #[unstable(
443     feature = "c_variadic",
444     reason = "the `c_variadic` feature has not been properly tested on \
445               all supported platforms",
446     issue = "44930"
447 )]
448 impl<'f> VaListImpl<'f> {
449     /// Convert a `VaListImpl` into a `VaList` that is binary-compatible with C's `va_list`.
450     #[inline]
as_va_list<'a>(&'a mut self) -> VaList<'a, 'f>451     pub fn as_va_list<'a>(&'a mut self) -> VaList<'a, 'f> {
452         VaList { inner: VaListImpl { ..*self }, _marker: PhantomData }
453     }
454 }
455 
456 #[cfg(all(
457     any(
458         target_arch = "aarch64",
459         target_arch = "powerpc",
460         target_arch = "s390x",
461         target_arch = "x86_64"
462     ),
463     any(
464         not(target_arch = "aarch64"),
465         not(any(target_os = "macos", target_os = "ios", target_os = "tvos"))
466     ),
467     not(target_family = "wasm"),
468     not(target_arch = "asmjs"),
469     not(target_os = "uefi"),
470     not(windows),
471 ))]
472 #[unstable(
473     feature = "c_variadic",
474     reason = "the `c_variadic` feature has not been properly tested on \
475               all supported platforms",
476     issue = "44930"
477 )]
478 impl<'f> VaListImpl<'f> {
479     /// Convert a `VaListImpl` into a `VaList` that is binary-compatible with C's `va_list`.
480     #[inline]
as_va_list<'a>(&'a mut self) -> VaList<'a, 'f>481     pub fn as_va_list<'a>(&'a mut self) -> VaList<'a, 'f> {
482         VaList { inner: self, _marker: PhantomData }
483     }
484 }
485 
486 #[unstable(
487     feature = "c_variadic",
488     reason = "the `c_variadic` feature has not been properly tested on \
489               all supported platforms",
490     issue = "44930"
491 )]
492 impl<'a, 'f: 'a> Deref for VaList<'a, 'f> {
493     type Target = VaListImpl<'f>;
494 
495     #[inline]
deref(&self) -> &VaListImpl<'f>496     fn deref(&self) -> &VaListImpl<'f> {
497         &self.inner
498     }
499 }
500 
501 #[unstable(
502     feature = "c_variadic",
503     reason = "the `c_variadic` feature has not been properly tested on \
504               all supported platforms",
505     issue = "44930"
506 )]
507 impl<'a, 'f: 'a> DerefMut for VaList<'a, 'f> {
508     #[inline]
deref_mut(&mut self) -> &mut VaListImpl<'f>509     fn deref_mut(&mut self) -> &mut VaListImpl<'f> {
510         &mut self.inner
511     }
512 }
513 
514 // The VaArgSafe trait needs to be used in public interfaces, however, the trait
515 // itself must not be allowed to be used outside this module. Allowing users to
516 // implement the trait for a new type (thereby allowing the va_arg intrinsic to
517 // be used on a new type) is likely to cause undefined behavior.
518 //
519 // FIXME(dlrobertson): In order to use the VaArgSafe trait in a public interface
520 // but also ensure it cannot be used elsewhere, the trait needs to be public
521 // within a private module. Once RFC 2145 has been implemented look into
522 // improving this.
523 mod sealed_trait {
524     /// Trait which permits the allowed types to be used with [super::VaListImpl::arg].
525     #[unstable(
526         feature = "c_variadic",
527         reason = "the `c_variadic` feature has not been properly tested on \
528                   all supported platforms",
529         issue = "44930"
530     )]
531     pub trait VaArgSafe {}
532 }
533 
534 macro_rules! impl_va_arg_safe {
535     ($($t:ty),+) => {
536         $(
537             #[unstable(feature = "c_variadic",
538                        reason = "the `c_variadic` feature has not been properly tested on \
539                                  all supported platforms",
540                        issue = "44930")]
541             impl sealed_trait::VaArgSafe for $t {}
542         )+
543     }
544 }
545 
546 impl_va_arg_safe! {i8, i16, i32, i64, usize}
547 impl_va_arg_safe! {u8, u16, u32, u64, isize}
548 impl_va_arg_safe! {f64}
549 
550 #[unstable(
551     feature = "c_variadic",
552     reason = "the `c_variadic` feature has not been properly tested on \
553               all supported platforms",
554     issue = "44930"
555 )]
556 impl<T> sealed_trait::VaArgSafe for *mut T {}
557 #[unstable(
558     feature = "c_variadic",
559     reason = "the `c_variadic` feature has not been properly tested on \
560               all supported platforms",
561     issue = "44930"
562 )]
563 impl<T> sealed_trait::VaArgSafe for *const T {}
564 
565 #[unstable(
566     feature = "c_variadic",
567     reason = "the `c_variadic` feature has not been properly tested on \
568               all supported platforms",
569     issue = "44930"
570 )]
571 impl<'f> VaListImpl<'f> {
572     /// Advance to the next arg.
573     #[inline]
arg<T: sealed_trait::VaArgSafe>(&mut self) -> T574     pub unsafe fn arg<T: sealed_trait::VaArgSafe>(&mut self) -> T {
575         // SAFETY: the caller must uphold the safety contract for `va_arg`.
576         unsafe { va_arg(self) }
577     }
578 
579     /// Copies the `va_list` at the current location.
with_copy<F, R>(&self, f: F) -> R where F: for<'copy> FnOnce(VaList<'copy, 'f>) -> R,580     pub unsafe fn with_copy<F, R>(&self, f: F) -> R
581     where
582         F: for<'copy> FnOnce(VaList<'copy, 'f>) -> R,
583     {
584         let mut ap = self.clone();
585         let ret = f(ap.as_va_list());
586         // SAFETY: the caller must uphold the safety contract for `va_end`.
587         unsafe {
588             va_end(&mut ap);
589         }
590         ret
591     }
592 }
593 
594 #[unstable(
595     feature = "c_variadic",
596     reason = "the `c_variadic` feature has not been properly tested on \
597               all supported platforms",
598     issue = "44930"
599 )]
600 impl<'f> Clone for VaListImpl<'f> {
601     #[inline]
clone(&self) -> Self602     fn clone(&self) -> Self {
603         let mut dest = crate::mem::MaybeUninit::uninit();
604         // SAFETY: we write to the `MaybeUninit`, thus it is initialized and `assume_init` is legal
605         unsafe {
606             va_copy(dest.as_mut_ptr(), self);
607             dest.assume_init()
608         }
609     }
610 }
611 
612 #[unstable(
613     feature = "c_variadic",
614     reason = "the `c_variadic` feature has not been properly tested on \
615               all supported platforms",
616     issue = "44930"
617 )]
618 impl<'f> Drop for VaListImpl<'f> {
drop(&mut self)619     fn drop(&mut self) {
620         // FIXME: this should call `va_end`, but there's no clean way to
621         // guarantee that `drop` always gets inlined into its caller,
622         // so the `va_end` would get directly called from the same function as
623         // the corresponding `va_copy`. `man va_end` states that C requires this,
624         // and LLVM basically follows the C semantics, so we need to make sure
625         // that `va_end` is always called from the same function as `va_copy`.
626         // For more details, see https://github.com/rust-lang/rust/pull/59625
627         // and https://llvm.org/docs/LangRef.html#llvm-va-end-intrinsic.
628         //
629         // This works for now, since `va_end` is a no-op on all current LLVM targets.
630     }
631 }
632 
633 extern "rust-intrinsic" {
634     /// Destroy the arglist `ap` after initialization with `va_start` or
635     /// `va_copy`.
636     #[rustc_nounwind]
va_end(ap: &mut VaListImpl<'_>)637     fn va_end(ap: &mut VaListImpl<'_>);
638 
639     /// Copies the current location of arglist `src` to the arglist `dst`.
640     #[rustc_nounwind]
va_copy<'f>(dest: *mut VaListImpl<'f>, src: &VaListImpl<'f>)641     fn va_copy<'f>(dest: *mut VaListImpl<'f>, src: &VaListImpl<'f>);
642 
643     /// Loads an argument of type `T` from the `va_list` `ap` and increment the
644     /// argument `ap` points to.
645     #[rustc_nounwind]
va_arg<T: sealed_trait::VaArgSafe>(ap: &mut VaListImpl<'_>) -> T646     fn va_arg<T: sealed_trait::VaArgSafe>(ap: &mut VaListImpl<'_>) -> T;
647 }
648