| 1 | use std::os::raw::{c_int, c_ulong}; |
| 2 | |
| 3 | #[cfg(any(target_os = "linux", target_os = "macos", target_os = "openbsd", target_os = "android"))] |
| 4 | #[macro_use] |
| 5 | mod platform; |
| 6 | |
| 7 | #[cfg(any(target_os = "linux", target_os = "macos", target_os = "openbsd", target_os = "android"))] |
| 8 | pub use platform::*; |
| 9 | |
| 10 | extern "C" { |
| 11 | #[doc(hidden)] |
| 12 | pub fn ioctl(fd: c_int, req: c_ulong, ...) -> c_int; |
| 13 | } |
| 14 | |
| 15 | #[doc(hidden)] |
| 16 | pub fn check_res(res: c_int) -> std::io::Result<()> { |
| 17 | if res < 0 { |
| 18 | Err(std::io::Error::last_os_error()) |
| 19 | } else { |
| 20 | Ok(()) |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | #[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "openbsd", target_os = "android")))] |
| 25 | use platform_not_supported; |
| 26 | |
| 27 | #[cfg(doctest)] |
| 28 | mod test_readme { |
| 29 | macro_rules! external_doc_test { |
| 30 | ($x:expr) => { |
| 31 | #[doc = $x] |
| 32 | extern "C" {} |
| 33 | }; |
| 34 | } |
| 35 | |
| 36 | external_doc_test!(include_str!("../../README.md")); |
| 37 | } |