diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-01-25 03:37:44 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-25 03:37:44 +0000 |
commit | 5cd01a1fd7417ee6e16636443965c0a197ff2843 (patch) | |
tree | ec06e25f28ac2f989b1af4408d00407b9e548258 /src/sys/uio.rs | |
parent | ae2b7b3552f3b800ab0f5e92dad06cd2e7df25e6 (diff) | |
parent | 6c4b9133f14d4488dc1b86411568b49e99fbe629 (diff) | |
download | nix-5cd01a1fd7417ee6e16636443965c0a197ff2843.zip |
Merge #1603
1603: uclibc support r=rtzoeller a=skrap
uclibc is a libc alternative (peer to glibc and musl) which is used in low-resource embedded linux applications.
It's supported in rust as the `target_env` of several tier 3 targets, but `nix` currently doesn't build. This patch provides a few customizations to get uclibc building.
To test:
* Get nightly rust
* Follow directions for getting a cross toolchain and env setup here: https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/armv7-unknown-linux-uclibceabihf.md
Thanks for your consideration!
Co-authored-by: Jonah Petri <jonah@petri.us>
Diffstat (limited to 'src/sys/uio.rs')
-rw-r--r-- | src/sys/uio.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/sys/uio.rs b/src/sys/uio.rs index 125c2e6c..a1fc8e5f 100644 --- a/src/sys/uio.rs +++ b/src/sys/uio.rs @@ -34,6 +34,8 @@ pub fn readv(fd: RawFd, iov: &mut [IoVec<&mut [u8]>]) -> Result<usize> { #[cfg_attr(docsrs, doc(cfg(all())))] pub fn pwritev(fd: RawFd, iov: &[IoVec<&[u8]>], offset: off_t) -> Result<usize> { + #[cfg(target_env = "uclibc")] + let offset = offset as libc::off64_t; // uclibc doesn't use off_t let res = unsafe { libc::pwritev(fd, iov.as_ptr() as *const libc::iovec, iov.len() as c_int, offset) }; @@ -52,6 +54,8 @@ pub fn pwritev(fd: RawFd, iov: &[IoVec<&[u8]>], #[cfg_attr(docsrs, doc(cfg(all())))] pub fn preadv(fd: RawFd, iov: &[IoVec<&mut [u8]>], offset: off_t) -> Result<usize> { + #[cfg(target_env = "uclibc")] + let offset = offset as libc::off64_t; // uclibc doesn't use off_t let res = unsafe { libc::preadv(fd, iov.as_ptr() as *const libc::iovec, iov.len() as c_int, offset) }; @@ -127,7 +131,7 @@ feature! { /// [ptrace]: ../ptrace/index.html /// [`IoVec`]: struct.IoVec.html /// [`RemoteIoVec`]: struct.RemoteIoVec.html -#[cfg(target_os = "linux")] +#[cfg(all(target_os = "linux", not(target_env = "uclibc")))] pub fn process_vm_writev( pid: crate::unistd::Pid, local_iov: &[IoVec<&[u8]>], @@ -162,7 +166,7 @@ pub fn process_vm_writev( /// [`ptrace`]: ../ptrace/index.html /// [`IoVec`]: struct.IoVec.html /// [`RemoteIoVec`]: struct.RemoteIoVec.html -#[cfg(any(target_os = "linux"))] +#[cfg(all(target_os = "linux", not(target_env = "uclibc")))] pub fn process_vm_readv( pid: crate::unistd::Pid, local_iov: &[IoVec<&mut [u8]>], |