Skip to content

Commit fb03bb7

Browse files
committed
zircon: update some more zx and lp constants
* Use size_t where size_t is used, while it's not critical on our specifically supported architectures, this is more accurate. * Update HND_SPECIAL_COUNT to the correct value, and give it the size that enum is likely to be.
1 parent 17a2a76 commit fb03bb7

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

src/libstd/sys/unix/process/process_fuchsia.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use io;
12-
use libc;
12+
use libc::{self, size_t};
1313
use mem;
1414
use ptr;
1515

@@ -148,8 +148,8 @@ impl Process {
148148
use sys::process::zircon::*;
149149

150150
let mut proc_info: zx_info_process_t = Default::default();
151-
let mut actual: zx_size_t = 0;
152-
let mut avail: zx_size_t = 0;
151+
let mut actual: size_t = 0;
152+
let mut avail: size_t = 0;
153153

154154
unsafe {
155155
zx_cvt(zx_object_wait_one(self.handle.raw(), ZX_TASK_TERMINATED,
@@ -171,8 +171,8 @@ impl Process {
171171
use sys::process::zircon::*;
172172

173173
let mut proc_info: zx_info_process_t = Default::default();
174-
let mut actual: zx_size_t = 0;
175-
let mut avail: zx_size_t = 0;
174+
let mut actual: size_t = 0;
175+
let mut avail: size_t = 0;
176176

177177
unsafe {
178178
let status = zx_object_wait_one(self.handle.raw(), ZX_TASK_TERMINATED,

src/libstd/sys/unix/process/zircon.rs

+11-17
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,13 @@ use io;
1515
use os::raw::c_char;
1616
use u64;
1717

18-
use libc::{c_int, c_void};
18+
use libc::{c_int, c_void, size_t};
1919

2020
pub type zx_handle_t = u32;
2121
pub type zx_vaddr_t = usize;
2222
pub type zx_rights_t = u32;
2323
pub type zx_status_t = i32;
2424

25-
// TODO(raggi): zx_size_t was removed from Zircon. various syscall API docs use size_t here, but
26-
// don't define that well at the ABI level yet, as the C spec definition of size_t isn't what is
27-
// meant. In the future Zirocn will define size_t more strictly for it's ABI. At that time,
28-
// zx_size_t should be removed here, and replaced with an appropriately sized type with a
29-
// sufficiently strict definition.
30-
pub type zx_size_t = usize;
31-
3225
pub const ZX_HANDLE_INVALID: zx_handle_t = 0;
3326

3427
pub type zx_time_t = u64;
@@ -120,36 +113,37 @@ extern {
120113
pending: *mut zx_signals_t) -> zx_status_t;
121114

122115
pub fn zx_object_get_info(handle: zx_handle_t, topic: u32, buffer: *mut c_void,
123-
buffer_size: zx_size_t, actual_size: *mut zx_size_t,
124-
avail: *mut zx_size_t) -> zx_status_t;
116+
buffer_size: size_t, actual_size: *mut size_t,
117+
avail: *mut size_t) -> zx_status_t;
125118
}
126119

127120
// From `enum special_handles` in system/ulib/launchpad/launchpad.c
128121
// HND_LOADER_SVC = 0
129122
// HND_EXEC_VMO = 1
130-
pub const HND_SPECIAL_COUNT: usize = 2;
123+
// HND_SEGMENTS_VMAR = 2
124+
const HND_SPECIAL_COUNT: c_int = 3;
131125

132126
#[repr(C)]
133127
pub struct launchpad_t {
134128
argc: u32,
135129
envc: u32,
136130
args: *const c_char,
137-
args_len: usize,
131+
args_len: size_t,
138132
env: *const c_char,
139-
env_len: usize,
133+
env_len: size_t,
140134

141135
handles: *mut zx_handle_t,
142136
handles_info: *mut u32,
143-
handle_count: usize,
144-
handle_alloc: usize,
137+
handle_count: size_t,
138+
handle_alloc: size_t,
145139

146140
entry: zx_vaddr_t,
147141
base: zx_vaddr_t,
148142
vdso_base: zx_vaddr_t,
149143

150-
stack_size: usize,
144+
stack_size: size_t,
151145

152-
special_handles: [zx_handle_t; HND_SPECIAL_COUNT],
146+
special_handles: [zx_handle_t; HND_SPECIAL_COUNT as usize],
153147
loader_message: bool,
154148
}
155149

0 commit comments

Comments
 (0)