Upgrade to witx 0.8.0 with tagged unions (#921)

* witx tagged unions: updates to wig to use new semantics

* wig: emit a `#variant: ()` union variant for empty variants

* wasi-common: translate to use tagged unions

* update to flattened layout of event struct

* wig: generate layout tests, and delete bindgen ones

the bindgen tests became out-of-date with the latest changes to the
representation of unions, and the re-jiggering of various struct
definitions that went along with it.

* wasi: point at master with tagged union PR merged

* fix event struct repr on windows
This commit is contained in:
Pat Hickey
2020-02-20 07:52:03 -08:00
committed by GitHub
parent 80b095f2e2
commit 4460e569cf
19 changed files with 270 additions and 2170 deletions

View File

@@ -78,91 +78,3 @@ impl Dirent {
Ok(raw)
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn bindgen_test_layout___wasi_prestat_t() {
assert_eq!(
::std::mem::size_of::<__wasi_prestat_t>(),
16usize,
concat!("Size of: ", stringify!(__wasi_prestat_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_prestat_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_prestat_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_prestat_t>())).pr_type as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_prestat_t),
"::",
stringify!(pr_type)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_prestat_t>())).u as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_prestat_t),
"::",
stringify!(u)
)
);
}
#[test]
fn bindgen_test_layout___wasi_prestat_t___wasi_prestat_u___wasi_prestat_u_dir_t() {
assert_eq!(
::std::mem::size_of::<__wasi_prestat_dir_t>(),
8usize,
concat!("Size of: ", stringify!(__wasi_prestat_dir_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_prestat_dir_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_prestat_dir_t))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_prestat_dir_t>())).pr_name_len as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_prestat_dir_t),
"::",
stringify!(pr_name_len)
)
);
}
#[test]
fn bindgen_test_layout___wasi_prestat_t___wasi_prestat_u() {
assert_eq!(
::std::mem::size_of::<__wasi_prestat_u_t>(),
8usize,
concat!("Size of: ", stringify!(__wasi_prestat_u))
);
assert_eq!(
::std::mem::align_of::<__wasi_prestat_u_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_prestat_u))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_prestat_u_t>())).dir as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_prestat_u_t),
"::",
stringify!(dir)
)
);
}
}

View File

