pub(crate) fn last_os_error() -> Error { // We assume that on all targets which use the `util_libc` module `c_int` is equal to `i32` let errno: i32 = unsafe { get_errno() };
if errno > 0 { let code = errno
.checked_neg()
.expect("Positive number can be always negated");
Error::from_neg_error_code(code)
} else {
Error::ERRNO_NOT_POSITIVE
}
}
/// Fill a buffer by repeatedly invoking `sys_fill`. /// /// The `sys_fill` function: /// - should return -1 and set errno on failure /// - should return the number of bytes written on success #[allow(dead_code)] pub(crate) fn sys_fill_exact( mut buf: &mut [MaybeUninit<u8>],
sys_fill: implFn(&mut [MaybeUninit<u8>]) -> libc::ssize_t,
) -> Result<(), Error> { while !buf.is_empty() { let res = sys_fill(buf); match res {
res if res > 0 => { let len = usize::try_from(res).map_err(|_| Error::UNEXPECTED)?;
buf = buf.get_mut(len..).ok_or(Error::UNEXPECTED)?;
}
-1 => { let err = last_os_error(); // We should try again if the call was interrupted. if err.raw_os_error() != Some(libc::EINTR) { return Err(err);
}
} // Negative return codes not equal to -1 should be impossible. // EOF (ret = 0) should be impossible, as the data we are reading // should be an infinite stream of random bytes.
_ => return Err(Error::UNEXPECTED),
}
}
Ok(())
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.20 Sekunden
(vorverarbeitet am 2026-08-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.