Skip to content

Commit

Permalink
Fixes nix-rust#1116 - Feature flag and target_env check to selectivel…
Browse files Browse the repository at this point in the history
…y include GNU function wrappers
  • Loading branch information
shravanrn committed Sep 1, 2019
1 parent a4a465d commit 34fbc5d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ caps = "0.3.1"
[target.'cfg(target_os = "freebsd")'.dev-dependencies]
sysctl = "0.1"

[features]
exclude_gnu = []

[[test]]
name = "test"
path = "test/test.rs"
Expand Down
2 changes: 2 additions & 0 deletions src/sched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod sched_linux_like {
use libc::{self, c_int, c_void};
use std::mem;
use std::option::Option;
#[cfg(all(target_env = "gnu", not(feature = "exclude_gnu")))]
use std::os::unix::io::RawFd;
use unistd::Pid;
use {Error, Result};
Expand Down Expand Up @@ -130,6 +131,7 @@ mod sched_linux_like {
Errno::result(res).map(drop)
}

#[cfg(all(target_env = "gnu", not(feature = "exclude_gnu")))]
pub fn setns(fd: RawFd, nstype: CloneFlags) -> Result<()> {
let res = unsafe { libc::setns(fd, nstype.bits()) };

Expand Down
4 changes: 2 additions & 2 deletions src/sys/uio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub struct RemoteIoVec {
/// [ptrace]: ../ptrace/index.html
/// [`IoVec`]: struct.IoVec.html
/// [`RemoteIoVec`]: struct.RemoteIoVec.html
#[cfg(target_os = "linux")]
#[cfg(all(target_env = "gnu", not(feature = "exclude_gnu")))]
pub fn process_vm_writev(pid: ::unistd::Pid, local_iov: &[IoVec<&[u8]>], remote_iov: &[RemoteIoVec]) -> Result<usize> {
let res = unsafe {
libc::process_vm_writev(pid.into(),
Expand Down Expand Up @@ -147,7 +147,7 @@ pub fn process_vm_writev(pid: ::unistd::Pid, local_iov: &[IoVec<&[u8]>], remote_
/// [`ptrace`]: ../ptrace/index.html
/// [`IoVec`]: struct.IoVec.html
/// [`RemoteIoVec`]: struct.RemoteIoVec.html
#[cfg(any(target_os = "linux"))]
#[cfg(all(target_env = "gnu", not(feature = "exclude_gnu")))]
pub fn process_vm_readv(pid: ::unistd::Pid, local_iov: &[IoVec<&mut [u8]>], remote_iov: &[RemoteIoVec]) -> Result<usize> {
let res = unsafe {
libc::process_vm_readv(pid.into(),
Expand Down
2 changes: 1 addition & 1 deletion test/sys/test_uio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ fn test_preadv() {
}

#[test]
#[cfg(target_os = "linux")]
#[cfg(all(target_env = "gnu", not(feature = "exclude_gnu")))]
// FIXME: qemu-user doesn't implement process_vm_readv/writev on most arches
#[cfg_attr(not(any(target_arch = "x86", target_arch = "x86_64")), ignore)]
fn test_process_vm_readv() {
Expand Down

0 comments on commit 34fbc5d

Please sign in to comment.