Browse Source

WASI: Implement translation for events and subscriptions.

pull/93/head
Dan Gohman 6 years ago
parent
commit
5b77f95284
  1. 8
      wasmtime-wasi/src/syscalls.rs
  2. 168
      wasmtime-wasi/src/translate.rs
  3. 312
      wasmtime-wasi/src/wasm32.rs

8
wasmtime-wasi/src/syscalls.rs

@ -193,8 +193,7 @@ syscalls! {
let e = host::wasmtime_ssp_args_get(argv_environ, host_argv.as_mut_ptr(), host_argv_buf);
encode_charstar_slice(argv, host_argv.as_mut_ptr(), (*argv_environ).argc + 1,
argv_buf, host_argv_buf);
encode_charstar_slice(argv, host_argv, argv_buf, host_argv_buf);
return_encoded_errno(e)
}
@ -327,8 +326,7 @@ syscalls! {
let e = host::wasmtime_ssp_environ_get(argv_environ, host_environ.as_mut_ptr(), host_environ_buf);
encode_charstar_slice(environ, host_environ.as_mut_ptr(), (*argv_environ).environ_count + 1,
environ_buf, host_environ_buf);
encode_charstar_slice(environ, host_environ, environ_buf, host_environ_buf);
return_encoded_errno(e)
}
@ -1376,7 +1374,7 @@ syscalls! {
trace!(" | *out[{}]=...", index);
}
}
encode_event_slice(vmctx, out, host_out).unwrap();
encode_event_slice(vmctx, out, host_out);
return_encoded_errno(e)
}

168
wasmtime-wasi/src/translate.rs

