1use crate::c;
2
3pub fn errno_location() -> *mut c::c_int {
5 #[cfg(any(target_os = "dragonfly", target_os = "linux"))]
6 unsafe {
7 c::__errno_location()
8 }
9
10 #[cfg(any(target_os = "android", target_os = "netbsd", target_os = "openbsd"))]
11 unsafe {
12 c::__errno()
13 }
14
15 #[cfg(any(target_os = "freebsd", target_os = "ios", target_os = "macos"))]
16 unsafe {
17 c::__error()
18 }
19}
20
21pub fn get_errno() -> c::c_int {
23 unsafe { *errno_location() }
24}
25
26pub fn set_errno(val: c::c_int) {
28 unsafe { *errno_location() = val };
29}