Skip to content

Commit d1aec5f

Browse files
committed
Fix formatting of trusty.rs
1 parent ee94527 commit d1aec5f

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

src/trusty.rs

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
1-
#[cfg(feature = "trusty_sys")]
2-
extern crate trusty_sys;
3-
41
pub use core::ffi::c_void;
52

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-
123
pub type size_t = usize;
134
pub type ssize_t = isize;
145

156
pub type off_t = i64;
167

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;
8+
cfg_if! {
9+
if #[cfg(any(target_arch = "aarch64", target_arch = "arm"))] {
10+
pub type c_char = u8;
11+
} else if #[cfg(target_arch = "x86_64")] {
12+
pub type c_char = i8;
13+
}
14+
}
2115

2216
pub type c_schar = i8;
2317
pub type c_uchar = u8;
@@ -26,15 +20,15 @@ pub type c_ushort = u16;
2620
pub type c_int = i32;
2721
pub type c_uint = u32;
2822

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;
23+
cfg_if! {
24+
if #[cfg(target_pointer_width = "32")] {
25+
pub type c_long = i32;
26+
pub type c_ulong = u32;
27+
} else if #[cfg(target_pointer_width = "64")] {
28+
pub type c_long = i64;
29+
pub type c_ulong = u64;
30+
}
31+
}
3832

3933
pub type c_longlong = i64;
4034
pub type c_ulonglong = u64;
@@ -52,15 +46,21 @@ pub type c_int64_t = i64;
5246
pub type time_t = c_long;
5347

5448
pub type clockid_t = c_int;
55-
pub const CLOCK_REALTIME: clockid_t = 0;
5649

5750
s! {
51+
pub struct iovec {
52+
pub iov_base: *mut ::c_void,
53+
pub iov_len: ::size_t,
54+
}
55+
5856
pub struct timespec {
5957
pub tv_sec: time_t,
6058
pub tv_nsec: c_long,
6159
}
6260
}
6361

62+
pub const CLOCK_REALTIME: clockid_t = 0;
63+
6464
pub const STDOUT_FILENO: ::c_int = 1;
6565
pub const STDERR_FILENO: ::c_int = 2;
6666

@@ -92,10 +92,3 @@ extern "C" {
9292
pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
9393
pub fn nanosleep(rqtp: *const ::timespec, rmtp: *mut ::timespec) -> ::c_int;
9494
}
95-
96-
s! {
97-
pub struct iovec {
98-
pub iov_base: *mut ::c_void,
99-
pub iov_len: ::size_t,
100-
}
101-
}

0 commit comments

Comments
 (0)