|
5 | 5 | #![feature(cfg_target_has_atomic)]
|
6 | 6 | #![feature(compiler_builtins)]
|
7 | 7 | #![feature(core_ffi_c)]
|
8 |
| -#![feature(core_intrinsics)] |
| 8 | +#![feature(intrinsics)] |
| 9 | +#![feature(rustc_attrs)] |
9 | 10 | #![feature(inline_const)]
|
10 | 11 | #![feature(lang_items)]
|
11 | 12 | #![feature(linkage)]
|
@@ -80,3 +81,50 @@ pub mod x86;
|
80 | 81 | pub mod x86_64;
|
81 | 82 |
|
82 | 83 | pub mod probestack;
|
| 84 | + |
| 85 | +// `core` is changing the feature name for the `intrinsics` module. |
| 86 | +// To permit that transition, we avoid using that feature for now. |
| 87 | +mod intrinsics { |
| 88 | + extern "rust-intrinsic" { |
| 89 | + #[rustc_nounwind] |
| 90 | + pub fn atomic_load_unordered<T: Copy>(src: *const T) -> T; |
| 91 | + |
| 92 | + #[rustc_nounwind] |
| 93 | + pub fn atomic_store_unordered<T: Copy>(dst: *mut T, val: T); |
| 94 | + |
| 95 | + /// Informs the optimizer that this point in the code is not reachable, |
| 96 | + /// enabling further optimizations. |
| 97 | + /// |
| 98 | + /// N.B., this is very different from the `unreachable!()` macro: Unlike the |
| 99 | + /// macro, which panics when it is executed, it is *undefined behavior* to |
| 100 | + /// reach code marked with this function. |
| 101 | + /// |
| 102 | + /// The stabilized version of this intrinsic is [`core::hint::unreachable_unchecked`]. |
| 103 | + #[rustc_nounwind] |
| 104 | + pub fn unreachable() -> !; |
| 105 | + |
| 106 | + /// Performs an exact division, resulting in undefined behavior where |
| 107 | + /// `x % y != 0` or `y == 0` or `x == T::MIN && y == -1` |
| 108 | + /// |
| 109 | + /// This intrinsic does not have a stable counterpart. |
| 110 | + #[rustc_nounwind] |
| 111 | + pub fn exact_div<T: Copy>(x: T, y: T) -> T; |
| 112 | + |
| 113 | + /// Performs an unchecked division, resulting in undefined behavior |
| 114 | + /// where `y == 0` or `x == T::MIN && y == -1` |
| 115 | + /// |
| 116 | + /// Safe wrappers for this intrinsic are available on the integer |
| 117 | + /// primitives via the `checked_div` method. For example, |
| 118 | + /// [`u32::checked_div`] |
| 119 | + #[rustc_nounwind] |
| 120 | + pub fn unchecked_div<T: Copy>(x: T, y: T) -> T; |
| 121 | + /// Returns the remainder of an unchecked division, resulting in |
| 122 | + /// undefined behavior when `y == 0` or `x == T::MIN && y == -1` |
| 123 | + /// |
| 124 | + /// Safe wrappers for this intrinsic are available on the integer |
| 125 | + /// primitives via the `checked_rem` method. For example, |
| 126 | + /// [`u32::checked_rem`] |
| 127 | + #[rustc_nounwind] |
| 128 | + pub fn unchecked_rem<T: Copy>(x: T, y: T) -> T; |
| 129 | + } |
| 130 | +} |
0 commit comments