]> git.lizzy.rs Git - rust.git/blobdiff - src/libstd/sys/sgx/abi/mem.rs
Add `std::os::fortanix_sgx` module
[rust.git] / src / libstd / sys / sgx / abi / mem.rs
index bf32c712216bc35ab84f1839a1bf84a30195254f..11eb64606c43ed104eaffdb329620995f450ee68 100644 (file)
 
 // Do not remove inline: will result in relocation failure
 #[inline(always)]
-pub unsafe fn rel_ptr<T>(offset: u64) -> *const T {
+pub(crate) unsafe fn rel_ptr<T>(offset: u64) -> *const T {
     (image_base() + offset) as *const T
 }
 
 // Do not remove inline: will result in relocation failure
 #[inline(always)]
-pub unsafe fn rel_ptr_mut<T>(offset: u64) -> *mut T {
+pub(crate) unsafe fn rel_ptr_mut<T>(offset: u64) -> *mut T {
     (image_base() + offset) as *mut T
 }
 
@@ -34,6 +34,17 @@ fn image_base() -> u64 {
     base
 }
 
+/// Returns `true` if the specified memory range is in the enclave.
+#[unstable(feature = "sgx_platform", issue = "56975")]
+pub fn is_enclave_range(p: *const u8, len: usize) -> bool {
+    let start=p as u64;
+    let end=start + (len as u64);
+    start >= image_base() &&
+        end <= image_base() + (unsafe { ENCLAVE_SIZE } as u64) // unsafe ok: link-time constant
+}
+
+/// Returns `true` if the specified memory range is in userspace.
+#[unstable(feature = "sgx_platform", issue = "56975")]
 pub fn is_user_range(p: *const u8, len: usize) -> bool {
     let start=p as u64;
     let end=start + (len as u64);