@@ -1055,6 +1055,56 @@ pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;
10551055pub const SF_LOG : :: c_ulong = 0x00400000 ;
10561056pub const SF_SNAPINVAL : :: c_ulong = 0x00800000 ;
10571057
1058+ fn _ALIGN ( p : usize ) -> usize {
1059+ ( p + _ALIGNBYTES) & !_ALIGNBYTES
1060+ }
1061+
1062+ f ! {
1063+ pub fn CMSG_DATA ( cmsg: * const :: cmsghdr) -> * mut :: c_uchar {
1064+ ( cmsg as * mut :: c_uchar)
1065+ . offset( _ALIGN( :: mem:: size_of:: <:: cmsghdr>( ) ) as isize )
1066+ }
1067+
1068+ pub fn CMSG_LEN ( length: :: c_uint) -> :: c_uint {
1069+ _ALIGN( :: mem:: size_of:: <:: cmsghdr>( ) ) as :: c_uint + length
1070+ }
1071+
1072+ pub fn CMSG_NXTHDR ( mhdr: * const :: msghdr, cmsg: * const :: cmsghdr)
1073+ -> * mut :: cmsghdr
1074+ {
1075+ if cmsg. is_null( ) {
1076+ return :: CMSG_FIRSTHDR ( mhdr) ;
1077+ } ;
1078+ let next = cmsg as usize + _ALIGN( ( * cmsg) . cmsg_len as usize )
1079+ + _ALIGN( :: mem:: size_of:: <:: cmsghdr>( ) ) ;
1080+ let max = ( * mhdr) . msg_control as usize
1081+ + ( * mhdr) . msg_controllen as usize ;
1082+ if next > max {
1083+ 0 as * mut :: cmsghdr
1084+ } else {
1085+ ( cmsg as usize + _ALIGN( ( * cmsg) . cmsg_len as usize ) )
1086+ as * mut :: cmsghdr
1087+ }
1088+ }
1089+
1090+ pub fn CMSG_SPACE ( length: :: c_uint) -> :: c_uint {
1091+ ( _ALIGN( :: mem:: size_of:: <:: cmsghdr>( ) ) + _ALIGN( length as usize ) )
1092+ as :: c_uint
1093+ }
1094+
1095+ pub fn WSTOPSIG ( status: :: c_int) -> :: c_int {
1096+ status >> 8
1097+ }
1098+
1099+ pub fn WIFSIGNALED ( status: :: c_int) -> bool {
1100+ ( status & 0o177 ) != 0o177 && ( status & 0o177 ) != 0
1101+ }
1102+
1103+ pub fn WIFSTOPPED ( status: :: c_int) -> bool {
1104+ ( status & 0o177 ) == 0o177
1105+ }
1106+ }
1107+
10581108// dirfd() is a macro on netbsd to access
10591109// the first field of the struct where dirp points to:
10601110// http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36
0 commit comments