@@ -1002,7 +1002,7 @@ pub(crate) unsafe fn fd_prestat_get(
memory,
prestat_ptr,
host::__wasi_prestat_t {
pr_type: wasi::__WASI_PREOPENTYPE_DIR,
tag: wasi::__WASI_PREOPENTYPE_DIR,
u: host::__wasi_prestat_u_t {
dir: host::__wasi_prestat_dir_t {
pr_name_len: path.len(),

View File

@@ -225,9 +225,9 @@ pub(crate) fn poll_oneoff(
return Err(Error::EINVAL);
}
for subscription in subscriptions {
match subscription.r#type {
match subscription.u.tag {
wasi::__WASI_EVENTTYPE_CLOCK => {
let clock = unsafe { subscription.u.clock };
let clock = unsafe { subscription.u.u.clock };
let delay = wasi_clock_to_relative_ns_delay(clock)?;
log::debug!("poll_oneoff event.u.clock = {:?}", clock);
@@ -242,17 +242,9 @@ pub(crate) fn poll_oneoff(
*timeout = current;
}
}
r#type
if r#type == wasi::__WASI_EVENTTYPE_FD_READ
|| r#type == wasi::__WASI_EVENTTYPE_FD_WRITE =>
{
let wasi_fd = unsafe { subscription.u.fd_readwrite.file_descriptor };
let rights = if r#type == wasi::__WASI_EVENTTYPE_FD_READ {
wasi::__WASI_RIGHTS_FD_READ | wasi::__WASI_RIGHTS_POLL_FD_READWRITE
} else {
wasi::__WASI_RIGHTS_FD_WRITE | wasi::__WASI_RIGHTS_POLL_FD_READWRITE
};
wasi::__WASI_EVENTTYPE_FD_READ => {
let wasi_fd = unsafe { subscription.u.u.fd_read.file_descriptor };
let rights = wasi::__WASI_RIGHTS_FD_READ | wasi::__WASI_RIGHTS_POLL_FD_READWRITE;
match unsafe {
wasi_ctx
.get_fd_entry(wasi_fd)
@@ -260,25 +252,52 @@ pub(crate) fn poll_oneoff(
} {
Ok(descriptor) => fd_events.push(FdEventData {
descriptor,
r#type: subscription.r#type,
r#type: wasi::__WASI_EVENTTYPE_FD_READ,
userdata: subscription.userdata,
}),
Err(err) => {
let event = wasi::__wasi_event_t {
userdata: subscription.userdata,
r#type,
error: err.as_wasi_error().as_raw_errno(),
u: wasi::__wasi_event_u_t {
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: 0,
},
r#type: wasi::__WASI_EVENTTYPE_FD_READ,
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: 0,
},
};
events.push(event);
}
};
}
wasi::__WASI_EVENTTYPE_FD_WRITE => {
let wasi_fd = unsafe { subscription.u.u.fd_write.file_descriptor };
let rights = wasi::__WASI_RIGHTS_FD_WRITE | wasi::__WASI_RIGHTS_POLL_FD_READWRITE;
match unsafe {
wasi_ctx
.get_fd_entry(wasi_fd)
.and_then(|fe| fe.as_descriptor(rights, 0))
} {
Ok(descriptor) => fd_events.push(FdEventData {
descriptor,
r#type: wasi::__WASI_EVENTTYPE_FD_WRITE,
userdata: subscription.userdata,
}),
Err(err) => {
let event = wasi::__wasi_event_t {
userdata: subscription.userdata,
error: err.as_wasi_error().as_raw_errno(),
r#type: wasi::__WASI_EVENTTYPE_FD_WRITE,
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: 0,
},
};
events.push(event);
}
};
}
_ => unreachable!(),
}
}

View File

@@ -329,9 +329,9 @@ pub(crate) fn dec_prestat_byref(
) -> Result<host::__wasi_prestat_t> {
let raw = dec_raw_byref::<wasi32::__wasi_prestat_t>(memory, prestat_ptr)?;
match PrimInt::from_le(raw.pr_type) {
match PrimInt::from_le(raw.tag) {
wasi::__WASI_PREOPENTYPE_DIR => Ok(host::__wasi_prestat_t {
pr_type: wasi::__WASI_PREOPENTYPE_DIR,
tag: wasi::__WASI_PREOPENTYPE_DIR,
u: host::__wasi_prestat_u_t {
dir: host::__wasi_prestat_dir_t {
pr_name_len: dec_usize(PrimInt::from_le(unsafe { raw.u.dir.pr_name_len })),
@@ -347,9 +347,9 @@ pub(crate) fn enc_prestat_byref(
prestat_ptr: wasi32::uintptr_t,
prestat: host::__wasi_prestat_t,
) -> Result<()> {
let raw = match prestat.pr_type {
let raw = match prestat.tag {
wasi::__WASI_PREOPENTYPE_DIR => Ok(wasi32::__wasi_prestat_t {
pr_type: PrimInt::to_le(wasi::__WASI_PREOPENTYPE_DIR),
tag: PrimInt::to_le(wasi::__WASI_PREOPENTYPE_DIR),
u: wasi32::__wasi_prestat_u_t {
dir: wasi32::__wasi_prestat_dir_t {
pr_name_len: enc_usize(unsafe { prestat.u.dir.pr_name_len }),
@@ -410,10 +410,10 @@ pub(crate) fn dec_subscriptions(
.into_iter()
.map(|raw_subscription| {
let userdata = PrimInt::from_le(raw_subscription.userdata);
let r#type = PrimInt::from_le(raw_subscription.r#type);
let raw_u = raw_subscription.u;
let u = match r#type {
wasi::__WASI_EVENTTYPE_CLOCK => wasi::__wasi_subscription_u_t {
let tag = PrimInt::from_le(raw_subscription.u.tag);
let raw_u = raw_subscription.u.u;
let u = match tag {
wasi::__WASI_EVENTTYPE_CLOCK => wasi::__wasi_subscription_u_u_t {
clock: unsafe {
wasi::__wasi_subscription_clock_t {
id: PrimInt::from_le(raw_u.clock.id),
@@ -423,21 +423,23 @@ pub(crate) fn dec_subscriptions(
}
},
},
wasi::__WASI_EVENTTYPE_FD_READ | wasi::__WASI_EVENTTYPE_FD_WRITE => {
wasi::__wasi_subscription_u_t {
fd_readwrite: wasi::__wasi_subscription_fd_readwrite_t {
file_descriptor: PrimInt::from_le(unsafe {
raw_u.fd_readwrite.file_descriptor
}),
},
}
}
wasi::__WASI_EVENTTYPE_FD_READ => wasi::__wasi_subscription_u_u_t {
fd_read: wasi::__wasi_subscription_fd_readwrite_t {
file_descriptor: PrimInt::from_le(unsafe { raw_u.fd_read.file_descriptor }),
},
},
wasi::__WASI_EVENTTYPE_FD_WRITE => wasi::__wasi_subscription_u_u_t {
fd_write: wasi::__wasi_subscription_fd_readwrite_t {
file_descriptor: PrimInt::from_le(unsafe {
raw_u.fd_write.file_descriptor
}),
},
},
_ => return Err(Error::EINVAL),
};
Ok(wasi::__wasi_subscription_t {
userdata,
r#type,
u,
u: wasi::__wasi_subscription_u_t { tag, u },
})
})
.collect::<Result<Vec<_>>>()
@@ -456,17 +458,16 @@ pub(crate) fn enc_events(
*raw_output_iter
.next()
.expect("the number of events cannot exceed the number of subscriptions") = {
let fd_readwrite = unsafe { event.u.fd_readwrite };
let userdata = PrimInt::to_le(event.userdata);
let error = PrimInt::to_le(event.error);
let r#type = PrimInt::to_le(event.r#type);
let flags = PrimInt::to_le(event.fd_readwrite.flags);
let nbytes = PrimInt::to_le(event.fd_readwrite.nbytes);
wasi::__wasi_event_t {
userdata: PrimInt::to_le(event.userdata),
r#type: PrimInt::to_le(event.r#type),
error: PrimInt::to_le(event.error),
u: wasi::__wasi_event_u_t {
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: PrimInt::to_le(fd_readwrite.nbytes),
flags: PrimInt::to_le(fd_readwrite.flags),
},
},
userdata,
error,
r#type,
fd_readwrite: wasi::__wasi_event_fd_readwrite_t { flags, nbytes },
}
};
}

View File

@@ -78,91 +78,3 @@ impl Dirent {
Ok(raw)
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn bindgen_test_layout___wasi_prestat_t() {
assert_eq!(
::std::mem::size_of::<__wasi_prestat_t>(),
16usize,
concat!("Size of: ", stringify!(__wasi_prestat_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_prestat_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_prestat_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_prestat_t>())).pr_type as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_prestat_t),
"::",
stringify!(pr_type)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_prestat_t>())).u as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_prestat_t),
"::",
stringify!(u)
)
);
}
#[test]
fn bindgen_test_layout___wasi_prestat_t___wasi_prestat_u___wasi_prestat_u_dir_t() {
assert_eq!(
::std::mem::size_of::<__wasi_prestat_dir_t>(),
8usize,
concat!("Size of: ", stringify!(__wasi_prestat_dir_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_prestat_dir_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_prestat_dir_t))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_prestat_dir_t>())).pr_name_len as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_prestat_dir_t),
"::",
stringify!(pr_name_len)
)
);
}
#[test]
fn bindgen_test_layout___wasi_prestat_t___wasi_prestat_u() {
assert_eq!(
::std::mem::size_of::<__wasi_prestat_u_t>(),
8usize,
concat!("Size of: ", stringify!(__wasi_prestat_u_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_prestat_u_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_prestat_u_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_prestat_u_t>())).dir as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_prestat_u_t),
"::",
stringify!(dir)
)
);
}
}

View File

@@ -985,7 +985,7 @@ pub(crate) unsafe fn fd_prestat_get(
memory,
prestat_ptr,
host::__wasi_prestat_t {
pr_type: wasi::__WASI_PREOPENTYPE_DIR,
tag: wasi::__WASI_PREOPENTYPE_DIR,
u: host::__wasi_prestat_u_t {
dir: host::__wasi_prestat_dir_t {
pr_name_len: path.len(),

View File

@@ -219,9 +219,9 @@ pub(crate) fn poll_oneoff(
let mut timeout: Option<ClockEventData> = None;
let mut fd_events = Vec::new();
for subscription in subscriptions {
match subscription.r#type {
match subscription.u.tag {
wasi::__WASI_EVENTTYPE_CLOCK => {
let clock = unsafe { subscription.u.clock };
let clock = unsafe { subscription.u.u.clock };
let delay = wasi_clock_to_relative_ns_delay(clock)?;
log::debug!("poll_oneoff event.u.clock = {:?}", clock);
@@ -236,17 +236,10 @@ pub(crate) fn poll_oneoff(
*timeout = current;
}
}
r#type
if r#type == wasi::__WASI_EVENTTYPE_FD_READ
|| r#type == wasi::__WASI_EVENTTYPE_FD_WRITE =>
{
let wasi_fd = unsafe { subscription.u.fd_readwrite.file_descriptor };
let rights = if r#type == wasi::__WASI_EVENTTYPE_FD_READ {
wasi::__WASI_RIGHTS_FD_READ
} else {
wasi::__WASI_RIGHTS_FD_WRITE
};
wasi::__WASI_EVENTTYPE_FD_READ => {
let wasi_fd = unsafe { subscription.u.u.fd_read.file_descriptor };
let rights = wasi::__WASI_RIGHTS_FD_READ | wasi::__WASI_RIGHTS_POLL_FD_READWRITE;
match unsafe {
wasi_ctx
.get_fd_entry(wasi_fd)
@@ -254,19 +247,45 @@ pub(crate) fn poll_oneoff(
} {
Ok(descriptor) => fd_events.push(FdEventData {
descriptor,
r#type: subscription.r#type,
r#type: wasi::__WASI_EVENTTYPE_FD_READ,
userdata: subscription.userdata,
}),
Err(err) => {
let event = wasi::__wasi_event_t {
userdata: subscription.userdata,
r#type,
error: err.as_wasi_error().as_raw_errno(),
u: wasi::__wasi_event_u_t {
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: 0,
},
r#type: wasi::__WASI_EVENTTYPE_FD_READ,
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: 0,
},
};
events.push(event);
}
};
}
wasi::__WASI_EVENTTYPE_FD_WRITE => {
let wasi_fd = unsafe { subscription.u.u.fd_write.file_descriptor };
let rights = wasi::__WASI_RIGHTS_FD_WRITE | wasi::__WASI_RIGHTS_POLL_FD_READWRITE;
match unsafe {
wasi_ctx
.get_fd_entry(wasi_fd)
.and_then(|fe| fe.as_descriptor(rights, 0))
} {
Ok(descriptor) => fd_events.push(FdEventData {
descriptor,
r#type: wasi::__WASI_EVENTTYPE_FD_WRITE,
userdata: subscription.userdata,
}),
Err(err) => {
let event = wasi::__wasi_event_t {
userdata: subscription.userdata,
error: err.as_wasi_error().as_raw_errno(),
r#type: wasi::__WASI_EVENTTYPE_FD_WRITE,
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: 0,
},
};
events.push(event);

View File

@@ -329,9 +329,9 @@ pub(crate) fn dec_prestat_byref(
) -> Result<host::__wasi_prestat_t> {
let raw = dec_raw_byref::<wasi32::__wasi_prestat_t>(memory, prestat_ptr)?;
match PrimInt::from_le(raw.pr_type) {
match PrimInt::from_le(raw.tag) {
wasi::__WASI_PREOPENTYPE_DIR => Ok(host::__wasi_prestat_t {
pr_type: wasi::__WASI_PREOPENTYPE_DIR,
tag: wasi::__WASI_PREOPENTYPE_DIR,
u: host::__wasi_prestat_u_t {
dir: host::__wasi_prestat_dir_t {
pr_name_len: dec_usize(PrimInt::from_le(unsafe { raw.u.dir.pr_name_len })),
@@ -347,9 +347,9 @@ pub(crate) fn enc_prestat_byref(
prestat_ptr: wasi32::uintptr_t,
prestat: host::__wasi_prestat_t,
) -> Result<()> {
let raw = match prestat.pr_type {
let raw = match prestat.tag {
wasi::__WASI_PREOPENTYPE_DIR => Ok(wasi32::__wasi_prestat_t {
pr_type: PrimInt::to_le(wasi::__WASI_PREOPENTYPE_DIR),
tag: PrimInt::to_le(wasi::__WASI_PREOPENTYPE_DIR),
u: wasi32::__wasi_prestat_u_t {
dir: wasi32::__wasi_prestat_dir_t {
pr_name_len: enc_usize(unsafe { prestat.u.dir.pr_name_len }),
@@ -410,10 +410,10 @@ pub(crate) fn dec_subscriptions(
.into_iter()
.map(|raw_subscription| {
let userdata = PrimInt::from_le(raw_subscription.userdata);
let r#type = PrimInt::from_le(raw_subscription.r#type);
let raw_u = raw_subscription.u;
let u = match r#type {
wasi::__WASI_EVENTTYPE_CLOCK => wasi::__wasi_subscription_u_t {
let tag = PrimInt::from_le(raw_subscription.u.tag);
let raw_u = raw_subscription.u.u;
let u = match tag {
wasi::__WASI_EVENTTYPE_CLOCK => wasi::__wasi_subscription_u_u_t {
clock: unsafe {
wasi::__wasi_subscription_clock_t {
identifier: PrimInt::from_le(raw_u.clock.identifier),
@@ -424,21 +424,23 @@ pub(crate) fn dec_subscriptions(
}
},
},
wasi::__WASI_EVENTTYPE_FD_READ | wasi::__WASI_EVENTTYPE_FD_WRITE => {
wasi::__wasi_subscription_u_t {
fd_readwrite: wasi::__wasi_subscription_fd_readwrite_t {
file_descriptor: PrimInt::from_le(unsafe {
raw_u.fd_readwrite.file_descriptor
}),
},
}
}
wasi::__WASI_EVENTTYPE_FD_READ => wasi::__wasi_subscription_u_u_t {
fd_read: wasi::__wasi_subscription_fd_readwrite_t {
file_descriptor: PrimInt::from_le(unsafe { raw_u.fd_read.file_descriptor }),
},
},
wasi::__WASI_EVENTTYPE_FD_WRITE => wasi::__wasi_subscription_u_u_t {
fd_write: wasi::__wasi_subscription_fd_readwrite_t {
file_descriptor: PrimInt::from_le(unsafe {
raw_u.fd_write.file_descriptor
}),
},
},
_ => return Err(Error::EINVAL),
};
Ok(wasi::__wasi_subscription_t {
userdata,
r#type,
u,
u: wasi::__wasi_subscription_u_t { tag, u },
})
})
.collect::<Result<Vec<_>>>()
@@ -457,17 +459,16 @@ pub(crate) fn enc_events(
*raw_output_iter
.next()
.expect("the number of events cannot exceed the number of subscriptions") = {
let fd_readwrite = unsafe { event.u.fd_readwrite };
let userdata = PrimInt::to_le(event.userdata);
let error = PrimInt::to_le(event.error);
let r#type = PrimInt::to_le(event.r#type);
let flags = PrimInt::to_le(event.fd_readwrite.flags);
let nbytes = PrimInt::to_le(event.fd_readwrite.nbytes);
wasi::__wasi_event_t {
userdata: PrimInt::to_le(event.userdata),
r#type: PrimInt::to_le(event.r#type),
error: PrimInt::to_le(event.error),
u: wasi::__wasi_event_u_t {
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: PrimInt::to_le(fd_readwrite.nbytes),
flags: PrimInt::to_le(fd_readwrite.flags),
},
},
userdata,
error,
r#type,
fd_readwrite: wasi::__wasi_event_fd_readwrite_t { flags, nbytes },
}
};
}

View File

@@ -111,13 +111,11 @@ fn poll_oneoff_handle_timeout_event(
) {
events.push(wasi::__wasi_event_t {
userdata: timeout.userdata,
r#type: wasi::__WASI_EVENTTYPE_CLOCK,
error: wasi::__WASI_ERRNO_SUCCESS,
u: wasi::__wasi_event_u_t {
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: 0,
},
r#type: wasi::__WASI_EVENTTYPE_CLOCK,
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
flags: 0,
nbytes: 0,
},
});
}
@@ -149,49 +147,41 @@ fn poll_oneoff_handle_fd_event<'a>(
let output_event = if revents.contains(PollFlags::POLLNVAL) {
wasi::__wasi_event_t {
userdata: fd_event.userdata,
r#type: fd_event.r#type,
error: wasi::__WASI_ERRNO_BADF,
u: wasi::__wasi_event_u_t {
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: wasi::__WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP,
},
r#type: fd_event.r#type,
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: wasi::__WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP,
},
}
} else if revents.contains(PollFlags::POLLERR) {
wasi::__wasi_event_t {
userdata: fd_event.userdata,
r#type: fd_event.r#type,
error: wasi::__WASI_ERRNO_IO,
u: wasi::__wasi_event_u_t {
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: wasi::__WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP,
},
r#type: fd_event.r#type,
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: wasi::__WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP,
},
}
} else if revents.contains(PollFlags::POLLHUP) {
wasi::__wasi_event_t {
userdata: fd_event.userdata,
r#type: fd_event.r#type,
error: wasi::__WASI_ERRNO_SUCCESS,
u: wasi::__wasi_event_u_t {
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: wasi::__WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP,
},
r#type: fd_event.r#type,
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: wasi::__WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP,
},
}
} else if revents.contains(PollFlags::POLLIN) | revents.contains(PollFlags::POLLOUT) {
wasi::__wasi_event_t {
userdata: fd_event.userdata,
r#type: fd_event.r#type,
error: wasi::__WASI_ERRNO_SUCCESS,
u: wasi::__wasi_event_u_t {
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: nbytes.try_into()?,
flags: 0,
},
r#type: fd_event.r#type,
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: nbytes.try_into()?,
flags: 0,
},
}
} else {

View File

@@ -117,758 +117,3 @@ pub fn whence_to_str(whence: __wasi_whence_t) -> &'static str {
}
pub const __WASI_DIRCOOKIE_START: __wasi_dircookie_t = 0;
#[cfg(test)]
mod test {
use super::*;
#[test]
fn bindgen_test_layout_wasi_dirent_t() {
assert_eq!(
::std::mem::size_of::<__wasi_dirent_t>(),
24usize,
concat!("Size of: ", stringify!(__wasi_dirent_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_dirent_t>())).d_next as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_dirent_t),
"::",
stringify!(d_next)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_dirent_t>())).d_ino as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_dirent_t),
"::",
stringify!(d_ino)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_dirent_t>())).d_namlen as *const _ as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(__wasi_dirent_t),
"::",
stringify!(d_namlen)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_dirent_t>())).d_type as *const _ as usize },
20usize,
concat!(
"Offset of field: ",
stringify!(__wasi_dirent_t),
"::",
stringify!(d_type)
)
);
}
#[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_fd_readwrite_t>(),
16usize,
concat!("Size of: ", stringify!(__wasi_event_fd_readwrite_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_event_fd_readwrite_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_event_fd_readwrite_t))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_event_fd_readwrite_t>())).nbytes as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_event_fd_readwrite_t),
"::",
stringify!(nbytes)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_event_fd_readwrite_t>())).flags as *const _ as usize
},
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_event_fd_readwrite_t),
"::",
stringify!(flags)
)
);
}
#[test]
fn bindgen_test_layout___wasi_event_t___wasi_event_u() {
assert_eq!(
::std::mem::size_of::<__wasi_event_u_t>(),
16usize,
concat!("Size of: ", stringify!(__wasi_event_u_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_event_u_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_event_u_t))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_event_u_t>())).fd_readwrite as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_event_u_t),
"::",
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>())).r#type as *const _ as usize },
10usize,
concat!(
"Offset of field: ",
stringify!(__wasi_event_t),
"::",
stringify!(r#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)
)
);
}
#[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!(
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>())).r#type as *const _ as usize },
10usize,
concat!(
"Offset of field: ",
stringify!(__wasi_event_t),
"::",
stringify!(r#type)
)
);
}
#[test]
fn bindgen_test_layout_wasi_fdstat_t() {
assert_eq!(
::std::mem::size_of::<__wasi_fdstat_t>(),
24usize,
concat!("Size of: ", stringify!(__wasi_fdstat_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_fdstat_t>())).fs_filetype as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_fdstat_t),
"::",
stringify!(fs_filetype)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_fdstat_t>())).fs_flags as *const _ as usize },
2usize,
concat!(
"Offset of field: ",
stringify!(__wasi_fdstat_t),
"::",
stringify!(fs_flags)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_fdstat_t>())).fs_rights_base as *const _ as usize
},
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_fdstat_t),
"::",
stringify!(fs_rights_base)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_fdstat_t>())).fs_rights_inheriting as *const _
as usize
},
16usize,
concat!(
"Offset of field: ",
stringify!(__wasi_fdstat_t),
"::",
stringify!(fs_rights_inheriting)
)
);
}
#[test]
fn bindgen_test_layout_wasi_filestat_t() {
assert_eq!(
::std::mem::size_of::<__wasi_filestat_t>(),
56usize,
concat!("Size of: ", stringify!(__wasi_filestat_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).dev as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_dev)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).ino as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_ino)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).filetype as *const _ as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_filetype)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).nlink as *const _ as usize },
20usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_nlink)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).size as *const _ as usize },
24usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_size)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).atim as *const _ as usize },
32usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_atim)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).mtim as *const _ as usize },
40usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_mtim)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).ctim as *const _ as usize },
48usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_ctim)
)
);
}
#[test]
fn bindgen_test_layout___wasi_subscription_clock_t() {
assert_eq!(
::std::mem::size_of::<__wasi_subscription_clock_t>(),
40usize,
concat!("Size of: ", stringify!(__wasi_subscription_clock_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_subscription_clock_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_subscription_clock_t))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_clock_t>())).identifier as *const _
as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_clock_t),
"::",
stringify!(identifier)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_clock_t>())).id as *const _ as usize
},
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_clock_t),
"::",
stringify!(clock_id)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_clock_t>())).timeout as *const _ as usize
},
16usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_clock_t),
"::",
stringify!(timeout)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_clock_t>())).precision as *const _
as usize
},
24usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_clock_t),
"::",
stringify!(precision)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_clock_t>())).flags as *const _ as usize
},
32usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_clock_t),
"::",
stringify!(flags)
)
);
}
#[test]
fn bindgen_test_layout___wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_fd_readwrite_t(
) {
assert_eq!(
::std::mem::size_of::<__wasi_subscription_fd_readwrite_t>(),
4usize,
concat!("Size of: ", stringify!(__wasi_subscription_fd_readwrite_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_subscription_fd_readwrite_t>(),
4usize,
concat!(
"Alignment of ",
stringify!(__wasi_subscription_fd_readwrite_t)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_fd_readwrite_t>())).file_descriptor
as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_fd_readwrite_t),
"::",
stringify!(fd)
)
);
}
#[test]
fn bindgen_test_layout___wasi_subscription_t___wasi_subscription_u() {
assert_eq!(
::std::mem::size_of::<__wasi_subscription_u_t>(),
40usize,
concat!("Size of: ", stringify!(__wasi_subscription_u_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_subscription_u_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_subscription_u_t))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_u_t>())).clock as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_u_t),
"::",
stringify!(clock)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_u_t>())).fd_readwrite as *const _
as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_u_t),
"::",
stringify!(fd_readwrite)
)
);
}
#[test]
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,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_t),
"::",
stringify!(userdata)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_t>())).r#type as *const _ as usize
},
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_t),
"::",
stringify!(r#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)
)
);
}
#[test]
fn bindgen_test_layout___wasi_filestat_t() {
assert_eq!(
::std::mem::size_of::<__wasi_filestat_t>(),
56usize,
concat!("Size of: ", stringify!(__wasi_filestat_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_filestat_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_filestat_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).dev as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_dev)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).ino as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_ino)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).filetype as *const _ as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_filetype)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).nlink as *const _ as usize },
20usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_nlink)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).size as *const _ as usize },
24usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_size)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).atim as *const _ as usize },
32usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_atim)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).mtim as *const _ as usize },
40usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_mtim)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).ctim as *const _ as usize },
48usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_ctim)
)
);
}
#[test]
fn bindgen_test_layout___wasi_fdstat_t() {
assert_eq!(
::std::mem::size_of::<__wasi_fdstat_t>(),
24usize,
concat!("Size of: ", stringify!(__wasi_fdstat_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_fdstat_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_fdstat_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_fdstat_t>())).fs_filetype as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_fdstat_t),
"::",
stringify!(fs_filetype)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_fdstat_t>())).fs_flags as *const _ as usize },
2usize,
concat!(
"Offset of field: ",
stringify!(__wasi_fdstat_t),
"::",
stringify!(fs_flags)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_fdstat_t>())).fs_rights_base as *const _ as usize
},
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_fdstat_t),
"::",
stringify!(fs_rights_base)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_fdstat_t>())).fs_rights_inheriting as *const _
as usize
},
16usize,
concat!(
"Offset of field: ",
stringify!(__wasi_fdstat_t),
"::",
stringify!(fs_rights_inheriting)
)
);
}
#[test]
fn bindgen_test_layout___wasi_dirent_t() {
assert_eq!(
::std::mem::size_of::<__wasi_dirent_t>(),
24usize,
concat!("Size of: ", stringify!(__wasi_dirent_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_dirent_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_dirent_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_dirent_t>())).d_next as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_dirent_t),
"::",
stringify!(d_next)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_dirent_t>())).d_ino as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_dirent_t),
"::",
stringify!(d_ino)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_dirent_t>())).d_namlen as *const _ as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(__wasi_dirent_t),
"::",
stringify!(d_namlen)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_dirent_t>())).d_type as *const _ as usize },
20usize,
concat!(
"Offset of field: ",
stringify!(__wasi_dirent_t),
"::",
stringify!(d_type)
)
);
}
}

