Skip to content

Commit

Permalink
Merge #739
Browse files Browse the repository at this point in the history
739: Support features across more platforms r=Susurrus

 * Exposes `utsname` on all platforms
 * Expose `signalfd` on Android

Closes #607.
  • Loading branch information
bors[bot] committed Aug 21, 2017
2 parents 97caa0c + c787799 commit b76cbee
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
([#722](https://github.com/nix-rust/nix/pull/722))
- Added `nix::unistd:fexecve`.
([#727](https://github.com/nix-rust/nix/pull/727))
- Expose `uname()` on all platforms.
([#739](https://github.com/nix-rust/nix/pull/739))
- Expose `signalfd` module on Android as well.
([#739](https://github.com/nix-rust/nix/pull/739))

### Changed
- Renamed existing `ptrace` wrappers to encourage namespacing ([#692](https://github.com/nix-rust/nix/pull/692))
Expand Down
7 changes: 3 additions & 4 deletions src/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ pub mod memfd;
#[macro_use]
pub mod ioctl;

#[cfg(any(target_os = "linux", target_os = "android"))]
// TODO: Add support for dragonfly, freebsd, and ios/macos.
#[cfg(any(target_os = "android", target_os = "linux"))]
pub mod sendfile;

pub mod signal;

// FIXME: Add to Android once libc#671 lands in a release
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "android", target_os = "linux"))]
pub mod signalfd;

pub mod socket;
Expand All @@ -39,7 +39,6 @@ pub mod reboot;

pub mod termios;

#[cfg(any(target_os = "linux", target_os = "android"))]
pub mod utsname;

pub mod wait;
Expand Down
17 changes: 14 additions & 3 deletions src/sys/utsname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,21 @@ fn to_str<'a>(s: *const *const c_char) -> &'a str {

#[cfg(test)]
mod test {
use super::uname;
#[cfg(target_os = "linux")]
#[test]
pub fn test_uname_linux() {
assert_eq!(super::uname().sysname(), "Linux");
}

#[cfg(any(target_os = "macos", target_os = "ios"))]
#[test]
pub fn test_uname_darwin() {
assert_eq!(super::uname().sysname(), "Darwin");
}

#[cfg(target_os = "freebsd")]
#[test]
pub fn test_uname() {
assert_eq!(uname().sysname(), "Linux");
pub fn test_uname_freebsd() {
assert_eq!(super::uname().sysname(), "FreeBSD");
}
}

0 comments on commit b76cbee

Please sign in to comment.