1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
diff --git a/src/memory.rs b/src/memory.rs
index 17986bc..49e994e 100644
--- a/src/memory.rs
+++ b/src/memory.rs
@@ -119,15 +119,15 @@ pub(crate) fn enc_slice_of<T>(
macro_rules! dec_enc_scalar {
( $ty:ident, $dec:ident, $dec_byref:ident, $enc:ident, $enc_byref:ident) => {
pub(crate) fn $dec(x: wasm32::$ty) -> host::$ty {
- host::$ty::from_le(x)
+ x
}
pub(crate) fn $dec_byref(memory: &mut [u8], ptr: wasm32::uintptr_t) -> Result<host::$ty> {
- dec_pointee::<wasm32::$ty>(memory, ptr).map($dec)
+ dec_pointee::<wasm32::$ty>(memory, ptr).map(host::$ty::from_le)
}
pub(crate) fn $enc(x: host::$ty) -> wasm32::$ty {
- x.to_le()
+ x
}
pub(crate) fn $enc_byref(
@@ -135,7 +135,7 @@ macro_rules! dec_enc_scalar {
ptr: wasm32::uintptr_t,
x: host::$ty,
) -> Result<()> {
- enc_pointee::<wasm32::$ty>(memory, ptr, $enc(x))
+ enc_pointee::<wasm32::$ty>(memory, ptr, x.to_le())
}
};
}
@@ -238,16 +238,16 @@ dec_enc_scalar!(
enc_linkcount_byref
);
-pub(crate) fn dec_filestat(filestat: wasm32::__wasi_filestat_t) -> host::__wasi_filestat_t {
+fn from_le_filestat(filestat: wasm32::__wasi_filestat_t) -> host::__wasi_filestat_t {
host::__wasi_filestat_t {
- st_dev: dec_device(filestat.st_dev),
- st_ino: dec_inode(filestat.st_ino),
- st_filetype: dec_filetype(filestat.st_filetype),
- st_nlink: dec_linkcount(filestat.st_nlink),
- st_size: dec_filesize(filestat.st_size),
- st_atim: dec_timestamp(filestat.st_atim),
- st_mtim: dec_timestamp(filestat.st_mtim),
- st_ctim: dec_timestamp(filestat.st_ctim),
+ st_dev: host::__wasi_device_t::from_le(filestat.st_dev),
+ st_ino: host::__wasi_inode_t::from_le(filestat.st_ino),
+ st_filetype: host::__wasi_filetype_t::from_le(filestat.st_filetype),
+ st_nlink: host::__wasi_linkcount_t::from_le(filestat.st_nlink),
+ st_size: host::__wasi_filesize_t::from_le(filestat.st_size),
+ st_atim: host::__wasi_timestamp_t::from_le(filestat.st_atim),
+ st_mtim: host::__wasi_timestamp_t::from_le(filestat.st_mtim),
+ st_ctim: host::__wasi_timestamp_t::from_le(filestat.st_ctim),
}
}
@@ -255,19 +255,19 @@ pub(crate) fn dec_filestat_byref(
memory: &mut [u8],
filestat_ptr: wasm32::uintptr_t,
) -> Result<host::__wasi_filestat_t> {
- dec_pointee::<wasm32::__wasi_filestat_t>(memory, filestat_ptr).map(dec_filestat)
+ dec_pointee::<wasm32::__wasi_filestat_t>(memory, filestat_ptr).map(from_le_filestat)
}
-pub(crate) fn enc_filestat(filestat: host::__wasi_filestat_t) -> wasm32::__wasi_filestat_t {
+pub(crate) fn to_le_filestat(filestat: host::__wasi_filestat_t) -> wasm32::__wasi_filestat_t {
wasm32::__wasi_filestat_t {
- st_dev: enc_device(filestat.st_dev),
- st_ino: enc_inode(filestat.st_ino),
- st_filetype: enc_filetype(filestat.st_filetype),
- st_nlink: enc_linkcount(filestat.st_nlink),
- st_size: enc_filesize(filestat.st_size),
- st_atim: enc_timestamp(filestat.st_atim),
- st_mtim: enc_timestamp(filestat.st_mtim),
- st_ctim: enc_timestamp(filestat.st_ctim),
+ st_dev: filestat.st_dev.to_le(),
+ st_ino: filestat.st_ino.to_le(),
+ st_filetype: filestat.st_filetype.to_le(),
+ st_nlink: filestat.st_nlink.to_le(),
+ st_size: filestat.st_size.to_le(),
+ st_atim: filestat.st_atim.to_le(),
+ st_mtim: filestat.st_mtim.to_le(),
+ st_ctim: filestat.st_ctim.to_le(),
}
}