summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorMaybe Waffle <waffle.lapkin@gmail.com>2022-08-19 13:26:37 +0400
committerMaybe Waffle <waffle.lapkin@gmail.com>2022-08-21 15:46:03 +0400
commitefef211876b193ebc5e33dc9414c5a3dc14e9739 (patch)
tree14f041a2c9702f9392b9fbf40ed6ff9e9f0d50cd /library/std/src
parented084ba292609da9fe05808f186b72453013c094 (diff)
downloadrust-efef211876b193ebc5e33dc9414c5a3dc14e9739.tar.gz
rust-efef211876b193ebc5e33dc9414c5a3dc14e9739.zip
Make use of `pointer::is_aligned[_to]`
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/lib.rs1
-rw-r--r--library/std/src/sys/sgx/abi/usercalls/alloc.rs4
2 files changed, 3 insertions, 2 deletions
diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs
index a8d6645794a..ab7335e69c9 100644
--- a/library/std/src/lib.rs
+++ b/library/std/src/lib.rs
@@ -284,6 +284,7 @@
 #![feature(panic_can_unwind)]
 #![feature(panic_info_message)]
 #![feature(panic_internals)]
+#![feature(pointer_is_aligned)]
 #![feature(portable_simd)]
 #![feature(prelude_2024)]
 #![feature(provide_any)]
diff --git a/library/std/src/sys/sgx/abi/usercalls/alloc.rs b/library/std/src/sys/sgx/abi/usercalls/alloc.rs
index 66fa1efbf10..a2c8ab7f38d 100644
--- a/library/std/src/sys/sgx/abi/usercalls/alloc.rs
+++ b/library/std/src/sys/sgx/abi/usercalls/alloc.rs
@@ -115,7 +115,7 @@ pub unsafe trait UserSafe {
     /// * the pointer is null.
     /// * the pointed-to range is not in user memory.
     unsafe fn check_ptr(ptr: *const Self) {
-        let is_aligned = |p: *const u8| -> bool { 0 == p.addr() & (Self::align_of() - 1) };
+        let is_aligned = |p: *const u8| -> bool { p.is_aligned_to(Self::align_of()) };
 
         assert!(is_aligned(ptr as *const u8));
         assert!(is_user_range(ptr as _, mem::size_of_val(unsafe { &*ptr })));
@@ -367,7 +367,7 @@ pub(crate) unsafe fn copy_to_userspace(src: *const u8, dst: *mut u8, len: usize)
         unsafe {
             copy_bytewise_to_userspace(src, dst, len);
         }
-    } else if len % 8 == 0 && dst as usize % 8 == 0 {
+    } else if len % 8 == 0 && dst.is_aligned_to(8) {
         // Copying 8-byte aligned quadwords: copy quad word per quad word
         unsafe {
             copy_aligned_quadwords_to_userspace(src, dst, len);