MCPcopy Create free account
hub / github.com/bendudson/EuraliOS / nonzero_bit_index

Function nonzero_bit_index

kernel/src/memory/frame_allocator.rs:21–30  ·  view source on GitHub ↗

Return the index of a non-zero bit Uses the BSF instruction: Assumes that at least one bit is not zero

(bitmap: u32)

Source from the content-addressed store, hash-verified

19///
20/// Assumes that at least one bit is not zero
21fn nonzero_bit_index(bitmap: u32) -> u32 {
22 let index: u32;
23 unsafe {
24 asm!("bsf eax, ecx",
25 in("ecx") bitmap,
26 lateout("eax") index,
27 options(pure, nomem, nostack));
28 }
29 index
30}
31
32#[test_case]
33fn test_nonzero_bit_index() {

Callers 1

fetch_frameMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected