Skip to content

Commit cf80d77

Browse files
committed
make RNG and ENV public
1 parent 1aac3a4 commit cf80d77

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Changelog
22

3+
## [v0.9.1]
4+
- Make static RNG and ENV variables public
5+
36
## [v0.9.0]
47
- update stable-structures to v0.7.0
58
- update dependecies
69
- introduce ic-test
710
- add durability tests
811

9-
1012
## [v0.8.2]
1113
- update version ic-cdk v0.18.3
1214
- update pocket-ic to v9.0
@@ -67,6 +69,7 @@
6769
- Benchmark tests added.
6870

6971

72+
[v0.9.1]: https://github.com/wasm-forge/ic-wasi-polyfill/compare/v0.9.0...v0.9.1
7073
[v0.9.0]: https://github.com/wasm-forge/ic-wasi-polyfill/compare/v0.8.2...v0.9.0
7174
[v0.8.2]: https://github.com/wasm-forge/ic-wasi-polyfill/compare/v0.8.1...v0.8.2
7275
[v0.8.1]: https://github.com/wasm-forge/ic-wasi-polyfill/compare/v0.8.0...v0.8.1

fuzz-tests/src/test_setup.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Manual changes are possible, but you still need to make sure they are not lost, if the file is regenerated.
33
// If possible, it is best to keep any additional manual test preparation steps outside, in `tests.rs`,
44
// then this file can be regenerated without risk of losing work.
5+
#![allow(dead_code)]
56

67
use ic_test::IcpTest;
78

ic-wasi-polyfill/src/environment.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ impl Environment {
6969
}
7070
}
7171

72+
impl Default for Environment {
73+
fn default() -> Self {
74+
Self::new()
75+
}
76+
}
77+
7278
#[cfg(test)]
7379
mod tests {
7480
use crate::wasi;

ic-wasi-polyfill/src/lib.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ pub unsafe fn forward_to_debug(iovs: *const wasi::Ciovec, len: i32, res: *mut wa
7676
}
7777

7878
thread_local! {
79-
static RNG : RefCell<rand::rngs::StdRng> = RefCell::new(rand::rngs::StdRng::from_seed([0;32]));
79+
pub static RNG : RefCell<rand::rngs::StdRng> = RefCell::new(rand::rngs::StdRng::from_seed([0;32]));
8080

8181
pub static FS: RefCell<FileSystem> = RefCell::new(
8282
FileSystem::new(Box::new(DummyStorage::new())).unwrap()
8383
);
8484

85-
static ENV: RefCell<Environment> = RefCell::new(Environment::new());
85+
pub static ENV: RefCell<Environment> = RefCell::new(Environment::new());
8686
}
8787

8888
#[allow(unused_macros)]
@@ -137,7 +137,7 @@ pub unsafe extern "C" fn __ic_custom_fd_write(
137137
{
138138
let lengths: Vec<_> = src_io_vec.iter().map(|x| x.len).collect();
139139

140-
let l = format!("iovs.lengths={:?}", lengths);
140+
let l = format!("iovs.lengths={lengths:?}");
141141
debug_instructions!("__ic_custom_fd_write", "fd={fd:?} iovs.len={len:?} {l}");
142142
}
143143

@@ -191,7 +191,7 @@ pub unsafe extern "C" fn __ic_custom_fd_read(
191191
#[cfg(feature = "report_wasi_calls")]
192192
{
193193
let lengths: Vec<_> = dst_io_vec.iter().map(|x: &DstBuf| x.len).collect();
194-
let l = format!("iovs.lengths={:?}", lengths);
194+
let l = format!("iovs.lengths={lengths:?}");
195195

196196
debug_instructions!("__ic_custom_fd_read", "fd={fd:?} iovs.lengths={l}");
197197
}
@@ -248,7 +248,7 @@ pub unsafe extern "C" fn __ic_custom_fd_pwrite(
248248
#[cfg(feature = "report_wasi_calls")]
249249
{
250250
let lengths: Vec<_> = src_io_vec.iter().map(|x: &SrcBuf| x.len).collect();
251-
let l = format!("iovs.lengths={:?}", lengths);
251+
let l = format!("iovs.lengths={lengths:?}");
252252
debug_instructions!(
253253
"__ic_custom_fd_pwrite",
254254
"fd={fd:?} iovs.len={len:?} offset={offset} iovs.lengths={l}"
@@ -305,7 +305,7 @@ pub unsafe extern "C" fn __ic_custom_fd_pread(
305305
#[cfg(feature = "report_wasi_calls")]
306306
{
307307
let lengths: Vec<_> = dst_io_vec.iter().map(|x: &DstBuf| x.len).collect();
308-
let l = format!("iovs.lengths={:?}", lengths);
308+
let l = format!("iovs.lengths={lengths:?}");
309309

310310
debug_instructions!(
311311
"__ic_custom_fd_pread",
@@ -1012,10 +1012,7 @@ pub unsafe extern "C" fn __ic_custom_fd_readdir(
10121012

10131013
#[cfg(feature = "report_wasi_calls")]
10141014
{
1015-
let mn = std::cmp::min(
1016-
std::cmp::min(bytes_len as usize, unsafe { *res } as usize),
1017-
50,
1018-
);
1015+
let mn = std::cmp::min(std::cmp::min(bytes_len as usize, unsafe { *res }), 50);
10191016
let buf = unsafe { std::slice::from_raw_parts_mut(bytes, mn) };
10201017

10211018
let t = format!("buf={buf:?}... res={}", unsafe { *res });

0 commit comments

Comments
 (0)