|
| 1 | +From dc028fa4f316bec221c9b59d02a1c2648bb1cbbd Mon Sep 17 00:00:00 2001 |
| 2 | +From: David LeGare <legare@google.com> |
| 3 | +Date: Mon, 23 May 2022 17:58:51 +0000 |
| 4 | +Subject: [PATCH] Add support for the Trusty OS |
| 5 | + |
| 6 | +--- |
| 7 | + src/lib.rs | 6 ++++++ |
| 8 | + src/trusty.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ |
| 9 | + 2 files changed, 52 insertions(+) |
| 10 | + create mode 100644 src/trusty.rs |
| 11 | + |
| 12 | +diff --git a/src/lib.rs b/src/lib.rs |
| 13 | +index d87d0d8e1..2eeb88c83 100644 |
| 14 | +--- a/src/lib.rs |
| 15 | ++++ b/src/lib.rs |
| 16 | +@@ -141,6 +141,12 @@ cfg_if! { |
| 17 | + |
| 18 | + mod hermit; |
| 19 | + pub use hermit::*; |
| 20 | ++ } else if #[cfg(target_os = "trusty")] { |
| 21 | ++ mod fixed_width_ints; |
| 22 | ++ pub use fixed_width_ints::*; |
| 23 | ++ |
| 24 | ++ mod trusty; |
| 25 | ++ pub use trusty::*; |
| 26 | + } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] { |
| 27 | + mod fixed_width_ints; |
| 28 | + pub use fixed_width_ints::*; |
| 29 | +diff --git a/src/trusty.rs b/src/trusty.rs |
| 30 | +new file mode 100644 |
| 31 | +index 000000000..2b7d57285 |
| 32 | +--- /dev/null |
| 33 | ++++ b/src/trusty.rs |
| 34 | +@@ -0,0 +1,46 @@ |
| 35 | ++pub use core::ffi::c_void; |
| 36 | ++ |
| 37 | ++pub type size_t = usize; |
| 38 | ++ |
| 39 | ++#[cfg(any(target_arch = "aarch64", target_arch = "arm"))] |
| 40 | ++pub type c_char = u8; |
| 41 | ++#[cfg(target_arch = "x86_64")] |
| 42 | ++pub type c_char = i8; |
| 43 | ++ |
| 44 | ++pub type c_schar = i8; |
| 45 | ++pub type c_uchar = u8; |
| 46 | ++pub type c_short = i16; |
| 47 | ++pub type c_ushort = u16; |
| 48 | ++pub type c_int = i32; |
| 49 | ++pub type c_uint = u32; |
| 50 | ++ |
| 51 | ++#[cfg(target_pointer_width = "32")] |
| 52 | ++pub type c_long = i32; |
| 53 | ++#[cfg(target_pointer_width = "64")] |
| 54 | ++pub type c_long = i64; |
| 55 | ++ |
| 56 | ++#[cfg(target_pointer_width = "32")] |
| 57 | ++pub type c_ulong = u32; |
| 58 | ++#[cfg(target_pointer_width = "64")] |
| 59 | ++pub type c_ulong = u64; |
| 60 | ++ |
| 61 | ++pub type c_longlong = i64; |
| 62 | ++pub type c_ulonglong = u64; |
| 63 | ++ |
| 64 | ++pub type c_uint8_t = u8; |
| 65 | ++pub type c_uint16_t = u16; |
| 66 | ++pub type c_uint32_t = u32; |
| 67 | ++pub type c_uint64_t = u64; |
| 68 | ++ |
| 69 | ++pub type c_int8_t = i8; |
| 70 | ++pub type c_int16_t = i16; |
| 71 | ++pub type c_int32_t = i32; |
| 72 | ++pub type c_int64_t = i64; |
| 73 | ++ |
| 74 | ++extern "C" { |
| 75 | ++ pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; |
| 76 | ++ pub fn malloc(size: size_t) -> *mut c_void; |
| 77 | ++ pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; |
| 78 | ++ pub fn free(p: *mut c_void); |
| 79 | ++ pub fn posix_memalign(memptr: *mut *mut ::c_void, align: ::size_t, size: ::size_t) -> ::c_int; |
| 80 | ++} |
| 81 | +-- |
| 82 | +2.36.1.124.g0e6072fb45-goog |
| 83 | + |
0 commit comments