Skip to content

Commit 17f87d4

Browse files
committed
Merge #527
527: Add cfmakeraw/cfsetspeed r=asomers We'll see how this tests on other platforms, but it's supported on BSDs and Linux supposedly.
2 parents 84901b0 + 0599d91 commit 17f87d4

File tree

9 files changed

+1185
-647
lines changed

9 files changed

+1185
-647
lines changed

.travis.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,6 @@ matrix:
108108
rust: nightly
109109

110110
allow_failures:
111-
# iOS is still being worked on, so for now don't block on compilation failures
112-
- env: TARGET=aarch64-apple-ios DISABLE_TESTS=1
113-
rust: 1.13.0
114-
os: osx
115-
- env: TARGET=armv7-apple-ios DISABLE_TESTS=1
116-
rust: 1.13.0
117-
os: osx
118-
- env: TARGET=armv7s-apple-ios DISABLE_TESTS=1
119-
rust: 1.13.0
120-
os: osx
121-
- env: TARGET=i386-apple-ios DISABLE_TESTS=1
122-
rust: 1.13.0
123-
os: osx
124-
- env: TARGET=x86_64-apple-ios DISABLE_TESTS=1
125-
rust: 1.13.0
126-
os: osx
127-
128111
# Planning to add these targets, but they can fail for now
129112
- env: TARGET=mips64-unknown-linux-gnuabi64
130113
rust: 1.13.0

