Skip to content

Commit 9993ef1

Browse files
committed
Remove the CMSG_ APIs from bitrig
1 parent 1be6177 commit 9993ef1

File tree

5 files changed

+100
-72
lines changed

5 files changed

+100
-72
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: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,56 @@ pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;
10551055
pub const SF_LOG: ::c_ulong = 0x00400000;
10561056
pub 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
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)