From e38d185870fed75c485db72bf3f4a4bafb7dbb0b Mon Sep 17 00:00:00 2001
From: 4lDO2 <4lDO2@protonmail.com>
Date: Wed, 8 Jul 2020 17:28:09 +0200
Subject: [PATCH] Use fmap2 to support passing an address.

---
 src/platform/redox/mod.rs | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/platform/redox/mod.rs b/src/platform/redox/mod.rs
index 58117dd3..4b561831 100644
--- a/src/platform/redox/mod.rs
+++ b/src/platform/redox/mod.rs
@@ -1,7 +1,7 @@
 use core::{mem, ptr, result::Result as CoreResult, slice};
 use syscall::{
     self,
-    data::{Map, Stat as redox_stat, StatVfs as redox_statvfs, TimeSpec as redox_timespec},
+    data::{Map2, Stat as redox_stat, StatVfs as redox_statvfs, TimeSpec as redox_timespec},
     PtraceEvent, Result,
 };
 
@@ -658,19 +658,20 @@ impl Pal for Sys {
     }
 
     unsafe fn mmap(
-        _addr: *mut c_void,
+        addr: *mut c_void,
         len: usize,
         prot: c_int,
         flags: c_int,
         fildes: c_int,
         off: off_t,
     ) -> *mut c_void {
-        let map = Map {
+        let map = Map2 {
             offset: off as usize,
             size: len,
             flags: syscall::MapFlags::from_bits_truncate(
                 ((prot as usize) << 16) | ((flags as usize) & 0xFFFF),
             ),
+            address: addr as usize,
         };
 
         if flags & MAP_ANON == MAP_ANON {
@@ -682,13 +683,13 @@ impl Pal for Sys {
                 return !0 as *mut c_void;
             }
 
-            let addr = e(syscall::fmap(fd, &map)) as *mut c_void;
+            let addr = e(syscall::fmap2(fd, &map)) as *mut c_void;
 
             let _ = syscall::close(fd);
 
             addr
         } else {
-            e(syscall::fmap(fildes as usize, &map)) as *mut c_void
+            e(syscall::fmap2(fildes as usize, &map)) as *mut c_void
         }
     }
 
-- 
GitLab