Skip to main content

dope_uring/raw/
source.rs

1use dope_sys::kernel::{self, errno};
2
3use crate::Backend;
4
5// SAFETY: read accesses the calling thread's actual native errno slot, preserving
6// the value set by its immediately preceding syscall.
7unsafe impl kernel::raw::Source for Backend {
8    fn read() -> i32 {
9        // SAFETY: this native TLS cell is read synchronously on its owning thread.
10        unsafe { libc::__errno_location().read() }
11    }
12}
13
14impl errno::Source for Backend {
15    fn clear() {
16        // SAFETY: this native TLS cell is written synchronously on its owning thread.
17        unsafe { libc::__errno_location().write(0) };
18    }
19}