From 4e7319cd3f3b0731416ee14666eb583caac75c97 Mon Sep 17 00:00:00 2001 From: lcnr/Bastian Kauschke Date: Mon, 3 Jun 2019 12:59:48 +0200 Subject: add unchecked math intrinsics --- src/libcore/intrinsics.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/libcore') diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 782a7ba4559..31a4e380a3d 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -1240,6 +1240,21 @@ extern "rust-intrinsic" { /// y < 0 or y >= N, where N is the width of T in bits. pub fn unchecked_shr(x: T, y: T) -> T; + /// Returns the result of an unchecked addition, resulting in + /// undefined behavior when `x + y > T::max_value()` or `x + y < T::min_value()`. + #[cfg(not(stage0))] + pub fn unchecked_add(x: T, y: T) -> T; + + /// Returns the result of an unchecked substraction, resulting in + /// undefined behavior when `x - y > T::max_value()` or `x - y < T::min_value()`. + #[cfg(not(stage0))] + pub fn unchecked_sub(x: T, y: T) -> T; + + /// Returns the result of an unchecked multiplication, resulting in + /// undefined behavior when `x * y > T::max_value()` or `x * y < T::min_value()`. + #[cfg(not(stage0))] + pub fn unchecked_mul(x: T, y: T) -> T; + /// Performs rotate left. /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `rotate_left` method. For example, -- cgit 1.4.1-3-g733a5