Skip to content

Commit 079cddd

Browse files
committed
---
yaml --- r: 195839 b: refs/heads/auto c: b85c4d1 h: refs/heads/master i: 195837: d886771 195835: 6b0892f 195831: f445053 195823: f5a2e19 195807: 43298a9 195775: d4099de 195711: 4a90b25 195583: 304231c v: v3
1 parent 46ffb3f commit 079cddd

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
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 1c11748a54027dc5f89185dcbb39ff8996d71515
13+
refs/heads/auto: b85c4d16d52c7f0a3fec5d4ce4d686f0a70fa512
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/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)