@@ -25,17 +25,6 @@ mod consts {
25
25
pub const DIRBITS : u8 = 3 ;
26
26
}
27
27
28
- #[ cfg( not( any( target_arch = "powerpc" ,
29
- target_arch = "mips" ,
30
- target_arch = "mips64" ,
31
- target_arch = "x86" ,
32
- target_arch = "arm" ,
33
- target_arch = "x86_64" ,
34
- target_arch = "powerpc64" ,
35
- target_arch = "s390x" ,
36
- target_arch = "aarch64" ) ) ) ]
37
- use this_arch_not_supported;
38
-
39
28
// "Generic" ioctl protocol
40
29
#[ cfg( any( target_arch = "x86" ,
41
30
target_arch = "arm" ,
@@ -86,30 +75,63 @@ macro_rules! ioc {
86
75
( ( $sz as $crate:: sys:: ioctl:: ioctl_num_type & $crate:: sys:: ioctl:: SIZEMASK ) << $crate:: sys:: ioctl:: SIZESHIFT ) )
87
76
}
88
77
89
- /// Encode an ioctl command that has no associated data.
78
+ /// Generate an ioctl request code for a command that passes no data.
79
+ ///
80
+ /// This is equivalent to the `_IO()` macro exposed by the C ioctl API.
81
+ ///
82
+ /// You should only use this macro directly if the `ioctl` you're working
83
+ /// with is "bad" and you cannot use `ioctl_none!()` directly.
84
+ ///
85
+ /// # Example
86
+ ///
87
+ /// ```
88
+ /// # #[macro_use] extern crate nix;
89
+ /// const KVMIO: u8 = 0xAE;
90
+ /// ioctl_write_int_bad!(kvm_create_vm, request_code_none!(KVMIO, 0x03));
91
+ /// # fn main() {}
92
+ /// ```
90
93
#[ macro_export]
91
- #[ doc( hidden) ]
92
- macro_rules! io {
94
+ macro_rules! request_code_none {
93
95
( $ty: expr, $nr: expr) => ( ioc!( $crate:: sys:: ioctl:: NONE , $ty, $nr, 0 ) )
94
96
}
95
97
96
- /// Encode an ioctl command that reads.
98
+ /// Generate an ioctl request code for a command that reads.
99
+ ///
100
+ /// This is equivalent to the `_IOR()` macro exposed by the C ioctl API.
101
+ ///
102
+ /// You should only use this macro directly if the `ioctl` you're working
103
+ /// with is "bad" and you cannot use `ioctl_read!()` directly.
104
+ ///
105
+ /// The read/write direction is relative to userland, so this
106
+ /// command would be userland is reading and the kernel is
107
+ /// writing.
97
108
#[ macro_export]
98
- #[ doc( hidden) ]
99
- macro_rules! ior {
109
+ macro_rules! request_code_read {
100
110
( $ty: expr, $nr: expr, $sz: expr) => ( ioc!( $crate:: sys:: ioctl:: READ , $ty, $nr, $sz) )
101
111
}
102
112
103
- /// Encode an ioctl command that writes.
113
+ /// Generate an ioctl request code for a command that writes.
114
+ ///
115
+ /// This is equivalent to the `_IOW()` macro exposed by the C ioctl API.
116
+ ///
117
+ /// You should only use this macro directly if the `ioctl` you're working
118
+ /// with is "bad" and you cannot use `ioctl_write!()` directly.
119
+ ///
120
+ /// The read/write direction is relative to userland, so this
121
+ /// command would be userland is writing and the kernel is
122
+ /// reading.
104
123
#[ macro_export]
105
- #[ doc( hidden) ]
106
- macro_rules! iow {
124
+ macro_rules! request_code_write {
107
125
( $ty: expr, $nr: expr, $sz: expr) => ( ioc!( $crate:: sys:: ioctl:: WRITE , $ty, $nr, $sz) )
108
126
}
109
127
110
- /// Encode an ioctl command that both reads and writes.
128
+ /// Generate an ioctl request code for a command that reads and writes.
129
+ ///
130
+ /// This is equivalent to the `_IOWR()` macro exposed by the C ioctl API.
131
+ ///
132
+ /// You should only use this macro directly if the `ioctl` you're working
133
+ /// with is "bad" and you cannot use `ioctl_readwrite!()` directly.
111
134
#[ macro_export]
112
- #[ doc( hidden) ]
113
- macro_rules! iorw {
135
+ macro_rules! request_code_readwrite {
114
136
( $ty: expr, $nr: expr, $sz: expr) => ( ioc!( $crate:: sys:: ioctl:: READ | $crate:: sys:: ioctl:: WRITE , $ty, $nr, $sz) )
115
137
}
0 commit comments