[wiggle] Don't make generated structs and unions Copy.
Some structs and unions are large enough that making them `Copy` isn't ideal. wasi-common only needed `Copy` in a few places that were easy to fix. `SubscriptionClock` is 32 bytes, so it's not a bad a idea to pass it by reference anyway.
This commit is contained in:
@@ -5,7 +5,7 @@ use std::time::SystemTime;
|
||||
|
||||
pub(crate) use sys::clock::*;
|
||||
|
||||
pub(crate) fn to_relative_ns_delay(clock: SubscriptionClock) -> Result<u128> {
|
||||
pub(crate) fn to_relative_ns_delay(clock: &SubscriptionClock) -> Result<u128> {
|
||||
if clock.flags != Subclockflags::SUBSCRIPTION_CLOCK_ABSTIME {
|
||||
return Ok(u128::from(clock.timeout));
|
||||
}
|
||||
|
||||
@@ -1185,7 +1185,7 @@ impl<'a> WasiSnapshotPreview1 for WasiCtx {
|
||||
for subscription in subscriptions {
|
||||
match subscription.u {
|
||||
types::SubscriptionU::Clock(clock) => {
|
||||
let delay = clock::to_relative_ns_delay(clock)?;
|
||||
let delay = clock::to_relative_ns_delay(&clock)?;
|
||||
log::debug!("poll_oneoff event.u.clock = {:?}", clock);
|
||||
log::debug!("poll_oneoff delay = {:?}ns", delay);
|
||||
let current = poll::ClockEventData {
|
||||
|
||||
@@ -95,7 +95,7 @@ impl AsBytes for types::Dirent {
|
||||
let mut bytes: Vec<u8> = Vec::with_capacity(offset);
|
||||
bytes.resize(offset, 0);
|
||||
let ptr = bytes.as_mut_ptr() as *mut Self;
|
||||
unsafe { ptr.write_unaligned(*self) };
|
||||
unsafe { ptr.write_unaligned(self.clone()) };
|
||||
Ok(bytes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ pub(super) fn define_struct(
|
||||
let (struct_lifetime, extra_derive) = if s.needs_lifetime() {
|
||||
(quote!(<'a>), quote!())
|
||||
} else {
|
||||
(quote!(), quote!(, Copy, PartialEq))
|
||||
(quote!(), quote!(, PartialEq))
|
||||
};
|
||||
|
||||
let transparent = if s.is_transparent() {
|
||||
|
||||
@@ -68,7 +68,7 @@ pub(super) fn define_union(names: &Names, name: &witx::Id, u: &witx::UnionDataty
|
||||
let (enum_lifetime, extra_derive) = if u.needs_lifetime() {
|
||||
(quote!(<'a>), quote!())
|
||||
} else {
|
||||
(quote!(), quote!(, Copy, PartialEq))
|
||||
(quote!(), quote!(, PartialEq))
|
||||
};
|
||||
|
||||
quote! {
|
||||
|
||||
Reference in New Issue
Block a user