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 importing macros without helpers in the 2018 edition #1041

Merged
merged 1 commit into from
Apr 12, 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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- 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.
([#1041](/~https://github.com/nix-rust/nix/pull/1041))

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);
```

### Removed
- `Daemon`, `NOTE_REAP`, and `NOTE_EXIT_REPARENTED` are now deprecated on OSX
Expand Down
10 changes: 5 additions & 5 deletions src/sys/ioctl/bsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,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 {
($g:expr, $n:expr) => (ioc!($crate::sys::ioctl::VOID, $g, $n, 0))
}
Expand All @@ -55,7 +55,7 @@ macro_rules! request_code_none {
///
/// You should only use this macro directly if the `ioctl` you're working
/// with is "bad" and you cannot use `ioctl_write_int!()` directly.
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! request_code_write_int {
($g:expr, $n:expr) => (ioc!($crate::sys::ioctl::VOID, $g, $n, ::std::mem::size_of::<$crate::libc::c_int>()))
}
Expand All @@ -70,7 +70,7 @@ macro_rules! request_code_write_int {
/// 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 {
($g:expr, $n:expr, $len:expr) => (ioc!($crate::sys::ioctl::OUT, $g, $n, $len))
}
Expand All @@ -85,7 +85,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 {
($g:expr, $n:expr, $len:expr) => (ioc!($crate::sys::ioctl::IN, $g, $n, $len))
}
Expand All @@ -96,7 +96,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 {
($g:expr, $n:expr, $len:expr) => (ioc!($crate::sys::ioctl::INOUT, $g, $n, $len))
}
28 changes: 14 additions & 14 deletions src/sys/ioctl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ macro_rules! convert_ioctl_res {
/// ioctl_none!(log_status, b'V', 70);
/// fn main() {}
/// ```
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! ioctl_none {
($(#[$attr:meta])* $name:ident, $ioty:expr, $nr:expr) => (
$(#[$attr])*
Expand Down Expand Up @@ -328,7 +328,7 @@ macro_rules! ioctl_none {
/// }
/// ```
// TODO: add an example using request_code_*!()
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! ioctl_none_bad {
($(#[$attr:meta])* $name:ident, $nr:expr) => (
$(#[$attr])*
Expand Down Expand Up @@ -365,7 +365,7 @@ macro_rules! ioctl_none_bad {
/// ioctl_read!(spi_read_mode, SPI_IOC_MAGIC, SPI_IOC_TYPE_MODE, u8);
/// # fn main() {}
/// ```
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! ioctl_read {
($(#[$attr:meta])* $name:ident, $ioty:expr, $nr:expr, $ty:ty) => (
$(#[$attr])*
Expand Down Expand Up @@ -402,7 +402,7 @@ macro_rules! ioctl_read {
/// ioctl_read_bad!(tcgets, libc::TCGETS, libc::termios);
/// # fn main() {}
/// ```
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! ioctl_read_bad {
($(#[$attr:meta])* $name:ident, $nr:expr, $ty:ty) => (
$(#[$attr])*
Expand Down Expand Up @@ -439,7 +439,7 @@ macro_rules! ioctl_read_bad {
/// ioctl_write_ptr!(s_audio, b'V', 34, v4l2_audio);
/// # fn main() {}
/// ```
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! ioctl_write_ptr {
($(#[$attr:meta])* $name:ident, $ioty:expr, $nr:expr, $ty:ty) => (
$(#[$attr])*
Expand Down Expand Up @@ -476,7 +476,7 @@ macro_rules! ioctl_write_ptr {
/// ioctl_write_ptr_bad!(tcsets, libc::TCSETS, libc::termios);
/// # fn main() {}
/// ```
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! ioctl_write_ptr_bad {
($(#[$attr:meta])* $name:ident, $nr:expr, $ty:ty) => (
$(#[$attr])*
Expand Down Expand Up @@ -517,7 +517,7 @@ cfg_if!{
/// ioctl_write_int!(vt_activate, b'v', 4);
/// # fn main() {}
/// ```
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! ioctl_write_int {
($(#[$attr:meta])* $name:ident, $ioty:expr, $nr:expr) => (
$(#[$attr])*
Expand Down Expand Up @@ -558,7 +558,7 @@ cfg_if!{
/// ioctl_write_int!(hci_dev_up, HCI_IOC_MAGIC, HCI_IOC_HCIDEVUP);
/// # fn main() {}
/// ```
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! ioctl_write_int {
($(#[$attr:meta])* $name:ident, $ioty:expr, $nr:expr) => (
$(#[$attr])*
Expand Down Expand Up @@ -603,7 +603,7 @@ cfg_if!{
/// ioctl_write_int_bad!(kvm_create_vm, request_code_none!(KVMIO, 0x03));
/// # fn main() {}
/// ```
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! ioctl_write_int_bad {
($(#[$attr:meta])* $name:ident, $nr:expr) => (
$(#[$attr])*
Expand Down Expand Up @@ -640,7 +640,7 @@ macro_rules! ioctl_write_int_bad {
/// ioctl_readwrite!(enum_audio, b'V', 65, v4l2_audio);
/// # fn main() {}
/// ```
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! ioctl_readwrite {
($(#[$attr:meta])* $name:ident, $ioty:expr, $nr:expr, $ty:ty) => (
$(#[$attr])*
Expand Down Expand Up @@ -668,7 +668,7 @@ macro_rules! ioctl_readwrite {
///
/// For a more in-depth explanation of ioctls, see [`::sys::ioctl`](sys/ioctl/index.html).
// TODO: Find an example for ioctl_readwrite_bad
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! ioctl_readwrite_bad {
($(#[$attr:meta])* $name:ident, $nr:expr, $ty:ty) => (
$(#[$attr])*
Expand Down Expand Up @@ -697,7 +697,7 @@ macro_rules! ioctl_readwrite_bad {
///
/// For a more in-depth explanation of ioctls, see [`::sys::ioctl`](sys/ioctl/index.html).
// TODO: Find an example for ioctl_read_buf
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! ioctl_read_buf {
($(#[$attr:meta])* $name:ident, $ioty:expr, $nr:expr, $ty:ty) => (
$(#[$attr])*
Expand Down Expand Up @@ -736,7 +736,7 @@ macro_rules! ioctl_read_buf {
/// ioctl_write_buf!(spi_transfer, SPI_IOC_MAGIC, SPI_IOC_TYPE_MESSAGE, spi_ioc_transfer);
/// # fn main() {}
/// ```
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! ioctl_write_buf {
($(#[$attr:meta])* $name:ident, $ioty:expr, $nr:expr, $ty:ty) => (
$(#[$attr])*
Expand Down Expand Up @@ -765,7 +765,7 @@ macro_rules! ioctl_write_buf {
///
/// For a more in-depth explanation of ioctls, see [`::sys::ioctl`](sys/ioctl/index.html).
// TODO: Find an example for readwrite_buf
#[macro_export]
#[macro_export(local_inner_macros)]
macro_rules! ioctl_readwrite_buf {
($(#[$attr:meta])* $name:ident, $ioty:expr, $nr:expr, $ty:ty) => (
$(#[$attr])*
Expand Down