From fb03bb72b9c5e46d98726ba520ba08fe8ba2082f Mon Sep 17 00:00:00 2001 From: James Tucker Date: Wed, 4 Oct 2017 15:29:01 -0700 Subject: [PATCH] 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. --- .../sys/unix/process/process_fuchsia.rs | 10 +++---- src/libstd/sys/unix/process/zircon.rs | 28 ++++++++----------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/libstd/sys/unix/process/process_fuchsia.rs b/src/libstd/sys/unix/process/process_fuchsia.rs index 5d34da04446f1..a7a67ed36e823 100644 --- a/src/libstd/sys/unix/process/process_fuchsia.rs +++ b/src/libstd/sys/unix/process/process_fuchsia.rs @@ -9,7 +9,7 @@ // except according to those terms. use io; -use libc; +use libc::{self, size_t}; use mem; use ptr; @@ -148,8 +148,8 @@ impl Process { use sys::process::zircon::*; let mut proc_info: zx_info_process_t = Default::default(); - let mut actual: zx_size_t = 0; - let mut avail: zx_size_t = 0; + let mut actual: size_t = 0; + let mut avail: size_t = 0; unsafe { zx_cvt(zx_object_wait_one(self.handle.raw(), ZX_TASK_TERMINATED, @@ -171,8 +171,8 @@ impl Process { use sys::process::zircon::*; let mut proc_info: zx_info_process_t = Default::default(); - let mut actual: zx_size_t = 0; - let mut avail: zx_size_t = 0; + let mut actual: size_t = 0; + let mut avail: size_t = 0; unsafe { let status = zx_object_wait_one(self.handle.raw(), ZX_TASK_TERMINATED, diff --git a/src/libstd/sys/unix/process/zircon.rs b/src/libstd/sys/unix/process/zircon.rs index 8d0ad30f9c8ba..90864e6ef3ff2 100644 --- a/src/libstd/sys/unix/process/zircon.rs +++ b/src/libstd/sys/unix/process/zircon.rs @@ -15,20 +15,13 @@ use io; use os::raw::c_char; use u64; -use libc::{c_int, c_void}; +use libc::{c_int, c_void, size_t}; pub type zx_handle_t = u32; pub type zx_vaddr_t = usize; pub type zx_rights_t = u32; pub type zx_status_t = i32; -// TODO(raggi): zx_size_t was removed from Zircon. various syscall API docs use size_t here, but -// don't define that well at the ABI level yet, as the C spec definition of size_t isn't what is -// meant. In the future Zirocn will define size_t more strictly for it's ABI. At that time, -// zx_size_t should be removed here, and replaced with an appropriately sized type with a -// sufficiently strict definition. -pub type zx_size_t = usize; - pub const ZX_HANDLE_INVALID: zx_handle_t = 0; pub type zx_time_t = u64; @@ -120,36 +113,37 @@ extern { pending: *mut zx_signals_t) -> zx_status_t; pub fn zx_object_get_info(handle: zx_handle_t, topic: u32, buffer: *mut c_void, - buffer_size: zx_size_t, actual_size: *mut zx_size_t, - avail: *mut zx_size_t) -> zx_status_t; + buffer_size: size_t, actual_size: *mut size_t, + avail: *mut size_t) -> zx_status_t; } // From `enum special_handles` in system/ulib/launchpad/launchpad.c // HND_LOADER_SVC = 0 // HND_EXEC_VMO = 1 -pub const HND_SPECIAL_COUNT: usize = 2; +// HND_SEGMENTS_VMAR = 2 +const HND_SPECIAL_COUNT: c_int = 3; #[repr(C)] pub struct launchpad_t { argc: u32, envc: u32, args: *const c_char, - args_len: usize, + args_len: size_t, env: *const c_char, - env_len: usize, + env_len: size_t, handles: *mut zx_handle_t, handles_info: *mut u32, - handle_count: usize, - handle_alloc: usize, + handle_count: size_t, + handle_alloc: size_t, entry: zx_vaddr_t, base: zx_vaddr_t, vdso_base: zx_vaddr_t, - stack_size: usize, + stack_size: size_t, - special_handles: [zx_handle_t; HND_SPECIAL_COUNT], + special_handles: [zx_handle_t; HND_SPECIAL_COUNT as usize], loader_message: bool, }