View File

@@ -13,160 +13,3 @@ pub type uintptr_t = u32;
pub type size_t = u32;
witx_wasi32_types!("old/snapshot_0" "wasi_unstable");
#[cfg(test)]
mod test {
use super::*;
#[test]
fn bindgen_test_layout_wasi_ciovec_t() {
assert_eq!(
::std::mem::size_of::<__wasi_ciovec_t>(),
8usize,
concat!("Size of: ", stringify!(__wasi_ciovec_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_ciovec_t>(),
4usize,
concat!("Alignment of ", stringify!(__wasi_ciovec_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_ciovec_t>())).buf as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_ciovec_t),
"::",
stringify!(buf)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_ciovec_t>())).buf_len as *const _ as usize },
4usize,
concat!(
"Offset of field: ",
stringify!(__wasi_ciovec_t),
"::",
stringify!(buf_len)
)
);
}
#[test]
fn bindgen_test_layout_wasi_iovec_t() {
assert_eq!(
::std::mem::size_of::<__wasi_iovec_t>(),
8usize,
concat!("Size of: ", stringify!(__wasi_iovec_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_iovec_t>(),
4usize,
concat!("Alignment of ", stringify!(__wasi_iovec_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_iovec_t>())).buf as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_iovec_t),
"::",
stringify!(buf)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_iovec_t>())).buf_len as *const _ as usize },
4usize,
concat!(
"Offset of field: ",
stringify!(__wasi_iovec_t),
"::",
stringify!(buf_len)
)
);
}
#[test]
fn bindgen_test_layout___wasi_prestat_t___wasi_prestat_u___wasi_prestat_u_dir_t() {
assert_eq!(
::std::mem::size_of::<__wasi_prestat_dir_t>(),
4usize,
concat!("Size of: ", stringify!(__wasi_prestat_dir_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_prestat_dir_t>(),
4usize,
concat!("Alignment of ", stringify!(__wasi_prestat_dir_t))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_prestat_dir_t>())).pr_name_len as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_prestat_dir_t),
"::",
stringify!(pr_name_len)
)
);
}
#[test]
fn bindgen_test_layout___wasi_prestat_t___wasi_prestat_u() {
assert_eq!(
::std::mem::size_of::<__wasi_prestat_u_t>(),
4usize,
concat!("Size of: ", stringify!(__wasi_prestat_u_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_prestat_u_t>(),
4usize,
concat!("Alignment of ", stringify!(__wasi_prestat_u_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_prestat_u_t>())).dir as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_prestat_u_t),
"::",
stringify!(dir)
)
);
}
#[test]
fn bindgen_test_layout___wasi_prestat_t() {
assert_eq!(
::std::mem::size_of::<__wasi_prestat_t>(),
8usize,
concat!("Size of: ", stringify!(__wasi_prestat_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_prestat_t>(),
4usize,
concat!("Alignment of ", stringify!(__wasi_prestat_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_prestat_t>())).pr_type as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_prestat_t),
"::",
stringify!(pr_type)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_prestat_t>())).u as *const _ as usize },
4usize,
concat!(
"Offset of field: ",
stringify!(__wasi_prestat_t),
"::",
stringify!(u)
)
);
}
}

