Skip to content

Commit 8874550

Browse files
committed
---
yaml --- r: 196085 b: refs/heads/beta c: b85c4d1 h: refs/heads/master i: 196083: 54dc8ef v: v3
1 parent 3e83b6f commit 8874550

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2929
refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3030
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
3131
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
32-
refs/heads/beta: 1c11748a54027dc5f89185dcbb39ff8996d71515
32+
refs/heads/beta: b85c4d16d52c7f0a3fec5d4ce4d686f0a70fa512
3333
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3434
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
3535
refs/heads/tmp: 9de34a84bb300bab1bf0227f577331620cd60511

branches/beta/src/libcore/num/wrapping.rs

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use intrinsics::{i16_mul_with_overflow, u16_mul_with_overflow};
3030
use intrinsics::{i32_mul_with_overflow, u32_mul_with_overflow};
3131
use intrinsics::{i64_mul_with_overflow, u64_mul_with_overflow};
3232

33-
use ::{i8,i16,i32,i64,u8,u16,u32,u64};
33+
use ::{i8,i16,i32,i64};
3434

3535
#[unstable(feature = "core", reason = "may be removed, renamed, or relocated")]
3636
#[deprecated(since = "1.0.0", reason = "moved to inherent methods")]
@@ -206,7 +206,7 @@ mod shift_max {
206206
pub const u64: u32 = i64;
207207
}
208208

209-
macro_rules! overflowing_impl {
209+
macro_rules! signed_overflowing_impl {
210210
($($t:ident)*) => ($(
211211
impl OverflowingOps for $t {
212212
#[inline(always)]
@@ -259,7 +259,53 @@ macro_rules! overflowing_impl {
259259
)*)
260260
}
261261

262-
overflowing_impl! { u8 u16 u32 u64 i8 i16 i32 i64 }
262+
macro_rules! unsigned_overflowing_impl {
263+
($($t:ident)*) => ($(
264+
impl OverflowingOps for $t {
265+
#[inline(always)]
266+
fn overflowing_add(self, rhs: $t) -> ($t, bool) {
267+
unsafe {
268+
concat_idents!($t, _add_with_overflow)(self, rhs)
269+
}
270+
}
271+
#[inline(always)]
272+
fn overflowing_sub(self, rhs: $t) -> ($t, bool) {
273+
unsafe {
274+
concat_idents!($t, _sub_with_overflow)(self, rhs)
275+
}
276+
}
277+
#[inline(always)]
278+
fn overflowing_mul(self, rhs: $t) -> ($t, bool) {
279+
unsafe {
280+
concat_idents!($t, _mul_with_overflow)(self, rhs)
281+
}
282+
}
283+
284+
#[inline(always)]
285+
fn overflowing_div(self, rhs: $t) -> ($t, bool) {
286+
(self/rhs, false)
287+
}
288+
#[inline(always)]
289+
fn overflowing_rem(self, rhs: $t) -> ($t, bool) {
290+
(self % rhs, false)
291+
}
292+
293+
#[inline(always)]
294+
fn overflowing_shl(self, rhs: u32) -> ($t, bool) {
295+
(self << (rhs & self::shift_max::$t),
296+
(rhs > self::shift_max::$t))
297+
}
298+
#[inline(always)]
299+
fn overflowing_shr(self, rhs: u32) -> ($t, bool) {
300+
(self >> (rhs & self::shift_max::$t),
301+
(rhs > self::shift_max::$t))
302+
}
303+
}
304+
)*)
305+
}
306+
307+
signed_overflowing_impl! { i8 i16 i32 i64 }
308+
unsigned_overflowing_impl! { u8 u16 u32 u64 }
263309

264310
#[cfg(target_pointer_width = "64")]
265311
impl OverflowingOps for usize {

0 commit comments

Comments
 (0)