Skip to content

Commit 5f9be7e

Browse files
committed
Remove the CMSG_ APIs from bitrig
1 parent 7da4f47 commit 5f9be7e

File tree

5 files changed

+101
-75
lines changed

5 files changed

+101
-75
lines changed

src/unix/bsd/netbsdlike/mod.rs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -595,56 +595,6 @@ pub const SF_APPEND: ::c_ulong = 0x00040000;
595595

596596
pub const TIMER_ABSTIME: ::c_int = 1;
597597

598-
fn _ALIGN(p: usize) -> usize {
599-
(p + _ALIGNBYTES) & !_ALIGNBYTES
600-
}
601-
602-
f! {
603-
pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar {
604-
(cmsg as *mut ::c_uchar)
605-
.offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize)
606-
}
607-
608-
pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
609-
_ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length
610-
}
611-
612-
pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr)
613-
-> *mut ::cmsghdr
614-
{
615-
if cmsg.is_null() {
616-
return ::CMSG_FIRSTHDR(mhdr);
617-
};
618-
let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)
619-
+ _ALIGN(::mem::size_of::<::cmsghdr>());
620-
let max = (*mhdr).msg_control as usize
621-
+ (*mhdr).msg_controllen as usize;
622-
if next > max {
623-
0 as *mut ::cmsghdr
624-
} else {
625-
(cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize))
626-
as *mut ::cmsghdr
627-
}
628-
}
629-
630-
pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
631-
(_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize))
632-
as ::c_uint
633-
}
634-
635-
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
636-
status >> 8
637-
}
638-
639-
pub fn WIFSIGNALED(status: ::c_int) -> bool {
640-
(status & 0o177) != 0o177 && (status & 0o177) != 0
641-
}
642-
643-
pub fn WIFSTOPPED(status: ::c_int) -> bool {
644-
(status & 0o177) == 0o177
645-
}
646-
}
647-
648598
#[link(name = "util")]
649599
extern {
650600
pub fn mincore(addr: *mut ::c_void, len: ::size_t,

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,10 +1060,58 @@ pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;
10601060
pub const SF_LOG: ::c_ulong = 0x00400000;
10611061
pub 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+
10661067
f! {
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
}
Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,2 @@
11
pub type c_long = i32;
22
pub type c_ulong = u32;
3-
4-
// should be pub(crate), but that requires Rust 1.18.0
5-
cfg_if! {
6-
if #[cfg(libc_const_size_of)] {
7-
#[doc(hidden)]
8-
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;
9-
} else {
10-
#[doc(hidden)]
11-
pub const _ALIGNBYTES: usize = 4 - 1;
12-
}
13-
}

src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,3 @@ pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1;
88
pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2;
99
pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 3;
1010
pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 4;
11-
12-
// should be pub(crate), but that requires Rust 1.18.0
13-
cfg_if! {
14-
if #[cfg(libc_const_size_of)] {
15-
#[doc(hidden)]
16-
pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
17-
} else {
18-
#[doc(hidden)]
19-
pub const _ALIGNBYTES: usize = 8 - 1;
20-
}
21-
}

src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,56 @@ pub const SIGSTKSZ : ::size_t = 28672;
392392

393393
pub const PT_FIRSTMACH: ::c_int = 32;
394394

395+
fn _ALIGN(p: usize) -> usize {
396+
(p + _ALIGNBYTES) & !_ALIGNBYTES
397+
}
398+
399+
f! {
400+
pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar {
401+
(cmsg as *mut ::c_uchar)
402+
.offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize)
403+
}
404+
405+
pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
406+
_ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length
407+
}
408+
409+
pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr)
410+
-> *mut ::cmsghdr
411+
{
412+
if cmsg.is_null() {
413+
return ::CMSG_FIRSTHDR(mhdr);
414+
};
415+
let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)
416+
+ _ALIGN(::mem::size_of::<::cmsghdr>());
417+
let max = (*mhdr).msg_control as usize
418+
+ (*mhdr).msg_controllen as usize;
419+
if next > max {
420+
0 as *mut ::cmsghdr
421+
} else {
422+
(cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize))
423+
as *mut ::cmsghdr
424+
}
425+
}
426+
427+
pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
428+
(_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize))
429+
as ::c_uint
430+
}
431+
432+
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
433+
status >> 8
434+
}
435+
436+
pub fn WIFSIGNALED(status: ::c_int) -> bool {
437+
(status & 0o177) != 0o177 && (status & 0o177) != 0
438+
}
439+
440+
pub fn WIFSTOPPED(status: ::c_int) -> bool {
441+
(status & 0o177) == 0o177
442+
}
443+
}
444+
395445
extern {
396446
pub fn accept4(s: ::c_int, addr: *mut ::sockaddr,
397447
addrlen: *mut ::socklen_t, flags: ::c_int) -> ::c_int;

0 commit comments

Comments
 (0)