View File

@@ -111,13 +111,11 @@ fn poll_oneoff_handle_timeout_event(
) {
events.push(wasi::__wasi_event_t {
userdata: timeout.userdata,
r#type: wasi::__WASI_EVENTTYPE_CLOCK,
error: wasi::__WASI_ERRNO_SUCCESS,
u: wasi::__wasi_event_u_t {
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: 0,
},
r#type: wasi::__WASI_EVENTTYPE_CLOCK,
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
flags: 0,
nbytes: 0,
},
});
}
@@ -149,49 +147,41 @@ fn poll_oneoff_handle_fd_event<'a>(
let output_event = if revents.contains(PollFlags::POLLNVAL) {
wasi::__wasi_event_t {
userdata: fd_event.userdata,
r#type: fd_event.r#type,
error: wasi::__WASI_ERRNO_BADF,
u: wasi::__wasi_event_u_t {
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: wasi::__WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP,
},
r#type: fd_event.r#type,
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: wasi::__WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP,
},
}
} else if revents.contains(PollFlags::POLLERR) {
wasi::__wasi_event_t {
userdata: fd_event.userdata,
r#type: fd_event.r#type,
error: wasi::__WASI_ERRNO_IO,
u: wasi::__wasi_event_u_t {
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: wasi::__WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP,
},
r#type: fd_event.r#type,
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: wasi::__WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP,
},
}
} else if revents.contains(PollFlags::POLLHUP) {
wasi::__wasi_event_t {
userdata: fd_event.userdata,
r#type: fd_event.r#type,
error: wasi::__WASI_ERRNO_SUCCESS,
u: wasi::__wasi_event_u_t {
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: wasi::__WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP,
},
r#type: fd_event.r#type,
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: wasi::__WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP,
},
}
} else if revents.contains(PollFlags::POLLIN) | revents.contains(PollFlags::POLLOUT) {
wasi::__wasi_event_t {
userdata: fd_event.userdata,
r#type: fd_event.r#type,
error: wasi::__WASI_ERRNO_SUCCESS,
u: wasi::__wasi_event_u_t {
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: nbytes.try_into()?,
flags: 0,
},
r#type: fd_event.r#type,
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: nbytes.try_into()?,
flags: 0,
},
}
} else {

View File

@@ -175,9 +175,7 @@ fn make_rw_event(event: &FdEventData, nbytes: Result<u64>) -> wasi::__wasi_event
userdata: event.userdata,
r#type: event.r#type,
error: error.as_raw_errno(),
u: wasi::__wasi_event_u_t {
fd_readwrite: wasi::__wasi_event_fd_readwrite_t { nbytes, flags: 0 },
},
fd_readwrite: wasi::__wasi_event_fd_readwrite_t { nbytes, flags: 0 },
}
}
@@ -186,11 +184,9 @@ fn make_timeout_event(timeout: &ClockEventData) -> wasi::__wasi_event_t {
userdata: timeout.userdata,
r#type: wasi::__WASI_EVENTTYPE_CLOCK,
error: wasi::__WASI_ERRNO_SUCCESS,
u: wasi::__wasi_event_u_t {
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: 0,
},
fd_readwrite: wasi::__wasi_event_fd_readwrite_t {
nbytes: 0,
flags: 0,
},
}
}

