File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -344,6 +344,36 @@ type _Opcode = c::c_uint;
344344#[ cfg( windows) ]
345345type _Opcode = i32 ;
346346
347+ /// Convenience macro for Rustix's ioctl write
348+ #[ macro_export]
349+ macro_rules! ioctl_write_ptr {
350+ ( $name: ident, $ioty: expr, $nr: expr, $ty: ty) => {
351+ pub unsafe fn $name( fd: std:: os:: fd:: BorrowedFd , data: & $ty) -> std:: io:: Result <( ) > {
352+ const OPCODE : $crate:: ioctl:: Opcode =
353+ $crate:: ioctl:: opcode:: write:: <$ty>( $ioty as u8 , $nr as u8 ) ;
354+ Ok ( rustix:: ioctl:: ioctl(
355+ fd,
356+ $crate:: ioctl:: Setter :: <OPCODE , $ty>:: new( * data) ,
357+ ) ?)
358+ }
359+ } ;
360+ }
361+
362+ /// Convenience macro for Rustix's ioctl read
363+ #[ macro_export]
364+ macro_rules! ioctl_readwrite {
365+ ( $name: ident, $ioty: expr, $nr: expr, $ty: ty) => {
366+ pub unsafe fn $name( fd: std:: os:: fd:: BorrowedFd , data: & mut $ty) -> std:: io:: Result <( ) > {
367+ const OPCODE : $crate:: ioctl:: Opcode =
368+ $crate:: ioctl:: opcode:: read_write:: <$ty>( $ioty as u8 , $nr as u8 ) ;
369+ Ok ( $crate:: ioctl:: ioctl(
370+ fd,
371+ $crate:: ioctl:: Updater :: <OPCODE , $ty>:: new( data) ,
372+ ) ?)
373+ }
374+ } ;
375+ }
376+
347377#[ cfg( linux_raw_dep) ]
348378#[ cfg( not( any( target_arch = "sparc" , target_arch = "sparc64" ) ) ) ]
349379#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments