MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / read_u64

Function read_u64

crates/virtual-machine/src/elf_parser.rs:121–131  ·  view source on GitHub ↗

Read a 64-bit little-endian value from bytes at the given offset

(bytes: &[u8], offset: usize)

Source from the content-addressed store, hash-verified

119 let slice = bytes
120 .get(offset..end)
121 .ok_or_else(|| VmError::Other("ELF read out of bounds".to_owned()))?;
122 Ok(u64::from_le_bytes([
123 slice[0], slice[1], slice[2], slice[3], slice[4], slice[5], slice[6], slice[7],
124 ]))
125}
126
127/// Align a value up to the nearest multiple of alignment
128pub fn align_up(value: u64, alignment: u64) -> u64 {
129 let alignment = alignment.max(1);
130 (value + alignment - 1) & !(alignment - 1)
131}

Callers 1

parseMethod · 0.70

Calls 1

getMethod · 0.80

Tested by

no test coverage detected