Fix wiggle tests
This commit is contained in:
committed by
Andrew Brown
parent
df9c725fa0
commit
fa98f0bc91
Submodule crates/wasi-common/WASI updated: 7c4fd252d0...3b684dd2fc
@@ -55,6 +55,7 @@ pub fn define_func(
|
||||
let mod_name = &module.name.as_str();
|
||||
let func_name = &func.name.as_str();
|
||||
quote! {
|
||||
#[allow(unreachable_code)] // deals with warnings in noreturn functions
|
||||
pub fn #ident(
|
||||
ctx: &#ctx_type,
|
||||
memory: &dyn #rt::GuestMemory,
|
||||
@@ -215,7 +216,7 @@ impl witx::Bindgen for Rust<'_> {
|
||||
if func.results.len() > 0 {
|
||||
results.push(quote!(ret));
|
||||
} else if func.noreturn {
|
||||
self.src.extend(quote!(return Err(ret)));
|
||||
self.src.extend(quote!(return Err(ret);));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,7 +251,9 @@ impl witx::Bindgen for Rust<'_> {
|
||||
|
||||
Instruction::VariantPayload => results.push(quote!(e)),
|
||||
|
||||
Instruction::Return { amt: 0 } => {}
|
||||
Instruction::Return { amt: 0 } => {
|
||||
self.src.extend(quote!(return Ok(())));
|
||||
}
|
||||
Instruction::Return { amt: 1 } => {
|
||||
let val = operands.pop().unwrap();
|
||||
self.src.extend(quote!(return Ok(#val)));
|
||||
@@ -278,6 +281,17 @@ impl witx::Bindgen for Rust<'_> {
|
||||
});
|
||||
}
|
||||
|
||||
Instruction::Load { ty } => {
|
||||
let ptr = operands.pop().unwrap();
|
||||
let wrap_err = wrap_err(&format!("read {}", ty.name.as_str()));
|
||||
let pointee_type = self.names.type_(&ty.name);
|
||||
results.push(quote! {
|
||||
#rt::GuestPtr::<#pointee_type>::new(memory, #ptr as u32)
|
||||
.read()
|
||||
.map_err(#wrap_err)?
|
||||
});
|
||||
}
|
||||
|
||||
Instruction::HandleFromI32 { ty } => {
|
||||
let val = operands.pop().unwrap();
|
||||
let ty = self.names.type_(&ty.name);
|
||||
@@ -294,7 +308,7 @@ impl witx::Bindgen for Rust<'_> {
|
||||
|
||||
// Conversions with matching bit-widths but different signededness
|
||||
// use `as` since we're basically just reinterpreting the bits.
|
||||
Instruction::U32FromI32 => {
|
||||
Instruction::U32FromI32 | Instruction::UsizeFromI32 => {
|
||||
let val = operands.pop().unwrap();
|
||||
results.push(quote!(#val as u32));
|
||||
}
|
||||
|
||||
@@ -6,8 +6,9 @@ mod module_trait;
|
||||
mod names;
|
||||
mod types;
|
||||
|
||||
use heck::ShoutySnakeCase;
|
||||
use lifetimes::anon_lifetime;
|
||||
use proc_macro2::TokenStream;
|
||||
use proc_macro2::{Literal, TokenStream};
|
||||
use quote::quote;
|
||||
|
||||
pub use config::Config;
|
||||
@@ -24,6 +25,19 @@ pub fn generate(doc: &witx::Document, names: &Names, errs: &ErrorTransform) -> T
|
||||
|
||||
let types = doc.typenames().map(|t| define_datatype(&names, &t));
|
||||
|
||||
let constants = doc.constants().map(|c| {
|
||||
let name = quote::format_ident!(
|
||||
"{}_{}",
|
||||
c.ty.as_str().to_shouty_snake_case(),
|
||||
c.name.as_str().to_shouty_snake_case()
|
||||
);
|
||||
let ty = names.type_(&c.ty);
|
||||
let value = Literal::u64_unsuffixed(c.value);
|
||||
quote! {
|
||||
pub const #name: #ty = #value;
|
||||
}
|
||||
});
|
||||
|
||||
let guest_error_methods = doc.error_types().map(|t| {
|
||||
let typename = names.type_ref(&t, anon_lifetime());
|
||||
let err_method = names.guest_error_conversion_method(&t);
|
||||
@@ -69,6 +83,7 @@ pub fn generate(doc: &witx::Document, names: &Names, errs: &ErrorTransform) -> T
|
||||
use std::convert::TryFrom;
|
||||
|
||||
#(#types)*
|
||||
#(#constants)*
|
||||
#guest_error_conversion
|
||||
#user_error_conversion
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ use witx::Module;
|
||||
pub fn passed_by_reference(ty: &witx::Type) -> bool {
|
||||
match ty {
|
||||
witx::Type::Pointer(_) | witx::Type::ConstPointer(_) | witx::Type::List(_) => true,
|
||||
witx::Type::Record(r) => r.bitflags_repr().is_none(),
|
||||
witx::Type::Variant(v) => !v.is_enum(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ pub(super) fn define_variant(names: &Names, name: &witx::Id, v: &witx::Variant)
|
||||
}
|
||||
});
|
||||
|
||||
let mut extra_derive = quote!();
|
||||
let enum_try_from = if v.cases.iter().all(|c| c.tref.is_none()) {
|
||||
let tryfrom_repr_cases = v.cases.iter().enumerate().map(|(i, c)| {
|
||||
let variant_name = names.enum_variant(&c.name);
|
||||
@@ -72,6 +73,7 @@ pub(super) fn define_variant(names: &Names, name: &witx::Id, v: &witx::Variant)
|
||||
quote!(#n => Ok(#ident::#variant_name))
|
||||
});
|
||||
let abi_ty = names.wasm_type(v.tag_repr.into());
|
||||
extra_derive = quote!(, Copy);
|
||||
quote! {
|
||||
impl TryFrom<#tag_ty> for #ident {
|
||||
type Error = #rt::GuestError;
|
||||
@@ -97,7 +99,7 @@ pub(super) fn define_variant(names: &Names, name: &witx::Id, v: &witx::Variant)
|
||||
let (enum_lifetime, extra_derive) = if v.needs_lifetime() {
|
||||
(quote!(<'a>), quote!())
|
||||
} else {
|
||||
(quote!(), quote!(, PartialEq))
|
||||
(quote!(), quote!(, PartialEq #extra_derive))
|
||||
};
|
||||
|
||||
quote! {
|
||||
|
||||
@@ -105,7 +105,7 @@ impl ReduceExcusesExcercise {
|
||||
self.return_ptr_loc.ptr as i32,
|
||||
);
|
||||
|
||||
assert_eq!(res, Ok(types::Errno::Ok.into()), "reduce excuses errno");
|
||||
assert_eq!(res, Ok(types::Errno::Ok as i32), "reduce excuses errno");
|
||||
|
||||
let expected = *self
|
||||
.excuse_values
|
||||
@@ -183,7 +183,7 @@ impl PopulateExcusesExcercise {
|
||||
self.array_ptr_loc.ptr as i32,
|
||||
self.elements.len() as i32,
|
||||
);
|
||||
assert_eq!(res, Ok(types::Errno::Ok.into()), "populate excuses errno");
|
||||
assert_eq!(res, Ok(types::Errno::Ok as i32), "populate excuses errno");
|
||||
|
||||
let arr: GuestPtr<'_, [GuestPtr<'_, types::Excuse>]> =
|
||||
host_memory.ptr((self.array_ptr_loc.ptr, self.elements.len() as u32));
|
||||
@@ -309,7 +309,7 @@ impl SumElementsExercise {
|
||||
self.start_ix as i32,
|
||||
self.return_loc.ptr as i32,
|
||||
);
|
||||
assert_eq!(res, Ok(types::Errno::Ok.into()), "sum_of_element errno");
|
||||
assert_eq!(res, Ok(types::Errno::Ok as i32), "sum_of_element errno");
|
||||
let result_ptr = host_memory.ptr::<i32>(self.return_loc.ptr);
|
||||
let result = result_ptr.read().expect("read result");
|
||||
|
||||
@@ -330,7 +330,7 @@ impl SumElementsExercise {
|
||||
);
|
||||
assert_eq!(
|
||||
res,
|
||||
Ok(types::Errno::InvalidArg.into()),
|
||||
Ok(types::Errno::InvalidArg as i32),
|
||||
"out of bounds sum_of_element errno"
|
||||
);
|
||||
|
||||
@@ -346,7 +346,7 @@ impl SumElementsExercise {
|
||||
if self.start_ix <= self.end_ix {
|
||||
assert_eq!(
|
||||
res,
|
||||
Ok(types::Errno::Ok.into()),
|
||||
Ok(types::Errno::Ok as i32),
|
||||
"expected ok sum_of_elements errno"
|
||||
);
|
||||
let result_ptr = host_memory.ptr::<i32>(self.return_loc.ptr);
|
||||
@@ -367,7 +367,7 @@ impl SumElementsExercise {
|
||||
} else {
|
||||
assert_eq!(
|
||||
res,
|
||||
Ok(types::Errno::InvalidArg.into()),
|
||||
Ok(types::Errno::InvalidArg as i32),
|
||||
"expected error out-of-bounds sum_of_elements"
|
||||
);
|
||||
}
|
||||
@@ -384,7 +384,7 @@ impl SumElementsExercise {
|
||||
);
|
||||
assert_eq!(
|
||||
res,
|
||||
Ok(types::Errno::InvalidArg.into()),
|
||||
Ok(types::Errno::InvalidArg as i32),
|
||||
"out of bounds sum_of_elements errno"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
(use "errno.witx")
|
||||
(use "excuse.witx")
|
||||
|
||||
(typename $const_excuse_array (array (@witx const_pointer $excuse)))
|
||||
(typename $excuse_array (array (@witx pointer $excuse)))
|
||||
(typename $const_excuse_array (list (@witx const_pointer $excuse)))
|
||||
(typename $excuse_array (list (@witx pointer $excuse)))
|
||||
|
||||
(module $arrays
|
||||
(@interface func (export "reduce_excuses")
|
||||
(param $excuses $const_excuse_array)
|
||||
(result $error $errno)
|
||||
(result $reduced $excuse)
|
||||
(result $error (expected $excuse (error $errno)))
|
||||
)
|
||||
(@interface func (export "populate_excuses")
|
||||
(param $excuses $excuse_array)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
)
|
||||
|
||||
(typename $pair_ints
|
||||
(struct
|
||||
(record
|
||||
(field $first s32)
|
||||
(field $second s32)))
|
||||
|
||||
(typename $s32 s32)
|
||||
|
||||
(module $array_traversal
|
||||
(@interface func (export "sum_of_element")
|
||||
(param $elements (array $pair_ints))
|
||||
(param $elements (list $pair_ints))
|
||||
(param $index (@witx usize))
|
||||
(result $error $errno)
|
||||
(result $sum s32))
|
||||
(result $error (expected $s32 (error $errno))))
|
||||
|
||||
(@interface func (export "sum_of_elements")
|
||||
(param $elements (array $pair_ints))
|
||||
(param $elements (list $pair_ints))
|
||||
(param $start (@witx usize))
|
||||
(param $end (@witx usize))
|
||||
(result $error $errno)
|
||||
(result $sum s32)))
|
||||
(result $error (expected $s32 (error $errno))))
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@ impl IntFloatExercise {
|
||||
|
||||
let e = atoms::int_float_args(&ctx, &host_memory, self.an_int as i32, self.an_float);
|
||||
|
||||
assert_eq!(e, Ok(types::Errno::Ok.into()), "int_float_args error");
|
||||
assert_eq!(e, Ok(types::Errno::Ok as i32), "int_float_args error");
|
||||
}
|
||||
|
||||
pub fn strat() -> BoxedStrategy<Self> {
|
||||
@@ -72,7 +72,7 @@ impl DoubleIntExercise {
|
||||
.ptr::<types::AliasToFloat>(self.return_loc.ptr)
|
||||
.read()
|
||||
.expect("failed to read return");
|
||||
assert_eq!(e, Ok(types::Errno::Ok.into()), "errno");
|
||||
assert_eq!(e, Ok(types::Errno::Ok as i32), "errno");
|
||||
assert_eq!(return_val, (self.input as f32) * 2.0, "return val");
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,8 @@
|
||||
(@interface func (export "int_float_args")
|
||||
(param $an_int u32)
|
||||
(param $an_float f32)
|
||||
(result $error $errno))
|
||||
(result $error (expected (error $errno))))
|
||||
(@interface func (export "double_int_return_float")
|
||||
(param $an_int u32)
|
||||
(result $error $errno)
|
||||
(result $doubled_it $alias_to_float))
|
||||
(result $error (expected $alias_to_float (error $errno))))
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
(typename $errno
|
||||
(enum u32
|
||||
(enum (@witx tag u32)
|
||||
;;; Success
|
||||
$ok
|
||||
;;; Invalid argument
|
||||
|
||||
@@ -17,11 +17,11 @@ mod convert_just_errno {
|
||||
// trivial function.
|
||||
wiggle::from_witx!({
|
||||
witx_literal: "
|
||||
(typename $errno (enum u8 $ok $invalid_arg $picket_line))
|
||||
(typename $errno (enum (@witx tag u8) $ok $invalid_arg $picket_line))
|
||||
(module $one_error_conversion
|
||||
(@interface func (export \"foo\")
|
||||
(param $strike u32)
|
||||
(result $err $errno)))
|
||||
(result $err (expected (error $errno)))))
|
||||
",
|
||||
ctx: WasiCtx,
|
||||
errors: { errno => RichError },
|
||||
@@ -68,7 +68,7 @@ mod convert_just_errno {
|
||||
let r0 = one_error_conversion::foo(&ctx, &host_memory, 0);
|
||||
assert_eq!(
|
||||
r0,
|
||||
Ok(i32::from(types::Errno::Ok)),
|
||||
Ok(types::Errno::Ok as i32),
|
||||
"Expected return value for strike=0"
|
||||
);
|
||||
assert!(ctx.log.borrow().is_empty(), "No error log for strike=0");
|
||||
@@ -77,7 +77,7 @@ mod convert_just_errno {
|
||||
let r1 = one_error_conversion::foo(&ctx, &host_memory, 1);
|
||||
assert_eq!(
|
||||
r1,
|
||||
Ok(i32::from(types::Errno::PicketLine)),
|
||||
Ok(types::Errno::PicketLine as i32),
|
||||
"Expected return value for strike=1"
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -90,7 +90,7 @@ mod convert_just_errno {
|
||||
let r2 = one_error_conversion::foo(&ctx, &host_memory, 2);
|
||||
assert_eq!(
|
||||
r2,
|
||||
Ok(i32::from(types::Errno::InvalidArg)),
|
||||
Ok(types::Errno::InvalidArg as i32),
|
||||
"Expected return value for strike=2"
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -120,15 +120,15 @@ mod convert_multiple_error_types {
|
||||
// Additionally, test that the function "baz" marked noreturn always returns a wiggle::Trap.
|
||||
wiggle::from_witx!({
|
||||
witx_literal: "
|
||||
(typename $errno (enum u8 $ok $invalid_arg $picket_line))
|
||||
(typename $errno2 (enum u8 $ok $too_much_coffee))
|
||||
(typename $errno (enum (@witx tag u8) $ok $invalid_arg $picket_line))
|
||||
(typename $errno2 (enum (@witx tag u8) $ok $too_much_coffee))
|
||||
(module $two_error_conversions
|
||||
(@interface func (export \"foo\")
|
||||
(param $strike u32)
|
||||
(result $err $errno))
|
||||
(result $err (expected (error $errno))))
|
||||
(@interface func (export \"bar\")
|
||||
(param $drink u32)
|
||||
(result $err $errno2))
|
||||
(result $err (expected (error $errno2))))
|
||||
(@interface func (export \"baz\")
|
||||
(param $drink u32)
|
||||
(@witx noreturn)))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
(typename $excuse
|
||||
(enum u8
|
||||
(enum (@witx tag u8)
|
||||
$dog_ate
|
||||
$traffic
|
||||
$sleeping))
|
||||
|
||||
@@ -75,11 +75,11 @@ impl ConfigureCarExercise {
|
||||
let res = flags::configure_car(
|
||||
&ctx,
|
||||
&host_memory,
|
||||
self.old_config.into(),
|
||||
self.old_config.bits() as i32,
|
||||
self.other_config_by_ptr.ptr as i32,
|
||||
self.return_ptr_loc.ptr as i32,
|
||||
);
|
||||
assert_eq!(res, Ok(types::Errno::Ok.into()), "configure car errno");
|
||||
assert_eq!(res, Ok(types::Errno::Ok as i32), "configure car errno");
|
||||
|
||||
let res_config = host_memory
|
||||
.ptr::<types::CarConfig>(self.return_ptr_loc.ptr)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
(use "errno.witx")
|
||||
|
||||
(typename $car_config
|
||||
(flags u8
|
||||
(flags (@witx repr u8)
|
||||
$automatic
|
||||
$awd
|
||||
$suv))
|
||||
@@ -10,7 +10,6 @@
|
||||
(@interface func (export "configure_car")
|
||||
(param $old_config $car_config)
|
||||
(param $old_config_by_ptr (@witx const_pointer $car_config))
|
||||
(result $error $errno)
|
||||
(result $new_config $car_config)
|
||||
(result $error (expected $car_config (error $errno)))
|
||||
)
|
||||
)
|
||||
|
||||
@@ -37,7 +37,7 @@ impl HandleExercise {
|
||||
|
||||
let e = handle_examples::fd_create(&ctx, &host_memory, self.return_loc.ptr as i32);
|
||||
|
||||
assert_eq!(e, Ok(types::Errno::Ok.into()), "fd_create error");
|
||||
assert_eq!(e, Ok(types::Errno::Ok as i32), "fd_create error");
|
||||
|
||||
let h_got: u32 = host_memory
|
||||
.ptr(self.return_loc.ptr)
|
||||
@@ -48,13 +48,13 @@ impl HandleExercise {
|
||||
|
||||
let e = handle_examples::fd_consume(&ctx, &host_memory, h_got as i32);
|
||||
|
||||
assert_eq!(e, Ok(types::Errno::Ok.into()), "fd_consume error");
|
||||
assert_eq!(e, Ok(types::Errno::Ok as i32), "fd_consume error");
|
||||
|
||||
let e = handle_examples::fd_consume(&ctx, &host_memory, h_got as i32 + 1);
|
||||
|
||||
assert_eq!(
|
||||
e,
|
||||
Ok(types::Errno::InvalidArg.into()),
|
||||
Ok(types::Errno::InvalidArg as i32),
|
||||
"fd_consume invalid error"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
|
||||
(module $handle_examples
|
||||
(@interface func (export "fd_create")
|
||||
(result $error $errno)
|
||||
(result $fd $fd))
|
||||
(result $error (expected $fd (error $errno))))
|
||||
(@interface func (export "fd_consume")
|
||||
(param $fd $fd)
|
||||
(result $error $errno))
|
||||
(result $error (expected (error $errno))))
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ impl_errno!(types::Errno, types::GuestErrorConversion);
|
||||
|
||||
impl<'a> ints::Ints for WasiCtx<'a> {
|
||||
fn cookie_cutter(&self, init_cookie: types::Cookie) -> Result<types::Bool, types::Errno> {
|
||||
let res = if init_cookie == types::Cookie::START {
|
||||
let res = if init_cookie == types::COOKIE_START {
|
||||
types::Bool::True
|
||||
} else {
|
||||
types::Bool::False
|
||||
@@ -50,10 +50,10 @@ impl CookieCutterExercise {
|
||||
let res = ints::cookie_cutter(
|
||||
&ctx,
|
||||
&host_memory,
|
||||
self.cookie.into(),
|
||||
self.cookie as i64,
|
||||
self.return_ptr_loc.ptr as i32,
|
||||
);
|
||||
assert_eq!(res, Ok(types::Errno::Ok.into()), "cookie cutter errno");
|
||||
assert_eq!(res, Ok(types::Errno::Ok as i32), "cookie cutter errno");
|
||||
|
||||
let is_cookie_start = host_memory
|
||||
.ptr::<types::Bool>(self.return_ptr_loc.ptr)
|
||||
@@ -66,7 +66,7 @@ impl CookieCutterExercise {
|
||||
} else {
|
||||
false
|
||||
},
|
||||
self.cookie == types::Cookie::START,
|
||||
self.cookie == types::COOKIE_START,
|
||||
"returned Bool should test if input was Cookie::START",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
(use "errno.witx")
|
||||
|
||||
(typename $cookie
|
||||
(int u64
|
||||
(const $start 0)))
|
||||
(typename $cookie u64)
|
||||
(@witx const $cookie $start 0)
|
||||
|
||||
(typename $bool
|
||||
(enum u8
|
||||
$false
|
||||
$true))
|
||||
(typename $bool bool)
|
||||
|
||||
(module $ints
|
||||
(@interface func (export "cookie_cutter")
|
||||
(param $init_cookie $cookie)
|
||||
(result $error $errno)
|
||||
(result $is_start $bool)
|
||||
(result $error (expected $bool (error $errno)))
|
||||
)
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ mod enum_test {
|
||||
wiggle::from_witx!({
|
||||
witx_literal:
|
||||
"(typename $self
|
||||
(enum u8
|
||||
(enum (@witx tag u8)
|
||||
$self
|
||||
$2big
|
||||
)
|
||||
@@ -35,7 +35,7 @@ mod module_trait_fn_and_arg_test {
|
||||
});
|
||||
impl<'a> self_::Self_ for WasiCtx<'a> {
|
||||
#[allow(unused_variables)]
|
||||
fn fn_(&self, use_: u32, virtual_: u32) -> Result<(), ()> {
|
||||
fn fn_(&self, use_: u32, virtual_: u32) {
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ mod struct_test {
|
||||
wiggle::from_witx!({
|
||||
witx_literal:
|
||||
"(typename $self
|
||||
(struct
|
||||
(record
|
||||
(field $become s32)
|
||||
(field $mut s32)
|
||||
)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
(typename $union
|
||||
(enum u8
|
||||
(enum (@witx tag u8)
|
||||
$self
|
||||
$power
|
||||
)
|
||||
)
|
||||
|
||||
(typename $self
|
||||
(union $union
|
||||
(variant (@witx tag $union)
|
||||
;; A union variant that will expand to a strict keyword `Self`.
|
||||
(field $self (@witx pointer f32))
|
||||
(case $self (@witx pointer f32))
|
||||
;; Oh it's true, that there's power in a union!
|
||||
(field $power (@witx pointer f32))
|
||||
(case $power (@witx pointer f32))
|
||||
)
|
||||
)
|
||||
|
||||
@@ -152,12 +152,12 @@ impl PointersAndEnumsExercise {
|
||||
let e = pointers::pointers_and_enums(
|
||||
&ctx,
|
||||
&host_memory,
|
||||
self.input1.into(),
|
||||
self.input1 as i32,
|
||||
self.input2_loc.ptr as i32,
|
||||
self.input3_loc.ptr as i32,
|
||||
self.input4_ptr_loc.ptr as i32,
|
||||
);
|
||||
assert_eq!(e, Ok(types::Errno::Ok.into()), "errno");
|
||||
assert_eq!(e, Ok(types::Errno::Ok as i32), "errno");
|
||||
|
||||
// Implementation of pointers_and_enums writes input3 to the input2_loc:
|
||||
let written_to_input2_loc: i32 = host_memory
|
||||
@@ -166,8 +166,7 @@ impl PointersAndEnumsExercise {
|
||||
.expect("input2 ref");
|
||||
|
||||
assert_eq!(
|
||||
written_to_input2_loc,
|
||||
self.input3.into(),
|
||||
written_to_input2_loc, self.input3 as i32,
|
||||
"pointers_and_enums written to input2"
|
||||
);
|
||||
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
(param $an_excuse_by_reference (@witx pointer $excuse))
|
||||
(param $a_lamer_excuse (@witx const_pointer $excuse))
|
||||
(param $two_layers_of_excuses (@witx pointer (@witx const_pointer $excuse)))
|
||||
(result $error $errno))
|
||||
(result $error (expected (error $errno))))
|
||||
)
|
||||
|
||||
@@ -88,7 +88,7 @@ impl HelloStringExercise {
|
||||
self.test_word.len() as i32,
|
||||
self.return_ptr_loc.ptr as i32,
|
||||
);
|
||||
assert_eq!(res, Ok(types::Errno::Ok.into()), "hello string errno");
|
||||
assert_eq!(res, Ok(types::Errno::Ok as i32), "hello string errno");
|
||||
|
||||
let given = host_memory
|
||||
.ptr::<u32>(self.return_ptr_loc.ptr)
|
||||
@@ -209,7 +209,7 @@ impl MultiStringExercise {
|
||||
self.c.len() as i32,
|
||||
self.return_ptr_loc.ptr as i32,
|
||||
);
|
||||
assert_eq!(res, Ok(types::Errno::Ok.into()), "multi string errno");
|
||||
assert_eq!(res, Ok(types::Errno::Ok as i32), "multi string errno");
|
||||
|
||||
let given = host_memory
|
||||
.ptr::<u32>(self.return_ptr_loc.ptr)
|
||||
@@ -287,7 +287,7 @@ impl OverlappingStringExercise {
|
||||
a_len - self.offset_c as i32,
|
||||
self.return_ptr_loc.ptr as i32,
|
||||
);
|
||||
assert_eq!(res, Ok(types::Errno::Ok.into()), "multi string errno");
|
||||
assert_eq!(res, Ok(types::Errno::Ok as i32), "multi string errno");
|
||||
|
||||
let given = host_memory
|
||||
.ptr::<u32>(self.return_ptr_loc.ptr)
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
(use "errno.witx")
|
||||
|
||||
(typename $ret u32)
|
||||
|
||||
(module $strings
|
||||
(@interface func (export "hello_string")
|
||||
(param $a_string string)
|
||||
(result $error $errno)
|
||||
(result $total_bytes u32)
|
||||
(result $error (expected $ret (error $errno)))
|
||||
)
|
||||
|
||||
(@interface func (export "multi_string")
|
||||
(param $a string)
|
||||
(param $b string)
|
||||
(param $c string)
|
||||
(result $error $errno)
|
||||
(result $total_bytes u32)
|
||||
(result $error (expected $ret (error $errno)))
|
||||
)
|
||||
)
|
||||
|
||||
@@ -118,7 +118,7 @@ impl SumOfPairExercise {
|
||||
self.return_loc.ptr as i32,
|
||||
);
|
||||
|
||||
assert_eq!(sum_err, Ok(types::Errno::Ok.into()), "sum errno");
|
||||
assert_eq!(sum_err, Ok(types::Errno::Ok as i32), "sum errno");
|
||||
|
||||
let return_val: i64 = host_memory
|
||||
.ptr(self.return_loc.ptr)
|
||||
@@ -218,7 +218,7 @@ impl SumPairPtrsExercise {
|
||||
|
||||
assert_eq!(
|
||||
res,
|
||||
Ok(types::Errno::Ok.into()),
|
||||
Ok(types::Errno::Ok as i32),
|
||||
"sum of pair of ptrs errno"
|
||||
);
|
||||
|
||||
@@ -299,7 +299,7 @@ impl SumIntAndPtrExercise {
|
||||
self.return_loc.ptr as i32,
|
||||
);
|
||||
|
||||
assert_eq!(res, Ok(types::Errno::Ok.into()), "sum of int and ptr errno");
|
||||
assert_eq!(res, Ok(types::Errno::Ok as i32), "sum of int and ptr errno");
|
||||
|
||||
let doubled: i64 = host_memory
|
||||
.ptr(self.return_loc.ptr)
|
||||
@@ -338,7 +338,7 @@ impl ReturnPairInts {
|
||||
|
||||
let err = structs::return_pair_ints(&ctx, &host_memory, self.return_loc.ptr as i32);
|
||||
|
||||
assert_eq!(err, Ok(types::Errno::Ok.into()), "return struct errno");
|
||||
assert_eq!(err, Ok(types::Errno::Ok as i32), "return struct errno");
|
||||
|
||||
let return_struct: types::PairInts = host_memory
|
||||
.ptr(self.return_loc.ptr)
|
||||
@@ -420,7 +420,7 @@ impl ReturnPairPtrsExercise {
|
||||
|
||||
assert_eq!(
|
||||
res,
|
||||
Ok(types::Errno::Ok.into()),
|
||||
Ok(types::Errno::Ok as i32),
|
||||
"return pair of ptrs errno"
|
||||
);
|
||||
|
||||
@@ -530,7 +530,7 @@ impl SumArrayExercise {
|
||||
);
|
||||
|
||||
// should be no error - if hostcall did a GuestError it should eprintln it.
|
||||
assert_eq!(res, Ok(types::Errno::Ok.into()), "reduce excuses errno");
|
||||
assert_eq!(res, Ok(types::Errno::Ok as i32), "reduce excuses errno");
|
||||
|
||||
// Sum is inputs upcasted to u16
|
||||
let expected: u16 = self.inputs.iter().map(|v| *v as u16).sum();
|
||||
|
||||
@@ -2,49 +2,46 @@
|
||||
(use "errno.witx")
|
||||
|
||||
(typename $pair_ints
|
||||
(struct
|
||||
(record
|
||||
(field $first s32)
|
||||
(field $second s32)))
|
||||
|
||||
(typename $pair_int_ptrs
|
||||
(struct
|
||||
(record
|
||||
(field $first (@witx const_pointer s32))
|
||||
(field $second (@witx const_pointer s32))))
|
||||
|
||||
(typename $pair_int_and_ptr
|
||||
(struct
|
||||
(record
|
||||
(field $first (@witx const_pointer s32))
|
||||
(field $second s32)))
|
||||
|
||||
(typename $some_bytes (array u8))
|
||||
(typename $some_bytes (list u8))
|
||||
|
||||
(typename $struct_of_array
|
||||
(struct
|
||||
(record
|
||||
(field $arr $some_bytes)))
|
||||
|
||||
(typename $s64 s64)
|
||||
(typename $u16 u16)
|
||||
|
||||
(module $structs
|
||||
(@interface func (export "sum_of_pair")
|
||||
(param $an_pair $pair_ints)
|
||||
(result $error $errno)
|
||||
(result $doubled s64))
|
||||
(result $error (expected $s64 (error $errno))))
|
||||
(@interface func (export "sum_of_pair_of_ptrs")
|
||||
(param $an_pair $pair_int_ptrs)
|
||||
(result $error $errno)
|
||||
(result $doubled s64))
|
||||
(result $error (expected $s64 (error $errno))))
|
||||
(@interface func (export "sum_of_int_and_ptr")
|
||||
(param $an_pair $pair_int_and_ptr)
|
||||
(result $error $errno)
|
||||
(result $double s64))
|
||||
(result $error (expected $s64 (error $errno))))
|
||||
(@interface func (export "return_pair_ints")
|
||||
(result $error $errno)
|
||||
(result $an_pair $pair_ints))
|
||||
(result $error (expected $pair_ints (error $errno))))
|
||||
(@interface func (export "return_pair_of_ptrs")
|
||||
(param $first (@witx const_pointer s32))
|
||||
(param $second (@witx const_pointer s32))
|
||||
(result $error $errno)
|
||||
(result $an_pair $pair_int_ptrs))
|
||||
(result $error (expected $pair_int_ptrs (error $errno))))
|
||||
(@interface func (export "sum_array")
|
||||
(param $an_arr $struct_of_array)
|
||||
(result $error $errno)
|
||||
(result $doubled u16))
|
||||
(result $error (expected $u16 (error $errno))))
|
||||
)
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
;;; Identifiers for clocks.
|
||||
(typename $clockid
|
||||
(enum u32
|
||||
(enum (@witx tag u32)
|
||||
;;; The clock measuring real time. Time value zero corresponds with
|
||||
;;; 1970-01-01T00:00:00Z.
|
||||
$realtime
|
||||
@@ -36,7 +36,7 @@
|
||||
;;; API; some are used in higher-level library layers, and others are provided
|
||||
;;; merely for alignment with POSIX.
|
||||
(typename $errno
|
||||
(enum u16
|
||||
(enum (@witx tag u16)
|
||||
;;; No error occurred. System call completed successfully.
|
||||
$success
|
||||
;;; Argument list too long.
|
||||
@@ -196,7 +196,7 @@
|
||||
|
||||
;;; File descriptor rights, determining which actions may be performed.
|
||||
(typename $rights
|
||||
(flags u64
|
||||
(flags (@witx repr u64)
|
||||
;;; The right to invoke `fd_datasync`.
|
||||
;;
|
||||
;;; If `path_open` is set, includes the right to invoke
|
||||
@@ -278,7 +278,7 @@
|
||||
|
||||
;;; A region of memory for scatter/gather reads.
|
||||
(typename $iovec
|
||||
(struct
|
||||
(record
|
||||
;;; The address of the buffer to be filled.
|
||||
(field $buf (@witx pointer u8))
|
||||
;;; The length of the buffer to be filled.
|
||||
@@ -288,7 +288,7 @@
|
||||
|
||||
;;; A region of memory for scatter/gather writes.
|
||||
(typename $ciovec
|
||||
(struct
|
||||
(record
|
||||
;;; The address of the buffer to be written.
|
||||
(field $buf (@witx const_pointer u8))
|
||||
;;; The length of the buffer to be written.
|
||||
@@ -296,15 +296,15 @@
|
||||
)
|
||||
)
|
||||
|
||||
(typename $iovec_array (array $iovec))
|
||||
(typename $ciovec_array (array $ciovec))
|
||||
(typename $iovec_array (list $iovec))
|
||||
(typename $ciovec_array (list $ciovec))
|
||||
|
||||
;;; Relative offset within a file.
|
||||
(typename $filedelta s64)
|
||||
|
||||
;;; The position relative to which to set the offset of the file descriptor.
|
||||
(typename $whence
|
||||
(enum u8
|
||||
(enum (@witx tag u8)
|
||||
;;; Seek relative to start-of-file.
|
||||
$set
|
||||
;;; Seek relative to current position.
|
||||
@@ -327,7 +327,7 @@
|
||||
|
||||
;;; The type of a file descriptor or file.
|
||||
(typename $filetype
|
||||
(enum u8
|
||||
(enum (@witx tag u8)
|
||||
;;; The type of the file descriptor or file is unknown or is different from any of the other types specified.
|
||||
$unknown
|
||||
;;; The file descriptor or file refers to a block device inode.
|
||||
@@ -349,7 +349,7 @@
|
||||
|
||||
;;; A directory entry.
|
||||
(typename $dirent
|
||||
(struct
|
||||
(record
|
||||
;;; The offset of the next directory entry stored in this directory.
|
||||
(field $d_next $dircookie)
|
||||
;;; The serial number of the file referred to by this directory entry.
|
||||
@@ -363,7 +363,7 @@
|
||||
|
||||
;;; File or memory access pattern advisory information.
|
||||
(typename $advice
|
||||
(enum u8
|
||||
(enum (@witx tag u8)
|
||||
;;; The application has no advice to give on its behavior with respect to the specified data.
|
||||
$normal
|
||||
;;; The application expects to access the specified data sequentially from lower offsets to higher offsets.
|
||||
@@ -381,7 +381,7 @@
|
||||
|
||||
;;; File descriptor flags.
|
||||
(typename $fdflags
|
||||
(flags u16
|
||||
(flags (@witx repr u16)
|
||||
;;; Append mode: Data written to the file is always appended to the file's end.
|
||||
$append
|
||||
;;; Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
|
||||
@@ -399,7 +399,7 @@
|
||||
|
||||
;;; File descriptor attributes.
|
||||
(typename $fdstat
|
||||
(struct
|
||||
(record
|
||||
;;; File type.
|
||||
(field $fs_filetype $filetype)
|
||||
;;; File descriptor flags.
|
||||
@@ -418,7 +418,7 @@
|
||||
|
||||
;;; Which file time attributes to adjust.
|
||||
(typename $fstflags
|
||||
(flags u16
|
||||
(flags (@witx repr u16)
|
||||
;;; Adjust the last data access timestamp to the value stored in `filestat::atim`.
|
||||
$atim
|
||||
;;; Adjust the last data access timestamp to the time of clock `clockid::realtime`.
|
||||
@@ -432,7 +432,7 @@
|
||||
|
||||
;;; Flags determining the method of how paths are resolved.
|
||||
(typename $lookupflags
|
||||
(flags u32
|
||||
(flags (@witx repr u32)
|
||||
;;; As long as the resolved path corresponds to a symbolic link, it is expanded.
|
||||
$symlink_follow
|
||||
)
|
||||
@@ -440,7 +440,7 @@
|
||||
|
||||
;;; Open flags used by `path_open`.
|
||||
(typename $oflags
|
||||
(flags u16
|
||||
(flags (@witx repr u16)
|
||||
;;; Create file if it does not exist.
|
||||
$creat
|
||||
;;; Fail if not a directory.
|
||||
@@ -457,7 +457,7 @@
|
||||
|
||||
;;; File attributes.
|
||||
(typename $filestat
|
||||
(struct
|
||||
(record
|
||||
;;; Device ID of device containing the file.
|
||||
(field $dev $device)
|
||||
;;; File serial number.
|
||||
@@ -483,7 +483,7 @@
|
||||
|
||||
;;; Type of a subscription to an event or its occurrence.
|
||||
(typename $eventtype
|
||||
(enum u8
|
||||
(enum (@witx tag u8)
|
||||
;;; The time value of clock `subscription_clock::id` has
|
||||
;;; reached timestamp `subscription_clock::timeout`.
|
||||
$clock
|
||||
@@ -499,7 +499,7 @@
|
||||
;;; The state of the file descriptor subscribed to with
|
||||
;;; `eventtype::fd_read` or `eventtype::fd_write`.
|
||||
(typename $eventrwflags
|
||||
(flags u16
|
||||
(flags (@witx repr u16)
|
||||
;;; The peer of this socket has closed or disconnected.
|
||||
$fd_readwrite_hangup
|
||||
)
|
||||
@@ -508,7 +508,7 @@
|
||||
;;; The contents of an $event when type is `eventtype::fd_read` or
|
||||
;;; `eventtype::fd_write`.
|
||||
(typename $event_fd_readwrite
|
||||
(struct
|
||||
(record
|
||||
;;; The number of bytes available for reading or writing.
|
||||
(field $nbytes $filesize)
|
||||
;;; The state of the file descriptor.
|
||||
@@ -518,7 +518,7 @@
|
||||
|
||||
;;; An event that occurred.
|
||||
(typename $event
|
||||
(struct
|
||||
(record
|
||||
;;; User-provided value that got attached to `subscription::userdata`.
|
||||
(field $userdata $userdata)
|
||||
;;; If non-zero, an error that occurred while processing the subscription request.
|
||||
@@ -534,7 +534,7 @@
|
||||
;;; Flags determining how to interpret the timestamp provided in
|
||||
;;; `subscription_clock::timeout`.
|
||||
(typename $subclockflags
|
||||
(flags u16
|
||||
(flags (@witx repr u16)
|
||||
;;; If set, treat the timestamp provided in
|
||||
;;; `subscription_clock::timeout` as an absolute timestamp of clock
|
||||
;;; `subscription_clock::id`. If clear, treat the timestamp
|
||||
@@ -546,7 +546,7 @@
|
||||
|
||||
;;; The contents of a `subscription` when type is `eventtype::clock`.
|
||||
(typename $subscription_clock
|
||||
(struct
|
||||
(record
|
||||
;;; The clock against which to compare the timestamp.
|
||||
(field $id $clockid)
|
||||
;;; The absolute or relative timestamp.
|
||||
@@ -562,7 +562,7 @@
|
||||
;;; The contents of a `subscription` when type is type is
|
||||
;;; `eventtype::fd_read` or `eventtype::fd_write`.
|
||||
(typename $subscription_fd_readwrite
|
||||
(struct
|
||||
(record
|
||||
;;; The file descriptor on which to wait for it to become ready for reading or writing.
|
||||
(field $file_descriptor $fd)
|
||||
)
|
||||
@@ -570,16 +570,16 @@
|
||||
|
||||
;;; The contents of a `subscription`.
|
||||
(typename $subscription_u
|
||||
(union $eventtype
|
||||
(field $clock $subscription_clock)
|
||||
(field $fd_read $subscription_fd_readwrite)
|
||||
(field $fd_write $subscription_fd_readwrite)
|
||||
(union (@witx tag $eventtype)
|
||||
$subscription_clock
|
||||
$subscription_fd_readwrite
|
||||
$subscription_fd_readwrite
|
||||
)
|
||||
)
|
||||
|
||||
;;; Subscription to an event.
|
||||
(typename $subscription
|
||||
(struct
|
||||
(record
|
||||
;;; User-provided value that is attached to the subscription in the
|
||||
;;; implementation and returned through `event::userdata`.
|
||||
(field $userdata $userdata)
|
||||
@@ -593,7 +593,7 @@
|
||||
|
||||
;;; Signal condition.
|
||||
(typename $signal
|
||||
(enum u8
|
||||
(enum (@witx tag u8)
|
||||
;;; No signal. Note that POSIX has special semantics for `kill(pid, 0)`,
|
||||
;;; so this value is reserved.
|
||||
$none
|
||||
@@ -606,7 +606,7 @@
|
||||
;;; Terminal quit signal.
|
||||
;;; Action: Terminates the process.
|
||||
$quit
|
||||
;;; Illegal instruction.
|
||||
;;; Illegal inrecordion.
|
||||
;;; Action: Terminates the process.
|
||||
$ill
|
||||
;;; Trace/breakpoint trap.
|
||||
@@ -692,7 +692,7 @@
|
||||
|
||||
;;; Flags provided to `sock_recv`.
|
||||
(typename $riflags
|
||||
(flags u16
|
||||
(flags (@witx repr u16)
|
||||
;;; Returns the message without removing it from the socket's receive queue.
|
||||
$recv_peek
|
||||
;;; On byte-stream sockets, block until the full amount of data can be returned.
|
||||
@@ -702,7 +702,7 @@
|
||||
|
||||
;;; Flags returned by `sock_recv`.
|
||||
(typename $roflags
|
||||
(flags u16
|
||||
(flags (@witx repr u16)
|
||||
;;; Returned by `sock_recv`: Message data has been truncated.
|
||||
$recv_data_truncated
|
||||
)
|
||||
@@ -714,7 +714,7 @@
|
||||
|
||||
;;; Which channels on a socket to shut down.
|
||||
(typename $sdflags
|
||||
(flags u8
|
||||
(flags (@witx repr u8)
|
||||
;;; Disables further receive operations.
|
||||
$rd
|
||||
;;; Disables further send operations.
|
||||
@@ -724,7 +724,7 @@
|
||||
|
||||
;;; Identifiers for preopened capabilities.
|
||||
(typename $preopentype
|
||||
(enum u8
|
||||
(enum (@witx tag u8)
|
||||
;;; A pre-opened directory.
|
||||
$dir
|
||||
)
|
||||
@@ -732,7 +732,7 @@
|
||||
|
||||
;;; The contents of a $prestat when type is `preopentype::dir`.
|
||||
(typename $prestat_dir
|
||||
(struct
|
||||
(record
|
||||
;;; The length of the directory name for use with `fd_prestat_dir_name`.
|
||||
(field $pr_name_len $size)
|
||||
)
|
||||
@@ -740,7 +740,7 @@
|
||||
|
||||
;;; Information about a pre-opened capability.
|
||||
(typename $prestat
|
||||
(union $preopentype
|
||||
(field $dir $prestat_dir)
|
||||
(union (@witx tag $preopentype)
|
||||
$prestat_dir
|
||||
)
|
||||
)
|
||||
|
||||
@@ -108,7 +108,7 @@ impl GetTagExercise {
|
||||
let ctx = WasiCtx::new();
|
||||
let host_memory = HostMemory::new();
|
||||
|
||||
let discriminant: u8 = reason_tag(&self.input).into();
|
||||
let discriminant = reason_tag(&self.input) as u8;
|
||||
host_memory
|
||||
.ptr(self.input_loc.ptr)
|
||||
.write(discriminant)
|
||||
@@ -133,7 +133,7 @@ impl GetTagExercise {
|
||||
self.return_loc.ptr as i32,
|
||||
);
|
||||
|
||||
assert_eq!(e, Ok(types::Errno::Ok.into()), "get_tag errno");
|
||||
assert_eq!(e, Ok(types::Errno::Ok as i32), "get_tag errno");
|
||||
|
||||
let return_val: types::Excuse = host_memory
|
||||
.ptr(self.return_loc.ptr)
|
||||
@@ -185,7 +185,7 @@ impl ReasonMultExercise {
|
||||
let ctx = WasiCtx::new();
|
||||
let host_memory = HostMemory::new();
|
||||
|
||||
let discriminant: u8 = reason_tag(&self.input).into();
|
||||
let discriminant = reason_tag(&self.input) as u8;
|
||||
host_memory
|
||||
.ptr(self.input_loc.ptr)
|
||||
.write(discriminant)
|
||||
@@ -217,7 +217,7 @@ impl ReasonMultExercise {
|
||||
self.multiply_by as i32,
|
||||
);
|
||||
|
||||
assert_eq!(e, Ok(types::Errno::Ok.into()), "reason_mult errno");
|
||||
assert_eq!(e, Ok(types::Errno::Ok as i32), "reason_mult errno");
|
||||
|
||||
match self.input {
|
||||
types::Reason::DogAte(f) => {
|
||||
|
||||
@@ -5,27 +5,26 @@
|
||||
;; Fight for the full product of your labor!
|
||||
|
||||
(typename $reason
|
||||
(union $excuse
|
||||
(field $dog_ate f32)
|
||||
(field $traffic s32)
|
||||
(empty $sleeping)))
|
||||
(variant (@witx tag $excuse)
|
||||
(case $dog_ate f32)
|
||||
(case $traffic s32)
|
||||
(case $sleeping)))
|
||||
|
||||
(typename $reason_mut
|
||||
(union $excuse
|
||||
(field $dog_ate (@witx pointer f32))
|
||||
(field $traffic (@witx pointer s32))
|
||||
(empty $sleeping)))
|
||||
(variant (@witx tag $excuse)
|
||||
(case $dog_ate (@witx pointer f32))
|
||||
(case $traffic (@witx pointer s32))
|
||||
(case $sleeping)))
|
||||
|
||||
(module $union_example
|
||||
(@interface func (export "get_tag")
|
||||
(param $r $reason)
|
||||
(result $error $errno)
|
||||
(result $t $excuse)
|
||||
(result $error (expected $excuse (error $errno)))
|
||||
)
|
||||
|
||||
(@interface func (export "reason_mult")
|
||||
(param $r $reason_mut)
|
||||
(param $multiply_by u32)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
)
|
||||
|
||||
@@ -322,7 +322,7 @@ impl<'a> crate::wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiCtx<'a> {
|
||||
unimplemented!("poll_oneoff")
|
||||
}
|
||||
|
||||
fn proc_exit(&self, _rval: types::Exitcode) -> std::result::Result<(), ()> {
|
||||
fn proc_exit(&self, _rval: types::Exitcode) -> wiggle::Trap {
|
||||
unimplemented!("proc_exit")
|
||||
}
|
||||
|
||||
|
||||
@@ -17,15 +17,13 @@
|
||||
(@interface func (export "args_get")
|
||||
(param $argv (@witx pointer (@witx pointer u8)))
|
||||
(param $argv_buf (@witx pointer u8))
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
;;; Return command-line argument data sizes.
|
||||
(@interface func (export "args_sizes_get")
|
||||
(result $error $errno)
|
||||
;;; The number of arguments.
|
||||
(result $argc $size)
|
||||
;;; The size of the argument string data.
|
||||
(result $argv_buf_size $size)
|
||||
;;; Returns the number of arguments and the size of the argument string
|
||||
;;; data, or an error.
|
||||
(result $error (expected (tuple $size $size) (error $errno)))
|
||||
)
|
||||
|
||||
;;; Read environment variable data.
|
||||
@@ -33,15 +31,13 @@
|
||||
(@interface func (export "environ_get")
|
||||
(param $environ (@witx pointer (@witx pointer u8)))
|
||||
(param $environ_buf (@witx pointer u8))
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
;;; Return environment variable data sizes.
|
||||
(@interface func (export "environ_sizes_get")
|
||||
(result $error $errno)
|
||||
;;; The number of environment variable arguments.
|
||||
(result $environc $size)
|
||||
;;; The size of the environment variable data.
|
||||
(result $environ_buf_size $size)
|
||||
;;; Returns the number of environment variable arguments and the size of the
|
||||
;;; environment variable data.
|
||||
(result $error (expected (tuple $size $size) (error $errno)))
|
||||
)
|
||||
|
||||
;;; Return the resolution of a clock.
|
||||
@@ -51,9 +47,8 @@
|
||||
(@interface func (export "clock_res_get")
|
||||
;;; The clock for which to return the resolution.
|
||||
(param $id $clockid)
|
||||
(result $error $errno)
|
||||
;;; The resolution of the clock.
|
||||
(result $resolution $timestamp)
|
||||
;;; The resolution of the clock, or an error if one happened.
|
||||
(result $error (expected $timestamp (error $errno)))
|
||||
)
|
||||
;;; Return the time value of a clock.
|
||||
;;; Note: This is similar to `clock_gettime` in POSIX.
|
||||
@@ -62,9 +57,8 @@
|
||||
(param $id $clockid)
|
||||
;;; The maximum lag (exclusive) that the returned time value may have, compared to its actual value.
|
||||
(param $precision $timestamp)
|
||||
(result $error $errno)
|
||||
;;; The time value of the clock.
|
||||
(result $time $timestamp)
|
||||
(result $error (expected $timestamp (error $errno)))
|
||||
)
|
||||
|
||||
;;; Provide file advisory information on a file descriptor.
|
||||
@@ -77,7 +71,7 @@
|
||||
(param $len $filesize)
|
||||
;;; The advice.
|
||||
(param $advice $advice)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Force the allocation of space in a file.
|
||||
@@ -88,30 +82,29 @@
|
||||
(param $offset $filesize)
|
||||
;;; The length of the area that is allocated.
|
||||
(param $len $filesize)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Close a file descriptor.
|
||||
;;; Note: This is similar to `close` in POSIX.
|
||||
(@interface func (export "fd_close")
|
||||
(param $fd $fd)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Synchronize the data of a file to disk.
|
||||
;;; Note: This is similar to `fdatasync` in POSIX.
|
||||
(@interface func (export "fd_datasync")
|
||||
(param $fd $fd)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Get the attributes of a file descriptor.
|
||||
;;; Note: This returns similar flags to `fsync(fd, F_GETFL)` in POSIX, as well as additional fields.
|
||||
(@interface func (export "fd_fdstat_get")
|
||||
(param $fd $fd)
|
||||
(result $error $errno)
|
||||
;;; The buffer where the file descriptor's attributes are stored.
|
||||
(result $stat $fdstat)
|
||||
(result $error (expected $fdstat (error $errno)))
|
||||
)
|
||||
|
||||
;;; Adjust the flags associated with a file descriptor.
|
||||
@@ -120,7 +113,7 @@
|
||||
(param $fd $fd)
|
||||
;;; The desired values of the file descriptor flags.
|
||||
(param $flags $fdflags)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Adjust the rights associated with a file descriptor.
|
||||
@@ -130,15 +123,14 @@
|
||||
;;; The desired rights of the file descriptor.
|
||||
(param $fs_rights_base $rights)
|
||||
(param $fs_rights_inheriting $rights)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Return the attributes of an open file.
|
||||
(@interface func (export "fd_filestat_get")
|
||||
(param $fd $fd)
|
||||
(result $error $errno)
|
||||
;;; The buffer where the file's attributes are stored.
|
||||
(result $buf $filestat)
|
||||
(result $error (expected $filestat (error $errno)))
|
||||
)
|
||||
|
||||
;;; Adjust the size of an open file. If this increases the file's size, the extra bytes are filled with zeros.
|
||||
@@ -147,7 +139,7 @@
|
||||
(param $fd $fd)
|
||||
;;; The desired file size.
|
||||
(param $size $filesize)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Adjust the timestamps of an open file or directory.
|
||||
@@ -160,7 +152,7 @@
|
||||
(param $mtim $timestamp)
|
||||
;;; A bitmask indicating which timestamps to adjust.
|
||||
(param $fst_flags $fstflags)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Read from a file descriptor, without using and updating the file descriptor's offset.
|
||||
@@ -171,17 +163,15 @@
|
||||
(param $iovs $iovec_array)
|
||||
;;; The offset within the file at which to read.
|
||||
(param $offset $filesize)
|
||||
(result $error $errno)
|
||||
;;; The number of bytes read.
|
||||
(result $nread $size)
|
||||
(result $error (expected $size (error $errno)))
|
||||
)
|
||||
|
||||
;;; Return a description of the given preopened file descriptor.
|
||||
(@interface func (export "fd_prestat_get")
|
||||
(param $fd $fd)
|
||||
(result $error $errno)
|
||||
;;; The buffer where the description is stored.
|
||||
(result $buf $prestat)
|
||||
(result $error (expected $prestat (error $errno)))
|
||||
)
|
||||
|
||||
;;; Return a description of the given preopened file descriptor.
|
||||
@@ -190,7 +180,7 @@
|
||||
;;; A buffer into which to write the preopened directory name.
|
||||
(param $path (@witx pointer u8))
|
||||
(param $path_len $size)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Write to a file descriptor, without using and updating the file descriptor's offset.
|
||||
@@ -201,9 +191,8 @@
|
||||
(param $iovs $ciovec_array)
|
||||
;;; The offset within the file at which to write.
|
||||
(param $offset $filesize)
|
||||
(result $error $errno)
|
||||
;;; The number of bytes written.
|
||||
(result $nwritten $size)
|
||||
(result $error (expected $size (error $errno)))
|
||||
)
|
||||
|
||||
;;; Read from a file descriptor.
|
||||
@@ -212,15 +201,14 @@
|
||||
(param $fd $fd)
|
||||
;;; List of scatter/gather vectors to which to store data.
|
||||
(param $iovs $iovec_array)
|
||||
(result $error $errno)
|
||||
;;; The number of bytes read.
|
||||
(result $nread $size)
|
||||
(result $error (expected $size (error $errno)))
|
||||
)
|
||||
|
||||
;;; Read directory entries from a directory.
|
||||
;;; When successful, the contents of the output buffer consist of a sequence of
|
||||
;;; directory entries. Each directory entry consists of a dirent_t object,
|
||||
;;; followed by dirent_t::d_namlen bytes holding the name of the directory
|
||||
;;; directory entries. Each directory entry consists of a `dirent` object,
|
||||
;;; followed by `dirent::d_namlen` bytes holding the name of the directory
|
||||
;;; entry.
|
||||
;;
|
||||
;;; This function fills the output buffer as much as possible, potentially
|
||||
@@ -234,9 +222,8 @@
|
||||
(param $buf_len $size)
|
||||
;;; The location within the directory to start reading
|
||||
(param $cookie $dircookie)
|
||||
(result $error $errno)
|
||||
;;; The number of bytes stored in the read buffer. If less than the size of the read buffer, the end of the directory has been reached.
|
||||
(result $bufused $size)
|
||||
(result $error (expected $size (error $errno)))
|
||||
)
|
||||
|
||||
;;; Atomically replace a file descriptor by renumbering another file descriptor.
|
||||
@@ -253,7 +240,7 @@
|
||||
(param $fd $fd)
|
||||
;;; The file descriptor to overwrite.
|
||||
(param $to $fd)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Move the offset of a file descriptor.
|
||||
@@ -264,25 +251,23 @@
|
||||
(param $offset $filedelta)
|
||||
;;; The base from which the offset is relative.
|
||||
(param $whence $whence)
|
||||
(result $error $errno)
|
||||
;;; The new offset of the file descriptor, relative to the start of the file.
|
||||
(result $newoffset $filesize)
|
||||
(result $error (expected $filesize (error $errno)))
|
||||
)
|
||||
|
||||
;;; Synchronize the data and metadata of a file to disk.
|
||||
;;; Note: This is similar to `fsync` in POSIX.
|
||||
(@interface func (export "fd_sync")
|
||||
(param $fd $fd)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Return the current offset of a file descriptor.
|
||||
;;; Note: This is similar to `lseek(fd, 0, SEEK_CUR)` in POSIX.
|
||||
(@interface func (export "fd_tell")
|
||||
(param $fd $fd)
|
||||
(result $error $errno)
|
||||
;;; The current offset of the file descriptor, relative to the start of the file.
|
||||
(result $offset $filesize)
|
||||
(result $error (expected $filesize (error $errno)))
|
||||
)
|
||||
|
||||
;;; Write to a file descriptor.
|
||||
@@ -291,9 +276,7 @@
|
||||
(param $fd $fd)
|
||||
;;; List of scatter/gather vectors from which to retrieve data.
|
||||
(param $iovs $ciovec_array)
|
||||
(result $error $errno)
|
||||
;;; The number of bytes written.
|
||||
(result $nwritten $size)
|
||||
(result $error (expected $size (error $errno)))
|
||||
)
|
||||
|
||||
;;; Create a directory.
|
||||
@@ -302,7 +285,7 @@
|
||||
(param $fd $fd)
|
||||
;;; The path at which to create the directory.
|
||||
(param $path string)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Return the attributes of a file or directory.
|
||||
@@ -313,9 +296,8 @@
|
||||
(param $flags $lookupflags)
|
||||
;;; The path of the file or directory to inspect.
|
||||
(param $path string)
|
||||
(result $error $errno)
|
||||
;;; The buffer where the file's attributes are stored.
|
||||
(result $buf $filestat)
|
||||
(result $error (expected $filestat (error $errno)))
|
||||
)
|
||||
|
||||
;;; Adjust the timestamps of a file or directory.
|
||||
@@ -332,7 +314,7 @@
|
||||
(param $mtim $timestamp)
|
||||
;;; A bitmask indicating which timestamps to adjust.
|
||||
(param $fst_flags $fstflags)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Create a hard link.
|
||||
@@ -347,7 +329,7 @@
|
||||
(param $new_fd $fd)
|
||||
;;; The destination path at which to create the hard link.
|
||||
(param $new_path string)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Open a file or directory.
|
||||
@@ -377,11 +359,10 @@
|
||||
;;; descriptor itself, while the *inheriting* rights are rights that apply to
|
||||
;;; file descriptors derived from it.
|
||||
(param $fs_rights_base $rights)
|
||||
(param $fs_rights_inherting $rights)
|
||||
(param $fs_rights_inheriting $rights)
|
||||
(param $fdflags $fdflags)
|
||||
(result $error $errno)
|
||||
;;; The file descriptor of the file that has been opened.
|
||||
(result $opened_fd $fd)
|
||||
(result $error (expected $fd (error $errno)))
|
||||
)
|
||||
|
||||
;;; Read the contents of a symbolic link.
|
||||
@@ -393,9 +374,8 @@
|
||||
;;; The buffer to which to write the contents of the symbolic link.
|
||||
(param $buf (@witx pointer u8))
|
||||
(param $buf_len $size)
|
||||
(result $error $errno)
|
||||
;;; The number of bytes placed in the buffer.
|
||||
(result $bufused $size)
|
||||
(result $error (expected $size (error $errno)))
|
||||
)
|
||||
|
||||
;;; Remove a directory.
|
||||
@@ -405,7 +385,7 @@
|
||||
(param $fd $fd)
|
||||
;;; The path to a directory to remove.
|
||||
(param $path string)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Rename a file or directory.
|
||||
@@ -418,7 +398,7 @@
|
||||
(param $new_fd $fd)
|
||||
;;; The destination path to which to rename the file or directory.
|
||||
(param $new_path string)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Create a symbolic link.
|
||||
@@ -429,7 +409,7 @@
|
||||
(param $fd $fd)
|
||||
;;; The destination path at which to create the symbolic link.
|
||||
(param $new_path string)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
|
||||
@@ -440,7 +420,7 @@
|
||||
(param $fd $fd)
|
||||
;;; The path to a file to unlink.
|
||||
(param $path string)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Concurrently poll for the occurrence of a set of events.
|
||||
@@ -451,9 +431,8 @@
|
||||
(param $out (@witx pointer $event))
|
||||
;;; Both the number of subscriptions and events.
|
||||
(param $nsubscriptions $size)
|
||||
(result $error $errno)
|
||||
;;; The number of events stored.
|
||||
(result $nevents $size)
|
||||
(result $error (expected $size (error $errno)))
|
||||
)
|
||||
|
||||
;;; Terminate the process normally. An exit code of 0 indicates successful
|
||||
@@ -462,6 +441,7 @@
|
||||
(@interface func (export "proc_exit")
|
||||
;;; The exit code returned by the process.
|
||||
(param $rval $exitcode)
|
||||
(@witx noreturn)
|
||||
)
|
||||
|
||||
;;; Send a signal to the process of the calling thread.
|
||||
@@ -469,13 +449,13 @@
|
||||
(@interface func (export "proc_raise")
|
||||
;;; The signal condition to trigger.
|
||||
(param $sig $signal)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Temporarily yield execution of the calling thread.
|
||||
;;; Note: This is similar to `sched_yield` in POSIX.
|
||||
(@interface func (export "sched_yield")
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Write high-quality random data into a buffer.
|
||||
@@ -488,7 +468,7 @@
|
||||
;;; The buffer to fill with random data.
|
||||
(param $buf (@witx pointer u8))
|
||||
(param $buf_len $size)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
|
||||
;;; Receive a message from a socket.
|
||||
@@ -500,11 +480,8 @@
|
||||
(param $ri_data $iovec_array)
|
||||
;;; Message flags.
|
||||
(param $ri_flags $riflags)
|
||||
(result $error $errno)
|
||||
;;; Number of bytes stored in ri_data.
|
||||
(result $ro_datalen $size)
|
||||
;;; Message flags.
|
||||
(result $ro_flags $roflags)
|
||||
;;; Number of bytes stored in ri_data and message flags.
|
||||
(result $error (expected (tuple $size $roflags) (error $errno)))
|
||||
)
|
||||
|
||||
;;; Send a message on a socket.
|
||||
@@ -516,9 +493,8 @@
|
||||
(param $si_data $ciovec_array)
|
||||
;;; Message flags.
|
||||
(param $si_flags $siflags)
|
||||
(result $error $errno)
|
||||
;;; Number of bytes transmitted.
|
||||
(result $so_datalen $size)
|
||||
(result $error (expected $size (error $errno)))
|
||||
)
|
||||
|
||||
;;; Shut down socket send and receive channels.
|
||||
@@ -527,6 +503,6 @@
|
||||
(param $fd $fd)
|
||||
;;; Which channels on the socket to shut down.
|
||||
(param $how $sdflags)
|
||||
(result $error $errno)
|
||||
(result $error (expected (error $errno)))
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user