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