mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-22 13:11:32 +00:00
feat(runtime-c-api) Support WasiVersion::Latest
.
This commit is contained in:
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
## **[Unreleased]**
|
## **[Unreleased]**
|
||||||
|
|
||||||
|
- [#1030](https://github.com/wasmerio/wasmer/pull/1030) Ability to generate `ImportObject` for a specific version WASI version with the C API.
|
||||||
- [#1028](https://github.com/wasmerio/wasmer/pull/1028) Introduce strict/non-strict modes for `get_wasi_version`
|
- [#1028](https://github.com/wasmerio/wasmer/pull/1028) Introduce strict/non-strict modes for `get_wasi_version`
|
||||||
- [#1029](https://github.com/wasmerio/wasmer/pull/1029) Add the “floating” `WasiVersion::Latest` version.
|
- [#1029](https://github.com/wasmerio/wasmer/pull/1029) Add the “floating” `WasiVersion::Latest` version.
|
||||||
- [#1030](https://github.com/wasmerio/wasmer/pull/1030) Ability to generate `ImportObject` for a specific version WASI version with the C API.
|
|
||||||
- [#1028](https://github.com/wasmerio/wasmer/pull/1028) Introduce strict/non-strict modes for `get_wasi_version`
|
- [#1028](https://github.com/wasmerio/wasmer/pull/1028) Introduce strict/non-strict modes for `get_wasi_version`
|
||||||
- [#1006](https://github.com/wasmerio/wasmer/pull/1006) Fix minor panic issue when `wasmer::compile_with` called with llvm backend
|
- [#1006](https://github.com/wasmerio/wasmer/pull/1006) Fix minor panic issue when `wasmer::compile_with` called with llvm backend
|
||||||
- [#1009](https://github.com/wasmerio/wasmer/pull/1009) Enable LLVM verifier for all tests, add new llvm-backend-tests crate.
|
- [#1009](https://github.com/wasmerio/wasmer/pull/1009) Enable LLVM verifier for all tests, add new llvm-backend-tests crate.
|
||||||
|
@ -8,17 +8,24 @@ use wasmer_wasi as wasi;
|
|||||||
pub enum Version {
|
pub enum Version {
|
||||||
/// Version cannot be detected or is unknown.
|
/// Version cannot be detected or is unknown.
|
||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
|
|
||||||
|
/// Latest version. See `wasmer_wasi::WasiVersion::Latest` to
|
||||||
|
/// leran more.
|
||||||
|
Latest = 1,
|
||||||
|
|
||||||
/// `wasi_unstable`.
|
/// `wasi_unstable`.
|
||||||
Snapshot0 = 1,
|
Snapshot0 = 2,
|
||||||
|
|
||||||
/// `wasi_snapshot_preview1`.
|
/// `wasi_snapshot_preview1`.
|
||||||
Snapshot1 = 2,
|
Snapshot1 = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<c_uchar> for Version {
|
impl From<c_uchar> for Version {
|
||||||
fn from(value: c_uchar) -> Self {
|
fn from(value: c_uchar) -> Self {
|
||||||
match value {
|
match value {
|
||||||
1 => Self::Snapshot0,
|
1 => Self::Latest,
|
||||||
2 => Self::Snapshot1,
|
2 => Self::Snapshot0,
|
||||||
|
3 => Self::Snapshot1,
|
||||||
_ => Self::Unknown,
|
_ => Self::Unknown,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,7 +73,7 @@ pub unsafe extern "C" fn wasmer_wasi_generate_import_object(
|
|||||||
let mapped_dir_list = get_slice_checked(mapped_dirs, mapped_dirs_len as usize);
|
let mapped_dir_list = get_slice_checked(mapped_dirs, mapped_dirs_len as usize);
|
||||||
|
|
||||||
wasmer_wasi_generate_import_object_inner(
|
wasmer_wasi_generate_import_object_inner(
|
||||||
Version::Snapshot1,
|
Version::Latest,
|
||||||
arg_list,
|
arg_list,
|
||||||
env_list,
|
env_list,
|
||||||
preopened_file_list,
|
preopened_file_list,
|
||||||
@ -123,6 +130,7 @@ pub unsafe extern "C" fn wasmer_wasi_get_version(module: *const wasmer_module_t)
|
|||||||
Some(version) => match version {
|
Some(version) => match version {
|
||||||
wasi::WasiVersion::Snapshot0 => Version::Snapshot0,
|
wasi::WasiVersion::Snapshot0 => Version::Snapshot0,
|
||||||
wasi::WasiVersion::Snapshot1 => Version::Snapshot1,
|
wasi::WasiVersion::Snapshot1 => Version::Snapshot1,
|
||||||
|
wasi::WasiVersion::Latest => Version::Latest,
|
||||||
},
|
},
|
||||||
None => Version::Unknown,
|
None => Version::Unknown,
|
||||||
}
|
}
|
||||||
@ -151,6 +159,7 @@ fn wasmer_wasi_generate_import_object_inner(
|
|||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
let version = match version {
|
let version = match version {
|
||||||
|
Version::Latest => wasi::WasiVersion::Latest,
|
||||||
Version::Snapshot0 => wasi::WasiVersion::Snapshot0,
|
Version::Snapshot0 => wasi::WasiVersion::Snapshot0,
|
||||||
Version::Snapshot1 => wasi::WasiVersion::Snapshot1,
|
Version::Snapshot1 => wasi::WasiVersion::Snapshot1,
|
||||||
_ => panic!("Version {:?} is invalid.", version),
|
_ => panic!("Version {:?} is invalid.", version),
|
||||||
@ -186,7 +195,8 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_versions_from_uint() {
|
fn test_versions_from_uint() {
|
||||||
assert_eq!(Version::Unknown, 0.into());
|
assert_eq!(Version::Unknown, 0.into());
|
||||||
assert_eq!(Version::Snapshot0, 1.into());
|
assert_eq!(Version::Latest, 1.into());
|
||||||
assert_eq!(Version::Snapshot1, 2.into());
|
assert_eq!(Version::Snapshot0, 2.into());
|
||||||
|
assert_eq!(Version::Snapshot1, 3.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,14 +30,19 @@ enum Version {
|
|||||||
* Version cannot be detected or is unknown.
|
* Version cannot be detected or is unknown.
|
||||||
*/
|
*/
|
||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
|
/**
|
||||||
|
* Latest version. See `wasmer_wasi::WasiVersion::Latest` to
|
||||||
|
* leran more.
|
||||||
|
*/
|
||||||
|
Latest = 1,
|
||||||
/**
|
/**
|
||||||
* `wasi_unstable`.
|
* `wasi_unstable`.
|
||||||
*/
|
*/
|
||||||
Snapshot0 = 1,
|
Snapshot0 = 2,
|
||||||
/**
|
/**
|
||||||
* `wasi_snapshot_preview1`.
|
* `wasi_snapshot_preview1`.
|
||||||
*/
|
*/
|
||||||
Snapshot1 = 2,
|
Snapshot1 = 3,
|
||||||
};
|
};
|
||||||
typedef uint8_t Version;
|
typedef uint8_t Version;
|
||||||
|
|
||||||
|
@ -28,10 +28,13 @@
|
|||||||
enum class Version : uint8_t {
|
enum class Version : uint8_t {
|
||||||
/// Version cannot be detected or is unknown.
|
/// Version cannot be detected or is unknown.
|
||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
|
/// Latest version. See `wasmer_wasi::WasiVersion::Latest` to
|
||||||
|
/// leran more.
|
||||||
|
Latest = 1,
|
||||||
/// `wasi_unstable`.
|
/// `wasi_unstable`.
|
||||||
Snapshot0 = 1,
|
Snapshot0 = 2,
|
||||||
/// `wasi_snapshot_preview1`.
|
/// `wasi_snapshot_preview1`.
|
||||||
Snapshot1 = 2,
|
Snapshot1 = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// List of export/import kinds.
|
/// List of export/import kinds.
|
||||||
|
Reference in New Issue
Block a user