| 160 | /// `fd` must be a valid open file descriptor. |
| 161 | #[inline] |
| 162 | pub(super) unsafe fn raw_fd<'a, Num: ArgNumber>(fd: RawFd) -> ArgReg<'a, Num> { |
| 163 | // Use `no_fd` when passing `-1` is intended. |
| 164 | #[cfg(feature = "fs")] |
| 165 | debug_assert!(fd == crate::fs::CWD.as_raw_fd() || fd == crate::fs::ABS.as_raw_fd() || fd >= 0); |
| 166 | |
| 167 | // Don't pass the `IORING_REGISTER_FILES_SKIP` sentry value this way. |
| 168 | #[cfg(feature = "io_uring")] |
| 169 | debug_assert_ne!(fd, crate::io_uring::IORING_REGISTER_FILES_SKIP.as_raw_fd()); |
| 170 | |
| 171 | // Linux doesn't look at the high bits beyond the `c_int`, so use |
| 172 | // zero-extension rather than sign-extension because it's a smaller |
| 173 | // instruction. |
| 174 | let fd: c::c_int = fd; |
| 175 | pass_usize(fd as c::c_uint as usize) |
| 176 | } |
| 177 | |
| 178 | /// Deliberately pass `-1` to a file-descriptor argument, for system calls |
| 179 | /// like `mmap` where this indicates the argument is omitted. |