Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow import of Linux macros in Rust2018 #1066

Merged
merged 1 commit into from
May 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- Macros exported by `nix` may now be imported via `use` on the Rust 2018
edition without importing helper macros on Linux targets.
([#1066](https://github.com/nix-rust/nix/pull/1066))

For example, in Rust 2018, the `ioctl_read_bad!` macro can now be imported
without importing the `convert_ioctl_res!` macro.

```rust
use nix::ioctl_read_bad;

ioctl_read_bad!(tcgets, libc::TCGETS, libc::termios);
```

### Changed
### Fixed
### Removed
Expand Down Expand Up @@ -56,7 +69,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Fixed multiple bugs when using `sendmsg` and `recvmsg` with ancillary control messages
([#1020](https://github.com/nix-rust/nix/pull/1020))
- Macros exported by `nix` may now be imported via `use` on the Rust 2018
edition without importing helper macros.
edition without importing helper macros for BSD targets.
([#1041](https://github.com/nix-rust/nix/pull/1041))

For example, in Rust 2018, the `ioctl_read_bad!` macro can now be imported
Expand Down
8 changes: 4 additions & 4 deletions src/sys/ioctl/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ macro_rules! ioc {
/// ioctl_write_int_bad!(kvm_create_vm, request_code_none!(KVMIO, 0x03));
/// # fn main() {}
/// ```
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! request_code_none {
($ty:expr, $nr:expr) => (ioc!($crate::sys::ioctl::NONE, $ty, $nr, 0))
}
Expand All @@ -108,7 +108,7 @@ macro_rules! request_code_none {
/// The read/write direction is relative to userland, so this
/// command would be userland is reading and the kernel is
/// writing.
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! request_code_read {
($ty:expr, $nr:expr, $sz:expr) => (ioc!($crate::sys::ioctl::READ, $ty, $nr, $sz))
}
Expand All @@ -123,7 +123,7 @@ macro_rules! request_code_read {
/// The read/write direction is relative to userland, so this
/// command would be userland is writing and the kernel is
/// reading.
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! request_code_write {
($ty:expr, $nr:expr, $sz:expr) => (ioc!($crate::sys::ioctl::WRITE, $ty, $nr, $sz))
}
Expand All @@ -134,7 +134,7 @@ macro_rules! request_code_write {
///
/// You should only use this macro directly if the `ioctl` you're working
/// with is "bad" and you cannot use `ioctl_readwrite!()` directly.
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! request_code_readwrite {
($ty:expr, $nr:expr, $sz:expr) => (ioc!($crate::sys::ioctl::READ | $crate::sys::ioctl::WRITE, $ty, $nr, $sz))
}