Skip to content

Commit 7245feb

Browse files
authored
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`
2 parents 61bdd11 + 4ae22fb commit 7245feb

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

library/core/src/ffi/va_list.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use crate::ffi::c_void;
66
#[allow(unused_imports)]
77
use crate::fmt;
8+
use crate::intrinsics::{va_arg, va_copy, va_end};
89
use crate::marker::{PhantomData, PhantomInvariantLifetime};
910
use crate::ops::{Deref, DerefMut};
1011

@@ -280,20 +281,3 @@ impl<'f> Drop for VaListImpl<'f> {
280281
// This works for now, since `va_end` is a no-op on all current LLVM targets.
281282
}
282283
}
283-
284-
/// Destroy the arglist `ap` after initialization with `va_start` or
285-
/// `va_copy`.
286-
#[rustc_intrinsic]
287-
#[rustc_nounwind]
288-
unsafe fn va_end(ap: &mut VaListImpl<'_>);
289-
290-
/// Copies the current location of arglist `src` to the arglist `dst`.
291-
#[rustc_intrinsic]
292-
#[rustc_nounwind]
293-
unsafe fn va_copy<'f>(dest: *mut VaListImpl<'f>, src: &VaListImpl<'f>);
294-
295-
/// Loads an argument of type `T` from the `va_list` `ap` and increment the
296-
/// argument `ap` points to.
297-
#[rustc_intrinsic]
298-
#[rustc_nounwind]
299-
unsafe fn va_arg<T: VaArgSafe>(ap: &mut VaListImpl<'_>) -> T;

library/core/src/intrinsics/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
)]
5555
#![allow(missing_docs)]
5656

57+
use crate::ffi::va_list::{VaArgSafe, VaListImpl};
5758
use crate::marker::{ConstParamTy, DiscriminantKind, PointeeSized, Tuple};
5859
use crate::ptr;
5960

@@ -3142,3 +3143,25 @@ pub(crate) const fn miri_promise_symbolic_alignment(ptr: *const (), align: usize
31423143
}
31433144
)
31443145
}
3146+
3147+
/// Copies the current location of arglist `src` to the arglist `dst`.
3148+
///
3149+
/// FIXME: document safety requirements
3150+
#[rustc_intrinsic]
3151+
#[rustc_nounwind]
3152+
pub unsafe fn va_copy<'f>(dest: *mut VaListImpl<'f>, src: &VaListImpl<'f>);
3153+
3154+
/// Loads an argument of type `T` from the `va_list` `ap` and increment the
3155+
/// argument `ap` points to.
3156+
///
3157+
/// FIXME: document safety requirements
3158+
#[rustc_intrinsic]
3159+
#[rustc_nounwind]
3160+
pub unsafe fn va_arg<T: VaArgSafe>(ap: &mut VaListImpl<'_>) -> T;
3161+
3162+
/// Destroy the arglist `ap` after initialization with `va_start` or `va_copy`.
3163+
///
3164+
/// FIXME: document safety requirements
3165+
#[rustc_intrinsic]
3166+
#[rustc_nounwind]
3167+
pub unsafe fn va_end(ap: &mut VaListImpl<'_>);

0 commit comments

Comments
 (0)