diff options
author | Nicole LeGare <legare@google.com> | 2022-12-14 00:08:53 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-12-14 00:08:53 +0000 |
commit | 88bbcc13f66b3b25654c5512a3b2889c3735fd15 (patch) | |
tree | c5f84d71e0b79683c689a57287afb019d5260655 | |
parent | 77353f0ea12a3c61fc4334ed35bd113a0d6a42b7 (diff) | |
parent | 5f37120dd5b91eeaded3db15f71e14bc4f02bd5d (diff) | |
download | libc-88bbcc13f66b3b25654c5512a3b2889c3735fd15.tar.gz |
PATCH: Add mmap API for Trusty am: 5f37120dd5
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/libc/+/2345046
Change-Id: I39becd69e9b54ffbb9a924ba3e1882cc60ddf9b9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | patches/trusty-001.patch (renamed from patches/trusty.patch) | 0 | ||||
-rw-r--r-- | patches/trusty-002.patch | 53 | ||||
-rw-r--r-- | src/trusty.rs | 16 |
3 files changed, 69 insertions, 0 deletions
diff --git a/patches/trusty.patch b/patches/trusty-001.patch index 7fb0cbf0..7fb0cbf0 100644 --- a/patches/trusty.patch +++ b/patches/trusty-001.patch diff --git a/patches/trusty-002.patch b/patches/trusty-002.patch new file mode 100644 index 00000000..3297fea6 --- /dev/null +++ b/patches/trusty-002.patch @@ -0,0 +1,53 @@ +From 899aaaeeb0887a36d247df9fddaab8eca634a5c3 Mon Sep 17 00:00:00 2001 +From: Nicole LeGare <legare@google.com> +Date: Mon, 12 Dec 2022 18:42:21 +0000 +Subject: [PATCH] PATCH: Add mmap API for Trusty + +Change-Id: Ib9d576533be631c8f5e7cd21a3916e269f713cd1 +--- + src/trusty.rs | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/src/trusty.rs b/src/trusty.rs +index c7e4e4fa..7791a84a 100644 +--- a/src/trusty.rs ++++ b/src/trusty.rs +@@ -3,6 +3,8 @@ pub use core::ffi::c_void; + pub type size_t = usize; + pub type ssize_t = isize; + ++pub type off_t = i64; ++ + #[cfg(any(target_arch = "aarch64", target_arch = "arm"))] + pub type c_char = u8; + #[cfg(target_arch = "x86_64")] +@@ -43,6 +45,10 @@ pub type time_t = c_long; + pub const STDOUT_FILENO: ::c_int = 1; + pub const STDERR_FILENO: ::c_int = 2; + ++pub const AT_PAGESZ: ::c_ulong = 6; ++ ++pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; ++ + extern "C" { + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + pub fn malloc(size: size_t) -> *mut c_void; +@@ -53,6 +59,16 @@ extern "C" { + pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) -> ::ssize_t; + pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t; + pub fn strlen(cs: *const c_char) -> size_t; ++ pub fn getauxval(type_: c_ulong) -> c_ulong; ++ pub fn mmap( ++ addr: *mut ::c_void, ++ len: ::size_t, ++ prot: ::c_int, ++ flags: ::c_int, ++ fd: ::c_int, ++ offset: off_t, ++ ) -> *mut ::c_void; ++ pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int; + } + + s! { +-- +2.39.0.rc1.256.g54fd8350bd-goog diff --git a/src/trusty.rs b/src/trusty.rs index c7e4e4fa..e1508119 100644 --- a/src/trusty.rs +++ b/src/trusty.rs @@ -3,6 +3,8 @@ pub use core::ffi::c_void; pub type size_t = usize; pub type ssize_t = isize; +pub type off_t = i64; + #[cfg(any(target_arch = "aarch64", target_arch = "arm"))] pub type c_char = u8; #[cfg(target_arch = "x86_64")] @@ -43,6 +45,10 @@ pub type time_t = c_long; pub const STDOUT_FILENO: ::c_int = 1; pub const STDERR_FILENO: ::c_int = 2; +pub const AT_PAGESZ: ::c_ulong = 6; + +pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; + extern "C" { pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; pub fn malloc(size: size_t) -> *mut c_void; @@ -53,6 +59,16 @@ extern "C" { pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) -> ::ssize_t; pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t; pub fn strlen(cs: *const c_char) -> size_t; + pub fn getauxval(type_: c_ulong) -> c_ulong; + pub fn mmap( + addr: *mut ::c_void, + len: ::size_t, + prot: ::c_int, + flags: ::c_int, + fd: ::c_int, + offset: off_t, + ) -> *mut ::c_void; + pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int; } s! { |