summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/src/backend/libc/pty/syscalls.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rustix/src/backend/libc/pty/syscalls.rs')
-rw-r--r--vendor/rustix/src/backend/libc/pty/syscalls.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/vendor/rustix/src/backend/libc/pty/syscalls.rs b/vendor/rustix/src/backend/libc/pty/syscalls.rs
index 178201ead..6688ddb26 100644
--- a/vendor/rustix/src/backend/libc/pty/syscalls.rs
+++ b/vendor/rustix/src/backend/libc/pty/syscalls.rs
@@ -31,9 +31,26 @@ pub(crate) fn ptsname(fd: BorrowedFd, mut buffer: Vec<u8>) -> io::Result<CString
loop {
// On platforms with `ptsname_r`, use it.
- #[cfg(any(target_os = "freebsd", linux_like, target_os = "fuchsia"))]
+ #[cfg(any(linux_like, target_os = "fuchsia"))]
let r = unsafe { c::ptsname_r(borrowed_fd(fd), buffer.as_mut_ptr().cast(), buffer.len()) };
+ // FreeBSD 12 doesn't have `ptsname_r`.
+ #[cfg(target_os = "freebsd")]
+ let r = unsafe {
+ weak! {
+ fn ptsname_r(
+ c::c_int,
+ *mut c::c_char,
+ c::size_t
+ ) -> c::c_int
+ }
+ if let Some(func) = ptsname_r.get() {
+ func(borrowed_fd(fd), buffer.as_mut_ptr().cast(), buffer.len())
+ } else {
+ libc::ENOSYS
+ }
+ };
+
// MacOS 10.13.4 has `ptsname_r`; use it if we have it, otherwise fall
// back to calling the underlying ioctl directly.
#[cfg(apple)]
@@ -45,7 +62,7 @@ pub(crate) fn ptsname(fd: BorrowedFd, mut buffer: Vec<u8>) -> io::Result<CString
} else {
// The size declared in the `TIOCPTYGNAME` macro in sys/ttycom.h is 128.
let mut name: [u8; 128] = [0_u8; 128];
- match c::ioctl(borrowed_fd(fd), c::TIOCPTYGNAME as u64, &mut name) {
+ match c::ioctl(borrowed_fd(fd), c::TIOCPTYGNAME as _, &mut name) {
0 => {
let len = CStr::from_ptr(name.as_ptr().cast()).to_bytes().len();
std::ptr::copy_nonoverlapping(name.as_ptr(), buffer.as_mut_ptr(), len + 1);