Skip to content

Commit

Permalink
Merge #527
Browse files Browse the repository at this point in the history
527: Add cfmakeraw/cfsetspeed r=asomers

We'll see how this tests on other platforms, but it's supported on BSDs and Linux supposedly.
  • Loading branch information
bors[bot] committed Jul 11, 2017
2 parents 84901b0 + 0599d91 commit 17f87d4
Show file tree
Hide file tree
Showing 9 changed files with 1,185 additions and 647 deletions.
17 changes: 0 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,6 @@ matrix:
rust: nightly

allow_failures:
# iOS is still being worked on, so for now don't block on compilation failures
- env: TARGET=aarch64-apple-ios DISABLE_TESTS=1
rust: 1.13.0
os: osx
- env: TARGET=armv7-apple-ios DISABLE_TESTS=1
rust: 1.13.0
os: osx
- env: TARGET=armv7s-apple-ios DISABLE_TESTS=1
rust: 1.13.0
os: osx
- env: TARGET=i386-apple-ios DISABLE_TESTS=1
rust: 1.13.0
os: osx
- env: TARGET=x86_64-apple-ios DISABLE_TESTS=1
rust: 1.13.0
os: osx

# Planning to add these targets, but they can fail for now
- env: TARGET=mips64-unknown-linux-gnuabi64
rust: 1.13.0
Expand Down
22 changes: 13 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,32 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Added `nix::ptrace::{ptrace_get_data, ptrace_getsiginfo, ptrace_setsiginfo
and nix::Error::UnsupportedOperation}`
([#614](https://github.com/nix-rust/nix/pull/614))
- Added `cfmakeraw`, `cfsetspeed`, and `tcgetsid`. ([#527](https://github.com/nix-rust/nix/pull/527))

### Changed
- Changed ioctl! write to take argument by value instead as pointer.
If you need a pointer as argument, use ioctl! write buf.
- Changed `ioctl!(write ...)` to take argument by value instead as pointer.
If you need a pointer as argument, use `ioctl!(write buf ...)`.
([#626](https://github.com/nix-rust/nix/pull/626))
- Marked `sys::mman::{ mmap, munmap, madvise, munlock, msync }` as unsafe.
([#559](https://github.com/nix-rust/nix/pull/559))
- Minimum supported Rust version is now 1.13
- Minimum supported Rust version is now 1.13.
- Removed `revents` argument from `PollFd::new()` as it's an output argument and
will be overwritten regardless of value.
([#542](https://github.com/nix-rust/nix/pull/542))
- Changed type signature of `sys::select::FdSet::contains` to make `self`
immutable ([#564](https://github.com/nix-rust/nix/pull/564))
- Changed type of `sched::sched_setaffinity`'s `pid` argument to `pid_t`
- Introduced wrapper types for gid_t, pid_t, and uid_t as Gid, Pid, and Uid
- Introduced wrapper types for `gid_t`, `pid_t`, and `uid_t` as `Gid`, `Pid`, and `Uid`
respectively. Various functions have been changed to use these new types as
arguments. ([#629](https://github.com/nix-rust/nix/pull/629))
- Promoted all Android targets to Tier 2 support
- Fixed compilation on all Android and iOS targets ([#527](https://github.com/nix-rust/nix/pull/527))
and promoted them to Tier 2 support.
- `nix::sys::statfs::{statfs,fstatfs}` uses statfs definition from `libc::statfs` instead of own linux specific type `nix::sys::Statfs`.
Also file system type constants like `nix::sys::statfs::ADFS_SUPER_MAGIC` were removed in favor of the libc equivalent.
([#561](https://github.com/nix-rust/nix/pull/561))
- Revised the termios API including additional tests and documentation and exposed it on iOS. ([#527](https://github.com/nix-rust/nix/pull/527))

### Removed
- Removed io::Error from nix::Error and conversion from nix::Error to Errno
- Removed `io::Error` from `nix::Error` and the conversion from `nix::Error` to `Errno`
([#614](https://github.com/nix-rust/nix/pull/614))

### Fixed
Expand All @@ -62,6 +64,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
only available on x86, x86-64, and ARM, and also not on Android.
- Fixed `sys::socket::sendmsg` with zero entry `cmsgs` parameter.
([#623](https://github.com/nix-rust/nix/pull/623))
- Multiple constants related to the termios API have now been properly defined for
all supported platforms. ([#527](https://github.com/nix-rust/nix/pull/527))

## [0.8.1] 2017-04-16

Expand All @@ -75,7 +79,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Added `::nix::sys::termios::BaudRate` enum to provide portable baudrate
values. ([#518](https://github.com/nix-rust/nix/pull/518))
- Added a new `WaitStatus::PtraceEvent` to support ptrace events on Linux
and Android ([([#438](https://github.com/nix-rust/nix/pull/438))
and Android ([#438](https://github.com/nix-rust/nix/pull/438))
- Added support for POSIX AIO
([#483](https://github.com/nix-rust/nix/pull/483))
([#506](https://github.com/nix-rust/nix/pull/506))
Expand Down Expand Up @@ -111,7 +115,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Added `ppoll` in `::nix::poll`
([#520](https://github.com/nix-rust/nix/pull/520))
- Added support for getting and setting pipe size with fcntl(2) on Linux
([#540](https://github.com/nix-rust/nix/pull/540)
([#540](https://github.com/nix-rust/nix/pull/540))

### Changed
- `::nix::sys::termios::{cfgetispeed, cfsetispeed, cfgetospeed, cfsetospeed}`
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,41 +50,41 @@ The following targets are all supported by nix on Rust 1.13.0 or newer (unless
otherwise noted):

Tier 1:
* i686-unknown-linux-gnu
* x86_64-unknown-linux-gnu
* i686-apple-darwin
* x86_64-apple-darwin
* aarch64-unknown-linux-gnu
* armv7-unknown-linux-gnueabihf
* arm-unknown-linux-gnueabi
* x86_64-unknown-freebsd
* armv7-unknown-linux-gnueabihf
* i686-apple-darwin
* i686-unknown-linux-gnu
* i686-unknown-linux-musl
* mips-unknown-linux-gnu
* mipsel-unknown-linux-gnu
* powerpc-unknown-linux-gnu
* powerpc64-unknown-linux-gnu
* powerpc64le-unknown-linux-gnu
* mips-unknown-linux-gnu
* mipsel-unknown-linux-gnu
* i686-unknown-linux-musl
* x86_64-apple-darwin
* x86_64-unknown-freebsd
* x86_64-unknown-linux-gnu
* x86_64-unknown-linux-musl

Tier 2:
* i686-unknown-freebsd
* x86_64-unknown-netbsd
* aarch64-apple-ios
* aarch64-linux-android
* arm-linux-androideabi
* armv7-apple-ios
* armv7-linux-androideabi
* armv7s-apple-ios
* i386-apple-ios
* i686-linux-android (requires Rust >= 1.18)
* i686-unknown-freebsd
* x86_64-apple-ios
* x86_64-linux-android (requires Rust >= 1.18)
* x86_64-unknown-netbsd

Tier 3:
* aarch64-apple-ios
* arm-unknown-linux-musleabi (requires Rust >= 1.14)
* armv7-apple-ios
* armv7s-apple-ios
* i386-apple-ios
* mips64-unknown-linux-gnuabi64
* mips64el-unknown-linux-gnuabi64
* s390x-unknown-linux-gnu
* x86_64-apple-ios

## Usage

Expand Down
178 changes: 178 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,184 @@ macro_rules! libc_bitflags {
};
}

/// The `libc_enum!` macro helps with a common use case of defining an enum exclusively using
/// values from the `libc` crate. This macro supports both `pub` and private `enum`s.
///
/// The `libc` crate must be in scope with the name `libc`.
///
/// # Example
/// ```
/// libc_enum!{
/// pub enum ProtFlags {
/// PROT_NONE,
/// PROT_READ,
/// PROT_WRITE,
/// PROT_EXEC,
/// #[cfg(any(target_os = "linux", target_os = "android"))]
/// PROT_GROWSDOWN,
/// #[cfg(any(target_os = "linux", target_os = "android"))]
/// PROT_GROWSUP,
/// }
/// }
/// ```
macro_rules! libc_enum {
// (non-pub) Exit rule.
(@make_enum
{
name: $BitFlags:ident,
attrs: [$($attrs:tt)*],
entries: [$($entries:tt)*],
}
) => {
$($attrs)*
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum $BitFlags {
$($entries)*
}
};

// (pub) Exit rule.
(@make_enum
{
pub,
name: $BitFlags:ident,
attrs: [$($attrs:tt)*],
entries: [$($entries:tt)*],
}
) => {
$($attrs)*
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum $BitFlags {
$($entries)*
}
};

// (non-pub) Done accumulating.
(@accumulate_entries
{
name: $BitFlags:ident,
attrs: $attrs:tt,
},
$entries:tt;
) => {
libc_enum! {
@make_enum
{
name: $BitFlags,
attrs: $attrs,
entries: $entries,
}
}
};

// (pub) Done accumulating.
(@accumulate_entries
{
pub,
name: $BitFlags:ident,
attrs: $attrs:tt,
},
$entries:tt;
) => {
libc_enum! {
@make_enum
{
pub,
name: $BitFlags,
attrs: $attrs,
entries: $entries,
}
}
};

// Munch an attr.
(@accumulate_entries
$prefix:tt,
[$($entries:tt)*];
#[$attr:meta] $($tail:tt)*
) => {
libc_enum! {
@accumulate_entries
$prefix,
[
$($entries)*
#[$attr]
];
$($tail)*
}
};

// Munch last ident if not followed by a comma.
(@accumulate_entries
$prefix:tt,
[$($entries:tt)*];
$entry:ident
) => {
libc_enum! {
@accumulate_entries
$prefix,
[
$($entries)*
$entry = libc::$entry,
];
}
};

// Munch an ident; covers terminating comma case.
(@accumulate_entries
$prefix:tt,
[$($entries:tt)*];
$entry:ident, $($tail:tt)*
) => {
libc_enum! {
@accumulate_entries
$prefix,
[
$($entries)*
$entry = libc::$entry,
];
$($tail)*
}
};

// (non-pub) Entry rule.
(
$(#[$attr:meta])*
enum $BitFlags:ident {
$($vals:tt)*
}
) => {
libc_enum! {
@accumulate_entries
{
name: $BitFlags,
attrs: [$(#[$attr])*],
},
[];
$($vals)*
}
};

// (pub) Entry rule.
(
$(#[$attr:meta])*
pub enum $BitFlags:ident {
$($vals:tt)*
}
) => {
libc_enum! {
@accumulate_entries
{
pub,
name: $BitFlags,
attrs: [$(#[$attr])*],
},
[];
$($vals)*
}
};
}

/// A Rust version of the familiar C `offset_of` macro. It returns the byte
/// offset of `field` within struct `ty`
macro_rules! offset_of {
Expand Down
Loading

0 comments on commit 17f87d4

Please sign in to comment.