Add syscall macro to unix
This commit is contained in:
parent
e8d19986bc
commit
4fe62c0a66
1 changed files with 10 additions and 0 deletions
|
|
@ -24,3 +24,13 @@ ioctl_write_ptr_bad!(if_set_addr6, libc::SIOCSIFADDR, libc::in6_ifreq);
|
|||
ioctl_write_ptr_bad!(if_set_brdaddr, libc::SIOCSIFBRDADDR, libc::ifreq);
|
||||
ioctl_write_ptr_bad!(if_set_mtu, libc::SIOCSIFMTU, libc::ifreq);
|
||||
ioctl_write_ptr_bad!(if_set_netmask, libc::SIOCSIFNETMASK, libc::ifreq);
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! syscall {
|
||||
($call: ident ( $($arg: expr),* $(,)* ) ) => {{
|
||||
match unsafe { ::libc::$call($($arg, )*) } {
|
||||
-1 => Err(::std::io::Error::last_os_error()),
|
||||
res => Ok(res),
|
||||
}
|
||||
}};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue