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 pub const CLOCK_REALTIME: clockid_t = 0; 56 pub struct timespec { 57 pub tv_sec: time_t, 58 pub tv_nsec: c_long, 59 } 60 61 pub const STDOUT_FILENO: ::c_int = 1; 62 pub const STDERR_FILENO: ::c_int = 2; 63 64 pub const AT_PAGESZ: ::c_ulong = 6; 65 66 pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; 67 68 extern "C" { calloc(nobj: size_t, size: size_t) -> *mut c_void69 pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; malloc(size: size_t) -> *mut c_void70 pub fn malloc(size: size_t) -> *mut c_void; realloc(p: *mut c_void, size: size_t) -> *mut c_void71 pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; free(p: *mut c_void)72 pub fn free(p: *mut c_void); memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void73 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_int74 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_t75 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_t76 pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t; close(fd: ::c_int) -> ::c_int77 pub fn close(fd: ::c_int) -> ::c_int; strlen(cs: *const c_char) -> size_t78 pub fn strlen(cs: *const c_char) -> size_t; getauxval(type_: c_ulong) -> c_ulong79 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_void80 pub fn mmap( 81 addr: *mut ::c_void, 82 len: ::size_t, 83 prot: ::c_int, 84 flags: ::c_int, 85 fd: ::c_int, 86 offset: off_t, 87 ) -> *mut ::c_void; munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int88 pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int; clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int89 pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; nanosleep(rqtp: *const ::timespec, rmtp: *mut ::timespec) -> ::c_int90 pub fn nanosleep(rqtp: *const ::timespec, rmtp: *mut ::timespec) -> ::c_int; 91 } 92 93 s! { 94 pub struct iovec { 95 pub iov_base: *mut ::c_void, 96 pub iov_len: ::size_t, 97 } 98 } 99