CHANGELOG.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,32 @@ This project adheres to [Semantic Versioning](http://semver.org/).
2121
- Added `nix::ptrace::{ptrace_get_data, ptrace_getsiginfo, ptrace_setsiginfo
2222
and nix::Error::UnsupportedOperation}`
2323
([#614](https://github.com/nix-rust/nix/pull/614))
24+
- Added `cfmakeraw`, `cfsetspeed`, and `tcgetsid`. ([#527](https://github.com/nix-rust/nix/pull/527))
2425

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

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

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

6670
## [0.8.1] 2017-04-16
6771

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

116120
### Changed
117121
- `::nix::sys::termios::{cfgetispeed, cfsetispeed, cfgetospeed, cfsetospeed}`

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,41 +50,41 @@ The following targets are all supported by nix on Rust 1.13.0 or newer (unless
5050
otherwise noted):
5151

5252
Tier 1:
53-
* i686-unknown-linux-gnu
54-
* x86_64-unknown-linux-gnu
55-
* i686-apple-darwin
56-
* x86_64-apple-darwin
5753
* aarch64-unknown-linux-gnu
58-
* armv7-unknown-linux-gnueabihf
5954
* arm-unknown-linux-gnueabi
60-
* x86_64-unknown-freebsd
55+
* armv7-unknown-linux-gnueabihf
56+
* i686-apple-darwin
57+
* i686-unknown-linux-gnu
58+
* i686-unknown-linux-musl
59+
* mips-unknown-linux-gnu
60+
* mipsel-unknown-linux-gnu
6161
* powerpc-unknown-linux-gnu
6262
* powerpc64-unknown-linux-gnu
6363
* powerpc64le-unknown-linux-gnu
64-
* mips-unknown-linux-gnu
65-
* mipsel-unknown-linux-gnu
66-
* i686-unknown-linux-musl
64+
* x86_64-apple-darwin
65+
* x86_64-unknown-freebsd
66+
* x86_64-unknown-linux-gnu
6767
* x86_64-unknown-linux-musl
6868

6969
Tier 2:
70-
* i686-unknown-freebsd
71-
* x86_64-unknown-netbsd
70+
* aarch64-apple-ios
7271
* aarch64-linux-android
7372
* arm-linux-androideabi
73+
* armv7-apple-ios
7474
* armv7-linux-androideabi
75+
* armv7s-apple-ios
76+
* i386-apple-ios
7577
* i686-linux-android (requires Rust >= 1.18)
78+
* i686-unknown-freebsd
79+
* x86_64-apple-ios
7680
* x86_64-linux-android (requires Rust >= 1.18)
81+
* x86_64-unknown-netbsd
7782

7883
Tier 3:
79-
* aarch64-apple-ios
8084
* arm-unknown-linux-musleabi (requires Rust >= 1.14)
81-
* armv7-apple-ios
82-
* armv7s-apple-ios
83-
* i386-apple-ios
8485
* mips64-unknown-linux-gnuabi64
8586
* mips64el-unknown-linux-gnuabi64
8687
* s390x-unknown-linux-gnu
87-
* x86_64-apple-ios
8888

8989
## Usage
9090

src/macros.rs

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,184 @@ macro_rules! libc_bitflags {
239239
};
240240
}
241241

242+
/// The `libc_enum!` macro helps with a common use case of defining an enum exclusively using
243+
/// values from the `libc` crate. This macro supports both `pub` and private `enum`s.
244+
///
245+
/// The `libc` crate must be in scope with the name `libc`.
246+
///
247+
/// # Example
248+
/// ```
249+
/// libc_enum!{
250+
/// pub enum ProtFlags {
251+
/// PROT_NONE,
252+
/// PROT_READ,
253+
/// PROT_WRITE,
254+
/// PROT_EXEC,
255+
/// #[cfg(any(target_os = "linux", target_os = "android"))]
256+
/// PROT_GROWSDOWN,
257+
/// #[cfg(any(target_os = "linux", target_os = "android"))]
258+
/// PROT_GROWSUP,
259+
/// }
260+
/// }
261+
/// ```
262+
macro_rules! libc_enum {
263+
// (non-pub) Exit rule.
264+
(@make_enum
265+
{
266+
name: $BitFlags:ident,
267+
attrs: [$($attrs:tt)*],
268+
entries: [$($entries:tt)*],
269+
}
270+
) => {
271+
$($attrs)*
272+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
273+
enum $BitFlags {
274+
$($entries)*
275+
}
276+
};
277+
278+
// (pub) Exit rule.
279+
(@make_enum
280+
{
281+
pub,
282+
name: $BitFlags:ident,
283+
attrs: [$($attrs:tt)*],
284+
entries: [$($entries:tt)*],
285+
}
286+
) => {
287+
$($attrs)*
288+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
289+
pub enum $BitFlags {
290+
$($entries)*
291+
}
292+
};
293+
294+
// (non-pub) Done accumulating.
295+
(@accumulate_entries
296+
{
297+
name: $BitFlags:ident,
298+
attrs: $attrs:tt,
299+
},
300+
$entries:tt;
301+
) => {
302+
libc_enum! {
303+
@make_enum
304+
{
305+
name: $BitFlags,
306+
attrs: $attrs,
307+
entries: $entries,
308+
}
309+
}
310+
};
311+
312+
// (pub) Done accumulating.
313+
(@accumulate_entries
314+
{
315+
pub,
316+
name: $BitFlags:ident,
317+
attrs: $attrs:tt,
318+
},
319+
$entries:tt;
320+
) => {
321+
libc_enum! {
322+
@make_enum
323+
{
324+
pub,
325+
name: $BitFlags,
326+
attrs: $attrs,
327+
entries: $entries,
328+
}
329+
}
330+
};
331+
332+
// Munch an attr.
333+
(@accumulate_entries
334+
$prefix:tt,
335+
[$($entries:tt)*];
336+
#[$attr:meta] $($tail:tt)*
337+
) => {
338+
libc_enum! {
339+
@accumulate_entries
340+
$prefix,
341+
[
342+
$($entries)*
343+
#[$attr]
344+
];
345+
$($tail)*
346+
}
347+
};
348+
349+
// Munch last ident if not followed by a comma.
350+
(@accumulate_entries
351+
$prefix:tt,
352+
[$($entries:tt)*];
353+
$entry:ident
354+
) => {
355+
libc_enum! {
356+
@accumulate_entries
357+
$prefix,
358+
[
359+
$($entries)*
360+
$entry = libc::$entry,
361+
];
362+
}
363+
};
364+
365+
// Munch an ident; covers terminating comma case.
366+
(@accumulate_entries
367+
$prefix:tt,
368+
[$($entries:tt)*];
369+
$entry:ident, $($tail:tt)*
370+
) => {
371+
libc_enum! {
372+
@accumulate_entries
373+
$prefix,
374+
[
375+
$($entries)*
376+
$entry = libc::$entry,
377+
];
378+
$($tail)*
379+
}
380+
};
381+
382+
// (non-pub) Entry rule.
383+
(
384+
$(#[$attr:meta])*
385+
enum $BitFlags:ident {
386+
$($vals:tt)*
387+
}
388+
) => {
389+
libc_enum! {
390+
@accumulate_entries
391+
{
392+
name: $BitFlags,
393+
attrs: [$(#[$attr])*],
394+
},
395+
[];
396+
$($vals)*
397+
}
398+
};
399+
400+
// (pub) Entry rule.
401+
(
402+
$(#[$attr:meta])*
403+
pub enum $BitFlags:ident {
404+
$($vals:tt)*
405+
}
406+
) => {
407+
libc_enum! {
408+
@accumulate_entries
409+
{
410+
pub,
411+
name: $BitFlags,
412+
attrs: [$(#[$attr])*],
413+
},
414+
[];
415+
$($vals)*
416+
}
417+
};
418+
}
419+
242420
/// A Rust version of the familiar C `offset_of` macro. It returns the byte
243421
/// offset of `field` within struct `ty`
244422
macro_rules! offset_of {

0 commit comments

Comments
 (0)