1 #[cfg(feature = "trusty_sys")] 2 extern crate trusty_sys; 3 4 pub use core::ffi::c_void; 5 6 #[cfg(feature = "trusty_sys")] 7 pub const PROT_READ: i32 = self::trusty_sys::MMAP_FLAG_PROT_READ as i32; 8 9 #[cfg(feature = "trusty_sys")] 10 pub const PROT_WRITE: i32 = self::trusty_sys::MMAP_FLAG_PROT_WRITE as i32; 11 12 pub type size_t = usize; 13 pub type ssize_t = isize; 14 15 pub type off_t = i64; 16 17 #[cfg(any(target_arch = "aarch64", target_arch = "arm"))] 18 pub type c_char = u8; 19 #[cfg(target_arch = "x86_64")] 20 pub type c_char = i8; 21 22 pub type c_schar = i8; 23 pub type c_uchar = u8; 24 pub type c_short = i16; 25 pub type c_ushort = u16; 26 pub type c_int = i32; 27 pub type c_uint = u32; 28 29 #[cfg(target_pointer_width = "32")] 30 pub type c_long = i32; 31 #[cfg(target_pointer_width = "64")] 32 pub type c_long = i64; 33 34 #[cfg(target_pointer_width = "32")] 35 pub type c_ulong = u32; 36 #[cfg(target_pointer_width = "64")] 37 pub type c_ulong = u64; 38 39 pub type c_longlong = i64; 40 pub type c_ulonglong = u64; 41 42 pub type c_uint8_t = u8; 43 pub type c_uint16_t = u16; 44 pub type c_uint32_t = u32; 45 pub type c_uint64_t = u64; 46 47 pub type c_int8_t = i8; 48 pub type c_int16_t = i16; 49 pub type c_int32_t = i32; 50 pub type c_int64_t = i64; 51 52 pub type time_t = c_long; 53 54 pub type clockid_t = c_int; 55 56 // Trusty only supports CLOCK_BOOTTIME 57 pub const CLOCK_BOOTTIME: clockid_t = 7; 58 pub struct timespec { 59 pub tv_sec: time_t, 60 pub tv_nsec: c_long, 61 } 62 63 pub const STDOUT_FILENO: ::c_int = 1; 64 pub const STDERR_FILENO: ::c_int = 2; 65 66 pub const AT_PAGESZ: ::c_ulong = 6; 67 68 pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; 69 70 extern "C" { calloc(nobj: size_t, size: size_t) -> *mut c_void71 pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; malloc(size: size_t) -> *mut c_void72 pub fn malloc(size: size_t) -> *mut c_void; realloc(p: *mut c_void, size: size_t) -> *mut c_void73 pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; free(p: *mut c_void)74 pub fn free(p: *mut c_void); memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void75 pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; posix_memalign(memptr: *mut *mut ::c_void, align: ::size_t, size: ::size_t) -> ::c_int76 pub fn posix_memalign(memptr: *mut *mut ::c_void, align: ::size_t, size: ::size_t) -> ::c_int; write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) -> ::ssize_t77 pub fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) -> ::ssize_t; writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t78 pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t; close(fd: ::c_int) -> ::c_int79 pub fn close(fd: ::c_int) -> ::c_int; strlen(cs: *const c_char) -> size_t80 pub fn strlen(cs: *const c_char) -> size_t; getauxval(type_: c_ulong) -> c_ulong81 pub fn getauxval(type_: c_ulong) -> c_ulong; mmap( addr: *mut ::c_void, len: ::size_t, prot: ::c_int, flags: ::c_int, fd: ::c_int, offset: off_t, ) -> *mut ::c_void82 pub fn mmap( 83 addr: *mut ::c_void, 84 len: ::size_t, 85 prot: ::c_int, 86 flags: ::c_int, 87 fd: ::c_int, 88 offset: off_t, 89 ) -> *mut ::c_void; munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int90 pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int; clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int91 pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; nanosleep(rqtp: *const ::timespec, rmtp: *mut ::timespec) -> ::c_int92 pub fn nanosleep(rqtp: *const ::timespec, rmtp: *mut ::timespec) -> ::c_int; 93 } 94 95 s! { 96 pub struct iovec { 97 pub iov_base: *mut ::c_void, 98 pub iov_len: ::size_t, 99 } 100 } 101