MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / try_decode_void

Function try_decode_void

src/backend/linux_raw/io/errno.rs:208–230  ·  view source on GitHub ↗
(
    raw: RetReg<Num>,
)

Source from the content-addressed store, hash-verified

206/// This must only be used with syscalls which return no value on success.
207#[inline]
208pub(in crate::backend) unsafe fn try_decode_void<Num: RetNumber>(
209 raw: RetReg<Num>,
210) -> io::Result<()> {
211 // Instead of using `check_result` here, we just check for zero, since this
212 // function is only used for system calls which have no other return value,
213 // and this produces smaller code.
214 if raw.is_nonzero() {
215 debug_assert!(raw.is_in_range(-4095..0));
216
217 // Tell the optimizer that we know the value is in the error range.
218 // This helps it avoid unnecessary integer conversions.
219 #[cfg(core_intrinsics)]
220 {
221 core::intrinsics::assume(raw.is_in_range(-4095..0));
222 }
223
224 return Err(Errno(raw.decode_error_code()));
225 }
226
227 raw.decode_void();
228
229 Ok(())
230}
231
232/// Check for an error from the result of a syscall which does not return on
233/// success. On success, return the unconsumed `raw` value.

Callers 2

retFunction · 0.85
ret_infallibleFunction · 0.85

Calls 5

is_nonzeroMethod · 0.80
is_in_rangeMethod · 0.80
decode_error_codeMethod · 0.80
decode_voidMethod · 0.80
ErrnoClass · 0.70

Tested by

no test coverage detected