mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-13 05:48:45 +00:00
Various fixes
* Fix bindings generation with manual patchup via syn * Fix .wit types and re-generate bindings * Enable some missing dependency features
This commit is contained in:
94
Cargo.lock
generated
94
Cargo.lock
generated
@@ -3937,6 +3937,73 @@ version = "1.0.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wai-bindgen-gen-core"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "27c779b29ab9bb82d1a2ac6218b5926cd3fb0392973ee0b4dfdb7e6d5bd4c87e"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"wai-parser",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wai-bindgen-gen-rust"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7be9a8d43877a97d0eea17f95e79abc3870a590459352126354ee3991248c399"
|
||||||
|
dependencies = [
|
||||||
|
"heck 0.3.3",
|
||||||
|
"wai-bindgen-gen-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wai-bindgen-gen-rust-wasm"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f33c72295f2fa33594e0efee829377c7c62a9b69d1e25fc402153e1d56ac4402"
|
||||||
|
dependencies = [
|
||||||
|
"heck 0.3.3",
|
||||||
|
"wai-bindgen-gen-core",
|
||||||
|
"wai-bindgen-gen-rust",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wai-bindgen-rust"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "93957196c4344f2826023233b8354e0dd522af87f77e620992d6d1d4f52f1210"
|
||||||
|
dependencies = [
|
||||||
|
"async-trait",
|
||||||
|
"bitflags",
|
||||||
|
"wai-bindgen-rust-impl",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wai-bindgen-rust-impl"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ab28580d6620f593c0501d88348b489338c2e4f5c0d81769fd1c0bbac3f884ec"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"syn",
|
||||||
|
"wai-bindgen-gen-core",
|
||||||
|
"wai-bindgen-gen-rust-wasm",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wai-parser"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bd8cc5a5c1a118c3c392bff93c548e6732d881daf92f23ac08466f7a22412f66"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"id-arena",
|
||||||
|
"pulldown-cmark",
|
||||||
|
"unicode-normalization",
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wait-timeout"
|
name = "wait-timeout"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
@@ -4141,6 +4208,7 @@ dependencies = [
|
|||||||
"js-sys",
|
"js-sys",
|
||||||
"macro-wasmer-universal-test",
|
"macro-wasmer-universal-test",
|
||||||
"more-asserts",
|
"more-asserts",
|
||||||
|
"rkyv",
|
||||||
"serde",
|
"serde",
|
||||||
"serde-wasm-bindgen",
|
"serde-wasm-bindgen",
|
||||||
"target-lexicon 0.12.5",
|
"target-lexicon 0.12.5",
|
||||||
@@ -4532,6 +4600,7 @@ dependencies = [
|
|||||||
"typetag",
|
"typetag",
|
||||||
"wasmer",
|
"wasmer",
|
||||||
"wasmer-vfs",
|
"wasmer-vfs",
|
||||||
|
"wasmer-wasi-types",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -4678,12 +4747,12 @@ dependencies = [
|
|||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
"serde",
|
"serde",
|
||||||
"time",
|
"time",
|
||||||
|
"wai-bindgen-rust",
|
||||||
"wasmer",
|
"wasmer",
|
||||||
"wasmer-derive",
|
"wasmer-derive",
|
||||||
"wasmer-types",
|
"wasmer-types",
|
||||||
"wasmer-wit-bindgen-gen-core",
|
"wasmer-wit-bindgen-gen-core",
|
||||||
"wasmer-wit-bindgen-gen-rust-wasm",
|
"wasmer-wit-bindgen-gen-rust-wasm",
|
||||||
"wasmer-wit-bindgen-rust",
|
|
||||||
"wasmer-wit-parser",
|
"wasmer-wit-parser",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -4732,29 +4801,6 @@ dependencies = [
|
|||||||
"wasmer-wit-bindgen-gen-rust",
|
"wasmer-wit-bindgen-gen-rust",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasmer-wit-bindgen-rust"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "968747f1271f74aab9b70d9c5d4921db9bd13b4ec3ba5506506e6e7dc58c918c"
|
|
||||||
dependencies = [
|
|
||||||
"async-trait",
|
|
||||||
"bitflags",
|
|
||||||
"wasmer-wit-bindgen-rust-impl",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasmer-wit-bindgen-rust-impl"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bd26fe00d08bd2119870b017d13413dfbd51e7750b6634d649fc7a7bbc057b85"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"syn",
|
|
||||||
"wasmer-wit-bindgen-gen-core",
|
|
||||||
"wasmer-wit-bindgen-gen-rust-wasm",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasmer-wit-parser"
|
name = "wasmer-wit-parser"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
|
|||||||
@@ -259,3 +259,6 @@ required-features = ["cranelift"]
|
|||||||
name = "features"
|
name = "features"
|
||||||
path = "examples/features.rs"
|
path = "examples/features.rs"
|
||||||
required-features = ["cranelift"]
|
required-features = ["cranelift"]
|
||||||
|
|
||||||
|
[patch.crates-io]
|
||||||
|
wasmer-vfs = { path = "./lib/vfs" }
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ bytes = "1"
|
|||||||
# - Optional shared dependencies.
|
# - Optional shared dependencies.
|
||||||
wat = { version = "1.0", optional = true }
|
wat = { version = "1.0", optional = true }
|
||||||
tracing = { version = "0.1", optional = true }
|
tracing = { version = "0.1", optional = true }
|
||||||
|
rkyv = { version = "0.7.38", features = ["indexmap"], optional = true }
|
||||||
|
|
||||||
# Dependencies and Development Dependencies for `sys`.
|
# Dependencies and Development Dependencies for `sys`.
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
@@ -130,6 +131,7 @@ enable-serde = [
|
|||||||
]
|
]
|
||||||
enable-rkyv = [
|
enable-rkyv = [
|
||||||
"wasmer-types/enable-rkyv",
|
"wasmer-types/enable-rkyv",
|
||||||
|
"wasmer-compiler/enable-rkyv",
|
||||||
]
|
]
|
||||||
|
|
||||||
wasmer-artifact-load = ["wasmer-compiler/wasmer-artifact-load"]
|
wasmer-artifact-load = ["wasmer-compiler/wasmer-artifact-load"]
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ impl Module {
|
|||||||
store: &impl AsStoreRef,
|
store: &impl AsStoreRef,
|
||||||
bytes: impl IntoBytes,
|
bytes: impl IntoBytes,
|
||||||
) -> Result<Self, wasmer_types::DeserializeError> {
|
) -> Result<Self, wasmer_types::DeserializeError> {
|
||||||
let bytes = bytes.into_bytes();
|
let bytes = bytes.into_bytes().to_vec();
|
||||||
let artifact = store.as_store_ref().engine().deserialize(&bytes)?;
|
let artifact = store.as_store_ref().engine().deserialize(&bytes)?;
|
||||||
Ok(Self::from_artifact(artifact))
|
Ok(Self::from_artifact(artifact))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ typetag = { version = "0.1", optional = true }
|
|||||||
slab = { version = "0.4", optional = true }
|
slab = { version = "0.4", optional = true }
|
||||||
wasmer = { path = "../api", version = "=3.0.0-rc.2", default-features = false }
|
wasmer = { path = "../api", version = "=3.0.0-rc.2", default-features = false }
|
||||||
wasmer-vfs = { path = "../vfs", version = "=3.0.0-rc.2", default-features = false }
|
wasmer-vfs = { path = "../vfs", version = "=3.0.0-rc.2", default-features = false }
|
||||||
|
wasmer-wasi-types = { path = "../wasi-types/", version = "3.0.0-rc.2" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["mem_fs"]
|
default = ["mem_fs"]
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use wasmer::{FunctionEnvMut, Store};
|
|||||||
pub use wasmer_vfs::FileDescriptor;
|
pub use wasmer_vfs::FileDescriptor;
|
||||||
pub use wasmer_vfs::StdioMode;
|
pub use wasmer_vfs::StdioMode;
|
||||||
use wasmer_vfs::VirtualFile;
|
use wasmer_vfs::VirtualFile;
|
||||||
|
use wasmer_wasi_types::wasi::BusDataFormat;
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, VirtualBusError>;
|
pub type Result<T> = std::result::Result<T, VirtualBusError>;
|
||||||
|
|
||||||
@@ -434,17 +435,17 @@ pub trait VirtualBusCalled: fmt::Debug + Send + Sync + 'static {
|
|||||||
fn reply(&self, format: BusDataFormat, buf: Vec<u8>);
|
fn reply(&self, format: BusDataFormat, buf: Vec<u8>);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Format that the supplied data is in
|
// /// Format that the supplied data is in
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
// #[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
pub enum BusDataFormat {
|
// pub enum BusDataFormat {
|
||||||
Raw,
|
// Raw,
|
||||||
Bincode,
|
// Bincode,
|
||||||
MessagePack,
|
// MessagePack,
|
||||||
Json,
|
// Json,
|
||||||
Yaml,
|
// Yaml,
|
||||||
Xml,
|
// Xml,
|
||||||
Rkyv,
|
// Rkyv,
|
||||||
}
|
// }
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct DefaultVirtualBus {}
|
pub struct DefaultVirtualBus {}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ edition = "2018"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wit-bindgen-rust = { package = "wasmer-wit-bindgen-rust", version = "0.1.1", optional = true }
|
wai-bindgen-rust = { version = "0.2.0" }
|
||||||
wit-bindgen-rust-wasm = { package = "wasmer-wit-bindgen-gen-rust-wasm", version = "0.1.1" }
|
wit-bindgen-rust-wasm = { package = "wasmer-wit-bindgen-gen-rust-wasm", version = "0.1.1" }
|
||||||
wit-bindgen-core = { package = "wasmer-wit-bindgen-gen-core", version = "0.1.1" }
|
wit-bindgen-core = { package = "wasmer-wit-bindgen-gen-core", version = "0.1.1" }
|
||||||
wit-parser = { package = "wasmer-wit-parser", version = "0.1.1" }
|
wit-parser = { package = "wasmer-wit-parser", version = "0.1.1" }
|
||||||
@@ -23,7 +23,7 @@ serde = { version = "1.0", features = ["derive"], optional = true }
|
|||||||
byteorder = "1.3"
|
byteorder = "1.3"
|
||||||
time = "0.2"
|
time = "0.2"
|
||||||
num_enum = "0.5.7"
|
num_enum = "0.5.7"
|
||||||
bitflags = "1.3.2"
|
bitflags = "1.3.0"
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
wasmer = { default-features = false, path = "../api", version = "3.0.0-beta" }
|
wasmer = { default-features = false, path = "../api", version = "3.0.0-beta" }
|
||||||
@@ -36,5 +36,5 @@ version = "1.3.0"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
enable-serde = ["serde", "wasmer-types/serde"]
|
enable-serde = ["serde", "wasmer-types/serde"]
|
||||||
js = ["wasmer/js", "wasmer/std" ]
|
js = ["wasmer/js", "wasmer/std"]
|
||||||
sys = ["wasmer/sys" ]
|
sys = ["wasmer/sys"]
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -Eeuxo pipefail
|
||||||
|
|
||||||
BASEDIR=$(dirname "$0")
|
BASEDIR=$(dirname "$0")
|
||||||
|
|
||||||
rm -f \
|
rm -f \
|
||||||
@@ -8,9 +10,13 @@ rm -f \
|
|||||||
|
|
||||||
cat "$BASEDIR"/wit-clean/typenames.wit "$BASEDIR"/wit-clean/wasi_unstable.wit > "$BASEDIR"/wit-clean/output.wit
|
cat "$BASEDIR"/wit-clean/typenames.wit "$BASEDIR"/wit-clean/wasi_unstable.wit > "$BASEDIR"/wit-clean/output.wit
|
||||||
|
|
||||||
git clone https://github.com/wasmerio/wit-bindgen --branch force-generate-structs --single-branch
|
cd "$BASEDIR"
|
||||||
git pull origin force-generate-structs
|
|
||||||
|
if [ ! -d ./wit-bindgen/.git ]; then
|
||||||
|
git clone https://github.com/wasmerio/wai --branch force-generate-structs --single-branch wit-bindgen
|
||||||
|
fi
|
||||||
cd wit-bindgen
|
cd wit-bindgen
|
||||||
|
git pull origin force-generate-structs
|
||||||
cargo build
|
cargo build
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
@@ -25,7 +31,7 @@ cp src/wasi/bindings2.rs src/wasi/bindings.rs
|
|||||||
rm src/wasi/bindings2.rs
|
rm src/wasi/bindings2.rs
|
||||||
|
|
||||||
cd ./wasi-types-generator-extra
|
cd ./wasi-types-generator-extra
|
||||||
cargo build
|
cargo run
|
||||||
pwd
|
pwd
|
||||||
`pwd`/target/debug/wasi-types-generator-extra
|
`pwd`/target/debug/wasi-types-generator-extra
|
||||||
cd ..
|
cd ..
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ pub use subscription::*;
|
|||||||
|
|
||||||
pub mod bus {
|
pub mod bus {
|
||||||
use crate::wasi::{
|
use crate::wasi::{
|
||||||
Bid, BusErrno, BusEventType, Cid, ExitCode, Fd, OptionCid, WasiHash, __wasi_busdataformat_t,
|
Bid, BusDataFormat, BusErrno, BusEventType, Cid, ExitCode, Fd, OptionCid, WasiHash,
|
||||||
};
|
};
|
||||||
use wasmer_derive::ValueType;
|
use wasmer_derive::ValueType;
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ pub mod bus {
|
|||||||
pub struct __wasi_busevent_call_t {
|
pub struct __wasi_busevent_call_t {
|
||||||
pub parent: OptionCid,
|
pub parent: OptionCid,
|
||||||
pub cid: Cid,
|
pub cid: Cid,
|
||||||
pub format: __wasi_busdataformat_t,
|
pub format: BusDataFormat,
|
||||||
pub topic_hash: WasiHash,
|
pub topic_hash: WasiHash,
|
||||||
pub fd: Fd,
|
pub fd: Fd,
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ pub mod bus {
|
|||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueType)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct __wasi_busevent_result_t {
|
pub struct __wasi_busevent_result_t {
|
||||||
pub format: __wasi_busdataformat_t,
|
pub format: BusDataFormat,
|
||||||
pub cid: Cid,
|
pub cid: Cid,
|
||||||
pub fd: Fd,
|
pub fd: Fd,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ pub mod output {
|
|||||||
pub type Tid = u32;
|
pub type Tid = u32;
|
||||||
pub type Pid = u32;
|
pub type Pid = u32;
|
||||||
/// Identifiers for clocks, snapshot0 version.
|
/// Identifiers for clocks, snapshot0 version.
|
||||||
#[repr(u32)]
|
#[repr(u8)]
|
||||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum Snapshot0Clockid {
|
pub enum Snapshot0Clockid {
|
||||||
/// The clock measuring real time. Time value zero corresponds with
|
/// The clock measuring real time. Time value zero corresponds with
|
||||||
@@ -60,7 +60,7 @@ pub mod output {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Identifiers for clocks.
|
/// Identifiers for clocks.
|
||||||
#[repr(u32)]
|
#[repr(u8)]
|
||||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum Clockid {
|
pub enum Clockid {
|
||||||
/// The clock measuring real time. Time value zero corresponds with
|
/// The clock measuring real time. Time value zero corresponds with
|
||||||
@@ -85,10 +85,10 @@ pub mod output {
|
|||||||
Clockid::Monotonic => {
|
Clockid::Monotonic => {
|
||||||
f.debug_tuple("Clockid::Monotonic").finish()
|
f.debug_tuple("Clockid::Monotonic").finish()
|
||||||
}
|
}
|
||||||
Snapshot0Clockid::ProcessCputimeId => {
|
Clockid::ProcessCputimeId => {
|
||||||
f.debug_tuple("Clockid::ProcessCputimeId").finish()
|
f.debug_tuple("Clockid::ProcessCputimeId").finish()
|
||||||
}
|
}
|
||||||
Snapshot0Clockid::ThreadCputimeId => {
|
Clockid::ThreadCputimeId => {
|
||||||
f.debug_tuple("Clockid::ThreadCputimeId").finish()
|
f.debug_tuple("Clockid::ThreadCputimeId").finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ pub mod output {
|
|||||||
/// Not all of these error codes are returned by the functions provided by this
|
/// Not all of these error codes are returned by the functions provided by this
|
||||||
/// API; some are used in higher-level library layers, and others are provided
|
/// API; some are used in higher-level library layers, and others are provided
|
||||||
/// merely for alignment with POSIX.
|
/// merely for alignment with POSIX.
|
||||||
#[repr(u16)]
|
#[repr(u8)]
|
||||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum Errno {
|
pub enum Errno {
|
||||||
/// No error occurred. System call completed successfully.
|
/// No error occurred. System call completed successfully.
|
||||||
@@ -435,7 +435,7 @@ pub mod output {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl std::error::Error for Errno{}
|
impl std::error::Error for Errno{}
|
||||||
#[repr(u32)]
|
#[repr(u8)]
|
||||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum BusErrno {
|
pub enum BusErrno {
|
||||||
/// No error occurred. Call completed successfully.
|
/// No error occurred. Call completed successfully.
|
||||||
@@ -544,7 +544,7 @@ pub mod output {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl std::error::Error for BusErrno{}
|
impl std::error::Error for BusErrno{}
|
||||||
bitflags! {
|
wit_bindgen_rust::bitflags::bitflags! {
|
||||||
/// File descriptor rights, determining which actions may be performed.
|
/// File descriptor rights, determining which actions may be performed.
|
||||||
pub struct Rights: u64 {
|
pub struct Rights: u64 {
|
||||||
/// The right to invoke `fd_datasync`.
|
/// The right to invoke `fd_datasync`.
|
||||||
@@ -780,7 +780,7 @@ pub mod output {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bitflags::bitflags! {
|
wit_bindgen_rust::bitflags::bitflags! {
|
||||||
/// File descriptor flags.
|
/// File descriptor flags.
|
||||||
pub struct Fdflags: u8 {
|
pub struct Fdflags: u8 {
|
||||||
/// Append mode: Data written to the file is always appended to the file's end.
|
/// Append mode: Data written to the file is always appended to the file's end.
|
||||||
@@ -822,7 +822,7 @@ pub mod output {
|
|||||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
f.debug_struct("Fdstat").field("fs-filetype", &self.fs_filetype).field("fs-flags", &self.fs_flags).field("fs-rights-base", &self.fs_rights_base).field("fs-rights-inheriting", &self.fs_rights_inheriting).finish()}
|
f.debug_struct("Fdstat").field("fs-filetype", &self.fs_filetype).field("fs-flags", &self.fs_flags).field("fs-rights-base", &self.fs_rights_base).field("fs-rights-inheriting", &self.fs_rights_inheriting).finish()}
|
||||||
}
|
}
|
||||||
bitflags::bitflags! {
|
wit_bindgen_rust::bitflags::bitflags! {
|
||||||
/// Which file time attributes to adjust.
|
/// Which file time attributes to adjust.
|
||||||
/// TODO: wit appears to not have support for flags repr
|
/// TODO: wit appears to not have support for flags repr
|
||||||
/// (@witx repr u16)
|
/// (@witx repr u16)
|
||||||
@@ -844,7 +844,7 @@ pub mod output {
|
|||||||
Self { bits }
|
Self { bits }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bitflags::bitflags! {
|
wit_bindgen_rust::bitflags::bitflags! {
|
||||||
/// Flags determining the method of how paths are resolved.
|
/// Flags determining the method of how paths are resolved.
|
||||||
/// TODO: wit appears to not have support for flags repr
|
/// TODO: wit appears to not have support for flags repr
|
||||||
/// (@witx repr u32)
|
/// (@witx repr u32)
|
||||||
@@ -860,7 +860,7 @@ pub mod output {
|
|||||||
Self { bits }
|
Self { bits }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bitflags::bitflags! {
|
wit_bindgen_rust::bitflags::bitflags! {
|
||||||
/// Open flags used by `path_open`.
|
/// Open flags used by `path_open`.
|
||||||
/// TODO: wit appears to not have support for flags repr
|
/// TODO: wit appears to not have support for flags repr
|
||||||
/// (@witx repr u16)
|
/// (@witx repr u16)
|
||||||
@@ -914,7 +914,7 @@ pub mod output {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bitflags::bitflags! {
|
wit_bindgen_rust::bitflags::bitflags! {
|
||||||
/// Flags determining how to interpret the timestamp provided in
|
/// Flags determining how to interpret the timestamp provided in
|
||||||
/// `subscription-clock::timeout`.
|
/// `subscription-clock::timeout`.
|
||||||
pub struct Subclockflags: u8 {
|
pub struct Subclockflags: u8 {
|
||||||
@@ -987,7 +987,7 @@ pub mod output {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bitflags::bitflags! {
|
wit_bindgen_rust::bitflags::bitflags! {
|
||||||
/// The state of the file descriptor subscribed to with
|
/// The state of the file descriptor subscribed to with
|
||||||
/// `eventtype::fd_read` or `eventtype::fd_write`.
|
/// `eventtype::fd_read` or `eventtype::fd_write`.
|
||||||
pub struct Eventrwflags: u8 {
|
pub struct Eventrwflags: u8 {
|
||||||
@@ -1017,104 +1017,10 @@ pub mod output {
|
|||||||
f.debug_struct("EventFdReadwrite").field("nbytes", &self.nbytes).field("flags", &self.flags).finish()}
|
f.debug_struct("EventFdReadwrite").field("nbytes", &self.nbytes).field("flags", &self.flags).finish()}
|
||||||
}
|
}
|
||||||
/// An event that occurred.
|
/// An event that occurred.
|
||||||
#[repr(C)]
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
pub struct Event {
|
|
||||||
/// User-provided value that got attached to `subscription::userdata`.
|
|
||||||
pub userdata: Userdata,
|
|
||||||
/// If non-zero, an error that occurred while processing the subscription request.
|
|
||||||
pub error: Errno,
|
|
||||||
/// The type of the event that occurred, and the contents of the event
|
|
||||||
pub data: EventEnum,
|
|
||||||
}
|
|
||||||
impl core::fmt::Debug for Event {
|
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
|
||||||
f.debug_struct("Event").field("userdata", &self.userdata).field("error", &self.error).field("data", &self.data).finish()}
|
|
||||||
}
|
|
||||||
/// The contents of an `event`.
|
/// The contents of an `event`.
|
||||||
#[derive(Clone, Copy)]
|
|
||||||
pub enum EventEnum{
|
|
||||||
FdRead(EventFdReadwrite),
|
|
||||||
FdWrite(EventFdReadwrite),
|
|
||||||
Clock,
|
|
||||||
}
|
|
||||||
impl core::fmt::Debug for EventEnum {
|
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
|
||||||
match self {
|
|
||||||
EventEnum::FdRead(e) => {
|
|
||||||
f.debug_tuple("EventEnum::FdRead").field(e).finish()
|
|
||||||
}
|
|
||||||
EventEnum::FdWrite(e) => {
|
|
||||||
f.debug_tuple("EventEnum::FdWrite").field(e).finish()
|
|
||||||
}
|
|
||||||
EventEnum::Clock => {
|
|
||||||
f.debug_tuple("EventEnum::Clock").finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// An event that occurred.
|
/// An event that occurred.
|
||||||
#[repr(C)]
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
pub struct Snapshot0Event {
|
|
||||||
/// User-provided value that got attached to `subscription::userdata`.
|
|
||||||
pub userdata: Userdata,
|
|
||||||
/// If non-zero, an error that occurred while processing the subscription request.
|
|
||||||
pub error: Errno,
|
|
||||||
/// The type of event that occured
|
|
||||||
pub type_: Eventtype,
|
|
||||||
/// The contents of the event, if it is an `eventtype::fd_read` or
|
|
||||||
/// `eventtype::fd_write`. `eventtype::clock` events ignore this field.
|
|
||||||
pub fd_readwrite: EventFdReadwrite,
|
|
||||||
}
|
|
||||||
impl core::fmt::Debug for Snapshot0Event {
|
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
|
||||||
f.debug_struct("Snapshot0Event").field("userdata", &self.userdata).field("error", &self.error).field("type", &self.type_).field("fd-readwrite", &self.fd_readwrite).finish()}
|
|
||||||
}
|
|
||||||
/// The contents of a `subscription`, snapshot0 version.
|
/// The contents of a `subscription`, snapshot0 version.
|
||||||
#[derive(Clone, Copy)]
|
|
||||||
pub enum Snapshot0SubscriptionEnum{
|
|
||||||
Clock(Snapshot0SubscriptionClock),
|
|
||||||
Read(SubscriptionFsReadwrite),
|
|
||||||
Write(SubscriptionFsReadwrite),
|
|
||||||
}
|
|
||||||
impl core::fmt::Debug for Snapshot0SubscriptionEnum {
|
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
|
||||||
match self {
|
|
||||||
Snapshot0SubscriptionEnum::Clock(e) => {
|
|
||||||
f.debug_tuple("Snapshot0SubscriptionEnum::Clock").field(e).finish()
|
|
||||||
}
|
|
||||||
Snapshot0SubscriptionEnum::Read(e) => {
|
|
||||||
f.debug_tuple("Snapshot0SubscriptionEnum::Read").field(e).finish()
|
|
||||||
}
|
|
||||||
Snapshot0SubscriptionEnum::Write(e) => {
|
|
||||||
f.debug_tuple("Snapshot0SubscriptionEnum::Write").field(e).finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// The contents of a `subscription`.
|
/// The contents of a `subscription`.
|
||||||
#[derive(Clone, Copy)]
|
|
||||||
pub enum SubscriptionEnum{
|
|
||||||
Clock(SubscriptionClock),
|
|
||||||
Read(SubscriptionFsReadwrite),
|
|
||||||
Write(SubscriptionFsReadwrite),
|
|
||||||
}
|
|
||||||
impl core::fmt::Debug for SubscriptionEnum {
|
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
|
||||||
match self {
|
|
||||||
SubscriptionEnum::Clock(e) => {
|
|
||||||
f.debug_tuple("SubscriptionEnum::Clock").field(e).finish()
|
|
||||||
}
|
|
||||||
SubscriptionEnum::Read(e) => {
|
|
||||||
f.debug_tuple("SubscriptionEnum::Read").field(e).finish()
|
|
||||||
}
|
|
||||||
SubscriptionEnum::Write(e) => {
|
|
||||||
f.debug_tuple("SubscriptionEnum::Write").field(e).finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// The contents of a `subscription` when the variant is
|
/// The contents of a `subscription` when the variant is
|
||||||
/// `eventtype::fd_read` or `eventtype::fd_write`.
|
/// `eventtype::fd_read` or `eventtype::fd_write`.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
@@ -1127,27 +1033,7 @@ pub mod output {
|
|||||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
f.debug_struct("SubscriptionFsReadwrite").field("file-descriptor", &self.file_descriptor).finish()}
|
f.debug_struct("SubscriptionFsReadwrite").field("file-descriptor", &self.file_descriptor).finish()}
|
||||||
}
|
}
|
||||||
#[repr(C)]
|
#[repr(u8)]
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
pub struct Snapshot0Subscription {
|
|
||||||
pub userdata: Userdata,
|
|
||||||
pub data: Snapshot0SubscriptionEnum,
|
|
||||||
}
|
|
||||||
impl core::fmt::Debug for Snapshot0Subscription {
|
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
|
||||||
f.debug_struct("Snapshot0Subscription").field("userdata", &self.userdata).field("data", &self.data).finish()}
|
|
||||||
}
|
|
||||||
#[repr(C)]
|
|
||||||
#[derive(Copy, Clone)]
|
|
||||||
pub struct Subscription {
|
|
||||||
pub userdata: Userdata,
|
|
||||||
pub data: SubscriptionEnum,
|
|
||||||
}
|
|
||||||
impl core::fmt::Debug for Subscription {
|
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
|
||||||
f.debug_struct("Subscription").field("userdata", &self.userdata).field("data", &self.data).finish()}
|
|
||||||
}
|
|
||||||
#[repr(u16)]
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum Socktype {
|
pub enum Socktype {
|
||||||
Dgram,
|
Dgram,
|
||||||
@@ -1343,7 +1229,7 @@ pub mod output {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[repr(u16)]
|
#[repr(u8)]
|
||||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum Addressfamily {
|
pub enum Addressfamily {
|
||||||
Unspec,
|
Unspec,
|
||||||
@@ -1535,7 +1421,7 @@ pub mod output {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub type Bid = u32;
|
pub type Bid = u32;
|
||||||
pub type Cid = u32;
|
pub type Cid = u64;
|
||||||
/// __wasi_option_t
|
/// __wasi_option_t
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
@@ -3005,4 +2891,24 @@ pub mod output {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct BusEvent {
|
||||||
|
pub tag: BusEventType,
|
||||||
|
pub padding: (u64,u64,u64,u64,u64,u64,u64,u32,u16,u8,),
|
||||||
|
}
|
||||||
|
impl core::fmt::Debug for BusEvent {
|
||||||
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
|
f.debug_struct("BusEvent").field("tag", &self.tag).field("padding", &self.padding).finish()}
|
||||||
|
}
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct BusEvent2 {
|
||||||
|
pub tag: BusEventType,
|
||||||
|
pub event: BusEvent,
|
||||||
|
}
|
||||||
|
impl core::fmt::Debug for BusEvent2 {
|
||||||
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
|
f.debug_struct("BusEvent2").field("tag", &self.tag).field("event", &self.event).finish()}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -122,34 +122,7 @@ impl From<Snapshot0SubscriptionClock> for SubscriptionClock {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Snapshot0Subscription> for Subscription {
|
impl std::fmt::Display for BusDataFormat {
|
||||||
fn from(other: Snapshot0Subscription) -> Self {
|
|
||||||
Self {
|
|
||||||
userdata: other.userdata,
|
|
||||||
type_: other.type_,
|
|
||||||
data: match other.type_ {
|
|
||||||
Eventtype::Clock => SubscriptionUnion {
|
|
||||||
clock: unsafe {
|
|
||||||
SubscriptionClock {
|
|
||||||
clock_id: other.u.clock.id.into(),
|
|
||||||
timeout: other.u.clock.timeout,
|
|
||||||
precision: other.u.clock.precision,
|
|
||||||
flags: other.u.clock.flags,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Eventtype::FdRead => SubscriptionUnion {
|
|
||||||
fd_readwrite: unsafe { other.u.fd_readwrite },
|
|
||||||
},
|
|
||||||
Eventtype::FdWrite => SubscriptionUnion {
|
|
||||||
fd_readwrite: unsafe { other.u.fd_readwrite },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::fmt::Display for __wasi_busdataformat_t {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "{:?}", self)
|
write!(f, "{:?}", self)
|
||||||
}
|
}
|
||||||
@@ -326,3 +299,69 @@ unsafe impl wasmer::ValueType for Prestat {
|
|||||||
zero!(field_end!(u), core::mem::size_of_val(self));
|
zero!(field_end!(u), core::mem::size_of_val(self));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Errno> for std::io::ErrorKind {
|
||||||
|
fn from(err: Errno) -> Self {
|
||||||
|
use std::io::ErrorKind;
|
||||||
|
match err {
|
||||||
|
Errno::Access => ErrorKind::PermissionDenied,
|
||||||
|
Errno::Addrinuse => ErrorKind::AddrInUse,
|
||||||
|
Errno::Addrnotavail => ErrorKind::AddrNotAvailable,
|
||||||
|
Errno::Again => ErrorKind::WouldBlock,
|
||||||
|
Errno::Already => ErrorKind::AlreadyExists,
|
||||||
|
Errno::Badf => ErrorKind::InvalidInput,
|
||||||
|
Errno::Badmsg => ErrorKind::InvalidData,
|
||||||
|
Errno::Canceled => ErrorKind::Interrupted,
|
||||||
|
Errno::Connaborted => ErrorKind::ConnectionAborted,
|
||||||
|
Errno::Connrefused => ErrorKind::ConnectionRefused,
|
||||||
|
Errno::Connreset => ErrorKind::ConnectionReset,
|
||||||
|
Errno::Exist => ErrorKind::AlreadyExists,
|
||||||
|
Errno::Intr => ErrorKind::Interrupted,
|
||||||
|
Errno::Inval => ErrorKind::InvalidInput,
|
||||||
|
Errno::Netreset => ErrorKind::ConnectionReset,
|
||||||
|
Errno::Noent => ErrorKind::NotFound,
|
||||||
|
Errno::Nomem => ErrorKind::OutOfMemory,
|
||||||
|
Errno::Nomsg => ErrorKind::InvalidData,
|
||||||
|
Errno::Notconn => ErrorKind::NotConnected,
|
||||||
|
Errno::Perm => ErrorKind::PermissionDenied,
|
||||||
|
Errno::Pipe => ErrorKind::BrokenPipe,
|
||||||
|
Errno::Timedout => ErrorKind::TimedOut,
|
||||||
|
_ => ErrorKind::Other,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Errno> for std::io::Error {
|
||||||
|
fn from(err: Errno) -> Self {
|
||||||
|
let kind: std::io::ErrorKind = err.into();
|
||||||
|
std::io::Error::new(kind, err.message())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<std::io::Error> for Errno {
|
||||||
|
fn from(err: std::io::Error) -> Self {
|
||||||
|
use std::io::ErrorKind;
|
||||||
|
match err.kind() {
|
||||||
|
ErrorKind::NotFound => Errno::Noent,
|
||||||
|
ErrorKind::PermissionDenied => Errno::Perm,
|
||||||
|
ErrorKind::ConnectionRefused => Errno::Connrefused,
|
||||||
|
ErrorKind::ConnectionReset => Errno::Connreset,
|
||||||
|
ErrorKind::ConnectionAborted => Errno::Connaborted,
|
||||||
|
ErrorKind::NotConnected => Errno::Notconn,
|
||||||
|
ErrorKind::AddrInUse => Errno::Addrinuse,
|
||||||
|
ErrorKind::AddrNotAvailable => Errno::Addrnotavail,
|
||||||
|
ErrorKind::BrokenPipe => Errno::Pipe,
|
||||||
|
ErrorKind::AlreadyExists => Errno::Exist,
|
||||||
|
ErrorKind::WouldBlock => Errno::Again,
|
||||||
|
ErrorKind::InvalidInput => Errno::Io,
|
||||||
|
ErrorKind::InvalidData => Errno::Io,
|
||||||
|
ErrorKind::TimedOut => Errno::Timedout,
|
||||||
|
ErrorKind::WriteZero => Errno::Io,
|
||||||
|
ErrorKind::Interrupted => Errno::Intr,
|
||||||
|
ErrorKind::Other => Errno::Io,
|
||||||
|
ErrorKind::UnexpectedEof => Errno::Io,
|
||||||
|
ErrorKind::Unsupported => Errno::Notsup,
|
||||||
|
_ => Errno::Io,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,3 +2,6 @@ pub(crate) mod extra;
|
|||||||
pub(crate) mod extra_manual;
|
pub(crate) mod extra_manual;
|
||||||
pub use extra::*;
|
pub use extra::*;
|
||||||
pub use extra_manual::*;
|
pub use extra_manual::*;
|
||||||
|
|
||||||
|
mod wasix_manual;
|
||||||
|
pub use wasix_manual::*;
|
||||||
|
|||||||
187
lib/wasi-types/src/wasi/wasix_manual.rs
Normal file
187
lib/wasi-types/src/wasi/wasix_manual.rs
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
use std::mem::MaybeUninit;
|
||||||
|
|
||||||
|
use wasmer::ValueType;
|
||||||
|
|
||||||
|
use super::{
|
||||||
|
Errno, EventFdReadwrite, Eventtype, Signal, Snapshot0SubscriptionClock, SubscriptionClock,
|
||||||
|
SubscriptionFsReadwrite, Userdata,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub type WasiHash = u128;
|
||||||
|
pub type WasiSmallHash = u64;
|
||||||
|
|
||||||
|
/// Thread local key
|
||||||
|
pub type TlKey = u32;
|
||||||
|
/// Thread local value
|
||||||
|
pub type TlVal = u64;
|
||||||
|
/// Thread local user data (associated with the value)
|
||||||
|
pub type TlUser = u64;
|
||||||
|
/// Long size used by checkpoints
|
||||||
|
pub type Longsize = u64;
|
||||||
|
|
||||||
|
/// The contents of a `subscription`, snapshot0 version.
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub union Snapshot0SubscriptionUnion {
|
||||||
|
pub clock: Snapshot0SubscriptionClock,
|
||||||
|
pub fd_readwrite: SubscriptionFsReadwrite,
|
||||||
|
}
|
||||||
|
/// The contents of a `subscription`.
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub union SubscriptionUnion {
|
||||||
|
pub clock: SubscriptionClock,
|
||||||
|
pub fd_readwrite: SubscriptionFsReadwrite,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct Snapshot0Subscription {
|
||||||
|
pub userdata: Userdata,
|
||||||
|
pub type_: Eventtype,
|
||||||
|
pub u: Snapshot0SubscriptionUnion,
|
||||||
|
}
|
||||||
|
impl core::fmt::Debug for Snapshot0Subscription {
|
||||||
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
|
f.debug_struct("Snapshot0Subscription")
|
||||||
|
.field("userdata", &self.userdata)
|
||||||
|
.field("type", &self.type_)
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct Subscription {
|
||||||
|
pub userdata: Userdata,
|
||||||
|
pub type_: Eventtype,
|
||||||
|
pub data: SubscriptionUnion,
|
||||||
|
}
|
||||||
|
impl core::fmt::Debug for Subscription {
|
||||||
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
|
f.debug_struct("Subscription")
|
||||||
|
.field("userdata", &self.userdata)
|
||||||
|
.field("type", &self.type_)
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Snapshot0Subscription> for Subscription {
|
||||||
|
fn from(other: Snapshot0Subscription) -> Self {
|
||||||
|
Self {
|
||||||
|
userdata: other.userdata,
|
||||||
|
type_: other.type_,
|
||||||
|
data: match other.type_ {
|
||||||
|
Eventtype::Clock => SubscriptionUnion {
|
||||||
|
clock: unsafe {
|
||||||
|
SubscriptionClock {
|
||||||
|
clock_id: other.u.clock.id.into(),
|
||||||
|
timeout: other.u.clock.timeout,
|
||||||
|
precision: other.u.clock.precision,
|
||||||
|
flags: other.u.clock.flags,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Eventtype::FdRead => SubscriptionUnion {
|
||||||
|
fd_readwrite: unsafe { other.u.fd_readwrite },
|
||||||
|
},
|
||||||
|
Eventtype::FdWrite => SubscriptionUnion {
|
||||||
|
fd_readwrite: unsafe { other.u.fd_readwrite },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The contents of an `event`.
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub union EventUnion {
|
||||||
|
pub clock: u8,
|
||||||
|
pub fd_readwrite: EventFdReadwrite,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct StackSnapshot {
|
||||||
|
pub user: u64,
|
||||||
|
pub hash: u128,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// An event that occurred.
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct Event {
|
||||||
|
/// User-provided value that got attached to `subscription::userdata`.
|
||||||
|
pub userdata: Userdata,
|
||||||
|
/// If non-zero, an error that occurred while processing the subscription request.
|
||||||
|
pub error: Errno,
|
||||||
|
/// Type of event that was triggered
|
||||||
|
pub type_: Eventtype,
|
||||||
|
/// The type of the event that occurred, and the contents of the event
|
||||||
|
pub u: EventUnion,
|
||||||
|
}
|
||||||
|
impl core::fmt::Debug for Event {
|
||||||
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
|
f.debug_struct("Event")
|
||||||
|
.field("userdata", &self.userdata)
|
||||||
|
.field("error", &self.error)
|
||||||
|
.field("type", &self.type_)
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// An event that occurred.
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
pub struct Snapshot0Event {
|
||||||
|
/// User-provided value that got attached to `subscription::userdata`.
|
||||||
|
pub userdata: Userdata,
|
||||||
|
/// If non-zero, an error that occurred while processing the subscription request.
|
||||||
|
pub error: Errno,
|
||||||
|
/// The type of event that occured
|
||||||
|
pub type_: Eventtype,
|
||||||
|
/// The contents of the event, if it is an `eventtype::fd_read` or
|
||||||
|
/// `eventtype::fd_write`. `eventtype::clock` events ignore this field.
|
||||||
|
pub fd_readwrite: EventFdReadwrite,
|
||||||
|
}
|
||||||
|
impl core::fmt::Debug for Snapshot0Event {
|
||||||
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
|
f.debug_struct("Snapshot0Event")
|
||||||
|
.field("userdata", &self.userdata)
|
||||||
|
.field("error", &self.error)
|
||||||
|
.field("type", &self.type_)
|
||||||
|
.field("fd-readwrite", &self.fd_readwrite)
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: modify bindings generator to derive Hash
|
||||||
|
impl std::hash::Hash for Signal {
|
||||||
|
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||||
|
core::mem::discriminant(self).hash(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl ValueType for Snapshot0Subscription {
|
||||||
|
#[inline]
|
||||||
|
fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>]) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl ValueType for Snapshot0Event {
|
||||||
|
#[inline]
|
||||||
|
fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>]) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl ValueType for Subscription {
|
||||||
|
#[inline]
|
||||||
|
fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>]) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl ValueType for Event {
|
||||||
|
#[inline]
|
||||||
|
fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>]) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl ValueType for StackSnapshot {
|
||||||
|
#[inline]
|
||||||
|
fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>]) {}
|
||||||
|
}
|
||||||
@@ -9,8 +9,10 @@ description = "Generator for wasi-types"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
convert_case = "0.5.0"
|
convert_case = "0.5.0"
|
||||||
|
quote = "1.0.21"
|
||||||
|
syn = { version = "1.0.103", features = ["full", "extra-traits"] }
|
||||||
|
|
||||||
[dependencies.wit-parser]
|
[dependencies.wit-parser]
|
||||||
default-features = false
|
default-features = false
|
||||||
package = "wasmer-wit-parser"
|
package = "wasmer-wit-parser"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
//! see issue [#3177](https://github.com/wasmerio/wasmer/issues/3177).
|
//! see issue [#3177](https://github.com/wasmerio/wasmer/issues/3177).
|
||||||
|
|
||||||
use convert_case::{Case, Casing};
|
use convert_case::{Case, Casing};
|
||||||
|
use quote::quote;
|
||||||
use wit_parser::TypeDefKind;
|
use wit_parser::TypeDefKind;
|
||||||
|
|
||||||
const WIT_1: &str = include_str!("../../wit-clean/output.wit");
|
const WIT_1: &str = include_str!("../../wit-clean/output.wit");
|
||||||
@@ -23,6 +24,90 @@ fn replace_in_string(s: &str, id: &str, ty: &str) -> String {
|
|||||||
format!("{}impl {id} {{ {replaced}", parts[0])
|
format!("{}impl {id} {{ {replaced}", parts[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn find_attr_by_name_mut<'a>(
|
||||||
|
mut attrs: impl Iterator<Item = &'a mut syn::Attribute>,
|
||||||
|
name: &str,
|
||||||
|
) -> Option<&'a mut syn::Attribute> {
|
||||||
|
attrs.find(|attr| {
|
||||||
|
if let Some(ident) = attr.path.get_ident() {
|
||||||
|
ident.to_string() == name
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Types(Vec<syn::Path>);
|
||||||
|
|
||||||
|
impl syn::parse::Parse for Types {
|
||||||
|
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
|
||||||
|
let result =
|
||||||
|
syn::punctuated::Punctuated::<syn::Path, syn::Token![,]>::parse_terminated(input)?;
|
||||||
|
let items = result.into_iter().collect();
|
||||||
|
Ok(Self(items))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fix up type definitions for bindings.
|
||||||
|
fn visit_item(item: &mut syn::Item) {
|
||||||
|
match item {
|
||||||
|
syn::Item::Enum(enum_) => {
|
||||||
|
let name = enum_.ident.to_string();
|
||||||
|
// Fix integer representation size for enums.
|
||||||
|
let repr_attr = find_attr_by_name_mut(enum_.attrs.iter_mut(), "repr");
|
||||||
|
|
||||||
|
// Change enum repr type.
|
||||||
|
match name.as_str() {
|
||||||
|
"Clockid" | "Snapshot0Clockid" | "BusErrno" => {
|
||||||
|
repr_attr.unwrap().tokens = quote!((u32));
|
||||||
|
}
|
||||||
|
"Errno" | "Socktype" | "Addressfamily" | "Sockproto" => {
|
||||||
|
repr_attr.unwrap().tokens = quote!((u16));
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add additional derives.
|
||||||
|
|
||||||
|
match name.as_str() {
|
||||||
|
"Clockid" => {
|
||||||
|
let attr = find_attr_by_name_mut(enum_.attrs.iter_mut(), "derive").unwrap();
|
||||||
|
let mut types = attr
|
||||||
|
.parse_args::<Types>()
|
||||||
|
.unwrap()
|
||||||
|
.0;
|
||||||
|
|
||||||
|
let prim = syn::parse_str::<syn::Path>("num_enum::TryFromPrimitive").unwrap();
|
||||||
|
types.push(prim);
|
||||||
|
|
||||||
|
let prim = syn::parse_str::<syn::Path>("Hash").unwrap();
|
||||||
|
types.push(prim);
|
||||||
|
|
||||||
|
attr.tokens = quote!( ( #( #types ),* ) );
|
||||||
|
}
|
||||||
|
"Signal" => {
|
||||||
|
let attr = find_attr_by_name_mut(enum_.attrs.iter_mut(), "derive").unwrap();
|
||||||
|
let mut types = attr
|
||||||
|
.parse_args::<Types>()
|
||||||
|
.unwrap()
|
||||||
|
.0;
|
||||||
|
let prim = syn::parse_str::<syn::Path>("num_enum::TryFromPrimitive").unwrap();
|
||||||
|
types.push(prim);
|
||||||
|
attr.tokens = quote!( ( #( #types ),* ) );
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// syn::Item::Struct(struct_) => {}
|
||||||
|
syn::Item::Mod(module) => {
|
||||||
|
if let Some((_delimiter, children)) = &mut module.content {
|
||||||
|
children.iter_mut().for_each(visit_item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut bindings_rs = BINDINGS_RS
|
let mut bindings_rs = BINDINGS_RS
|
||||||
.replace("#[allow(clippy::all)]", "")
|
.replace("#[allow(clippy::all)]", "")
|
||||||
@@ -54,6 +139,11 @@ fn main() {
|
|||||||
bindings_rs.pop();
|
bindings_rs.pop();
|
||||||
let bindings_rs = bindings_rs.join("\n");
|
let bindings_rs = bindings_rs.join("\n");
|
||||||
|
|
||||||
|
// Fix enum types.
|
||||||
|
let mut bindings_file = syn::parse_str::<syn::File>(&bindings_rs).unwrap();
|
||||||
|
bindings_file.items.iter_mut().for_each(visit_item);
|
||||||
|
let bindings_rs = quote!(#bindings_file).to_string();
|
||||||
|
|
||||||
let target_path = env!("CARGO_MANIFEST_DIR");
|
let target_path = env!("CARGO_MANIFEST_DIR");
|
||||||
let path = std::path::Path::new(&target_path)
|
let path = std::path::Path::new(&target_path)
|
||||||
.parent()
|
.parent()
|
||||||
@@ -66,6 +156,8 @@ fn main() {
|
|||||||
"
|
"
|
||||||
use std::mem::MaybeUninit;
|
use std::mem::MaybeUninit;
|
||||||
use wasmer::ValueType;
|
use wasmer::ValueType;
|
||||||
|
// TODO: Remove once bindings generate wai_bindgen_rust::bitflags::bitflags! (temp hack)
|
||||||
|
use wai_bindgen_rust as wit_bindgen_rust;
|
||||||
|
|
||||||
{bindings_rs}
|
{bindings_rs}
|
||||||
|
|
||||||
@@ -78,10 +170,22 @@ fn main() {
|
|||||||
let excluded_from_impl_valuetype = ["Prestat"];
|
let excluded_from_impl_valuetype = ["Prestat"];
|
||||||
|
|
||||||
for (_, i) in result.types.iter() {
|
for (_, i) in result.types.iter() {
|
||||||
|
let name = i.name.clone().unwrap_or_default().to_case(Case::Pascal);
|
||||||
|
if name.is_empty() {
|
||||||
|
eprintln!(
|
||||||
|
"WARNING: skipping extra trait generation for type without name: {:?}",
|
||||||
|
i
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
match i.kind {
|
match i.kind {
|
||||||
|
TypeDefKind::Tuple(_) => {
|
||||||
|
eprintln!("Skipping extra trait generation for tupe type {:?}", i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
| TypeDefKind::Record(_)
|
| TypeDefKind::Record(_)
|
||||||
| TypeDefKind::Flags(_)
|
| TypeDefKind::Flags(_)
|
||||||
| TypeDefKind::Tuple(_)
|
|
||||||
| TypeDefKind::Variant(_)
|
| TypeDefKind::Variant(_)
|
||||||
| TypeDefKind::Enum(_)
|
| TypeDefKind::Enum(_)
|
||||||
| TypeDefKind::Option(_)
|
| TypeDefKind::Option(_)
|
||||||
@@ -92,7 +196,6 @@ fn main() {
|
|||||||
| TypeDefKind::Stream(_)
|
| TypeDefKind::Stream(_)
|
||||||
// | TypeDefKind::Type(_)
|
// | TypeDefKind::Type(_)
|
||||||
=> {
|
=> {
|
||||||
let name = i.name.clone().unwrap_or_default().to_case(Case::Pascal);
|
|
||||||
if excluded_from_impl_valuetype.iter().any(|s| *s == name.as_str()) {
|
if excluded_from_impl_valuetype.iter().any(|s| *s == name.as_str()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -108,8 +211,6 @@ fn main() {
|
|||||||
_ => { }
|
_ => { }
|
||||||
}
|
}
|
||||||
|
|
||||||
let name = i.name.clone().unwrap_or_default().to_case(Case::Pascal);
|
|
||||||
|
|
||||||
if let wit_parser::TypeDefKind::Enum(e) = &i.kind {
|
if let wit_parser::TypeDefKind::Enum(e) = &i.kind {
|
||||||
contents.push_str(
|
contents.push_str(
|
||||||
&format!(
|
&format!(
|
||||||
|
|||||||
Submodule lib/wasi-types/wit-bindgen updated: 095d295be6...44a2bf8148
@@ -75,6 +75,12 @@ enum clockid {
|
|||||||
/// clock jumps. The epoch of this clock is undefined. The absolute time
|
/// clock jumps. The epoch of this clock is undefined. The absolute time
|
||||||
/// value of this clock therefore has no meaning.
|
/// value of this clock therefore has no meaning.
|
||||||
monotonic,
|
monotonic,
|
||||||
|
|
||||||
|
// FIXME: this needs to go into a WASIX specific definition
|
||||||
|
/// The CPU-time clock associated with the current process.
|
||||||
|
process-cputime-id,
|
||||||
|
/// The CPU-time clock associated with the current thread.
|
||||||
|
thread-cputime-id,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error codes returned by functions.
|
/// Error codes returned by functions.
|
||||||
@@ -614,55 +620,55 @@ record event-fd-readwrite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// An event that occurred.
|
/// An event that occurred.
|
||||||
record event {
|
// record event {
|
||||||
/// User-provided value that got attached to `subscription::userdata`.
|
// /// User-provided value that got attached to `subscription::userdata`.
|
||||||
userdata: userdata,
|
// userdata: userdata,
|
||||||
/// If non-zero, an error that occurred while processing the subscription request.
|
// /// If non-zero, an error that occurred while processing the subscription request.
|
||||||
error: errno,
|
// error: errno,
|
||||||
/// The type of the event that occurred, and the contents of the event
|
// /// The type of the event that occurred, and the contents of the event
|
||||||
data: event-enum
|
// data: event-enum
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// The contents of an `event`.
|
/// The contents of an `event`.
|
||||||
variant event-enum {
|
// variant event-enum {
|
||||||
// TODO: wit appears to not have support for tag type
|
// // TODO: wit appears to not have support for tag type
|
||||||
//(@witx tag $eventtype)
|
// //(@witx tag $eventtype)
|
||||||
fd-read(event-fd-readwrite),
|
// fd-read(event-fd-readwrite),
|
||||||
fd-write(event-fd-readwrite),
|
// fd-write(event-fd-readwrite),
|
||||||
clock,
|
// clock,
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
/// An event that occurred.
|
/// An event that occurred.
|
||||||
record snapshot0-event {
|
// record snapshot0-event {
|
||||||
/// User-provided value that got attached to `subscription::userdata`.
|
// /// User-provided value that got attached to `subscription::userdata`.
|
||||||
userdata: userdata,
|
// userdata: userdata,
|
||||||
/// If non-zero, an error that occurred while processing the subscription request.
|
// /// If non-zero, an error that occurred while processing the subscription request.
|
||||||
error: errno,
|
// error: errno,
|
||||||
/// The type of event that occured
|
// /// The type of event that occured
|
||||||
%type: eventtype,
|
// %type: eventtype,
|
||||||
/// The contents of the event, if it is an `eventtype::fd_read` or
|
// /// The contents of the event, if it is an `eventtype::fd_read` or
|
||||||
/// `eventtype::fd_write`. `eventtype::clock` events ignore this field.
|
// /// `eventtype::fd_write`. `eventtype::clock` events ignore this field.
|
||||||
fd-readwrite: event-fd-readwrite,
|
// fd-readwrite: event-fd-readwrite,
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// The contents of a `subscription`, snapshot0 version.
|
/// The contents of a `subscription`, snapshot0 version.
|
||||||
variant snapshot0-subscription-enum {
|
// variant snapshot0-subscription-enum {
|
||||||
// TODO: wit appears to have no support for tag types
|
// // TODO: wit appears to have no support for tag types
|
||||||
//(@witx tag $eventtype)
|
// //(@witx tag $eventtype)
|
||||||
clock(snapshot0-subscription-clock),
|
// clock(snapshot0-subscription-clock),
|
||||||
read(subscription-fs-readwrite),
|
// read(subscription-fs-readwrite),
|
||||||
write(subscription-fs-readwrite),
|
// write(subscription-fs-readwrite),
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// The contents of a `subscription`.
|
/// The contents of a `subscription`.
|
||||||
variant subscription-enum {
|
// variant subscription-enum {
|
||||||
// TODO: wit appears to have no support for tag types
|
// // TODO: wit appears to have no support for tag types
|
||||||
//(@witx tag $eventtype)
|
// //(@witx tag $eventtype)
|
||||||
clock(subscription-clock),
|
// clock(subscription-clock),
|
||||||
read(subscription-fs-readwrite),
|
// read(subscription-fs-readwrite),
|
||||||
write(subscription-fs-readwrite),
|
// write(subscription-fs-readwrite),
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// The contents of a `subscription` when the variant is
|
/// The contents of a `subscription` when the variant is
|
||||||
/// `eventtype::fd_read` or `eventtype::fd_write`.
|
/// `eventtype::fd_read` or `eventtype::fd_write`.
|
||||||
@@ -671,15 +677,15 @@ record subscription-fs-readwrite {
|
|||||||
file-descriptor: fd,
|
file-descriptor: fd,
|
||||||
}
|
}
|
||||||
|
|
||||||
record snapshot0-subscription {
|
// record snapshot0-subscription {
|
||||||
userdata: userdata,
|
// userdata: userdata,
|
||||||
data: snapshot0-subscription-enum,
|
// data: snapshot0-subscription-enum,
|
||||||
}
|
// }
|
||||||
|
|
||||||
record subscription {
|
// record subscription {
|
||||||
userdata: userdata,
|
// userdata: userdata,
|
||||||
data: subscription-enum,
|
// data: subscription-enum,
|
||||||
}
|
// }
|
||||||
|
|
||||||
enum socktype {
|
enum socktype {
|
||||||
dgram,
|
dgram,
|
||||||
@@ -806,7 +812,7 @@ enum bus-event-type {
|
|||||||
|
|
||||||
type bid = u32
|
type bid = u32
|
||||||
|
|
||||||
type cid = u32
|
type cid = u64
|
||||||
|
|
||||||
/// __wasi_option_t
|
/// __wasi_option_t
|
||||||
enum option-tag {
|
enum option-tag {
|
||||||
@@ -1236,7 +1242,41 @@ enum timeout {
|
|||||||
write,
|
write,
|
||||||
connect,
|
connect,
|
||||||
accept,
|
accept,
|
||||||
}// WASI Preview. This is an evolution of the API that WASI initially
|
}
|
||||||
|
|
||||||
|
// FIXME: move to wasix file and re-work naming?
|
||||||
|
// type longsize = u64
|
||||||
|
// type thread-local-key = u32
|
||||||
|
// type thread-local-value = u64
|
||||||
|
|
||||||
|
// type wasi-small-hash = u64
|
||||||
|
|
||||||
|
// FIXME: should be optional<T>?
|
||||||
|
// record option-hash {
|
||||||
|
// tag: option-tag,
|
||||||
|
// hash: wasi-hash,
|
||||||
|
// }
|
||||||
|
|
||||||
|
// record stack-snapshot {
|
||||||
|
// user: u64,
|
||||||
|
// hash: wasi-hash,
|
||||||
|
// }
|
||||||
|
|
||||||
|
record bus-event {
|
||||||
|
tag: bus-event-type,
|
||||||
|
// [u8; 63] == 504 bytes ==
|
||||||
|
// FIXME: why is this padding here?
|
||||||
|
padding: tuple<u64, u64, u64, u64, u64, u64, u64, u32, u16, u8>,
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: what's going on here?
|
||||||
|
record bus-event2 {
|
||||||
|
tag: bus-event-type,
|
||||||
|
event: bus-event,
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: port other stuff from deleted
|
||||||
|
// WASI Preview. This is an evolution of the API that WASI initially
|
||||||
// launched with.
|
// launched with.
|
||||||
//
|
//
|
||||||
// Some content here is derived from [CloudABI](https://github.com/NuxiNL/cloudabi).
|
// Some content here is derived from [CloudABI](https://github.com/NuxiNL/cloudabi).
|
||||||
|
|||||||
@@ -75,6 +75,12 @@ enum clockid {
|
|||||||
/// clock jumps. The epoch of this clock is undefined. The absolute time
|
/// clock jumps. The epoch of this clock is undefined. The absolute time
|
||||||
/// value of this clock therefore has no meaning.
|
/// value of this clock therefore has no meaning.
|
||||||
monotonic,
|
monotonic,
|
||||||
|
|
||||||
|
// FIXME: this needs to go into a WASIX specific definition
|
||||||
|
/// The CPU-time clock associated with the current process.
|
||||||
|
process-cputime-id,
|
||||||
|
/// The CPU-time clock associated with the current thread.
|
||||||
|
thread-cputime-id,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error codes returned by functions.
|
/// Error codes returned by functions.
|
||||||
@@ -614,55 +620,55 @@ record event-fd-readwrite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// An event that occurred.
|
/// An event that occurred.
|
||||||
record event {
|
// record event {
|
||||||
/// User-provided value that got attached to `subscription::userdata`.
|
// /// User-provided value that got attached to `subscription::userdata`.
|
||||||
userdata: userdata,
|
// userdata: userdata,
|
||||||
/// If non-zero, an error that occurred while processing the subscription request.
|
// /// If non-zero, an error that occurred while processing the subscription request.
|
||||||
error: errno,
|
// error: errno,
|
||||||
/// The type of the event that occurred, and the contents of the event
|
// /// The type of the event that occurred, and the contents of the event
|
||||||
data: event-enum
|
// data: event-enum
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// The contents of an `event`.
|
/// The contents of an `event`.
|
||||||
variant event-enum {
|
// variant event-enum {
|
||||||
// TODO: wit appears to not have support for tag type
|
// // TODO: wit appears to not have support for tag type
|
||||||
//(@witx tag $eventtype)
|
// //(@witx tag $eventtype)
|
||||||
fd-read(event-fd-readwrite),
|
// fd-read(event-fd-readwrite),
|
||||||
fd-write(event-fd-readwrite),
|
// fd-write(event-fd-readwrite),
|
||||||
clock,
|
// clock,
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
/// An event that occurred.
|
/// An event that occurred.
|
||||||
record snapshot0-event {
|
// record snapshot0-event {
|
||||||
/// User-provided value that got attached to `subscription::userdata`.
|
// /// User-provided value that got attached to `subscription::userdata`.
|
||||||
userdata: userdata,
|
// userdata: userdata,
|
||||||
/// If non-zero, an error that occurred while processing the subscription request.
|
// /// If non-zero, an error that occurred while processing the subscription request.
|
||||||
error: errno,
|
// error: errno,
|
||||||
/// The type of event that occured
|
// /// The type of event that occured
|
||||||
%type: eventtype,
|
// %type: eventtype,
|
||||||
/// The contents of the event, if it is an `eventtype::fd_read` or
|
// /// The contents of the event, if it is an `eventtype::fd_read` or
|
||||||
/// `eventtype::fd_write`. `eventtype::clock` events ignore this field.
|
// /// `eventtype::fd_write`. `eventtype::clock` events ignore this field.
|
||||||
fd-readwrite: event-fd-readwrite,
|
// fd-readwrite: event-fd-readwrite,
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// The contents of a `subscription`, snapshot0 version.
|
/// The contents of a `subscription`, snapshot0 version.
|
||||||
variant snapshot0-subscription-enum {
|
// variant snapshot0-subscription-enum {
|
||||||
// TODO: wit appears to have no support for tag types
|
// // TODO: wit appears to have no support for tag types
|
||||||
//(@witx tag $eventtype)
|
// //(@witx tag $eventtype)
|
||||||
clock(snapshot0-subscription-clock),
|
// clock(snapshot0-subscription-clock),
|
||||||
read(subscription-fs-readwrite),
|
// read(subscription-fs-readwrite),
|
||||||
write(subscription-fs-readwrite),
|
// write(subscription-fs-readwrite),
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// The contents of a `subscription`.
|
/// The contents of a `subscription`.
|
||||||
variant subscription-enum {
|
// variant subscription-enum {
|
||||||
// TODO: wit appears to have no support for tag types
|
// // TODO: wit appears to have no support for tag types
|
||||||
//(@witx tag $eventtype)
|
// //(@witx tag $eventtype)
|
||||||
clock(subscription-clock),
|
// clock(subscription-clock),
|
||||||
read(subscription-fs-readwrite),
|
// read(subscription-fs-readwrite),
|
||||||
write(subscription-fs-readwrite),
|
// write(subscription-fs-readwrite),
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// The contents of a `subscription` when the variant is
|
/// The contents of a `subscription` when the variant is
|
||||||
/// `eventtype::fd_read` or `eventtype::fd_write`.
|
/// `eventtype::fd_read` or `eventtype::fd_write`.
|
||||||
@@ -671,15 +677,15 @@ record subscription-fs-readwrite {
|
|||||||
file-descriptor: fd,
|
file-descriptor: fd,
|
||||||
}
|
}
|
||||||
|
|
||||||
record snapshot0-subscription {
|
// record snapshot0-subscription {
|
||||||
userdata: userdata,
|
// userdata: userdata,
|
||||||
data: snapshot0-subscription-enum,
|
// data: snapshot0-subscription-enum,
|
||||||
}
|
// }
|
||||||
|
|
||||||
record subscription {
|
// record subscription {
|
||||||
userdata: userdata,
|
// userdata: userdata,
|
||||||
data: subscription-enum,
|
// data: subscription-enum,
|
||||||
}
|
// }
|
||||||
|
|
||||||
enum socktype {
|
enum socktype {
|
||||||
dgram,
|
dgram,
|
||||||
@@ -806,7 +812,7 @@ enum bus-event-type {
|
|||||||
|
|
||||||
type bid = u32
|
type bid = u32
|
||||||
|
|
||||||
type cid = u32
|
type cid = u64
|
||||||
|
|
||||||
/// __wasi_option_t
|
/// __wasi_option_t
|
||||||
enum option-tag {
|
enum option-tag {
|
||||||
@@ -1239,22 +1245,22 @@ enum timeout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: move to wasix file and re-work naming?
|
// FIXME: move to wasix file and re-work naming?
|
||||||
type longsize = u64;
|
// type longsize = u64
|
||||||
type thread-local-key = u32;
|
// type thread-local-key = u32
|
||||||
type thread-local-value = u64;
|
// type thread-local-value = u64
|
||||||
type small-hash = u64;
|
|
||||||
type hash = tuple<u64, u64>;
|
// type wasi-small-hash = u64
|
||||||
|
|
||||||
// FIXME: should be optional<T>?
|
// FIXME: should be optional<T>?
|
||||||
record option-hash {
|
// record option-hash {
|
||||||
tag: option-tag,
|
// tag: option-tag,
|
||||||
hash: hash,
|
// hash: wasi-hash,
|
||||||
}
|
// }
|
||||||
|
|
||||||
record stack-snapshot {
|
// record stack-snapshot {
|
||||||
user: u64,
|
// user: u64,
|
||||||
hash: hash,
|
// hash: wasi-hash,
|
||||||
}
|
// }
|
||||||
|
|
||||||
record bus-event {
|
record bus-event {
|
||||||
tag: bus-event-type,
|
tag: bus-event-type,
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ js = ["wasmer/js", "mem-fs", "wasmer-vfs/no-time", "getrandom/js", "chrono", "wa
|
|||||||
js-default = ["js", "wasmer/js-default"]
|
js-default = ["js", "wasmer/js-default"]
|
||||||
test-js = ["js", "wasmer/js-default", "wasmer/wat"]
|
test-js = ["js", "wasmer/js-default", "wasmer/wat"]
|
||||||
|
|
||||||
os = [ "wasmer/wat", "wasmer/js-serializable-module", "async-trait", "urlencoding", "webc", "webc-vfs", "serde", "serde_derive", "serde_json", "serde_yaml", "shellexpand", "weezl", "hex", "linked_hash_set" ]
|
os = [ "wasmer/wat", "wasmer/js-serializable-module", "async-trait", "urlencoding", "webc", "webc-vfs", "serde", "serde_derive", "serde_json", "serde_yaml", "shellexpand", "weezl", "hex", "linked_hash_set", "wasmer/enable-rkyv" ]
|
||||||
|
|
||||||
host-vnet = [ "wasmer-wasi-local-networking" ]
|
host-vnet = [ "wasmer-wasi-local-networking" ]
|
||||||
host-threads = []
|
host-threads = []
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ pub mod legacy;
|
|||||||
|
|
||||||
use self::types::{
|
use self::types::{
|
||||||
wasi::{
|
wasi::{
|
||||||
Addressfamily, Advice, Bid, BusErrno, BusHandles, Cid, Clockid, Dircookie, Dirent, Errno,
|
Addressfamily, Advice, Bid, BusDataFormat, BusErrno, BusHandles, Cid, Clockid, Dircookie,
|
||||||
Event, EventFdReadwrite, Eventrwflags, Eventtype, ExitCode, Fd as WasiFd, Fdflags, Fdstat,
|
Dirent, Errno, Event, EventFdReadwrite, Eventrwflags, Eventtype, ExitCode, Fd as WasiFd,
|
||||||
Filesize, Filestat, Filetype, Fstflags, Linkcount, Longsize, OptionFd, Pid, Prestat,
|
Fdflags, Fdstat, Filesize, Filestat, Filetype, Fstflags, Linkcount, Longsize, OptionFd,
|
||||||
Rights, Snapshot0Clockid, Sockoption, Sockstatus, Socktype, StackSnapshot,
|
Pid, Prestat, Rights, Snapshot0Clockid, Sockoption, Sockstatus, Socktype, StackSnapshot,
|
||||||
StdioMode as WasiStdioMode, Streamsecurity, Subscription, SubscriptionFsReadwrite, Tid,
|
StdioMode as WasiStdioMode, Streamsecurity, Subscription, SubscriptionFsReadwrite, Tid,
|
||||||
Timestamp, TlKey, TlUser, TlVal, Tty, WasiHash, Whence, __wasi_busdataformat_t,
|
Timestamp, TlKey, TlUser, TlVal, Tty, WasiHash, Whence,
|
||||||
},
|
},
|
||||||
*,
|
*,
|
||||||
};
|
};
|
||||||
@@ -81,8 +81,8 @@ use wasmer::{
|
|||||||
WasmSlice,
|
WasmSlice,
|
||||||
};
|
};
|
||||||
use wasmer_vbus::{
|
use wasmer_vbus::{
|
||||||
BusDataFormat, BusInvocationEvent, BusSpawnedProcess, FileDescriptor, SignalHandlerAbi,
|
BusInvocationEvent, BusSpawnedProcess, FileDescriptor, SignalHandlerAbi, SpawnOptionsConfig,
|
||||||
SpawnOptionsConfig, StdioMode, VirtualBusError, VirtualBusInvokedWait,
|
StdioMode, VirtualBusError, VirtualBusInvokedWait,
|
||||||
};
|
};
|
||||||
use wasmer_vfs::{FileSystem, FsError, VirtualFile};
|
use wasmer_vfs::{FileSystem, FsError, VirtualFile};
|
||||||
use wasmer_vnet::{SocketHttpRequest, StreamSecurity};
|
use wasmer_vnet::{SocketHttpRequest, StreamSecurity};
|
||||||
@@ -5070,26 +5070,11 @@ pub fn tty_get<M: MemorySize>(
|
|||||||
rows: state.rows,
|
rows: state.rows,
|
||||||
width: state.width,
|
width: state.width,
|
||||||
height: state.height,
|
height: state.height,
|
||||||
stdin_tty: match state.stdin_tty {
|
stdin_tty: state.stdin_tty,
|
||||||
false => Bool::False,
|
stdout_tty: state.stdout_tty,
|
||||||
true => Bool::True,
|
stderr_tty: state.stderr_tty,
|
||||||
},
|
echo: state.echo,
|
||||||
stdout_tty: match state.stdout_tty {
|
line_buffered: state.line_buffered,
|
||||||
false => Bool::False,
|
|
||||||
true => Bool::True,
|
|
||||||
},
|
|
||||||
stderr_tty: match state.stderr_tty {
|
|
||||||
false => Bool::False,
|
|
||||||
true => Bool::True,
|
|
||||||
},
|
|
||||||
echo: match state.echo {
|
|
||||||
false => Bool::False,
|
|
||||||
true => Bool::True,
|
|
||||||
},
|
|
||||||
line_buffered: match state.line_buffered {
|
|
||||||
false => Bool::False,
|
|
||||||
true => Bool::True,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let memory = env.memory_view(&ctx);
|
let memory = env.memory_view(&ctx);
|
||||||
@@ -5109,14 +5094,8 @@ pub fn tty_set<M: MemorySize>(
|
|||||||
let env = ctx.data();
|
let env = ctx.data();
|
||||||
let memory = env.memory_view(&ctx);
|
let memory = env.memory_view(&ctx);
|
||||||
let state = wasi_try_mem!(tty_state.read(&memory));
|
let state = wasi_try_mem!(tty_state.read(&memory));
|
||||||
let echo = match state.echo {
|
let echo = state.echo;
|
||||||
Bool::False => false,
|
let line_buffered = state.line_buffered;
|
||||||
Bool::True => true,
|
|
||||||
};
|
|
||||||
let line_buffered = match state.line_buffered {
|
|
||||||
Bool::False => false,
|
|
||||||
Bool::True => true,
|
|
||||||
};
|
|
||||||
let line_feeds = true;
|
let line_feeds = true;
|
||||||
debug!(
|
debug!(
|
||||||
"wasi[{}:{}]::tty_set(echo={}, line_buffered={}, line_feeds={})",
|
"wasi[{}:{}]::tty_set(echo={}, line_buffered={}, line_feeds={})",
|
||||||
@@ -5132,18 +5111,9 @@ pub fn tty_set<M: MemorySize>(
|
|||||||
rows: state.rows,
|
rows: state.rows,
|
||||||
width: state.width,
|
width: state.width,
|
||||||
height: state.height,
|
height: state.height,
|
||||||
stdin_tty: match state.stdin_tty {
|
stdin_tty: state.stdin_tty,
|
||||||
Bool::False => false,
|
stdout_tty: state.stdout_tty,
|
||||||
Bool::True => true,
|
stderr_tty: state.stderr_tty,
|
||||||
},
|
|
||||||
stdout_tty: match state.stdout_tty {
|
|
||||||
Bool::False => false,
|
|
||||||
Bool::True => true,
|
|
||||||
},
|
|
||||||
stderr_tty: match state.stderr_tty {
|
|
||||||
Bool::False => false,
|
|
||||||
Bool::True => true,
|
|
||||||
},
|
|
||||||
echo,
|
echo,
|
||||||
line_buffered,
|
line_buffered,
|
||||||
line_feeds,
|
line_feeds,
|
||||||
@@ -7338,7 +7308,7 @@ pub fn bus_call<M: MemorySize>(
|
|||||||
mut ctx: FunctionEnvMut<'_, WasiEnv>,
|
mut ctx: FunctionEnvMut<'_, WasiEnv>,
|
||||||
bid: Bid,
|
bid: Bid,
|
||||||
topic_hash: WasmPtr<WasiHash>,
|
topic_hash: WasmPtr<WasiHash>,
|
||||||
format: __wasi_busdataformat_t,
|
format: BusDataFormat,
|
||||||
buf: WasmPtr<u8, M>,
|
buf: WasmPtr<u8, M>,
|
||||||
buf_len: M::Offset,
|
buf_len: M::Offset,
|
||||||
ret_cid: WasmPtr<Cid, M>,
|
ret_cid: WasmPtr<Cid, M>,
|
||||||
@@ -7429,7 +7399,7 @@ pub fn bus_subcall<M: MemorySize>(
|
|||||||
mut ctx: FunctionEnvMut<'_, WasiEnv>,
|
mut ctx: FunctionEnvMut<'_, WasiEnv>,
|
||||||
parent_cid: Cid,
|
parent_cid: Cid,
|
||||||
topic_hash: WasmPtr<WasiHash>,
|
topic_hash: WasmPtr<WasiHash>,
|
||||||
format: __wasi_busdataformat_t,
|
format: BusDataFormat,
|
||||||
buf: WasmPtr<u8, M>,
|
buf: WasmPtr<u8, M>,
|
||||||
buf_len: M::Offset,
|
buf_len: M::Offset,
|
||||||
ret_cid: WasmPtr<Cid, M>,
|
ret_cid: WasmPtr<Cid, M>,
|
||||||
@@ -7503,27 +7473,27 @@ pub fn bus_subcall<M: MemorySize>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Function for converting the format
|
// Function for converting the format
|
||||||
fn conv_bus_format(format: BusDataFormat) -> __wasi_busdataformat_t {
|
fn conv_bus_format(format: BusDataFormat) -> BusDataFormat {
|
||||||
match format {
|
match format {
|
||||||
BusDataFormat::Raw => __wasi_busdataformat_t::Raw,
|
BusDataFormat::Raw => BusDataFormat::Raw,
|
||||||
BusDataFormat::Bincode => __wasi_busdataformat_t::Bincode,
|
BusDataFormat::Bincode => BusDataFormat::Bincode,
|
||||||
BusDataFormat::MessagePack => __wasi_busdataformat_t::MessagePack,
|
BusDataFormat::MessagePack => BusDataFormat::MessagePack,
|
||||||
BusDataFormat::Json => __wasi_busdataformat_t::Json,
|
BusDataFormat::Json => BusDataFormat::Json,
|
||||||
BusDataFormat::Yaml => __wasi_busdataformat_t::Yaml,
|
BusDataFormat::Yaml => BusDataFormat::Yaml,
|
||||||
BusDataFormat::Xml => __wasi_busdataformat_t::Xml,
|
BusDataFormat::Xml => BusDataFormat::Xml,
|
||||||
BusDataFormat::Rkyv => __wasi_busdataformat_t::Rkyv,
|
BusDataFormat::Rkyv => BusDataFormat::Rkyv,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn conv_bus_format_from(format: __wasi_busdataformat_t) -> BusDataFormat {
|
fn conv_bus_format_from(format: BusDataFormat) -> BusDataFormat {
|
||||||
match format {
|
match format {
|
||||||
__wasi_busdataformat_t::Raw => BusDataFormat::Raw,
|
BusDataFormat::Raw => BusDataFormat::Raw,
|
||||||
__wasi_busdataformat_t::Bincode => BusDataFormat::Bincode,
|
BusDataFormat::Bincode => BusDataFormat::Bincode,
|
||||||
__wasi_busdataformat_t::MessagePack => BusDataFormat::MessagePack,
|
BusDataFormat::MessagePack => BusDataFormat::MessagePack,
|
||||||
__wasi_busdataformat_t::Json => BusDataFormat::Json,
|
BusDataFormat::Json => BusDataFormat::Json,
|
||||||
__wasi_busdataformat_t::Yaml => BusDataFormat::Yaml,
|
BusDataFormat::Yaml => BusDataFormat::Yaml,
|
||||||
__wasi_busdataformat_t::Xml => BusDataFormat::Xml,
|
BusDataFormat::Xml => BusDataFormat::Xml,
|
||||||
__wasi_busdataformat_t::Rkyv => BusDataFormat::Rkyv,
|
BusDataFormat::Rkyv => BusDataFormat::Rkyv,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7973,7 +7943,7 @@ pub fn bus_poll<M: MemorySize>(
|
|||||||
pub fn call_reply<M: MemorySize>(
|
pub fn call_reply<M: MemorySize>(
|
||||||
ctx: FunctionEnvMut<'_, WasiEnv>,
|
ctx: FunctionEnvMut<'_, WasiEnv>,
|
||||||
cid: Cid,
|
cid: Cid,
|
||||||
format: __wasi_busdataformat_t,
|
format: BusDataFormat,
|
||||||
buf: WasmPtr<u8, M>,
|
buf: WasmPtr<u8, M>,
|
||||||
buf_len: M::Offset,
|
buf_len: M::Offset,
|
||||||
) -> BusErrno {
|
) -> BusErrno {
|
||||||
|
|||||||
Reference in New Issue
Block a user