Skip to content

Commit

Permalink
zircon: update some more zx and lp constants
Browse files Browse the repository at this point in the history
 * 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.
  • Loading branch information
raggi committed Oct 4, 2017
1 parent 17a2a76 commit fb03bb7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
10 changes: 5 additions & 5 deletions src/libstd/sys/unix/process/process_fuchsia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.

use io;
use libc;
use libc::{self, size_t};
use mem;
use ptr;

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
28 changes: 11 additions & 17 deletions src/libstd/sys/unix/process/zircon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
}

Expand Down

0 comments on commit fb03bb7

Please sign in to comment.