diff options
| author | Ben Kimock <kimockb@gmail.com> | 2025-07-05 12:32:53 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-05 12:32:53 -0400 |
| commit | 7245febecd049a17af00cae20b08426c4772cf85 (patch) | |
| tree | a7a6f2e4f970f0f687a15fde6593177195ffa416 | |
| parent | 61bdd11b20042dba8d385efda41b76f499acda80 (diff) | |
| parent | 4ae22fba5b4af7ffa223c46e7d81a15f53a6a387 (diff) | |
| download | rust-7245febecd049a17af00cae20b08426c4772cf85.tar.gz rust-7245febecd049a17af00cae20b08426c4772cf85.zip | |
Rollup merge of #143445 - folkertdev:va-list-intrinsics, r=RalfJung
move `va_copy`, `va_arg` and `va_end` to `core::intrinsics` some questions: - should these functions be `pub`? - is a separate module justified? r? `@RalfJung`
| -rw-r--r-- | library/core/src/ffi/va_list.rs | 18 | ||||
| -rw-r--r-- | library/core/src/intrinsics/mod.rs | 23 |
2 files changed, 24 insertions, 17 deletions
diff --git a/library/core/src/ffi/va_list.rs b/library/core/src/ffi/va_list.rs index 8f7c090bc1b..88ad1197777 100644 --- a/library/core/src/ffi/va_list.rs +++ b/library/core/src/ffi/va_list.rs @@ -5,6 +5,7 @@ use crate::ffi::c_void; #[allow(unused_imports)] use crate::fmt; +use crate::intrinsics::{va_arg, va_copy, va_end}; use crate::marker::{PhantomData, PhantomInvariantLifetime}; use crate::ops::{Deref, DerefMut}; @@ -280,20 +281,3 @@ impl<'f> Drop for VaListImpl<'f> { // This works for now, since `va_end` is a no-op on all current LLVM targets. } } - -/// Destroy the arglist `ap` after initialization with `va_start` or -/// `va_copy`. -#[rustc_intrinsic] -#[rustc_nounwind] -unsafe fn va_end(ap: &mut VaListImpl<'_>); - -/// Copies the current location of arglist `src` to the arglist `dst`. -#[rustc_intrinsic] -#[rustc_nounwind] -unsafe fn va_copy<'f>(dest: *mut VaListImpl<'f>, src: &VaListImpl<'f>); - -/// Loads an argument of type `T` from the `va_list` `ap` and increment the -/// argument `ap` points to. -#[rustc_intrinsic] -#[rustc_nounwind] -unsafe fn va_arg<T: VaArgSafe>(ap: &mut VaListImpl<'_>) -> T; diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index ab99492638e..791d10eda6d 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -54,6 +54,7 @@ )] #![allow(missing_docs)] +use crate::ffi::va_list::{VaArgSafe, VaListImpl}; use crate::marker::{ConstParamTy, DiscriminantKind, PointeeSized, Tuple}; use crate::ptr; @@ -3142,3 +3143,25 @@ pub(crate) const fn miri_promise_symbolic_alignment(ptr: *const (), align: usize } ) } + +/// Copies the current location of arglist `src` to the arglist `dst`. +/// +/// FIXME: document safety requirements +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn va_copy<'f>(dest: *mut VaListImpl<'f>, src: &VaListImpl<'f>); + +/// Loads an argument of type `T` from the `va_list` `ap` and increment the +/// argument `ap` points to. +/// +/// FIXME: document safety requirements +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn va_arg<T: VaArgSafe>(ap: &mut VaListImpl<'_>) -> T; + +/// Destroy the arglist `ap` after initialization with `va_start` or `va_copy`. +/// +/// FIXME: document safety requirements +#[rustc_intrinsic] +#[rustc_nounwind] +pub unsafe fn va_end(ap: &mut VaListImpl<'_>); |
