diff options
author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-07-07 03:23:41 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-07 03:23:41 +0900 |
commit | 4fc045c78b00c3b6d2cfe91c0b512963c94ce9a6 (patch) | |
tree | bab8f497e5fc67d24bdd2a8da61647e69bb60f5e | |
parent | 16f8b945f8cfdb66429f5b961a9f3a6fcd417502 (diff) | |
parent | 962b984773e406ebf431bea886bff484a7c2cff0 (diff) | |
download | rust-libc-4fc045c78b00c3b6d2cfe91c0b512963c94ce9a6.tar.gz |
Merge pull request #1630 from myfreeweb/freebsd-mcontext
17 files changed, 334 insertions, 85 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs index e941baf056..07d80ce308 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1703,6 +1703,7 @@ fn test_freebsd(target: &str) { "sys/times.h", "sys/timex.h", "sys/types.h", + "sys/ucontext.h", "sys/uio.h", "sys/un.h", "sys/utsname.h", @@ -1809,6 +1810,22 @@ fn test_freebsd(target: &str) { // base system anyway. "CTL_MAXID" | "KERN_MAXID" | "HW_MAXID" | "USER_MAXID" => true, + // This was renamed in FreeBSD 12.2 and 13 (r352486). + "CTL_UNSPEC" | "CTL_SYSCTL" => true, + + // These were added in FreeBSD 12.2 and 13 (r352486), + // but they are just names for magic numbers that existed for ages. + "CTL_SYSCTL_DEBUG" + | "CTL_SYSCTL_NAME" + | "CTL_SYSCTL_NEXT" + | "CTL_SYSCTL_NAME2OID" + | "CTL_SYSCTL_OIDFMT" + | "CTL_SYSCTL_OIDDESCR" + | "CTL_SYSCTL_OIDLABEL" => true, + + // This was renamed in FreeBSD 12.2 and 13 (r350749). + "IPPROTO_SEP" | "IPPROTO_DCCP" => true, + _ => false, } }); diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index c03c644e83..f130974728 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -2,6 +2,7 @@ //! //! This covers *-apple-* triples currently pub type c_char = i8; +pub type wchar_t = i32; pub type clock_t = c_ulong; pub type time_t = c_long; pub type suseconds_t = i32; diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index b34cdb8719..5841947f33 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1,5 +1,6 @@ pub type dev_t = u32; pub type c_char = i8; +pub type wchar_t = i32; pub type clock_t = u64; pub type ino_t = u64; pub type lwpid_t = i32; diff --git a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs index 22fd2b84f9..db0093a529 100644 --- a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -1,34 +1,10 @@ pub type c_char = u8; pub type c_long = i64; pub type c_ulong = u64; +pub type wchar_t = u32; pub type time_t = i64; pub type suseconds_t = i64; - -s! { - pub struct stat { - pub st_dev: ::dev_t, - pub st_ino: ::ino_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: ::dev_t, - pub st_atime: ::time_t, - pub st_atime_nsec: ::c_long, - pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_long, - pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_long, - pub st_size: ::off_t, - pub st_blocks: ::blkcnt_t, - pub st_blksize: ::blksize_t, - pub st_flags: ::fflags_t, - pub st_gen: u32, - pub st_lspare: i32, - pub st_birthtime: ::time_t, - pub st_birthtime_nsec: ::c_long, - } -} +pub type register_t = i64; // should be pub(crate), but that requires Rust 1.18.0 cfg_if! { @@ -42,3 +18,4 @@ cfg_if! { } pub const MAP_32BIT: ::c_int = 0x00080000; +pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs index b7480aa78b..300b3dd45c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -1,8 +1,10 @@ pub type c_char = u8; pub type c_long = i32; pub type c_ulong = u32; +pub type wchar_t = u32; pub type time_t = i64; pub type suseconds_t = i32; +pub type register_t = i32; s! { pub struct stat { @@ -45,3 +47,4 @@ cfg_if! { } } pub const MAP_32BIT: ::c_int = 0x00080000; +pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs index f32128f775..f32128f775 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index 79a152fc85..b443da3118 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -217,8 +217,9 @@ extern "C" { } cfg_if! { - if #[cfg(target_arch = "x86_64")] { - mod x86_64; - pub use self::x86_64::*; + if #[cfg(any(target_arch = "x86_64", + target_arch = "aarch64"))] { + mod b64; + pub use self::b64::*; } } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/b64.rs index 80c6fa1684..80c6fa1684 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/b64.rs diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index 6bf7f957e6..e0dd712bbd 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -217,8 +217,9 @@ extern "C" { } cfg_if! { - if #[cfg(target_arch = "x86_64")] { - mod x86_64; - pub use self::x86_64::*; + if #[cfg(any(target_arch = "x86_64", + target_arch = "aarch64"))] { + mod b64; + pub use self::b64::*; } } diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index bd626754ec..35fe554a3a 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -322,10 +322,17 @@ pub const EXTATTR_NAMESPACE_EMPTY: ::c_int = 0; pub const EXTATTR_NAMESPACE_USER: ::c_int = 1; pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2; -pub const RAND_MAX: ::c_int = 0x7fff_fffd; -pub const PTHREAD_STACK_MIN: ::size_t = 2048; +cfg_if! { + if #[cfg(any(freebsd10, freebsd11, freebsd12))] { + pub const RAND_MAX: ::c_int = 0x7fff_fffd; + } else { + pub const RAND_MAX: ::c_int = 0x7fff_ffff; + } +} + +pub const PTHREAD_STACK_MIN: ::size_t = MINSIGSTKSZ; pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 4; -pub const SIGSTKSZ: ::size_t = 34816; +pub const SIGSTKSZ: ::size_t = MINSIGSTKSZ + 32768; pub const SF_NODISKIO: ::c_int = 0x00000001; pub const SF_MNOWAIT: ::c_int = 0x00000002; pub const SF_SYNC: ::c_int = 0x00000004; @@ -442,7 +449,13 @@ pub const CLOCK_SECOND: ::clockid_t = 13; pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 14; pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 15; +#[doc(hidden)] +#[deprecated( + since = "0.2.72", + note = "CTL_UNSPEC is deprecated. Use CTL_SYSCTL instead" +)] pub const CTL_UNSPEC: ::c_int = 0; +pub const CTL_SYSCTL: ::c_int = 0; pub const CTL_KERN: ::c_int = 1; pub const CTL_VM: ::c_int = 2; pub const CTL_VFS: ::c_int = 3; @@ -452,6 +465,13 @@ pub const CTL_HW: ::c_int = 6; pub const CTL_MACHDEP: ::c_int = 7; pub const CTL_USER: ::c_int = 8; pub const CTL_P1003_1B: ::c_int = 9; +pub const CTL_SYSCTL_DEBUG: ::c_int = 0; +pub const CTL_SYSCTL_NAME: ::c_int = 1; +pub const CTL_SYSCTL_NEXT: ::c_int = 2; +pub const CTL_SYSCTL_NAME2OID: ::c_int = 3; +pub const CTL_SYSCTL_OIDFMT: ::c_int = 4; +pub const CTL_SYSCTL_OIDDESCR: ::c_int = 5; +pub const CTL_SYSCTL_OIDLABEL: ::c_int = 6; pub const KERN_OSTYPE: ::c_int = 1; pub const KERN_OSRELEASE: ::c_int = 2; pub const KERN_OSREV: ::c_int = 3; @@ -769,8 +789,14 @@ pub const IPPROTO_BLT: ::c_int = 30; pub const IPPROTO_NSP: ::c_int = 31; /// Merit Internodal pub const IPPROTO_INP: ::c_int = 32; -/// Sequential Exchange +#[doc(hidden)] +#[deprecated( + since = "0.2.72", + note = "IPPROTO_SEP is deprecated. Use IPPROTO_DCCP instead" +)] pub const IPPROTO_SEP: ::c_int = 33; +/// Datagram Congestion Control Protocol +pub const IPPROTO_DCCP: ::c_int = 33; /// Third Party Connect pub const IPPROTO_3PC: ::c_int = 34; /// InterDomain Policy Routing diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index 5c0c6e7f32..7f5b975226 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -1,8 +1,10 @@ pub type c_char = u8; pub type c_long = i64; pub type c_ulong = u64; +pub type wchar_t = i32; pub type time_t = i64; pub type suseconds_t = i64; +pub type register_t = i64; s! { pub struct stat { @@ -42,3 +44,4 @@ cfg_if! { } pub const MAP_32BIT: ::c_int = 0x00080000; +pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index adec88cb54..c1181830f9 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -1,8 +1,10 @@ pub type c_char = i8; pub type c_long = i32; pub type c_ulong = u32; +pub type wchar_t = i32; pub type time_t = i32; pub type suseconds_t = i32; +pub type register_t = i32; s! { pub struct stat { @@ -41,3 +43,4 @@ cfg_if! { pub const _ALIGNBYTES: usize = 8 - 1; } } +pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs index 7ca870fd02..3a016a0519 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs @@ -1,7 +1,197 @@ +use {c_long, register_t}; + s_no_extra_traits! { #[allow(missing_debug_implementations)] #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4] } + + #[repr(align(16))] + pub struct mcontext_t { + pub mc_onstack: register_t, + pub mc_rdi: register_t, + pub mc_rsi: register_t, + pub mc_rdx: register_t, + pub mc_rcx: register_t, + pub mc_r8: register_t, + pub mc_r9: register_t, + pub mc_rax: register_t, + pub mc_rbx: register_t, + pub mc_rbp: register_t, + pub mc_r10: register_t, + pub mc_r11: register_t, + pub mc_r12: register_t, + pub mc_r13: register_t, + pub mc_r14: register_t, + pub mc_r15: register_t, + pub mc_trapno: u32, + pub mc_fs: u16, + pub mc_gs: u16, + pub mc_addr: register_t, + pub mc_flags: u32, + pub mc_es: u16, + pub mc_ds: u16, + pub mc_err: register_t, + pub mc_rip: register_t, + pub mc_cs: register_t, + pub mc_rflags: register_t, + pub mc_rsp: register_t, + pub mc_ss: register_t, + pub mc_len: c_long, + pub mc_fpformat: c_long, + pub mc_ownedfp: c_long, + pub mc_fpstate: [c_long; 64], + pub mc_fsbase: register_t, + pub mc_gsbase: register_t, + pub mc_xfpustate: register_t, + pub mc_xfpustate_len: register_t, + pub mc_spare: [c_long; 4], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for mcontext_t { + fn eq(&self, other: &mcontext_t) -> bool { + self.mc_onstack == other.mc_onstack && + self.mc_rdi == other.mc_rdi && + self.mc_rsi == other.mc_rsi && + self.mc_rdx == other.mc_rdx && + self.mc_rcx == other.mc_rcx && + self.mc_r8 == other.mc_r8 && + self.mc_r9 == other.mc_r9 && + self.mc_rax == other.mc_rax && + self.mc_rbx == other.mc_rbx && + self.mc_rbp == other.mc_rbp && + self.mc_r10 == other.mc_r10 && + self.mc_r11 == other.mc_r11 && + self.mc_r12 == other.mc_r12 && + self.mc_r13 == other.mc_r13 && + self.mc_r14 == other.mc_r14 && + self.mc_r15 == other.mc_r15 && + self.mc_trapno == other.mc_trapno && + self.mc_fs == other.mc_fs && + self.mc_gs == other.mc_gs && + self.mc_addr == other.mc_addr && + self.mc_flags == other.mc_flags && + self.mc_es == other.mc_es && + self.mc_ds == other.mc_ds && + self.mc_err == other.mc_err && + self.mc_rip == other.mc_rip && + self.mc_cs == other.mc_cs && + self.mc_rflags == other.mc_rflags && + self.mc_rsp == other.mc_rsp && + self.mc_ss == other.mc_ss && + self.mc_len == other.mc_len && + self.mc_fpformat == other.mc_fpformat && + self.mc_ownedfp == other.mc_ownedfp && + self.mc_fpstate.iter().zip(other.mc_fpstate.iter()) + .all(|(a, b)| a == b) && + self.mc_fsbase == other.mc_fsbase && + self.mc_gsbase == other.mc_gsbase && + self.mc_xfpustate == other.mc_xfpustate && + self.mc_xfpustate_len == other.mc_xfpustate_len && + self.mc_spare == other.mc_spare + } + } + impl Eq for mcontext_t {} + impl ::fmt::Debug for mcontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mcontext_t") + .field("mc_onstack", &self.mc_onstack) + .field("mc_rdi", &self.mc_rdi) + .field("mc_rsi", &self.mc_rsi) + .field("mc_rdx", &self.mc_rdx) + .field("mc_rcx", &self.mc_rcx) + .field("mc_r8", &self.mc_r8) + .field("mc_r9", &self.mc_r9) + .field("mc_rax", &self.mc_rax) + .field("mc_rbx", &self.mc_rbx) + .field("mc_rbp", &self.mc_rbp) + .field("mc_r10", &self.mc_r10) + .field("mc_r11", &self.mc_r11) + .field("mc_r12", &self.mc_r12) + .field("mc_r13", &self.mc_r13) + .field("mc_r14", &self.mc_r14) + .field("mc_r15", &self.mc_r15) + .field("mc_trapno", &self.mc_trapno) + .field("mc_fs", &self.mc_fs) + .field("mc_gs", &self.mc_gs) + .field("mc_addr", &self.mc_addr) + .field("mc_flags", &self.mc_flags) + .field("mc_es", &self.mc_es) + .field("mc_ds", &self.mc_ds) + .field("mc_err", &self.mc_err) + .field("mc_rip", &self.mc_rip) + .field("mc_cs", &self.mc_cs) + .field("mc_rflags", &self.mc_rflags) + .field("mc_rsp", &self.mc_rsp) + .field("mc_ss", &self.mc_ss) + .field("mc_len", &self.mc_len) + .field("mc_fpformat", &self.mc_fpformat) + .field("mc_ownedfp", &self.mc_ownedfp) + // FIXME: .field("mc_fpstate", &self.mc_fpstate) + .field("mc_fsbase", &self.mc_fsbase) + .field("mc_gsbase", &self.mc_gsbase) + .field("mc_xfpustate", &self.mc_xfpustate) + .field("mc_xfpustate_len", &self.mc_xfpustate_len) + .field("mc_spare", &self.mc_spare) + .finish() + } + } + impl ::hash::Hash for mcontext_t { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + self.mc_onstack.hash(state); + self.mc_rdi.hash(state); + self.mc_rsi.hash(state); + self.mc_rdx.hash(state); + self.mc_rcx.hash(state); + self.mc_r8.hash(state); + self.mc_r9.hash(state); + self.mc_rax.hash(state); + self.mc_rbx.hash(state); + self.mc_rbp.hash(state); + self.mc_r10.hash(state); + self.mc_r11.hash(state); + self.mc_r12.hash(state); + self.mc_r13.hash(state); + self.mc_r14.hash(state); + self.mc_r15.hash(state); + self.mc_trapno.hash(state); + self.mc_fs.hash(state); + self.mc_gs.hash(state); + self.mc_addr.hash(state); + self.mc_flags.hash(state); + self.mc_es.hash(state); + self.mc_ds.hash(state); + self.mc_err.hash(state); + self.mc_rip.hash(state); + self.mc_cs.hash(state); + self.mc_rflags.hash(state); + self.mc_rsp.hash(state); + self.mc_ss.hash(state); + self.mc_len.hash(state); + self.mc_fpformat.hash(state); + self.mc_ownedfp.hash(state); + self.mc_fpstate.hash(state); + self.mc_fsbase.hash(state); + self.mc_gsbase.hash(state); + self.mc_xfpustate.hash(state); + self.mc_xfpustate_len.hash(state); + self.mc_spare.hash(state); + } + } + } +} + +s! { + pub struct ucontext_t { + pub uc_sigmask: ::sigset_t, + pub uc_mcontext: ::mcontext_t, + pub uc_link: *mut ::ucontext_t, + pub uc_stack: ::stack_t, + pub uc_flags: ::c_int, + __spare__: [::c_int; 4], + } } diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index ff8f9a9d3e..d3333c8b11 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -1,8 +1,10 @@ pub type c_char = i8; pub type c_long = i64; pub type c_ulong = u64; +pub type wchar_t = i32; pub type time_t = i64; pub type suseconds_t = i64; +pub type register_t = i64; s! { pub struct reg32 { @@ -185,6 +187,18 @@ cfg_if! { } } pub const MAP_32BIT: ::c_int = 0x00080000; +pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 + +pub const _MC_HASSEGS: u32 = 0x1; +pub const _MC_HASBASES: u32 = 0x2; +pub const _MC_HASFPXSTATE: u32 = 0x4; +pub const _MC_FLAG_MASK: u32 = _MC_HASSEGS | _MC_HASBASES | _MC_HASFPXSTATE; + +pub const _MC_FPFMT_NODEV: c_long = 0x10000; +pub const _MC_FPFMT_XMM: c_long = 0x10002; +pub const _MC_FPOWNED_NONE: c_long = 0x20000; +pub const _MC_FPOWNED_FPU: c_long = 0x20001; +pub const _MC_FPOWNED_PCB: c_long = 0x20002; cfg_if! { if #[cfg(libc_align)] { diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index caf9e5432b..3158ed0e56 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1215,17 +1215,6 @@ extern "C" { addrlen: *mut ::socklen_t, flags: ::c_int, ) -> ::c_int; - pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int; - pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int; - pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int; - pub fn aio_error(aiocbp: *const aiocb) -> ::c_int; - pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t; - pub fn aio_suspend( - aiocb_list: *const *const aiocb, - nitems: ::c_int, - timeout: *const ::timespec, - ) -> ::c_int; - pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int; pub fn chflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int; pub fn chflagsat( fd: ::c_int, @@ -1311,43 +1300,6 @@ extern "C" { mode: ::mode_t, dev: dev_t, ) -> ::c_int; - pub fn mq_close(mqd: ::mqd_t) -> ::c_int; - pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; - pub fn mq_notify(mqd: ::mqd_t, notification: *const ::sigevent) - -> ::c_int; - pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; - pub fn mq_receive( - mqd: ::mqd_t, - msg_ptr: *mut ::c_char, - msg_len: ::size_t, - msg_prio: *mut ::c_uint, - ) -> ::ssize_t; - pub fn mq_send( - mqd: ::mqd_t, - msg_ptr: *const ::c_char, - msg_len: ::size_t, - msg_prio: ::c_uint, - ) -> ::c_int; - pub fn mq_setattr( - mqd: ::mqd_t, - newattr: *const ::mq_attr, - oldattr: *mut ::mq_attr, - ) -> ::c_int; - pub fn mq_timedreceive( - mqd: ::mqd_t, - msg_ptr: *mut ::c_char, - msg_len: ::size_t, - msg_prio: *mut ::c_uint, - abs_timeout: *const ::timespec, - ) -> ::ssize_t; - pub fn mq_timedsend( - mqd: ::mqd_t, - msg_ptr: *const ::c_char, - msg_len: ::size_t, - msg_prio: ::c_uint, - abs_timeout: *const ::timespec, - ) -> ::c_int; - pub fn mq_unlink(name: *const ::c_char) -> ::c_int; pub fn mincore( addr: *const ::c_void, len: ::size_t, @@ -1517,6 +1469,58 @@ extern "C" { pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int; } +#[link(name = "rt")] +extern "C" { + pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int; + pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int; + pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int; + pub fn aio_error(aiocbp: *const aiocb) -> ::c_int; + pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t; + pub fn aio_suspend( + aiocb_list: *const *const aiocb, + nitems: ::c_int, + timeout: *const ::timespec, + ) -> ::c_int; + pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int; + pub fn mq_close(mqd: ::mqd_t) -> ::c_int; + pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; + pub fn mq_notify(mqd: ::mqd_t, notification: *const ::sigevent) + -> ::c_int; + pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; + pub fn mq_receive( + mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msg_prio: *mut ::c_uint, + ) -> ::ssize_t; + pub fn mq_send( + mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msg_prio: ::c_uint, + ) -> ::c_int; + pub fn mq_setattr( + mqd: ::mqd_t, + newattr: *const ::mq_attr, + oldattr: *mut ::mq_attr, + ) -> ::c_int; + pub fn mq_timedreceive( + mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msg_prio: *mut ::c_uint, + abs_timeout: *const ::timespec, + ) -> ::ssize_t; + pub fn mq_timedsend( + mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msg_prio: ::c_uint, + abs_timeout: *const ::timespec, + ) -> ::c_int; + pub fn mq_unlink(name: *const ::c_char) -> ::c_int; +} + #[link(name = "util")] extern "C" { pub fn openpty( diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index a70c1d92be..1b55078d5a 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -1,4 +1,3 @@ -pub type wchar_t = i32; pub type off_t = i64; pub type useconds_t = u32; pub type blkcnt_t = i64; @@ -581,7 +580,15 @@ extern "C" { pub fn abs(i: ::c_int) -> ::c_int; pub fn atof(s: *const ::c_char) -> ::c_double; pub fn labs(i: ::c_long) -> ::c_long; + #[cfg_attr( + all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)), + link_name = "rand@FBSD_1.0" + )] pub fn rand() -> ::c_int; + #[cfg_attr( + all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)), + link_name = "srand@FBSD_1.0" + )] pub fn srand(seed: ::c_uint); pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 976b95c200..a2a8407770 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -1,3 +1,4 @@ +pub type wchar_t = i32; pub type time_t = i64; pub type mode_t = u32; pub type nlink_t = u32; |