• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mattwparas / steel / 18461079395

13 Oct 2025 09:20AM UTC coverage: 42.731% (-0.9%) from 43.668%
18461079395

Pull #536

github

web-flow
Merge 6f55a8b56 into e378cba22
Pull Request #536: Initial proposal for no_std support

63 of 755 new or added lines in 38 files covered. (8.34%)

73 existing lines in 15 files now uncovered.

12324 of 28841 relevant lines covered (42.73%)

3215759.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/crates/steel-core/src/getrandom_custom.rs
1
//! Custom fallback for `getrandom` when the `std` feature is disabled.
2
//!
3
//! The implementation below provides a deterministic, non-cryptographic source of
4
//! bytes so code that depends on `getrandom` (e.g. tests or hashing seeds) keeps
5
//! working in `no_std` builds without relying on the `wasm_js` backend.
6

7
use core::slice;
8
use getrandom::Error;
9

10
#[inline]
NEW
11
fn stir(mut state: u64) -> u64 {
×
12
    // xorshift64*; good enough for seeding hashers in no_std builds.
NEW
13
    state ^= state >> 12;
×
NEW
14
    state ^= state << 25;
×
NEW
15
    state ^= state >> 27;
×
NEW
16
    state.wrapping_mul(0x2545_F491_4F6C_DD1D)
×
17
}
18

19
fn fill_buffer(buf: &mut [u8], mut state: u64) {
20
    for byte in buf.iter_mut() {
21
        state = stir(state);
22
        *byte = (state >> 56) as u8;
23
    }
24
}
25

26
#[no_mangle]
27
pub unsafe extern "Rust" fn __getrandom_v03_custom(dest: *mut u8, len: usize) -> Result<(), Error> {
28
    if len == 0 {
29
        return Ok(());
30
    }
31

32
    if dest.is_null() {
33
        return Err(Error::UNSUPPORTED);
34
    }
35

36
    let buf = unsafe { slice::from_raw_parts_mut(dest, len) };
37
    let base = dest as usize as u64;
38
    let seed = 0xA076_1D64_78BD_642F ^ base.rotate_left(17) ^ (len as u64);
39
    fill_buffer(buf, seed);
40
    Ok(())
41
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc