diff --git a/src/int/mod.rs b/src/int/mod.rs index 1ce3d92da..a03e33dc5 100644 --- a/src/int/mod.rs +++ b/src/int/mod.rs @@ -429,14 +429,14 @@ macro_rules! impl_wide_int { fn wide_shift_left(&mut self, low: &mut Self, count: i32) { *self = (*self << count) | (*low >> ($bits - count)); - *low = *low << count; + *low <<= count; } fn wide_shift_right_with_sticky(&mut self, low: &mut Self, count: i32) { if count < $bits { let sticky = *low << ($bits - count); *low = *self << ($bits - count) | *low >> count | sticky; - *self = *self >> count; + *self >>= count; } else if count < 2 * $bits { let sticky = *self << (2 * $bits - count) | *low; *low = *self >> (count - $bits) | sticky; diff --git a/src/mem/impls.rs b/src/mem/impls.rs index 6bd1a7ba1..b3eef9901 100644 --- a/src/mem/impls.rs +++ b/src/mem/impls.rs @@ -1,10 +1,8 @@ -use super::c_int; - #[inline(always)] pub unsafe fn copy_forward(dest: *mut u8, src: *const u8, n: usize) { let mut i = 0; while i < n { - *dest.offset(i as isize) = *src.offset(i as isize); + *dest.add(i) = *src.add(i); i += 1; } } @@ -15,7 +13,7 @@ pub unsafe fn copy_backward(dest: *mut u8, src: *const u8, n: usize) { let mut i = n; while i != 0 { i -= 1; - *dest.offset(i as isize) = *src.offset(i as isize); + *dest.add(i) = *src.add(i); } } @@ -23,7 +21,7 @@ pub unsafe fn copy_backward(dest: *mut u8, src: *const u8, n: usize) { pub unsafe fn set_bytes(s: *mut u8, c: u8, n: usize) { let mut i = 0; while i < n { - *s.offset(i as isize) = c; + *s.add(i) = c; i += 1; } } diff --git a/src/mem/mod.rs b/src/mem/mod.rs index adb7c2c64..107762c43 100644 --- a/src/mem/mod.rs +++ b/src/mem/mod.rs @@ -45,8 +45,8 @@ pub unsafe extern "C" fn memset(s: *mut u8, c: c_int, n: usize) -> *mut u8 { pub unsafe extern "C" fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 { let mut i = 0; while i < n { - let a = *s1.offset(i as isize); - let b = *s2.offset(i as isize); + let a = *s1.add(i); + let b = *s2.add(i); if a != b { return a as i32 - b as i32; } diff --git a/src/mem/x86_64.rs b/src/mem/x86_64.rs index 7eefd8099..8cbbdf779 100644 --- a/src/mem/x86_64.rs +++ b/src/mem/x86_64.rs @@ -59,8 +59,8 @@ pub unsafe fn copy_backward(dest: *mut u8, src: *const u8, count: usize) { "cld", byte_count = in(reg) byte_count, inout("rcx") qword_count => _, - inout("rdi") dest.offset(count as isize).wrapping_sub(8) => _, - inout("rsi") src.offset(count as isize).wrapping_sub(8) => _, + inout("rdi") dest.add(count).wrapping_sub(8) => _, + inout("rsi") src.add(count).wrapping_sub(8) => _, options(nostack) ); }