View File

@@ -117,745 +117,3 @@ pub fn whence_to_str(whence: __wasi_whence_t) -> &'static str {
}
pub const __WASI_DIRCOOKIE_START: __wasi_dircookie_t = 0;
#[cfg(test)]
mod test {
use super::*;
#[test]
fn bindgen_test_layout_wasi_dirent_t() {
assert_eq!(
::std::mem::size_of::<__wasi_dirent_t>(),
24usize,
concat!("Size of: ", stringify!(__wasi_dirent_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_dirent_t>())).d_next as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_dirent_t),
"::",
stringify!(d_next)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_dirent_t>())).d_ino as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_dirent_t),
"::",
stringify!(d_ino)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_dirent_t>())).d_namlen as *const _ as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(__wasi_dirent_t),
"::",
stringify!(d_namlen)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_dirent_t>())).d_type as *const _ as usize },
20usize,
concat!(
"Offset of field: ",
stringify!(__wasi_dirent_t),
"::",
stringify!(d_type)
)
);
}
#[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_fd_readwrite_t>(),
16usize,
concat!("Size of: ", stringify!(__wasi_event_fd_readwrite_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_event_fd_readwrite_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_event_fd_readwrite_t))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_event_fd_readwrite_t>())).nbytes as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_event_fd_readwrite_t),
"::",
stringify!(nbytes)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_event_fd_readwrite_t>())).flags as *const _ as usize
},
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_event_fd_readwrite_t),
"::",
stringify!(flags)
)
);
}
#[test]
fn bindgen_test_layout___wasi_event_t___wasi_event_u() {
assert_eq!(
::std::mem::size_of::<__wasi_event_u_t>(),
16usize,
concat!("Size of: ", stringify!(__wasi_event_u_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_event_u_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_event_u_t))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_event_u_t>())).fd_readwrite as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_event_u_t),
"::",
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>())).r#type as *const _ as usize },
10usize,
concat!(
"Offset of field: ",
stringify!(__wasi_event_t),
"::",
stringify!(r#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)
)
);
}
#[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!(
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>())).r#type as *const _ as usize },
10usize,
concat!(
"Offset of field: ",
stringify!(__wasi_event_t),
"::",
stringify!(r#type)
)
);
}
#[test]
fn bindgen_test_layout_wasi_fdstat_t() {
assert_eq!(
::std::mem::size_of::<__wasi_fdstat_t>(),
24usize,
concat!("Size of: ", stringify!(__wasi_fdstat_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_fdstat_t>())).fs_filetype as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_fdstat_t),
"::",
stringify!(fs_filetype)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_fdstat_t>())).fs_flags as *const _ as usize },
2usize,
concat!(
"Offset of field: ",
stringify!(__wasi_fdstat_t),
"::",
stringify!(fs_flags)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_fdstat_t>())).fs_rights_base as *const _ as usize
},
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_fdstat_t),
"::",
stringify!(fs_rights_base)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_fdstat_t>())).fs_rights_inheriting as *const _
as usize
},
16usize,
concat!(
"Offset of field: ",
stringify!(__wasi_fdstat_t),
"::",
stringify!(fs_rights_inheriting)
)
);
}
#[test]
fn bindgen_test_layout_wasi_filestat_t() {
assert_eq!(
::std::mem::size_of::<__wasi_filestat_t>(),
64usize,
concat!("Size of: ", stringify!(__wasi_filestat_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).dev as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_dev)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).ino as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_ino)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).filetype as *const _ as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_filetype)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).nlink as *const _ as usize },
24usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_nlink)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).size as *const _ as usize },
32usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_size)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).atim as *const _ as usize },
40usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_atim)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).mtim as *const _ as usize },
48usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_mtim)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).ctim as *const _ as usize },
56usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_ctim)
)
);
}
#[test]
fn bindgen_test_layout___wasi_subscription_clock_t() {
assert_eq!(
::std::mem::size_of::<__wasi_subscription_clock_t>(),
32usize,
concat!("Size of: ", stringify!(__wasi_subscription_clock_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_subscription_clock_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_subscription_clock_t))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_clock_t>())).id as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_clock_t),
"::",
stringify!(clock_id)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_clock_t>())).timeout as *const _ as usize
},
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_clock_t),
"::",
stringify!(timeout)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_clock_t>())).precision as *const _
as usize
},
16usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_clock_t),
"::",
stringify!(precision)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_clock_t>())).flags as *const _ as usize
},
24usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_clock_t),
"::",
stringify!(flags)
)
);
}
#[test]
fn bindgen_test_layout___wasi_subscription_t___wasi_subscription_u___wasi_subscription_u_fd_readwrite_t(
) {
assert_eq!(
::std::mem::size_of::<__wasi_subscription_fd_readwrite_t>(),
4usize,
concat!("Size of: ", stringify!(__wasi_subscription_fd_readwrite_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_subscription_fd_readwrite_t>(),
4usize,
concat!(
"Alignment of ",
stringify!(__wasi_subscription_fd_readwrite_t)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_fd_readwrite_t>())).file_descriptor
as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_fd_readwrite_t),
"::",
stringify!(fd)
)
);
}
#[test]
fn bindgen_test_layout___wasi_subscription_t___wasi_subscription_u() {
assert_eq!(
::std::mem::size_of::<__wasi_subscription_u_t>(),
32usize,
concat!("Size of: ", stringify!(__wasi_subscription_u_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_subscription_u_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_subscription_u_t))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_u_t>())).clock as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_u_t),
"::",
stringify!(clock)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_u_t>())).fd_readwrite as *const _
as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_u_t),
"::",
stringify!(fd_readwrite)
)
);
}
#[test]
fn bindgen_test_layout___wasi_subscription_t() {
assert_eq!(
::std::mem::size_of::<__wasi_subscription_t>(),
48usize,
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,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_t),
"::",
stringify!(userdata)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_subscription_t>())).r#type as *const _ as usize
},
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_subscription_t),
"::",
stringify!(r#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)
)
);
}
#[test]
fn bindgen_test_layout___wasi_filestat_t() {
assert_eq!(
::std::mem::size_of::<__wasi_filestat_t>(),
64usize,
concat!("Size of: ", stringify!(__wasi_filestat_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_filestat_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_filestat_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).dev as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_dev)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).ino as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_ino)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).filetype as *const _ as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_filetype)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).nlink as *const _ as usize },
24usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_nlink)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).size as *const _ as usize },
32usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_size)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).atim as *const _ as usize },
40usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_atim)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).mtim as *const _ as usize },
48usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_mtim)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_filestat_t>())).ctim as *const _ as usize },
56usize,
concat!(
"Offset of field: ",
stringify!(__wasi_filestat_t),
"::",
stringify!(st_ctim)
)
);
}
#[test]
fn bindgen_test_layout___wasi_fdstat_t() {
assert_eq!(
::std::mem::size_of::<__wasi_fdstat_t>(),
24usize,
concat!("Size of: ", stringify!(__wasi_fdstat_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_fdstat_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_fdstat_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_fdstat_t>())).fs_filetype as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_fdstat_t),
"::",
stringify!(fs_filetype)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_fdstat_t>())).fs_flags as *const _ as usize },
2usize,
concat!(
"Offset of field: ",
stringify!(__wasi_fdstat_t),
"::",
stringify!(fs_flags)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_fdstat_t>())).fs_rights_base as *const _ as usize
},
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_fdstat_t),
"::",
stringify!(fs_rights_base)
)
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_fdstat_t>())).fs_rights_inheriting as *const _
as usize
},
16usize,
concat!(
"Offset of field: ",
stringify!(__wasi_fdstat_t),
"::",
stringify!(fs_rights_inheriting)
)
);
}
#[test]
fn bindgen_test_layout___wasi_dirent_t() {
assert_eq!(
::std::mem::size_of::<__wasi_dirent_t>(),
24usize,
concat!("Size of: ", stringify!(__wasi_dirent_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_dirent_t>(),
8usize,
concat!("Alignment of ", stringify!(__wasi_dirent_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_dirent_t>())).d_next as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_dirent_t),
"::",
stringify!(d_next)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_dirent_t>())).d_ino as *const _ as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(__wasi_dirent_t),
"::",
stringify!(d_ino)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_dirent_t>())).d_namlen as *const _ as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(__wasi_dirent_t),
"::",
stringify!(d_namlen)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_dirent_t>())).d_type as *const _ as usize },
20usize,
concat!(
"Offset of field: ",
stringify!(__wasi_dirent_t),
"::",
stringify!(d_type)
)
);
}
}

