1
Fork 0

Rollup merge of #134013 - BLANKatGITHUB:intrinsic, r=saethlin

Adds new intrinsic declaration

This pr is for #132735 removes removes `extern "intrinsic"`

I think its the last block of this file and was kind of asking for advice how to handle other files as mentioned in the issue .
This commit is contained in:
Matthias Krüger 2024-12-08 17:18:52 +01:00 committed by GitHub
commit fe5f5fd6b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3577,34 +3577,44 @@ pub const fn discriminant_value<T>(_v: &T) -> <T as DiscriminantKind>::Discrimin
unimplemented!() unimplemented!()
} }
extern "rust-intrinsic" { /// Rust's "try catch" construct for unwinding. Invokes the function pointer `try_fn` with the
/// Rust's "try catch" construct for unwinding. Invokes the function pointer `try_fn` with the /// data pointer `data`, and calls `catch_fn` if unwinding occurs while `try_fn` runs.
/// data pointer `data`, and calls `catch_fn` if unwinding occurs while `try_fn` runs. ///
/// /// `catch_fn` must not unwind.
/// `catch_fn` must not unwind. ///
/// /// The third argument is a function called if an unwind occurs (both Rust `panic` and foreign
/// The third argument is a function called if an unwind occurs (both Rust `panic` and foreign /// unwinds). This function takes the data pointer and a pointer to the target- and
/// unwinds). This function takes the data pointer and a pointer to the target- and /// runtime-specific exception object that was caught.
/// runtime-specific exception object that was caught. ///
/// /// Note that in the case of a foreign unwinding operation, the exception object data may not be
/// Note that in the case of a foreign unwinding operation, the exception object data may not be /// safely usable from Rust, and should not be directly exposed via the standard library. To
/// safely usable from Rust, and should not be directly exposed via the standard library. To /// prevent unsafe access, the library implementation may either abort the process or present an
/// prevent unsafe access, the library implementation may either abort the process or present an /// opaque error type to the user.
/// opaque error type to the user. ///
/// /// For more information, see the compiler's source, as well as the documentation for the stable
/// For more information, see the compiler's source, as well as the documentation for the stable /// version of this intrinsic, `std::panic::catch_unwind`.
/// version of this intrinsic, `std::panic::catch_unwind`. #[rustc_intrinsic]
#[rustc_nounwind] #[rustc_intrinsic_must_be_overridden]
pub fn catch_unwind(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32; #[rustc_nounwind]
pub unsafe fn catch_unwind(
_try_fn: fn(*mut u8),
_data: *mut u8,
_catch_fn: fn(*mut u8, *mut u8),
) -> i32 {
unreachable!()
}
/// Emits a `nontemporal` store, which gives a hint to the CPU that the data should not be held /// Emits a `nontemporal` store, which gives a hint to the CPU that the data should not be held
/// in cache. Except for performance, this is fully equivalent to `ptr.write(val)`. /// in cache. Except for performance, this is fully equivalent to `ptr.write(val)`.
/// ///
/// Not all architectures provide such an operation. For instance, x86 does not: while `MOVNT` /// Not all architectures provide such an operation. For instance, x86 does not: while `MOVNT`
/// exists, that operation is *not* equivalent to `ptr.write(val)` (`MOVNT` writes can be reordered /// exists, that operation is *not* equivalent to `ptr.write(val)` (`MOVNT` writes can be reordered
/// in ways that are not allowed for regular writes). /// in ways that are not allowed for regular writes).
#[rustc_nounwind] #[rustc_intrinsic]
pub fn nontemporal_store<T>(ptr: *mut T, val: T); #[rustc_intrinsic_must_be_overridden]
#[rustc_nounwind]
pub unsafe fn nontemporal_store<T>(_ptr: *mut T, _val: T) {
unreachable!()
} }
/// See documentation of `<*const T>::offset_from` for details. /// See documentation of `<*const T>::offset_from` for details.