@ -1,7 +1,7 @@
use cast;
use cast::From as _0;
use host;
use std::mem::{align_of, size_of};
use std::mem::{align_of, size_of, zeroed};
use std::slice;
use wasm32;
use wasmtime_runtime::{Export, VMContext};
@ -134,6 +134,22 @@ pub fn encode_linkcount(linkcount: host::__wasi_linkcount_t) -> wasm32::__wasi_l
linkcount
}
pub fn decode_userdata(userdata: wasm32::__wasi_userdata_t) -> host::__wasi_userdata_t {
userdata
}
pub fn encode_userdata(userdata: host::__wasi_userdata_t) -> wasm32::__wasi_userdata_t {
userdata
}
pub fn decode_eventtype(eventtype: wasm32::__wasi_eventtype_t) -> host::__wasi_eventtype_t {
eventtype
}
pub fn encode_eventtype(eventtype: host::__wasi_eventtype_t) -> wasm32::__wasi_eventtype_t {
eventtype
}
pub fn decode_filesize(filesize: wasm32::__wasi_filesize_t) -> host::__wasi_filesize_t {
filesize
}
@ -142,6 +158,24 @@ pub fn encode_filesize(filesize: host::__wasi_filesize_t) -> wasm32::__wasi_file
filesize
}
pub fn decode_eventrwflags(
eventrwflags: wasm32::__wasi_eventrwflags_t,
) -> host::__wasi_eventrwflags_t {
eventrwflags
}
pub fn encode_eventrwflags(
eventrwflags: host::__wasi_eventrwflags_t,
) -> wasm32::__wasi_eventrwflags_t {
eventrwflags
}
pub fn decode_subclockflags(
subclockflags: wasm32::__wasi_subclockflags_t,
) -> host::__wasi_subclockflags_t {
subclockflags
}
pub fn decode_fd(fd: wasm32::__wasi_fd_t) -> host::__wasi_fd_t {
fd
}
@ -261,17 +295,15 @@ pub unsafe fn decode_charstar_slice(
pub unsafe fn encode_charstar_slice(
ptr: *mut wasm32::uintptr_t,
host_ptr: *mut *mut libc::c_char,
count: usize,
host_vec: Vec<*mut libc::c_char>,
guest_base: wasm32::uintptr_t,
host_base: *mut libc::c_char,
) {
for i in 0..count {
let host = host_ptr.add(i).read();
for (i, host) in host_vec.iter().enumerate() {
let guest = if host.is_null() {
0
} else {
guest_base + (host as usize - host_base as usize) as wasm32::uintptr_t
guest_base + (*host as usize - host_base as usize) as wasm32::uintptr_t
};
ptr.add(i).write(guest);
}
@ -319,11 +351,38 @@ pub unsafe fn decode_iovec_slice(
slice.iter().map(|iov| decode_iovec(vmctx, iov)).collect()
}
pub unsafe fn decode_subscription(
_vmctx: &mut VMContext,
_subscription: wasm32::__wasi_subscription_t,
) -> host::__wasi_subscription_t {
unimplemented!("decode_subscription");
pub fn decode_subscription(
guest_subscription: wasm32::__wasi_subscription_t,
) -> Result<host::__wasi_subscription_t, host::__wasi_errno_t> {
let mut host_subscription = host::__wasi_subscription_t {
userdata: decode_userdata(guest_subscription.userdata),
type_: decode_eventtype(guest_subscription.type_),
u: unsafe { zeroed() },
};
match guest_subscription.type_ {
wasm32::__WASI_EVENTTYPE_CLOCK => unsafe {
host_subscription.u.clock =
host::__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t {
identifier: decode_userdata(guest_subscription.u.clock.identifier),
clock_id: decode_clockid(guest_subscription.u.clock.clock_id),
timeout: decode_timestamp(guest_subscription.u.clock.timeout),
precision: decode_timestamp(guest_subscription.u.clock.precision),
flags: decode_subclockflags(guest_subscription.u.clock.flags),
};
},
wasm32::__WASI_EVENTTYPE_FD_READ | wasm32::__WASI_EVENTTYPE_FD_WRITE => unsafe {
host_subscription
.u
.fd_readwrite =
host::__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_fd_readwrite_t {
fd: decode_fd(guest_subscription.u.fd_readwrite.fd),
}
},
_ => return Err(host::__WASI_EINVAL as host::__wasi_errno_t),
};
Ok(host_subscription)
}
pub unsafe fn decode_subscription_slice(
@ -333,17 +392,60 @@ pub unsafe fn decode_subscription_slice(
) -> Result<Vec<host::__wasi_subscription_t>, host::__wasi_errno_t> {
let slice = decode_slice_of::<wasm32::__wasi_subscription_t>(vmctx, ptr, len)?;
let slice = slice::from_raw_parts(slice.0, slice.1);
Ok(slice
slice
.iter()
.map(|subscription| decode_subscription(vmctx, *subscription))
.collect())
.map(|subscription| decode_subscription(*subscription))
.collect()
}
pub fn decode_event(
guest_event: wasm32::__wasi_event_t,
) -> Result<host::__wasi_event_t, host::__wasi_errno_t> {
let mut host_event = host::__wasi_event_t {
userdata: decode_userdata(guest_event.userdata),
error: decode_errno(guest_event.error),
type_: decode_eventtype(guest_event.type_),
u: unsafe { zeroed() },
};
match guest_event.type_ {
wasm32::__WASI_EVENTTYPE_CLOCK => {}
wasm32::__WASI_EVENTTYPE_FD_READ | wasm32::__WASI_EVENTTYPE_FD_WRITE => unsafe {
host_event.u.fd_readwrite =
host::__wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite_t {
nbytes: decode_filesize(guest_event.u.fd_readwrite.nbytes),
flags: decode_eventrwflags(guest_event.u.fd_readwrite.flags),
}
},
_ => return Err(host::__WASI_EINVAL as host::__wasi_errno_t),
};
Ok(host_event)
}
pub unsafe fn decode_event(
_vmctx: &mut VMContext,
_event: wasm32::__wasi_event_t,
) -> host::__wasi_event_t {
unimplemented!("decode_event");
pub fn encode_event(host_event: host::__wasi_event_t) -> wasm32::__wasi_event_t {
let mut guest_event = wasm32::__wasi_event_t {
userdata: encode_userdata(host_event.userdata),
error: encode_errno(host_event.error),
type_: encode_eventtype(host_event.type_),
u: unsafe { zeroed() },
__bindgen_padding_0: 0,
};
match u32::from(host_event.type_) {
host::__WASI_EVENTTYPE_CLOCK => {}
host::__WASI_EVENTTYPE_FD_READ | host::__WASI_EVENTTYPE_FD_WRITE => unsafe {
guest_event.u.fd_readwrite =
wasm32::__wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite_t {
nbytes: encode_filesize(host_event.u.fd_readwrite.nbytes),
flags: encode_eventrwflags(host_event.u.fd_readwrite.flags),
__bindgen_padding_0: zeroed(),
}
},
_ => panic!("unrecognized event type"),
};
guest_event
}
pub unsafe fn decode_event_slice(
@ -353,18 +455,24 @@ pub unsafe fn decode_event_slice(
) -> Result<Vec<host::__wasi_event_t>, host::__wasi_errno_t> {
let slice = decode_slice_of::<wasm32::__wasi_event_t>(vmctx, ptr, len)?;
let slice = slice::from_raw_parts(slice.0, slice.1);
Ok(slice
.iter()
.map(|event| decode_event(vmctx, *event))
.collect())
slice.iter().map(|event| decode_event(*event)).collect()
}
pub unsafe fn encode_event_slice(
_vmctx: &mut VMContext,
_ptr: wasm32::uintptr_t,
_host: Vec<host::__wasi_event_t>,
) -> Result<(), host::__wasi_errno_t> {
unimplemented!("encode_event_slice");
vmctx: &mut VMContext,
ptr: wasm32::uintptr_t,
host_vec: Vec<host::__wasi_event_t>,
) {
for (i, host) in host_vec.iter().enumerate() {
let guest = encode_event(*host);
encode_pointee(
vmctx,
ptr + (i * size_of::<wasm32::__wasi_event_t>()) as u32,
guest,
)
.unwrap();
}
}
pub unsafe fn decode_fd_byref(
@ -556,6 +664,10 @@ pub unsafe fn encode_filestat_byref(
encode_pointee::<wasm32::__wasi_filestat_t>(vmctx, filestat_ptr, wasm32_filestat)
}
pub fn decode_errno(errno: wasm32::__wasi_errno_t) -> host::__wasi_errno_t {
errno
}
pub fn encode_errno(e: host::__wasi_errno_t) -> wasm32::__wasi_errno_t {
assert!(e <= wasm32::__WASI_ENOTCAPABLE);
e

312
wasmtime-wasi/src/wasm32.rs

@ -213,7 +213,144 @@ pub struct __wasi_event_t {
pub error: __wasi_errno_t,
pub type_: __wasi_eventtype_t,
pub __bindgen_padding_0: u32,
pub __bindgen_anon_1: __wasi_event_t__bindgen_ty_1,
pub u: __wasi_event_t___wasi_event_u,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union __wasi_event_t___wasi_event_u {
pub fd_readwrite: __wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite_t,
_bindgen_union_align: [u64; 2usize],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite_t {
pub nbytes: __wasi_filesize_t,
pub flags: __wasi_eventrwflags_t,
pub __bindgen_padding_0: [u16; 3usize],
}
#[test]
fn bindgen_test_layout___wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite_t() {
assert_eq!(
::std::mem::size_of::<__wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite_t>(),
16usize,
concat!(
"Size of: ",
stringify!(__wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite_t)
)
);
assert_eq!(
::std::mem::align_of::<__wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite_t>(),
8usize,
concat!(
"Alignment of ",
stringify!(__wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite_t)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite_t>()))
.nbytes as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite_t),
"::",
stringify!(nbytes)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite_t>()))
.flags as *const _ as usize
},
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_event_t___wasi_event_u___wasi_event_u_fd_readwrite_t),
"::",
stringify!(flags)
)
);
}
#[test]
fn bindgen_test_layout___wasi_event_t___wasi_event_u() {
assert_eq!(
::std::mem::size_of::<__wasi_event_t___wasi_event_u>(),
16usize,
concat!("Size of: ", stringify!(__wasi_event_t___wasi_event_u))
);
assert_eq!(
::std::mem::align_of::<__wasi_event_t___wasi_event_u>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_event_t___wasi_event_u))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_event_t___wasi_event_u>())).fd_readwrite as *const _
as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_event_t___wasi_event_u),
"::",
stringify!(fd_readwrite)
)
);
}
#[test]
fn bindgen_test_layout___wasi_event_t() {
assert_eq!(
::std::mem::size_of::<__wasi_event_t>(),
32usize,
concat!("Size of: ", stringify!(__wasi_event_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_event_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_event_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_event_t>())).userdata as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_event_t),
"::",
stringify!(userdata)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_event_t>())).error as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_event_t),
"::",
stringify!(error)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_event_t>())).type_ as *const _ as usize },
10usize,
concat!(
"Offset of field: ",
stringify!(__wasi_event_t),
"::",
stringify!(type_)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_event_t>())).u as *const _ as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(__wasi_event_t),
"::",
stringify!(u)
)
);
}
#[repr(C)]
#[derive(Copy, Clone)]
@ -731,18 +868,19 @@ pub struct __wasi_subscription_t {
pub userdata: __wasi_userdata_t,
pub type_: __wasi_eventtype_t,
pub __bindgen_padding_0: u32,
pub __bindgen_anon_1: __wasi_subscription_t__bindgen_ty_1,
pub u: __wasi_subscription_t___wasi_subscription_u,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union __wasi_subscription_t__bindgen_ty_1 {
pub clock: __wasi_subscription_t__bindgen_ty_1__bindgen_ty_1,
pub fd_readwrite: __wasi_subscription_t__bindgen_ty_1__bindgen_ty_3,
pub union __wasi_subscription_t___wasi_subscription_u {
pub clock: __wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t,
pub fd_readwrite:
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_fd_readwrite_t,
_bindgen_union_align: [u64; 5usize],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __wasi_subscription_t__bindgen_ty_1__bindgen_ty_1 {
pub struct __wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t {
pub identifier: __wasi_userdata_t,
pub clock_id: __wasi_clockid_t,
pub __bindgen_padding_0: u32,
@ -751,78 +889,99 @@ pub struct __wasi_subscription_t__bindgen_ty_1__bindgen_ty_1 {
pub flags: __wasi_subclockflags_t,
pub __bindgen_padding_1: [u16; 3usize],
}
#[allow(non_snake_case)]
#[test]
fn bindgen_test_layout_wasi_subscription_t__bindgen_ty_1__bindgen_ty_1() {
fn bindgen_test_layout___wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t() {
assert_eq!(
::std::mem::size_of::<__wasi_subscription_t__bindgen_ty_1__bindgen_ty_1>(),
::std::mem::size_of::<
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t,
>(),
40usize,
concat!(
"Size of: ",
stringify!(__wasi_subscription_t__bindgen_ty_1__bindgen_ty_1)
stringify!(__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t)
)
);
assert_eq!(
::std::mem::align_of::<
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t,
>(),
8usize,
concat!(
"Alignment of ",
stringify!(__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_t__bindgen_ty_1__bindgen_ty_1>())).identifier
as *const _ as usize
&(*(::std::ptr::null::<
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t,
>()))
.identifier as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_t__bindgen_ty_1__bindgen_ty_1),
stringify!(__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t),
"::",
stringify!(identifier)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_t__bindgen_ty_1__bindgen_ty_1>())).clock_id
as *const _ as usize
&(*(::std::ptr::null::<
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t,
>()))
.clock_id as *const _ as usize
},
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_t__bindgen_ty_1__bindgen_ty_1),
stringify!(__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t),
"::",
stringify!(clock_id)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_t__bindgen_ty_1__bindgen_ty_1>())).timeout
as *const _ as usize
&(*(::std::ptr::null::<
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t,
>()))
.timeout as *const _ as usize
},
16usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_t__bindgen_ty_1__bindgen_ty_1),
stringify!(__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t),
"::",
stringify!(timeout)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_t__bindgen_ty_1__bindgen_ty_1>())).precision
as *const _ as usize
&(*(::std::ptr::null::<
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t,
>()))
.precision as *const _ as usize
},
24usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_t__bindgen_ty_1__bindgen_ty_1),
stringify!(__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t),
"::",
stringify!(precision)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_t__bindgen_ty_1__bindgen_ty_1>())).flags
as *const _ as usize
&(*(::std::ptr::null::<
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t,
>()))
.flags as *const _ as usize
},
32usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_t__bindgen_ty_1__bindgen_ty_1),
stringify!(__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_clock_t),
"::",
stringify!(flags)
)
@ -830,123 +989,111 @@ fn bindgen_test_layout_wasi_subscription_t__bindgen_ty_1__bindgen_ty_1() {
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __wasi_subscription_t__bindgen_ty_1__bindgen_ty_3 {
pub struct __wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_fd_readwrite_t {
pub fd: __wasi_fd_t,
}
#[allow(non_snake_case)]
#[test]
fn bindgen_test_layout_wasi_subscription_t__bindgen_ty_1__bindgen_ty_3() {
fn bindgen_test_layout___wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_fd_readwrite_t(
) {
assert_eq!(
::std::mem::size_of::<__wasi_subscription_t__bindgen_ty_1__bindgen_ty_3>(),
::std::mem::size_of::<
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_fd_readwrite_t,
>(),
4usize,
concat!(
"Size of: ",
stringify!(__wasi_subscription_t__bindgen_ty_1__bindgen_ty_3)
stringify!(
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_fd_readwrite_t
)
)
);
assert_eq!(
::std::mem::align_of::<__wasi_subscription_t__bindgen_ty_1__bindgen_ty_3>(),
::std::mem::align_of::<
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_fd_readwrite_t,
>(),
4usize,
concat!(
"Alignment of ",
stringify!(__wasi_subscription_t__bindgen_ty_1__bindgen_ty_3)
stringify!(
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_fd_readwrite_t
)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_t__bindgen_ty_1__bindgen_ty_3>())).fd
as *const _ as usize
&(*(::std::ptr::null::<
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_fd_readwrite_t,
>()))
.fd as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_t__bindgen_ty_1__bindgen_ty_3),
stringify!(
__wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_fd_readwrite_t
),
"::",
stringify!(fd)
)
);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __wasi_subscription_t__bindgen_ty_1__bindgen_ty_5 {
pub fd: __wasi_fd_t,
}
#[allow(non_snake_case)]
#[test]
fn bindgen_test_layout_wasi_subscription_t__bindgen_ty_1__bindgen_ty_5() {
fn bindgen_test_layout___wasi_subscription_t___wasi_subscription_u() {
assert_eq!(
::std::mem::size_of::<__wasi_subscription_t__bindgen_ty_1__bindgen_ty_5>(),
4usize,
::std::mem::size_of::<__wasi_subscription_t___wasi_subscription_u>(),
40usize,
concat!(
"Size of: ",
stringify!(__wasi_subscription_t__bindgen_ty_1__bindgen_ty_5)
stringify!(__wasi_subscription_t___wasi_subscription_u)
)
);
assert_eq!(
::std::mem::align_of::<__wasi_subscription_t__bindgen_ty_1__bindgen_ty_5>(),
4usize,
::std::mem::align_of::<__wasi_subscription_t___wasi_subscription_u>(),
8usize,
concat!(
"Alignment of ",
stringify!(__wasi_subscription_t__bindgen_ty_1__bindgen_ty_5)
stringify!(__wasi_subscription_t___wasi_subscription_u)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_t__bindgen_ty_1__bindgen_ty_5>())).fd
&(*(::std::ptr::null::<__wasi_subscription_t___wasi_subscription_u>())).clock
as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_t__bindgen_ty_1__bindgen_ty_5),
"::",
stringify!(fd)
)
);
}
#[allow(non_snake_case)]
#[test]
fn bindgen_test_layout_wasi_subscription_t__bindgen_ty_1() {
assert_eq!(
::std::mem::size_of::<__wasi_subscription_t__bindgen_ty_1>(),
40usize,
concat!("Size of: ", stringify!(__wasi_subscription_t__bindgen_ty_1))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_t__bindgen_ty_1>())).clock as *const _
as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_t__bindgen_ty_1),
stringify!(__wasi_subscription_t___wasi_subscription_u),
"::",
stringify!(clock)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_t__bindgen_ty_1>())).fd_readwrite as *const _
as usize
&(*(::std::ptr::null::<__wasi_subscription_t___wasi_subscription_u>())).fd_readwrite
as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_t__bindgen_ty_1),
stringify!(__wasi_subscription_t___wasi_subscription_u),
"::",
stringify!(fd_readwrite)
)
);
}
#[allow(non_snake_case)]
#[test]
fn bindgen_test_layout_wasi_subscription_t() {
fn bindgen_test_layout___wasi_subscription_t() {
assert_eq!(
::std::mem::size_of::<__wasi_subscription_t>(),
56usize,
concat!("Size of: ", stringify!(__wasi_subscription_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_subscription_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_subscription_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_subscription_t>())).userdata as *const _ as usize },
0usize,
@ -967,8 +1114,17 @@ fn bindgen_test_layout_wasi_subscription_t() {
stringify!(type_)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_subscription_t>())).u as *const _ as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_t),
"::",
stringify!(u)
)
);
}
pub fn strerror(errno: __wasi_errno_t) -> &'static str {
match errno {
__WASI_ESUCCESS => "__WASI_ESUCCESS",

Loading…
Cancel
Save