View File

@@ -13,160 +13,3 @@ pub type uintptr_t = u32;
pub type size_t = u32;
witx_wasi32_types!("snapshot" "wasi_snapshot_preview1");
#[cfg(test)]
mod test {
use super::*;
#[test]
fn bindgen_test_layout_wasi_ciovec_t() {
assert_eq!(
::std::mem::size_of::<__wasi_ciovec_t>(),
8usize,
concat!("Size of: ", stringify!(__wasi_ciovec_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_ciovec_t>(),
4usize,
concat!("Alignment of ", stringify!(__wasi_ciovec_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_ciovec_t>())).buf as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_ciovec_t),
"::",
stringify!(buf)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_ciovec_t>())).buf_len as *const _ as usize },
4usize,
concat!(
"Offset of field: ",
stringify!(__wasi_ciovec_t),
"::",
stringify!(buf_len)
)
);
}
#[test]
fn bindgen_test_layout_wasi_iovec_t() {
assert_eq!(
::std::mem::size_of::<__wasi_iovec_t>(),
8usize,
concat!("Size of: ", stringify!(__wasi_iovec_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_iovec_t>(),
4usize,
concat!("Alignment of ", stringify!(__wasi_iovec_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_iovec_t>())).buf as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_iovec_t),
"::",
stringify!(buf)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_iovec_t>())).buf_len as *const _ as usize },
4usize,
concat!(
"Offset of field: ",
stringify!(__wasi_iovec_t),
"::",
stringify!(buf_len)
)
);
}
#[test]
fn bindgen_test_layout___wasi_prestat_t___wasi_prestat_u___wasi_prestat_u_dir_t() {
assert_eq!(
::std::mem::size_of::<__wasi_prestat_dir_t>(),
4usize,
concat!("Size of: ", stringify!(__wasi_prestat_dir_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_prestat_dir_t>(),
4usize,
concat!("Alignment of ", stringify!(__wasi_prestat_dir_t))
);
assert_eq!(
unsafe {
&(*(::std::ptr::null::<__wasi_prestat_dir_t>())).pr_name_len as *const _ as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_prestat_dir_t),
"::",
stringify!(pr_name_len)
)
);
}
#[test]
fn bindgen_test_layout___wasi_prestat_t___wasi_prestat_u() {
assert_eq!(
::std::mem::size_of::<__wasi_prestat_u_t>(),
4usize,
concat!("Size of: ", stringify!(__wasi_prestat_u_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_prestat_u_t>(),
4usize,
concat!("Alignment of ", stringify!(__wasi_prestat_u_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_prestat_u_t>())).dir as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_prestat_u_t),
"::",
stringify!(dir)
)
);
}
#[test]
fn bindgen_test_layout___wasi_prestat_t() {
assert_eq!(
::std::mem::size_of::<__wasi_prestat_t>(),
8usize,
concat!("Size of: ", stringify!(__wasi_prestat_t))
);
assert_eq!(
::std::mem::align_of::<__wasi_prestat_t>(),
4usize,
concat!("Alignment of ", stringify!(__wasi_prestat_t))
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_prestat_t>())).pr_type as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(__wasi_prestat_t),
"::",
stringify!(pr_type)
)
);
assert_eq!(
unsafe { &(*(::std::ptr::null::<__wasi_prestat_t>())).u as *const _ as usize },
4usize,
concat!(
"Offset of field: ",
stringify!(__wasi_prestat_t),
"::",
stringify!(u)
)
);
}
}