@@ -114,10 +114,6 @@ mod platform;
114
114
115
115
pub use self :: platform:: * ;
116
116
117
- /// A hack to get the macros to work nicely.
118
- #[ doc( hidden) ]
119
- pub use :: libc as libc;
120
-
121
117
/// Convert raw ioctl return value to a Nix result
122
118
#[ macro_export]
123
119
#[ doc( hidden) ]
@@ -129,69 +125,70 @@ macro_rules! convert_ioctl_res {
129
125
) ;
130
126
}
131
127
128
+ /// Generates ioctl functions. See [::sys::ioctl](sys/ioctl/index.html).
132
129
#[ macro_export]
133
130
macro_rules! ioctl {
134
131
( bad $name: ident with $nr: expr) => (
135
- pub unsafe fn $name( fd: $crate:: sys :: ioctl :: libc:: c_int,
132
+ pub unsafe fn $name( fd: $crate:: libc:: c_int,
136
133
data: * mut u8 )
137
- -> $crate:: Result <$crate:: sys :: ioctl :: libc:: c_int> {
138
- convert_ioctl_res!( $crate:: sys :: ioctl :: libc:: ioctl( fd, $nr as $crate:: sys :: ioctl :: libc:: c_ulong, data) )
134
+ -> $crate:: Result <$crate:: libc:: c_int> {
135
+ convert_ioctl_res!( $crate:: libc:: ioctl( fd, $nr as $crate:: libc:: c_ulong, data) )
139
136
}
140
137
) ;
141
138
( bad none $name: ident with $nr: expr) => (
142
- pub unsafe fn $name( fd: $crate:: sys :: ioctl :: libc:: c_int)
143
- -> $crate:: Result <$crate:: sys :: ioctl :: libc:: c_int> {
144
- convert_ioctl_res!( libc:: ioctl( fd, $nr as $crate:: sys :: ioctl :: libc:: c_ulong) )
139
+ pub unsafe fn $name( fd: $crate:: libc:: c_int)
140
+ -> $crate:: Result <$crate:: libc:: c_int> {
141
+ convert_ioctl_res!( $crate :: libc:: ioctl( fd, $nr as $crate:: libc:: c_ulong) )
145
142
}
146
143
) ;
147
144
( none $name: ident with $ioty: expr, $nr: expr) => (
148
- pub unsafe fn $name( fd: $crate:: sys :: ioctl :: libc:: c_int)
149
- -> $crate:: Result <$crate:: sys :: ioctl :: libc:: c_int> {
150
- convert_ioctl_res!( $crate:: sys :: ioctl :: libc:: ioctl( fd, io!( $ioty, $nr) as $crate:: sys :: ioctl :: libc:: c_ulong) )
145
+ pub unsafe fn $name( fd: $crate:: libc:: c_int)
146
+ -> $crate:: Result <$crate:: libc:: c_int> {
147
+ convert_ioctl_res!( $crate:: libc:: ioctl( fd, io!( $ioty, $nr) as $crate:: libc:: c_ulong) )
151
148
}
152
149
) ;
153
150
( read $name: ident with $ioty: expr, $nr: expr; $ty: ty) => (
154
- pub unsafe fn $name( fd: $crate:: sys :: ioctl :: libc:: c_int,
151
+ pub unsafe fn $name( fd: $crate:: libc:: c_int,
155
152
val: * mut $ty)
156
- -> $crate:: Result <$crate:: sys :: ioctl :: libc:: c_int> {
157
- convert_ioctl_res!( $crate:: sys :: ioctl :: libc:: ioctl( fd, ior!( $ioty, $nr, :: std:: mem:: size_of:: <$ty>( ) ) as $crate:: sys :: ioctl :: libc:: c_ulong, val) )
153
+ -> $crate:: Result <$crate:: libc:: c_int> {
154
+ convert_ioctl_res!( $crate:: libc:: ioctl( fd, ior!( $ioty, $nr, :: std:: mem:: size_of:: <$ty>( ) ) as $crate:: libc:: c_ulong, val) )
158
155
}
159
156
) ;
160
157
( write $name: ident with $ioty: expr, $nr: expr; $ty: ty) => (
161
- pub unsafe fn $name( fd: $crate:: sys :: ioctl :: libc:: c_int,
158
+ pub unsafe fn $name( fd: $crate:: libc:: c_int,
162
159
val: $ty)
163
- -> $crate:: Result <$crate:: sys :: ioctl :: libc:: c_int> {
164
- convert_ioctl_res!( $crate:: sys :: ioctl :: libc:: ioctl( fd, iow!( $ioty, $nr, :: std:: mem:: size_of:: <$ty>( ) ) as $crate:: sys :: ioctl :: libc:: c_ulong, val) )
160
+ -> $crate:: Result <$crate:: libc:: c_int> {
161
+ convert_ioctl_res!( $crate:: libc:: ioctl( fd, iow!( $ioty, $nr, :: std:: mem:: size_of:: <$ty>( ) ) as $crate:: libc:: c_ulong, val) )
165
162
}
166
163
) ;
167
164
( readwrite $name: ident with $ioty: expr, $nr: expr; $ty: ty) => (
168
- pub unsafe fn $name( fd: $crate:: sys :: ioctl :: libc:: c_int,
165
+ pub unsafe fn $name( fd: $crate:: libc:: c_int,
169
166
val: * mut $ty)
170
- -> $crate:: Result <$crate:: sys :: ioctl :: libc:: c_int> {
171
- convert_ioctl_res!( $crate:: sys :: ioctl :: libc:: ioctl( fd, iorw!( $ioty, $nr, :: std:: mem:: size_of:: <$ty>( ) ) as $crate:: sys :: ioctl :: libc:: c_ulong, val) )
167
+ -> $crate:: Result <$crate:: libc:: c_int> {
168
+ convert_ioctl_res!( $crate:: libc:: ioctl( fd, iorw!( $ioty, $nr, :: std:: mem:: size_of:: <$ty>( ) ) as $crate:: libc:: c_ulong, val) )
172
169
}
173
170
) ;
174
171
( read buf $name: ident with $ioty: expr, $nr: expr; $ty: ty) => (
175
- pub unsafe fn $name( fd: $crate:: sys :: ioctl :: libc:: c_int,
172
+ pub unsafe fn $name( fd: $crate:: libc:: c_int,
176
173
val: * mut $ty,
177
174
len: usize )
178
- -> $crate:: Result <$crate:: sys :: ioctl :: libc:: c_int> {
179
- convert_ioctl_res!( $crate:: sys :: ioctl :: libc:: ioctl( fd, ior!( $ioty, $nr, len) as $crate:: sys :: ioctl :: libc:: c_ulong, val) )
175
+ -> $crate:: Result <$crate:: libc:: c_int> {
176
+ convert_ioctl_res!( $crate:: libc:: ioctl( fd, ior!( $ioty, $nr, len) as $crate:: libc:: c_ulong, val) )
180
177
}
181
178
) ;
182
179
( write buf $name: ident with $ioty: expr, $nr: expr; $ty: ty) => (
183
- pub unsafe fn $name( fd: $crate:: sys :: ioctl :: libc:: c_int,
180
+ pub unsafe fn $name( fd: $crate:: libc:: c_int,
184
181
val: * const $ty,
185
- len: usize ) -> $crate:: Result <$crate:: sys :: ioctl :: libc:: c_int> {
186
- convert_ioctl_res!( $crate:: sys :: ioctl :: libc:: ioctl( fd, iow!( $ioty, $nr, len) as $crate:: sys :: ioctl :: libc:: c_ulong, val) )
182
+ len: usize ) -> $crate:: Result <$crate:: libc:: c_int> {
183
+ convert_ioctl_res!( $crate:: libc:: ioctl( fd, iow!( $ioty, $nr, len) as $crate:: libc:: c_ulong, val) )
187
184
}
188
185
) ;
189
186
( readwrite buf $name: ident with $ioty: expr, $nr: expr; $ty: ty) => (
190
- pub unsafe fn $name( fd: $crate:: sys :: ioctl :: libc:: c_int,
187
+ pub unsafe fn $name( fd: $crate:: libc:: c_int,
191
188
val: * mut $ty,
192
189
len: usize )
193
- -> $crate:: Result <$crate:: sys :: ioctl :: libc:: c_int> {
194
- convert_ioctl_res!( $crate:: sys :: ioctl :: libc:: ioctl( fd, iorw!( $ioty, $nr, len) as $crate:: sys :: ioctl :: libc:: c_ulong, val) )
190
+ -> $crate:: Result <$crate:: libc:: c_int> {
191
+ convert_ioctl_res!( $crate:: libc:: ioctl( fd, iorw!( $ioty, $nr, len) as $crate:: libc:: c_ulong, val) )
195
192
}
196
193
) ;
197
194
}
0 commit comments