This commit is contained in:
luozijun 2017-12-12 00:50:29 +08:00
commit 722e133d78
7 changed files with 40 additions and 19 deletions

View File

@ -146,5 +146,6 @@ mod imp {
pub mod mem {
pub fn size_of_val<T>(_: &T) -> usize { 4 }
pub fn size_of<T>(_: &T) -> usize { 4 }
}
}

View File

@ -175,6 +175,15 @@ s! {
pub sdl_slen: ::c_uchar,
pub sdl_data: [::c_char; 46]
}
pub struct cmsgcred {
pub cmcred_pid: ::pid_t,
pub cmcred_uid: ::uid_t,
pub cmcred_euid: ::uid_t,
pub cmcred_gid: ::gid_t,
pub cmcred_ngroups: ::c_short,
pub cmcred_groups: [::gid_t; CMGROUP_MAX]
}
}
pub const AIO_LISTIO_MAX: ::c_int = 16;
@ -950,6 +959,8 @@ pub const OCRNL: ::tcflag_t = 0x10;
pub const ONOCR: ::tcflag_t = 0x20;
pub const ONLRET: ::tcflag_t = 0x40;
pub const CMGROUP_MAX: usize = 16;
f! {
pub fn WIFCONTINUED(status: ::c_int) -> bool {
status == 0x13

View File

@ -1,3 +1,5 @@
use dox::mem;
pub type clock_t = ::c_uint;
pub type suseconds_t = ::c_int;
pub type dev_t = u64;
@ -281,6 +283,16 @@ s! {
pub ifm_index: ::c_ushort,
pub ifm_data: if_data,
}
pub struct sockcred {
pub sc_pid: ::pid_t,
pub sc_uid: ::uid_t,
pub sc_euid: ::uid_t,
pub sc_gid: ::gid_t,
pub sc_egid: ::gid_t,
pub sc_ngroups: ::c_int,
pub sc_groups: [::gid_t; 1],
}
}
pub const AT_FDCWD: ::c_int = -100;
@ -910,12 +922,21 @@ pub const SOCK_NONBLOCK: ::c_int = 0x20000000;
// http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36
f! {
pub fn dirfd(dirp: *mut ::DIR) -> ::c_int {
unsafe { *(dirp as *const ::c_int) }
*(dirp as *const ::c_int)
}
pub fn WIFCONTINUED(status: ::c_int) -> bool {
status == 0xffff
}
pub fn SOCKCREDSIZE(ngrps: usize) -> usize {
let ngrps = if ngrps > 0 {
ngrps - 1
} else {
0
};
mem::size_of::<sockcred>() + mem::size_of::<::gid_t>() * ngrps
}
}
extern {

View File

@ -448,6 +448,12 @@ s! {
pub p_memsz: Elf64_Xword,
pub p_align: Elf64_Xword,
}
pub struct ucred {
pub pid: ::pid_t,
pub uid: ::uid_t,
pub gid: ::gid_t,
}
}
pub const ABDAY_1: ::nl_item = 0x20000;

View File

@ -75,12 +75,6 @@ s! {
pub mem_unit: ::c_uint,
pub __reserved: [::c_char; 256],
}
pub struct ucred {
pub pid: ::pid_t,
pub uid: ::uid_t,
pub gid: ::gid_t,
}
}
pub const SFD_CLOEXEC: ::c_int = 0x080000;

View File

@ -104,12 +104,6 @@ s! {
__unused5: *mut ::c_void,
}
pub struct ucred {
pub pid: ::pid_t,
pub uid: ::uid_t,
pub gid: ::gid_t,
}
pub struct statfs {
pub f_type: __fsword_t,
pub f_bsize: __fsword_t,

View File

@ -221,12 +221,6 @@ s! {
__unused5: *mut ::c_void,
}
pub struct ucred {
pub pid: ::pid_t,
pub uid: ::uid_t,
pub gid: ::gid_t,
}
pub struct flock {
pub l_type: ::c_short,
pub l_whence: ::c_short,