aboutsummaryrefslogtreecommitdiff
path: root/libc/src/unix/notbsd
diff options
context:
space:
mode:
Diffstat (limited to 'libc/src/unix/notbsd')
-rw-r--r--libc/src/unix/notbsd/android/b32/mod.rs2
-rw-r--r--libc/src/unix/notbsd/android/b64/mod.rs145
-rw-r--r--libc/src/unix/notbsd/android/mod.rs516
-rw-r--r--libc/src/unix/notbsd/emscripten/align.rs66
-rw-r--r--libc/src/unix/notbsd/emscripten/mod.rs (renamed from libc/src/unix/notbsd/emscripten.rs)305
-rw-r--r--libc/src/unix/notbsd/emscripten/no_align.rs63
-rw-r--r--libc/src/unix/notbsd/linux/align.rs98
-rw-r--r--libc/src/unix/notbsd/linux/mips/align.rs13
-rw-r--r--libc/src/unix/notbsd/linux/mips/mips32.rs10
-rw-r--r--libc/src/unix/notbsd/linux/mips/mips64.rs4
-rw-r--r--libc/src/unix/notbsd/linux/mips/mod.rs36
-rw-r--r--libc/src/unix/notbsd/linux/mips/no_align.rs10
-rw-r--r--libc/src/unix/notbsd/linux/mod.rs566
-rw-r--r--libc/src/unix/notbsd/linux/musl/b32/mips.rs8
-rw-r--r--libc/src/unix/notbsd/linux/musl/b32/x86.rs65
-rw-r--r--libc/src/unix/notbsd/linux/musl/b64/x86_64.rs65
-rw-r--r--libc/src/unix/notbsd/linux/musl/mod.rs73
-rw-r--r--libc/src/unix/notbsd/linux/no_align.rs80
-rw-r--r--libc/src/unix/notbsd/linux/other/align.rs13
-rw-r--r--libc/src/unix/notbsd/linux/other/b32/arm.rs3
-rw-r--r--libc/src/unix/notbsd/linux/other/b32/x86.rs152
-rw-r--r--libc/src/unix/notbsd/linux/other/b64/aarch64.rs2
-rw-r--r--libc/src/unix/notbsd/linux/other/b64/sparc64.rs2
-rw-r--r--libc/src/unix/notbsd/linux/other/b64/x86_64.rs144
-rw-r--r--libc/src/unix/notbsd/linux/other/mod.rs204
-rw-r--r--libc/src/unix/notbsd/linux/other/no_align.rs10
-rw-r--r--libc/src/unix/notbsd/linux/s390x/align.rs10
-rw-r--r--libc/src/unix/notbsd/linux/s390x/mod.rs (renamed from libc/src/unix/notbsd/linux/s390x.rs)72
-rw-r--r--libc/src/unix/notbsd/linux/s390x/no_align.rs7
-rw-r--r--libc/src/unix/notbsd/mod.rs288
30 files changed, 2413 insertions, 619 deletions
diff --git a/libc/src/unix/notbsd/android/b32/mod.rs b/libc/src/unix/notbsd/android/b32/mod.rs
index 394abe8..a8cc51b 100644
--- a/libc/src/unix/notbsd/android/b32/mod.rs
+++ b/libc/src/unix/notbsd/android/b32/mod.rs
@@ -14,7 +14,7 @@ s! {
pub sa_sigaction: ::sighandler_t,
pub sa_mask: ::sigset_t,
pub sa_flags: ::c_ulong,
- pub sa_restorer: ::dox::Option<extern fn()>,
+ pub sa_restorer: ::Option<extern fn()>,
}
pub struct rlimit64 {
diff --git a/libc/src/unix/notbsd/android/b64/mod.rs b/libc/src/unix/notbsd/android/b64/mod.rs
index fb94334..46becc5 100644
--- a/libc/src/unix/notbsd/android/b64/mod.rs
+++ b/libc/src/unix/notbsd/android/b64/mod.rs
@@ -16,7 +16,7 @@ s! {
pub sa_flags: ::c_uint,
pub sa_sigaction: ::sighandler_t,
pub sa_mask: ::sigset_t,
- pub sa_restorer: ::dox::Option<extern fn()>,
+ pub sa_restorer: ::Option<extern fn()>,
}
pub struct rlimit64 {
@@ -34,25 +34,6 @@ s! {
__reserved: [::c_char; 16],
}
- pub struct pthread_mutex_t {
- value: ::c_int,
- __reserved: [::c_char; 36],
- }
-
- pub struct pthread_cond_t {
- value: ::c_int,
- __reserved: [::c_char; 44],
- }
-
- pub struct pthread_rwlock_t {
- numLocks: ::c_int,
- writerThreadId: ::c_int,
- pendingReaders: ::c_int,
- pendingWriters: ::c_int,
- attr: i32,
- __reserved: [::c_char; 36],
- }
-
pub struct passwd {
pub pw_name: *mut ::c_char,
pub pw_passwd: *mut ::c_char,
@@ -126,6 +107,130 @@ s! {
}
}
+s_no_extra_traits!{
+ pub struct pthread_mutex_t {
+ value: ::c_int,
+ __reserved: [::c_char; 36],
+ }
+
+ pub struct pthread_cond_t {
+ value: ::c_int,
+ __reserved: [::c_char; 44],
+ }
+
+ pub struct pthread_rwlock_t {
+ numLocks: ::c_int,
+ writerThreadId: ::c_int,
+ pendingReaders: ::c_int,
+ pendingWriters: ::c_int,
+ attr: i32,
+ __reserved: [::c_char; 36],
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for pthread_mutex_t {
+ fn eq(&self, other: &pthread_mutex_t) -> bool {
+ self.value == other.value
+ && self
+ .__reserved
+ .iter()
+ .zip(other.__reserved.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+
+ impl Eq for pthread_mutex_t {}
+
+ impl ::fmt::Debug for pthread_mutex_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("pthread_mutex_t")
+ .field("value", &self.value)
+ // FIXME: .field("__reserved", &self.__reserved)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for pthread_mutex_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.value.hash(state);
+ self.__reserved.hash(state);
+ }
+ }
+
+ impl PartialEq for pthread_cond_t {
+ fn eq(&self, other: &pthread_cond_t) -> bool {
+ self.value == other.value
+ && self
+ .__reserved
+ .iter()
+ .zip(other.__reserved.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+
+ impl Eq for pthread_cond_t {}
+
+ impl ::fmt::Debug for pthread_cond_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("pthread_cond_t")
+ .field("value", &self.value)
+ // FIXME: .field("__reserved", &self.__reserved)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for pthread_cond_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.value.hash(state);
+ self.__reserved.hash(state);
+ }
+ }
+
+ impl PartialEq for pthread_rwlock_t {
+ fn eq(&self, other: &pthread_rwlock_t) -> bool {
+ self.numLocks == other.numLocks
+ && self.writerThreadId == other.writerThreadId
+ && self.pendingReaders == other.pendingReaders
+ && self.pendingWriters == other.pendingWriters
+ && self.attr == other.attr
+ && self
+ .__reserved
+ .iter()
+ .zip(other.__reserved.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+
+ impl Eq for pthread_rwlock_t {}
+
+ impl ::fmt::Debug for pthread_rwlock_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("pthread_rwlock_t")
+ .field("numLocks", &self.numLocks)
+ .field("writerThreadId", &self.writerThreadId)
+ .field("pendingReaders", &self.pendingReaders)
+ .field("pendingWriters", &self.pendingWriters)
+ .field("attr", &self.attr)
+ // FIXME: .field("__reserved", &self.__reserved)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for pthread_rwlock_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.numLocks.hash(state);
+ self.writerThreadId.hash(state);
+ self.pendingReaders.hash(state);
+ self.pendingWriters.hash(state);
+ self.attr.hash(state);
+ self.__reserved.hash(state);
+ }
+ }
+ }
+}
+
pub const RTLD_GLOBAL: ::c_int = 0x00100;
pub const RTLD_NOW: ::c_int = 2;
pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
diff --git a/libc/src/unix/notbsd/android/mod.rs b/libc/src/unix/notbsd/android/mod.rs
index 972281c..a430b1a 100644
--- a/libc/src/unix/notbsd/android/mod.rs
+++ b/libc/src/unix/notbsd/android/mod.rs
@@ -1,7 +1,5 @@
//! Android-specific definitions for linux-like values
-use dox::{mem, Option};
-
pub type clock_t = ::c_long;
pub type time_t = ::c_long;
pub type suseconds_t = ::c_long;
@@ -25,36 +23,12 @@ pub type idtype_t = ::c_int;
pub type loff_t = ::c_longlong;
s! {
- pub struct dirent {
- pub d_ino: u64,
- pub d_off: i64,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
- pub struct dirent64 {
- pub d_ino: u64,
- pub d_off: i64,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
pub struct stack_t {
pub ss_sp: *mut ::c_void,
pub ss_flags: ::c_int,
pub ss_size: ::size_t
}
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_errno: ::c_int,
- pub si_code: ::c_int,
- pub _pad: [::c_int; 29],
- _align: [usize; 0],
- }
-
pub struct __fsid_t {
__val: [::c_int; 2],
}
@@ -116,33 +90,11 @@ s! {
__reserved: [::c_int; 3],
}
- pub struct lastlog {
- ll_time: ::time_t,
- ll_line: [::c_char; UT_LINESIZE],
- ll_host: [::c_char; UT_HOSTSIZE],
- }
-
pub struct exit_status {
pub e_termination: ::c_short,
pub e_exit: ::c_short,
}
- pub struct utmp {
- pub ut_type: ::c_short,
- pub ut_pid: ::pid_t,
- pub ut_line: [::c_char; UT_LINESIZE],
- pub ut_id: [::c_char; 4],
-
- pub ut_user: [::c_char; UT_NAMESIZE],
- pub ut_host: [::c_char; UT_HOSTSIZE],
- pub ut_exit: exit_status,
- pub ut_session: ::c_long,
- pub ut_tv: ::timeval,
-
- pub ut_addr_v6: [::int32_t; 4],
- unused: [::c_char; 20],
- }
-
pub struct statvfs {
pub f_bsize: ::c_ulong,
pub f_frsize: ::c_ulong,
@@ -238,6 +190,361 @@ s! {
pub ipi6_addr: ::in6_addr,
pub ipi6_ifindex: ::c_int,
}
+
+ pub struct inotify_event {
+ pub wd: ::c_int,
+ pub mask: ::uint32_t,
+ pub cookie: ::uint32_t,
+ pub len: ::uint32_t
+ }
+}
+
+s_no_extra_traits!{
+ pub struct dirent {
+ pub d_ino: u64,
+ pub d_off: i64,
+ pub d_reclen: ::c_ushort,
+ pub d_type: ::c_uchar,
+ pub d_name: [::c_char; 256],
+ }
+
+ pub struct dirent64 {
+ pub d_ino: u64,
+ pub d_off: i64,
+ pub d_reclen: ::c_ushort,
+ pub d_type: ::c_uchar,
+ pub d_name: [::c_char; 256],
+ }
+
+ pub struct siginfo_t {
+ pub si_signo: ::c_int,
+ pub si_errno: ::c_int,
+ pub si_code: ::c_int,
+ pub _pad: [::c_int; 29],
+ _align: [usize; 0],
+ }
+
+ pub struct lastlog {
+ ll_time: ::time_t,
+ ll_line: [::c_char; UT_LINESIZE],
+ ll_host: [::c_char; UT_HOSTSIZE],
+ }
+
+ pub struct utmp {
+ pub ut_type: ::c_short,
+ pub ut_pid: ::pid_t,
+ pub ut_line: [::c_char; UT_LINESIZE],
+ pub ut_id: [::c_char; 4],
+ pub ut_user: [::c_char; UT_NAMESIZE],
+ pub ut_host: [::c_char; UT_HOSTSIZE],
+ pub ut_exit: exit_status,
+ pub ut_session: ::c_long,
+ pub ut_tv: ::timeval,
+ pub ut_addr_v6: [::int32_t; 4],
+ unused: [::c_char; 20],
+ }
+
+ pub struct sockaddr_alg {
+ pub salg_family: ::sa_family_t,
+ pub salg_type: [::c_uchar; 14],
+ pub salg_feat: u32,
+ pub salg_mask: u32,
+ pub salg_name: [::c_uchar; 64],
+ }
+
+ pub struct af_alg_iv {
+ pub ivlen: u32,
+ pub iv: [::c_uchar; 0],
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for dirent {
+ fn eq(&self, other: &dirent) -> bool {
+ self.d_ino == other.d_ino
+ && self.d_off == other.d_off
+ && self.d_reclen == other.d_reclen
+ && self.d_type == other.d_type
+ && self
+ .d_name
+ .iter()
+ .zip(other.d_name.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+
+ impl Eq for dirent {}
+
+ impl ::fmt::Debug for dirent {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("dirent")
+ .field("d_ino", &self.d_ino)
+ .field("d_off", &self.d_off)
+ .field("d_reclen", &self.d_reclen)
+ .field("d_type", &self.d_type)
+ // FIXME: .field("d_name", &self.d_name)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for dirent {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.d_ino.hash(state);
+ self.d_off.hash(state);
+ self.d_reclen.hash(state);
+ self.d_type.hash(state);
+ self.d_name.hash(state);
+ }
+ }
+
+ impl PartialEq for dirent64 {
+ fn eq(&self, other: &dirent64) -> bool {
+ self.d_ino == other.d_ino
+ && self.d_off == other.d_off
+ && self.d_reclen == other.d_reclen
+ && self.d_type == other.d_type
+ && self
+ .d_name
+ .iter()
+ .zip(other.d_name.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+
+ impl Eq for dirent64 {}
+
+ impl ::fmt::Debug for dirent64 {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("dirent64")
+ .field("d_ino", &self.d_ino)
+ .field("d_off", &self.d_off)
+ .field("d_reclen", &self.d_reclen)
+ .field("d_type", &self.d_type)
+ // FIXME: .field("d_name", &self.d_name)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for dirent64 {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.d_ino.hash(state);
+ self.d_off.hash(state);
+ self.d_reclen.hash(state);
+ self.d_type.hash(state);
+ self.d_name.hash(state);
+ }
+ }
+
+ impl PartialEq for siginfo_t {
+ fn eq(&self, other: &siginfo_t) -> bool {
+ self.si_signo == other.si_signo
+ && self.si_errno == other.si_errno
+ && self.si_code == other.si_code
+ // Ignore _pad
+ // Ignore _align
+ }
+ }
+
+ impl Eq for siginfo_t {}
+
+ impl ::fmt::Debug for siginfo_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("siginfo_t")
+ .field("si_signo", &self.si_signo)
+ .field("si_errno", &self.si_errno)
+ .field("si_code", &self.si_code)
+ // Ignore _pad
+ // Ignore _align
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for siginfo_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.si_signo.hash(state);
+ self.si_errno.hash(state);
+ self.si_code.hash(state);
+ // Ignore _pad
+ // Ignore _align
+ }
+ }
+
+ impl PartialEq for lastlog {
+ fn eq(&self, other: &lastlog) -> bool {
+ self.ll_time == other.ll_time
+ && self
+ .ll_line
+ .iter()
+ .zip(other.ll_line.iter())
+ .all(|(a,b)| a == b)
+ && self
+ .ll_host
+ .iter()
+ .zip(other.ll_host.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+
+ impl Eq for lastlog {}
+
+ impl ::fmt::Debug for lastlog {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("lastlog")
+ .field("ll_time", &self.ll_time)
+ .field("ll_line", &self.ll_line)
+ // FIXME: .field("ll_host", &self.ll_host)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for lastlog {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.ll_time.hash(state);
+ self.ll_line.hash(state);
+ self.ll_host.hash(state);
+ }
+ }
+
+ impl PartialEq for utmp {
+ fn eq(&self, other: &utmp) -> bool {
+ self.ut_type == other.ut_type
+ && self.ut_pid == other.ut_pid
+ && self
+ .ut_line
+ .iter()
+ .zip(other.ut_line.iter())
+ .all(|(a,b)| a == b)
+ && self.ut_id == other.ut_id
+ && self
+ .ut_user
+ .iter()
+ .zip(other.ut_user.iter())
+ .all(|(a,b)| a == b)
+ && self
+ .ut_host
+ .iter()
+ .zip(other.ut_host.iter())
+ .all(|(a,b)| a == b)
+ && self.ut_exit == other.ut_exit
+ && self.ut_session == other.ut_session
+ && self.ut_tv == other.ut_tv
+ && self.ut_addr_v6 == other.ut_addr_v6
+ && self.unused == other.unused
+ }
+ }
+
+ impl Eq for utmp {}
+
+ impl ::fmt::Debug for utmp {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("utmp")
+ .field("ut_type", &self.ut_type)
+ .field("ut_pid", &self.ut_pid)
+ .field("ut_line", &self.ut_line)
+ .field("ut_id", &self.ut_id)
+ .field("ut_user", &self.ut_user)
+ // FIXME: .field("ut_host", &self.ut_host)
+ .field("ut_exit", &self.ut_exit)
+ .field("ut_session", &self.ut_session)
+ .field("ut_tv", &self.ut_tv)
+ .field("ut_addr_v6", &self.ut_addr_v6)
+ .field("unused", &self.unused)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for utmp {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.ut_type.hash(state);
+ self.ut_pid.hash(state);
+ self.ut_line.hash(state);
+ self.ut_id.hash(state);
+ self.ut_user.hash(state);
+ self.ut_host.hash(state);
+ self.ut_exit.hash(state);
+ self.ut_session.hash(state);
+ self.ut_tv.hash(state);
+ self.ut_addr_v6.hash(state);
+ self.unused.hash(state);
+ }
+ }
+
+ impl PartialEq for sockaddr_alg {
+ fn eq(&self, other: &sockaddr_alg) -> bool {
+ self.salg_family == other.salg_family
+ && self
+ .salg_type
+ .iter()
+ .zip(other.salg_type.iter())
+ .all(|(a, b)| a == b)
+ && self.salg_feat == other.salg_feat
+ && self.salg_mask == other.salg_mask
+ && self
+ .salg_name
+ .iter()
+ .zip(other.salg_name.iter())
+ .all(|(a, b)| a == b)
+ }
+ }
+
+ impl Eq for sockaddr_alg {}
+
+ impl ::fmt::Debug for sockaddr_alg {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("sockaddr_alg")
+ .field("salg_family", &self.salg_family)
+ .field("salg_type", &self.salg_type)
+ .field("salg_feat", &self.salg_feat)
+ .field("salg_mask", &self.salg_mask)
+ .field("salg_name", &&self.salg_name[..])
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for sockaddr_alg {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.salg_family.hash(state);
+ self.salg_type.hash(state);
+ self.salg_feat.hash(state);
+ self.salg_mask.hash(state);
+ self.salg_name.hash(state);
+ }
+ }
+
+ impl af_alg_iv {
+ fn as_slice(&self) -> &[u8] {
+ unsafe {
+ ::core::slice::from_raw_parts(
+ self.iv.as_ptr(),
+ self.ivlen as usize
+ )
+ }
+ }
+ }
+
+ impl PartialEq for af_alg_iv {
+ fn eq(&self, other: &af_alg_iv) -> bool {
+ *self.as_slice() == *other.as_slice()
+ }
+ }
+
+ impl Eq for af_alg_iv {}
+
+ impl ::fmt::Debug for af_alg_iv {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("af_alg_iv")
+ .field("iv", &self.as_slice())
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for af_alg_iv {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.as_slice().hash(state);
+ }
+ }
+ }
}
pub const O_TRUNC: ::c_int = 512;
@@ -1052,6 +1359,15 @@ pub const SFD_NONBLOCK: ::c_int = O_NONBLOCK;
pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK;
pub const SO_ORIGINAL_DST: ::c_int = 80;
+pub const IP_ORIGDSTADDR : ::c_int = 20;
+pub const IP_RECVORIGDSTADDR : ::c_int = IP_ORIGDSTADDR;
+pub const IPV6_ORIGDSTADDR : ::c_int = 74;
+pub const IPV6_RECVORIGDSTADDR : ::c_int = IPV6_ORIGDSTADDR;
+pub const IPV6_FLOWINFO: ::c_int = 11;
+pub const IPV6_FLOWLABEL_MGR: ::c_int = 32;
+pub const IPV6_FLOWINFO_SEND: ::c_int = 33;
+pub const IPV6_FLOWINFO_FLOWLABEL: ::c_int = 0x000fffff;
+pub const IPV6_FLOWINFO_PRIORITY: ::c_int = 0x0ff00000;
pub const IUTF8: ::tcflag_t = 0x00004000;
pub const CMSPAR: ::tcflag_t = 0o10000000000;
pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
@@ -1476,7 +1792,87 @@ pub const MODULE_INIT_IGNORE_VERMAGIC: ::c_uint = 0x0002;
// Similarity to Linux it's not used but defined for compatibility.
pub const ENOATTR: ::c_int = ::ENODATA;
+// linux/if_alg.h
+pub const ALG_SET_KEY: ::c_int = 1;
+pub const ALG_SET_IV: ::c_int = 2;
+pub const ALG_SET_OP: ::c_int = 3;
+pub const ALG_SET_AEAD_ASSOCLEN: ::c_int = 4;
+pub const ALG_SET_AEAD_AUTHSIZE: ::c_int = 5;
+
+pub const ALG_OP_DECRYPT: ::c_int = 0;
+pub const ALG_OP_ENCRYPT: ::c_int = 1;
+
+// uapi/linux/inotify.h
+pub const IN_ACCESS: ::uint32_t = 0x0000_0001;
+pub const IN_MODIFY: ::uint32_t = 0x0000_0002;
+pub const IN_ATTRIB: ::uint32_t = 0x0000_0004;
+pub const IN_CLOSE_WRITE: ::uint32_t = 0x0000_0008;
+pub const IN_CLOSE_NOWRITE: ::uint32_t = 0x0000_0010;
+pub const IN_CLOSE: ::uint32_t = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE);
+pub const IN_OPEN: ::uint32_t = 0x0000_0020;
+pub const IN_MOVED_FROM: ::uint32_t = 0x0000_0040;
+pub const IN_MOVED_TO: ::uint32_t = 0x0000_0080;
+pub const IN_MOVE: ::uint32_t = (IN_MOVED_FROM | IN_MOVED_TO);
+pub const IN_CREATE: ::uint32_t = 0x0000_0100;
+pub const IN_DELETE: ::uint32_t = 0x0000_0200;
+pub const IN_DELETE_SELF: ::uint32_t = 0x0000_0400;
+pub const IN_MOVE_SELF: ::uint32_t = 0x0000_0800;
+pub const IN_UNMOUNT: ::uint32_t = 0x0000_2000;
+pub const IN_Q_OVERFLOW: ::uint32_t = 0x0000_4000;
+pub const IN_IGNORED: ::uint32_t = 0x0000_8000;
+pub const IN_ONLYDIR: ::uint32_t = 0x0100_0000;
+pub const IN_DONT_FOLLOW: ::uint32_t = 0x0200_0000;
+// pub const IN_EXCL_UNLINK: ::uint32_t = 0x0400_0000;
+
+// pub const IN_MASK_CREATE: ::uint32_t = 0x1000_0000;
+// pub const IN_MASK_ADD: ::uint32_t = 0x2000_0000;
+pub const IN_ISDIR: ::uint32_t = 0x4000_0000;
+pub const IN_ONESHOT: ::uint32_t = 0x8000_0000;
+
+pub const IN_ALL_EVENTS: ::uint32_t = (
+ IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE |
+ IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM |
+ IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF |
+ IN_MOVE_SELF
+);
+
+pub const IN_CLOEXEC: ::c_int = O_CLOEXEC;
+pub const IN_NONBLOCK: ::c_int = O_NONBLOCK;
+
+pub const FUTEX_WAIT: ::c_int = 0;
+pub const FUTEX_WAKE: ::c_int = 1;
+pub const FUTEX_FD: ::c_int = 2;
+pub const FUTEX_REQUEUE: ::c_int = 3;
+pub const FUTEX_CMP_REQUEUE: ::c_int = 4;
+pub const FUTEX_WAKE_OP: ::c_int = 5;
+pub const FUTEX_LOCK_PI: ::c_int = 6;
+pub const FUTEX_UNLOCK_PI: ::c_int = 7;
+pub const FUTEX_TRYLOCK_PI: ::c_int = 8;
+pub const FUTEX_WAIT_BITSET: ::c_int = 9;
+pub const FUTEX_WAKE_BITSET: ::c_int = 10;
+pub const FUTEX_WAIT_REQUEUE_PI: ::c_int = 11;
+pub const FUTEX_CMP_REQUEUE_PI: ::c_int = 12;
+
+pub const FUTEX_PRIVATE_FLAG: ::c_int = 128;
+pub const FUTEX_CLOCK_REALTIME: ::c_int = 256;
+pub const FUTEX_CMD_MASK: ::c_int =
+ !(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME);
+
f! {
+ pub fn CMSG_NXTHDR(mhdr: *const msghdr,
+ cmsg: *const cmsghdr) -> *mut cmsghdr {
+ let next = (cmsg as usize
+ + super::CMSG_ALIGN((*cmsg).cmsg_len as usize))
+ as *mut cmsghdr;
+ let max = (*mhdr).msg_control as usize
+ + (*mhdr).msg_controllen as usize;
+ if (next.offset(1)) as usize > max {
+ 0 as *mut cmsghdr
+ } else {
+ next as *mut cmsghdr
+ }
+ }
+
pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
for slot in cpuset.__bits.iter_mut() {
*slot = 0;
@@ -1484,21 +1880,21 @@ f! {
}
pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in___bits = 8 * mem::size_of_val(&cpuset.__bits[0]);
+ let size_in___bits = 8 * ::mem::size_of_val(&cpuset.__bits[0]);
let (idx, offset) = (cpu / size_in___bits, cpu % size_in___bits);
cpuset.__bits[idx] |= 1 << offset;
()
}
pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in___bits = 8 * mem::size_of_val(&cpuset.__bits[0]);
+ let size_in___bits = 8 * ::mem::size_of_val(&cpuset.__bits[0]);
let (idx, offset) = (cpu / size_in___bits, cpu % size_in___bits);
cpuset.__bits[idx] &= !(1 << offset);
()
}
pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
- let size_in___bits = 8 * mem::size_of_val(&cpuset.__bits[0]);
+ let size_in___bits = 8 * ::mem::size_of_val(&cpuset.__bits[0]);
let (idx, offset) = (cpu / size_in___bits, cpu % size_in___bits);
0 != (cpuset.__bits[idx] & (1 << offset))
}
@@ -1654,7 +2050,7 @@ extern {
pub fn setfsuid(uid: ::uid_t) -> ::c_int;
pub fn sigsuspend(mask: *const ::sigset_t) -> ::c_int;
#[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")]
- pub fn getgrgid_r(uid: ::uid_t,
+ pub fn getgrgid_r(gid: ::gid_t,
grp: *mut ::group,
buf: *mut ::c_char,
buflen: ::size_t,
@@ -1700,9 +2096,9 @@ extern {
#[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
pub fn sigwait(set: *const sigset_t,
sig: *mut ::c_int) -> ::c_int;
- pub fn pthread_atfork(prepare: Option<unsafe extern fn()>,
- parent: Option<unsafe extern fn()>,
- child: Option<unsafe extern fn()>) -> ::c_int;
+ pub fn pthread_atfork(prepare: ::Option<unsafe extern fn()>,
+ parent: ::Option<unsafe extern fn()>,
+ child: ::Option<unsafe extern fn()>) -> ::c_int;
pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
pub fn getgrouplist(user: *const ::c_char,
group: ::gid_t,
@@ -1722,6 +2118,16 @@ extern {
f: extern fn(*mut ::c_void) -> *mut ::c_void,
value: *mut ::c_void) -> ::c_int;
pub fn __errno() -> *mut ::c_int;
+ pub fn inotify_rm_watch(fd: ::c_int, wd: ::uint32_t) -> ::c_int;
+ pub fn sendmmsg(sockfd: ::c_int, msgvec: *const ::mmsghdr, vlen: ::c_uint,
+ flags: ::c_int) -> ::c_int;
+ pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
+ flags: ::c_int, timeout: *const ::timespec) -> ::c_int;
+ pub fn inotify_init() -> ::c_int;
+ pub fn inotify_init1(flags: ::c_int) -> ::c_int;
+ pub fn inotify_add_watch(fd: ::c_int,
+ path: *const ::c_char,
+ mask: ::uint32_t) -> ::c_int;
}
cfg_if! {
diff --git a/libc/src/unix/notbsd/emscripten/align.rs b/libc/src/unix/notbsd/emscripten/align.rs
new file mode 100644
index 0000000..26a49b2
--- /dev/null
+++ b/libc/src/unix/notbsd/emscripten/align.rs
@@ -0,0 +1,66 @@
+macro_rules! expand_align {
+ () => {
+ s! {
+ #[repr(align(4))]
+ pub struct pthread_mutex_t {
+ size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
+ }
+
+ #[repr(align(4))]
+ pub struct pthread_rwlock_t {
+ size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
+ }
+
+ #[repr(align(4))]
+ pub struct pthread_mutexattr_t {
+ size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
+ }
+
+ #[repr(align(4))]
+ pub struct pthread_rwlockattr_t {
+ size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T],
+ }
+
+ #[repr(align(4))]
+ pub struct pthread_condattr_t {
+ size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
+ }
+ }
+
+ s_no_extra_traits! {
+ #[cfg_attr(target_pointer_width = "32",
+ repr(align(4)))]
+ #[cfg_attr(target_pointer_width = "64",
+ repr(align(8)))]
+ pub struct pthread_cond_t {
+ size: [u8; ::__SIZEOF_PTHREAD_COND_T],
+ }
+ }
+
+ cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for pthread_cond_t {
+ fn eq(&self, other: &pthread_cond_t) -> bool {
+ self.size
+ .iter()
+ .zip(other.size.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+ impl Eq for pthread_cond_t {}
+ impl ::fmt::Debug for pthread_cond_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("pthread_cond_t")
+ // FIXME: .field("size", &self.size)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for pthread_cond_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.size.hash(state);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/libc/src/unix/notbsd/emscripten.rs b/libc/src/unix/notbsd/emscripten/mod.rs
index 28791d8..0f8c76e 100644
--- a/libc/src/unix/notbsd/emscripten.rs
+++ b/libc/src/unix/notbsd/emscripten/mod.rs
@@ -1,5 +1,3 @@
-use dox::{mem, Option};
-
pub type c_char = i8;
pub type wchar_t = i32;
pub type useconds_t = u32;
@@ -35,25 +33,14 @@ pub type c_long = i32;
pub type c_ulong = u32;
pub type nlink_t = u32;
+#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum fpos64_t {} // TODO: fill this out with a struct
+impl ::Copy for fpos64_t {}
+impl ::Clone for fpos64_t {
+ fn clone(&self) -> fpos64_t { *self }
+}
s! {
- pub struct dirent {
- pub d_ino: ::ino_t,
- pub d_off: ::off_t,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
- pub struct dirent64 {
- pub d_ino: ::ino64_t,
- pub d_off: ::off64_t,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
pub struct rlimit64 {
pub rlim_cur: rlim64_t,
pub rlim_max: rlim64_t,
@@ -72,51 +59,6 @@ s! {
__unused5: *mut ::c_void,
}
- #[cfg_attr(feature = "align", repr(align(4)))]
- pub struct pthread_mutex_t {
- #[cfg(not(feature = "align"))]
- __align: [::c_long; 0],
- size: [u8; __SIZEOF_PTHREAD_MUTEX_T],
- }
-
- #[cfg_attr(feature = "align", repr(align(4)))]
- pub struct pthread_rwlock_t {
- #[cfg(not(feature = "align"))]
- __align: [::c_long; 0],
- size: [u8; __SIZEOF_PTHREAD_RWLOCK_T],
- }
-
- #[cfg_attr(feature = "align", repr(align(4)))]
- pub struct pthread_mutexattr_t {
- #[cfg(not(feature = "align"))]
- __align: [::c_int; 0],
- size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T],
- }
-
- #[cfg_attr(feature = "align", repr(align(4)))]
- pub struct pthread_rwlockattr_t {
- #[cfg(not(feature = "align"))]
- __align: [::c_int; 0],
- size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T],
- }
-
- #[cfg_attr(all(feature = "align", target_pointer_width = "32"),
- repr(align(4)))]
- #[cfg_attr(all(feature = "align", target_pointer_width = "64"),
- repr(align(8)))]
- pub struct pthread_cond_t {
- #[cfg(not(feature = "align"))]
- __align: [*const ::c_void; 0],
- size: [u8; __SIZEOF_PTHREAD_COND_T],
- }
-
- #[cfg_attr(feature = "align", repr(align(4)))]
- pub struct pthread_condattr_t {
- #[cfg(not(feature = "align"))]
- __align: [::c_int; 0],
- size: [u8; __SIZEOF_PTHREAD_CONDATTR_T],
- }
-
pub struct passwd {
pub pw_name: *mut ::c_char,
pub pw_passwd: *mut ::c_char,
@@ -225,11 +167,6 @@ s! {
pub msgseg: ::c_ushort,
}
- pub struct mmsghdr {
- pub msg_hdr: ::msghdr,
- pub msg_len: ::c_uint,
- }
-
pub struct sembuf {
pub sem_num: ::c_ushort,
pub sem_op: ::c_short,
@@ -257,7 +194,7 @@ s! {
pub sa_sigaction: ::sighandler_t,
pub sa_mask: ::sigset_t,
pub sa_flags: ::c_int,
- pub sa_restorer: ::dox::Option<extern fn()>,
+ pub sa_restorer: ::Option<extern fn()>,
}
pub struct ipc_perm {
@@ -291,23 +228,6 @@ s! {
pub l_pid: ::pid_t,
}
- pub struct sysinfo {
- pub uptime: ::c_ulong,
- pub loads: [::c_ulong; 3],
- pub totalram: ::c_ulong,
- pub freeram: ::c_ulong,
- pub sharedram: ::c_ulong,
- pub bufferram: ::c_ulong,
- pub totalswap: ::c_ulong,
- pub freeswap: ::c_ulong,
- pub procs: ::c_ushort,
- pub pad: ::c_ushort,
- pub totalhigh: ::c_ulong,
- pub freehigh: ::c_ulong,
- pub mem_unit: ::c_uint,
- pub __reserved: [::c_char; 256],
- }
-
pub struct pthread_attr_t {
__size: [u32; 11]
}
@@ -482,6 +402,177 @@ s! {
}
}
+s_no_extra_traits! {
+ pub struct dirent {
+ pub d_ino: ::ino_t,
+ pub d_off: ::off_t,
+ pub d_reclen: ::c_ushort,
+ pub d_type: ::c_uchar,
+ pub d_name: [::c_char; 256],
+ }
+
+ pub struct dirent64 {
+ pub d_ino: ::ino64_t,
+ pub d_off: ::off64_t,
+ pub d_reclen: ::c_ushort,
+ pub d_type: ::c_uchar,
+ pub d_name: [::c_char; 256],
+ }
+
+ pub struct sysinfo {
+ pub uptime: ::c_ulong,
+ pub loads: [::c_ulong; 3],
+ pub totalram: ::c_ulong,
+ pub freeram: ::c_ulong,
+ pub sharedram: ::c_ulong,
+ pub bufferram: ::c_ulong,
+ pub totalswap: ::c_ulong,
+ pub freeswap: ::c_ulong,
+ pub procs: ::c_ushort,
+ pub pad: ::c_ushort,
+ pub totalhigh: ::c_ulong,
+ pub freehigh: ::c_ulong,
+ pub mem_unit: ::c_uint,
+ pub __reserved: [::c_char; 256],
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for dirent {
+ fn eq(&self, other: &dirent) -> bool {
+ self.d_ino == other.d_ino
+ && self.d_off == other.d_off
+ && self.d_reclen == other.d_reclen
+ && self.d_type == other.d_type
+ && self
+ .d_name
+ .iter()
+ .zip(other.d_name.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+ impl Eq for dirent {}
+ impl ::fmt::Debug for dirent {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("dirent")
+ .field("d_ino", &self.d_ino)
+ .field("d_off", &self.d_off)
+ .field("d_reclen", &self.d_reclen)
+ .field("d_type", &self.d_type)
+ // FIXME: .field("d_name", &self.d_name)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for dirent {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.d_ino.hash(state);
+ self.d_off.hash(state);
+ self.d_reclen.hash(state);
+ self.d_type.hash(state);
+ self.d_name.hash(state);
+ }
+ }
+
+ impl PartialEq for dirent64 {
+ fn eq(&self, other: &dirent64) -> bool {
+ self.d_ino == other.d_ino
+ && self.d_off == other.d_off
+ && self.d_reclen == other.d_reclen
+ && self.d_type == other.d_type
+ && self
+ .d_name
+ .iter()
+ .zip(other.d_name.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+ impl Eq for dirent64 {}
+ impl ::fmt::Debug for dirent64 {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("dirent64")
+ .field("d_ino", &self.d_ino)
+ .field("d_off", &self.d_off)
+ .field("d_reclen", &self.d_reclen)
+ .field("d_type", &self.d_type)
+ // FIXME: .field("d_name", &self.d_name)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for dirent64 {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.d_ino.hash(state);
+ self.d_off.hash(state);
+ self.d_reclen.hash(state);
+ self.d_type.hash(state);
+ self.d_name.hash(state);
+ }
+ }
+
+ impl PartialEq for sysinfo {
+ fn eq(&self, other: &sysinfo) -> bool {
+ self.uptime == other.uptime
+ && self.loads == other.loads
+ && self.totalram == other.totalram
+ && self.freeram == other.freeram
+ && self.sharedram == other.sharedram
+ && self.bufferram == other.bufferram
+ && self.totalswap == other.totalswap
+ && self.freeswap == other.freeswap
+ && self.procs == other.procs
+ && self.pad == other.pad
+ && self.totalhigh == other.totalhigh
+ && self.freehigh == other.freehigh
+ && self.mem_unit == other.mem_unit
+ && self
+ .__reserved
+ .iter()
+ .zip(other.__reserved.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+ impl Eq for sysinfo {}
+ impl ::fmt::Debug for sysinfo {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("sysinfo")
+ .field("uptime", &self.uptime)
+ .field("loads", &self.loads)
+ .field("totalram", &self.totalram)
+ .field("freeram", &self.freeram)
+ .field("sharedram", &self.sharedram)
+ .field("bufferram", &self.bufferram)
+ .field("totalswap", &self.totalswap)
+ .field("freeswap", &self.freeswap)
+ .field("procs", &self.procs)
+ .field("pad", &self.pad)
+ .field("totalhigh", &self.totalhigh)
+ .field("freehigh", &self.freehigh)
+ .field("mem_unit", &self.mem_unit)
+ // FIXME: .field("__reserved", &self.__reserved)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for sysinfo {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.uptime.hash(state);
+ self.loads.hash(state);
+ self.totalram.hash(state);
+ self.freeram.hash(state);
+ self.sharedram.hash(state);
+ self.bufferram.hash(state);
+ self.totalswap.hash(state);
+ self.freeswap.hash(state);
+ self.procs.hash(state);
+ self.pad.hash(state);
+ self.totalhigh.hash(state);
+ self.freehigh.hash(state);
+ self.mem_unit.hash(state);
+ self.__reserved.hash(state);
+ }
+ }
+ }
+}
+
pub const ABDAY_1: ::nl_item = 0x20000;
pub const ABDAY_2: ::nl_item = 0x20001;
pub const ABDAY_3: ::nl_item = 0x20002;
@@ -1510,6 +1601,23 @@ pub const ARPD_FLUSH: ::c_ushort = 0x03;
pub const ATF_MAGIC: ::c_int = 0x80;
f! {
+ pub fn CMSG_NXTHDR(mhdr: *const msghdr,
+ cmsg: *const cmsghdr) -> *mut cmsghdr {
+ if ((*cmsg).cmsg_len as usize) < ::mem::size_of::<cmsghdr>() {
+ return 0 as *mut cmsghdr;
+ };
+ let next = (cmsg as usize +
+ super::CMSG_ALIGN((*cmsg).cmsg_len as usize))
+ as *mut cmsghdr;
+ let max = (*mhdr).msg_control as usize
+ + (*mhdr).msg_controllen as usize;
+ if (next.offset(1)) as usize > max {
+ 0 as *mut cmsghdr
+ } else {
+ next as *mut cmsghdr
+ }
+ }
+
pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
for slot in cpuset.bits.iter_mut() {
*slot = 0;
@@ -1517,21 +1625,23 @@ f! {
}
pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
+ let size_in_bits
+ = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
cpuset.bits[idx] |= 1 << offset;
()
}
pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
+ let size_in_bits
+ = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
cpuset.bits[idx] &= !(1 << offset);
()
}
pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
- let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]);
+ let size_in_bits = 8 * ::mem::size_of_val(&cpuset.bits[0]);
let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
0 != (cpuset.bits[idx] & (1 << offset))
}
@@ -1640,7 +1750,7 @@ extern {
pub fn glob(pattern: *const c_char,
flags: ::c_int,
- errfunc: Option<extern fn(epath: *const c_char,
+ errfunc: ::Option<extern fn(epath: *const c_char,
errno: ::c_int) -> ::c_int>,
pglob: *mut ::glob_t) -> ::c_int;
pub fn globfree(pglob: *mut ::glob_t);
@@ -1666,9 +1776,9 @@ extern {
pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int;
- pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
+ pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
flags: ::c_int) -> ::c_int;
- pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
+ pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
pub fn sync();
pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
@@ -1679,3 +1789,14 @@ extern {
f: extern fn(*mut ::c_void) -> *mut ::c_void,
value: *mut ::c_void) -> ::c_int;
}
+
+cfg_if! {
+ if #[cfg(libc_align)] {
+ #[macro_use]
+ mod align;
+ } else {
+ #[macro_use]
+ mod no_align;
+ }
+}
+expand_align!();
diff --git a/libc/src/unix/notbsd/emscripten/no_align.rs b/libc/src/unix/notbsd/emscripten/no_align.rs
new file mode 100644
index 0000000..ece4dff
--- /dev/null
+++ b/libc/src/unix/notbsd/emscripten/no_align.rs
@@ -0,0 +1,63 @@
+macro_rules! expand_align {
+ () => {
+ s! {
+ pub struct pthread_mutex_t {
+ __align: [::c_long; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
+ }
+
+ pub struct pthread_rwlock_t {
+ __align: [::c_long; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
+ }
+
+ pub struct pthread_mutexattr_t {
+ __align: [::c_int; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
+ }
+
+ pub struct pthread_rwlockattr_t {
+ __align: [::c_int; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T],
+ }
+
+ pub struct pthread_condattr_t {
+ __align: [::c_int; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
+ }
+ }
+
+ s_no_extra_traits! {
+ pub struct pthread_cond_t {
+ __align: [*const ::c_void; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_COND_T],
+ }
+ }
+
+ cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for pthread_cond_t {
+ fn eq(&self, other: &pthread_cond_t) -> bool {
+ self.size
+ .iter()
+ .zip(other.size.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+ impl Eq for pthread_cond_t {}
+ impl ::fmt::Debug for pthread_cond_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("pthread_cond_t")
+ // FIXME: .field("size", &self.size)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for pthread_cond_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.size.hash(state);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/libc/src/unix/notbsd/linux/align.rs b/libc/src/unix/notbsd/linux/align.rs
new file mode 100644
index 0000000..0ff4649
--- /dev/null
+++ b/libc/src/unix/notbsd/linux/align.rs
@@ -0,0 +1,98 @@
+macro_rules! expand_align {
+ () => {
+ s! {
+ #[cfg_attr(any(target_pointer_width = "32",
+ target_arch = "x86_64",
+ target_arch = "powerpc64",
+ target_arch = "mips64",
+ target_arch = "s390x",
+ target_arch = "sparc64",
+ target_arch = "aarch64"),
+ repr(align(4)))]
+ #[cfg_attr(not(any(target_pointer_width = "32",
+ target_arch = "x86_64",
+ target_arch = "powerpc64",
+ target_arch = "mips64",
+ target_arch = "s390x",
+ target_arch = "sparc64",
+ target_arch = "aarch64")),
+ repr(align(8)))]
+ pub struct pthread_mutexattr_t {
+ #[doc(hidden)]
+ size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
+ }
+
+ #[cfg_attr(any(target_env = "musl", target_pointer_width = "32"),
+ repr(align(4)))]
+ #[cfg_attr(all(not(target_env = "musl"),
+ target_pointer_width = "64"),
+ repr(align(8)))]
+ pub struct pthread_rwlockattr_t {
+ #[doc(hidden)]
+ size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T],
+ }
+
+ #[repr(align(4))]
+ pub struct pthread_condattr_t {
+ #[doc(hidden)]
+ size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
+ }
+ }
+
+ s_no_extra_traits! {
+ #[cfg_attr(all(target_env = "musl",
+ target_pointer_width = "32"),
+ repr(align(4)))]
+ #[cfg_attr(all(target_env = "musl",
+ target_pointer_width = "64"),
+ repr(align(8)))]
+ #[cfg_attr(all(not(target_env = "musl"),
+ target_arch = "x86"),
+ repr(align(4)))]
+ #[cfg_attr(all(not(target_env = "musl"),
+ not(target_arch = "x86")),
+ repr(align(8)))]
+ pub struct pthread_cond_t {
+ #[doc(hidden)]
+ size: [u8; ::__SIZEOF_PTHREAD_COND_T],
+ }
+
+ #[cfg_attr(all(target_pointer_width = "32",
+ any(target_arch = "mips",
+ target_arch = "arm",
+ target_arch = "powerpc",
+ target_arch = "x86_64",
+ target_arch = "x86")),
+ repr(align(4)))]
+ #[cfg_attr(any(target_pointer_width = "64",
+ not(any(target_arch = "mips",
+ target_arch = "arm",
+ target_arch = "powerpc",
+ target_arch = "x86_64",
+ target_arch = "x86"))),
+ repr(align(8)))]
+ pub struct pthread_mutex_t {
+ #[doc(hidden)]
+ size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
+ }
+
+ #[cfg_attr(all(target_pointer_width = "32",
+ any(target_arch = "mips",
+ target_arch = "arm",
+ target_arch = "powerpc",
+ target_arch = "x86_64",
+ target_arch = "x86")),
+ repr(align(4)))]
+ #[cfg_attr(any(target_pointer_width = "64",
+ not(any(target_arch = "mips",
+ target_arch = "arm",
+ target_arch = "powerpc",
+ target_arch = "x86_64",
+ target_arch = "x86"))),
+ repr(align(8)))]
+ pub struct pthread_rwlock_t {
+ size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
+ }
+ }
+ }
+}
diff --git a/libc/src/unix/notbsd/linux/mips/align.rs b/libc/src/unix/notbsd/linux/mips/align.rs
new file mode 100644
index 0000000..4a0e074
--- /dev/null
+++ b/libc/src/unix/notbsd/linux/mips/align.rs
@@ -0,0 +1,13 @@
+s! {
+ // FIXME this is actually a union
+ #[cfg_attr(target_pointer_width = "32",
+ repr(align(4)))]
+ #[cfg_attr(target_pointer_width = "64",
+ repr(align(8)))]
+ pub struct sem_t {
+ #[cfg(target_pointer_width = "32")]
+ __size: [::c_char; 16],
+ #[cfg(target_pointer_width = "64")]
+ __size: [::c_char; 32],
+ }
+}
diff --git a/libc/src/unix/notbsd/linux/mips/mips32.rs b/libc/src/unix/notbsd/linux/mips/mips32.rs
index a6c08a5..d9d5589 100644
--- a/libc/src/unix/notbsd/linux/mips/mips32.rs
+++ b/libc/src/unix/notbsd/linux/mips/mips32.rs
@@ -133,7 +133,7 @@ s! {
pub sa_flags: ::c_int,
pub sa_sigaction: ::sighandler_t,
pub sa_mask: sigset_t,
- pub sa_restorer: ::dox::Option<extern fn()>,
+ pub sa_restorer: ::Option<extern fn()>,
_resv: [::c_int; 1],
}
@@ -353,7 +353,6 @@ pub const SYS_mknod: ::c_long = 4000 + 14;
pub const SYS_chmod: ::c_long = 4000 + 15;
pub const SYS_lchown: ::c_long = 4000 + 16;
pub const SYS_break: ::c_long = 4000 + 17;
-pub const SYS_unused18: ::c_long = 4000 + 18;
pub const SYS_lseek: ::c_long = 4000 + 19;
pub const SYS_getpid: ::c_long = 4000 + 20;
pub const SYS_mount: ::c_long = 4000 + 21;
@@ -363,7 +362,6 @@ pub const SYS_getuid: ::c_long = 4000 + 24;
pub const SYS_stime: ::c_long = 4000 + 25;
pub const SYS_ptrace: ::c_long = 4000 + 26;
pub const SYS_alarm: ::c_long = 4000 + 27;
-pub const SYS_unused28: ::c_long = 4000 + 28;
pub const SYS_pause: ::c_long = 4000 + 29;
pub const SYS_utime: ::c_long = 4000 + 30;
pub const SYS_stty: ::c_long = 4000 + 31;
@@ -394,7 +392,6 @@ pub const SYS_fcntl: ::c_long = 4000 + 55;
pub const SYS_mpx: ::c_long = 4000 + 56;
pub const SYS_setpgid: ::c_long = 4000 + 57;
pub const SYS_ulimit: ::c_long = 4000 + 58;
-pub const SYS_unused59: ::c_long = 4000 + 59;
pub const SYS_umask: ::c_long = 4000 + 60;
pub const SYS_chroot: ::c_long = 4000 + 61;
pub const SYS_ustat: ::c_long = 4000 + 62;
@@ -417,9 +414,7 @@ pub const SYS_gettimeofday: ::c_long = 4000 + 78;
pub const SYS_settimeofday: ::c_long = 4000 + 79;
pub const SYS_getgroups: ::c_long = 4000 + 80;
pub const SYS_setgroups: ::c_long = 4000 + 81;
-pub const SYS_reserved82: ::c_long = 4000 + 82;
pub const SYS_symlink: ::c_long = 4000 + 83;
-pub const SYS_unused84: ::c_long = 4000 + 84;
pub const SYS_readlink: ::c_long = 4000 + 85;
pub const SYS_uselib: ::c_long = 4000 + 86;
pub const SYS_swapon: ::c_long = 4000 + 87;
@@ -444,7 +439,6 @@ pub const SYS_getitimer: ::c_long = 4000 + 105;
pub const SYS_stat: ::c_long = 4000 + 106;
pub const SYS_lstat: ::c_long = 4000 + 107;
pub const SYS_fstat: ::c_long = 4000 + 108;
-pub const SYS_unused109: ::c_long = 4000 + 109;
pub const SYS_iopl: ::c_long = 4000 + 110;
pub const SYS_vhangup: ::c_long = 4000 + 111;
pub const SYS_idle: ::c_long = 4000 + 112;
@@ -485,7 +479,6 @@ pub const SYS_writev: ::c_long = 4000 + 146;
pub const SYS_cacheflush: ::c_long = 4000 + 147;
pub const SYS_cachectl: ::c_long = 4000 + 148;
pub const SYS_sysmips: ::c_long = 4000 + 149;
-pub const SYS_unused150: ::c_long = 4000 + 150;
pub const SYS_getsid: ::c_long = 4000 + 151;
pub const SYS_fdatasync: ::c_long = 4000 + 152;
pub const SYS__sysctl: ::c_long = 4000 + 153;
@@ -556,7 +549,6 @@ pub const SYS_mincore: ::c_long = 4000 + 217;
pub const SYS_madvise: ::c_long = 4000 + 218;
pub const SYS_getdents64: ::c_long = 4000 + 219;
pub const SYS_fcntl64: ::c_long = 4000 + 220;
-pub const SYS_reserved221: ::c_long = 4000 + 221;
pub const SYS_gettid: ::c_long = 4000 + 222;
pub const SYS_readahead: ::c_long = 4000 + 223;
pub const SYS_setxattr: ::c_long = 4000 + 224;
diff --git a/libc/src/unix/notbsd/linux/mips/mips64.rs b/libc/src/unix/notbsd/linux/mips/mips64.rs
index e8b02a3..f480e50 100644
--- a/libc/src/unix/notbsd/linux/mips/mips64.rs
+++ b/libc/src/unix/notbsd/linux/mips/mips64.rs
@@ -131,7 +131,7 @@ s! {
pub sa_flags: ::c_int,
pub sa_sigaction: ::sighandler_t,
pub sa_mask: sigset_t,
- pub sa_restorer: ::dox::Option<extern fn()>,
+ pub sa_restorer: ::Option<extern fn()>,
}
pub struct stack_t {
@@ -496,7 +496,6 @@ pub const SYS_nfsservctl: ::c_long = 5000 + 173;
pub const SYS_getpmsg: ::c_long = 5000 + 174;
pub const SYS_putpmsg: ::c_long = 5000 + 175;
pub const SYS_afs_syscall: ::c_long = 5000 + 176;
-pub const SYS_reserved177: ::c_long = 5000 + 177;
pub const SYS_gettid: ::c_long = 5000 + 178;
pub const SYS_readahead: ::c_long = 5000 + 179;
pub const SYS_setxattr: ::c_long = 5000 + 180;
@@ -512,7 +511,6 @@ pub const SYS_removexattr: ::c_long = 5000 + 189;
pub const SYS_lremovexattr: ::c_long = 5000 + 190;
pub const SYS_fremovexattr: ::c_long = 5000 + 191;
pub const SYS_tkill: ::c_long = 5000 + 192;
-pub const SYS_reserved193: ::c_long = 5000 + 193;
pub const SYS_futex: ::c_long = 5000 + 194;
pub const SYS_sched_setaffinity: ::c_long = 5000 + 195;
pub const SYS_sched_getaffinity: ::c_long = 5000 + 196;
diff --git a/libc/src/unix/notbsd/linux/mips/mod.rs b/libc/src/unix/notbsd/linux/mips/mod.rs
index 8809bef..35534b4 100644
--- a/libc/src/unix/notbsd/linux/mips/mod.rs
+++ b/libc/src/unix/notbsd/linux/mips/mod.rs
@@ -20,20 +20,6 @@ s! {
__unused5: *mut ::c_void,
}
- // FIXME this is actually a union
- #[cfg_attr(all(feature = "align", target_pointer_width = "32"),
- repr(align(4)))]
- #[cfg_attr(all(feature = "align", target_pointer_width = "64"),
- repr(align(8)))]
- pub struct sem_t {
- #[cfg(target_pointer_width = "32")]
- __size: [::c_char; 16],
- #[cfg(target_pointer_width = "64")]
- __size: [::c_char; 32],
- #[cfg(not(feature = "align"))]
- __align: [::c_long; 0],
- }
-
pub struct termios2 {
pub c_iflag: ::tcflag_t,
pub c_oflag: ::tcflag_t,
@@ -720,10 +706,10 @@ pub const GENL_UNS_ADMIN_PERM: ::c_int = 0x10;
pub const GENL_ID_VFS_DQUOT: ::c_int = ::NLMSG_MIN_TYPE + 1;
pub const GENL_ID_PMCRAID: ::c_int = ::NLMSG_MIN_TYPE + 2;
-pub const NFT_TABLE_MAXNAMELEN: ::c_int = 32;
-pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 32;
-pub const NFT_SET_MAXNAMELEN: ::c_int = 32;
-pub const NFT_OBJ_MAXNAMELEN: ::c_int = 32;
+pub const NFT_TABLE_MAXNAMELEN: ::c_int = 256;
+pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 256;
+pub const NFT_SET_MAXNAMELEN: ::c_int = 256;
+pub const NFT_OBJ_MAXNAMELEN: ::c_int = 256;
pub const NFT_USERDATA_MAXLEN: ::c_int = 256;
pub const NFT_REG_VERDICT: ::c_int = 0;
@@ -780,7 +766,7 @@ pub const NFT_MSG_NEWOBJ: ::c_int = 18;
pub const NFT_MSG_GETOBJ: ::c_int = 19;
pub const NFT_MSG_DELOBJ: ::c_int = 20;
pub const NFT_MSG_GETOBJ_RESET: ::c_int = 21;
-pub const NFT_MSG_MAX: ::c_int = 22;
+pub const NFT_MSG_MAX: ::c_int = 25;
pub const NFT_SET_ANONYMOUS: ::c_int = 0x1;
pub const NFT_SET_CONSTANT: ::c_int = 0x2;
@@ -927,7 +913,7 @@ extern {
sz: ::c_int) -> ::c_int;
pub fn glob64(pattern: *const ::c_char,
flags: ::c_int,
- errfunc: ::dox::Option<extern fn(epath: *const ::c_char,
+ errfunc: ::Option<extern fn(epath: *const ::c_char,
errno: ::c_int)
-> ::c_int>,
pglob: *mut glob64_t) -> ::c_int;
@@ -962,3 +948,13 @@ cfg_if! {
// Unknown target_arch
}
}
+
+cfg_if! {
+ if #[cfg(libc_align)] {
+ mod align;
+ pub use self::align::*;
+ } else {
+ mod no_align;
+ pub use self::no_align::*;
+ }
+}
diff --git a/libc/src/unix/notbsd/linux/mips/no_align.rs b/libc/src/unix/notbsd/linux/mips/no_align.rs
new file mode 100644
index 0000000..e32bf67
--- /dev/null
+++ b/libc/src/unix/notbsd/linux/mips/no_align.rs
@@ -0,0 +1,10 @@
+s! {
+ // FIXME this is actually a union
+ pub struct sem_t {
+ #[cfg(target_pointer_width = "32")]
+ __size: [::c_char; 16],
+ #[cfg(target_pointer_width = "64")]
+ __size: [::c_char; 32],
+ __align: [::c_long; 0],
+ }
+}
diff --git a/libc/src/unix/notbsd/linux/mod.rs b/libc/src/unix/notbsd/linux/mod.rs
index 8669a06..2419a41 100644
--- a/libc/src/unix/notbsd/linux/mod.rs
+++ b/libc/src/unix/notbsd/linux/mod.rs
@@ -1,7 +1,5 @@
//! Linux-specific definitions for linux-like values
-use dox::{mem, Option};
-
pub type useconds_t = u32;
pub type dev_t = u64;
pub type socklen_t = u32;
@@ -38,25 +36,14 @@ pub type Elf64_Sxword = i64;
pub type Elf32_Section = u16;
pub type Elf64_Section = u16;
+#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum fpos64_t {} // TODO: fill this out with a struct
+impl ::Copy for fpos64_t {}
+impl ::Clone for fpos64_t {
+ fn clone(&self) -> fpos64_t { *self }
+}
s! {
- pub struct dirent {
- pub d_ino: ::ino_t,
- pub d_off: ::off_t,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
- pub struct dirent64 {
- pub d_ino: ::ino64_t,
- pub d_off: ::off64_t,
- pub d_reclen: ::c_ushort,
- pub d_type: ::c_uchar,
- pub d_name: [::c_char; 256],
- }
-
pub struct rlimit64 {
pub rlim_cur: rlim64_t,
pub rlim_max: rlim64_t,
@@ -75,150 +62,6 @@ s! {
__unused5: *mut ::c_void,
}
- #[cfg_attr(all(feature = "align",
- target_pointer_width = "32",
- any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc",
- target_arch = "x86_64",
- target_arch = "x86")),
- repr(align(4)))]
- #[cfg_attr(all(feature = "align",
- any(target_pointer_width = "64",
- not(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc",
- target_arch = "x86_64",
- target_arch = "x86")))),
- repr(align(8)))]
- pub struct pthread_mutex_t {
- #[cfg(all(not(feature = "align"),
- any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc",
- all(target_arch = "x86_64",
- target_pointer_width = "32"))))]
- __align: [::c_long; 0],
- #[cfg(not(any(feature = "align",
- target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc",
- all(target_arch = "x86_64",
- target_pointer_width = "32"))))]
- __align: [::c_longlong; 0],
- size: [u8; __SIZEOF_PTHREAD_MUTEX_T],
- }
-
- #[cfg_attr(all(feature = "align",
- target_pointer_width = "32",
- any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc",
- target_arch = "x86_64",
- target_arch = "x86")),
- repr(align(4)))]
- #[cfg_attr(all(feature = "align",
- any(target_pointer_width = "64",
- not(any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc",
- target_arch = "x86_64",
- target_arch = "x86")))),
- repr(align(8)))]
- pub struct pthread_rwlock_t {
- #[cfg(all(not(feature = "align"),
- any(target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc",
- all(target_arch = "x86_64",
- target_pointer_width = "32"))))]
- __align: [::c_long; 0],
- #[cfg(not(any(feature = "align",
- target_arch = "mips",
- target_arch = "arm",
- target_arch = "powerpc",
- all(target_arch = "x86_64",
- target_pointer_width = "32"))))]
- __align: [::c_longlong; 0],
- size: [u8; __SIZEOF_PTHREAD_RWLOCK_T],
- }
-
- #[cfg_attr(all(feature = "align",
- any(target_pointer_width = "32",
- target_arch = "x86_64", target_arch = "powerpc64",
- target_arch = "mips64", target_arch = "s390x",
- target_arch = "sparc64",
- all(target_arch = "aarch64", target_env = "musl"))),
- repr(align(4)))]
- #[cfg_attr(all(feature = "align",
- not(any(target_pointer_width = "32",
- target_arch = "x86_64", target_arch = "powerpc64",
- target_arch = "mips64", target_arch = "s390x",
- target_arch = "sparc64",
- all(target_arch = "aarch64", target_env = "musl")))),
- repr(align(8)))]
- pub struct pthread_mutexattr_t {
- #[cfg(all(not(features = "align"),
- any(target_arch = "x86_64", target_arch = "powerpc64",
- target_arch = "mips64", target_arch = "s390x",
- target_arch = "sparc64",
- all(target_arch = "aarch64", target_env = "musl"))))]
- __align: [::c_int; 0],
- #[cfg(all(not(features = "align"),
- not(any(target_arch = "x86_64", target_arch = "powerpc64",
- target_arch = "mips64", target_arch = "s390x",
- target_arch = "sparc64",
- all(target_arch = "aarch64", target_env = "musl")))))]
- __align: [::c_long; 0],
- size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T],
- }
-
- #[cfg_attr(all(feature = "align",
- any(target_env = "musl", target_pointer_width = "32")),
- repr(align(4)))]
- #[cfg_attr(all(feature = "align",
- not(target_env = "musl"),
- target_pointer_width = "64"),
- repr(align(8)))]
- pub struct pthread_rwlockattr_t {
- #[cfg(all(not(feature = "align"), target_env = "musl"))]
- __align: [::c_int; 0],
- #[cfg(all(not(feature = "align"), not(target_env = "musl")))]
- __align: [::c_long; 0],
- size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T],
- }
-
- #[cfg_attr(all(feature = "align",
- target_env = "musl",
- target_pointer_width = "32"),
- repr(align(4)))]
- #[cfg_attr(all(feature = "align",
- target_env = "musl",
- target_pointer_width = "64"),
- repr(align(8)))]
- #[cfg_attr(all(feature = "align",
- not(target_env = "musl"),
- target_arch = "x86"),
- repr(align(4)))]
- #[cfg_attr(all(feature = "align",
- not(target_env = "musl"),
- not(target_arch = "x86")),
- repr(align(8)))]
- pub struct pthread_cond_t {
- #[cfg(all(not(feature = "align"), target_env = "musl"))]
- __align: [*const ::c_void; 0],
- #[cfg(not(any(feature = "align", target_env = "musl")))]
- __align: [::c_longlong; 0],
- size: [u8; __SIZEOF_PTHREAD_COND_T],
- }
-
- #[cfg_attr(feature = "align", repr(align(4)))]
- pub struct pthread_condattr_t {
- #[cfg(not(feature = "align"))]
- __align: [::c_int; 0],
- size: [u8; __SIZEOF_PTHREAD_CONDATTR_T],
- }
-
pub struct passwd {
pub pw_name: *mut ::c_char,
pub pw_passwd: *mut ::c_char,
@@ -346,11 +189,6 @@ s! {
pub msgseg: ::c_ushort,
}
- pub struct mmsghdr {
- pub msg_hdr: ::msghdr,
- pub msg_len: ::c_uint,
- }
-
pub struct sembuf {
pub sem_num: ::c_ushort,
pub sem_op: ::c_short,
@@ -655,6 +493,265 @@ s! {
pub updated: ::c_ulong,
pub ha: [::c_uchar; ::MAX_ADDR_LEN],
}
+
+ pub struct inotify_event {
+ pub wd: ::c_int,
+ pub mask: ::uint32_t,
+ pub cookie: ::uint32_t,
+ pub len: ::uint32_t
+ }
+}
+
+s_no_extra_traits!{
+ pub struct dirent {
+ pub d_ino: ::ino_t,
+ pub d_off: ::off_t,
+ pub d_reclen: ::c_ushort,
+ pub d_type: ::c_uchar,
+ pub d_name: [::c_char; 256],
+ }
+
+ pub struct dirent64 {
+ pub d_ino: ::ino64_t,
+ pub d_off: ::off64_t,
+ pub d_reclen: ::c_ushort,
+ pub d_type: ::c_uchar,
+ pub d_name: [::c_char; 256],
+ }
+
+ pub struct sockaddr_alg {
+ pub salg_family: ::sa_family_t,
+ pub salg_type: [::c_uchar; 14],
+ pub salg_feat: u32,
+ pub salg_mask: u32,
+ pub salg_name: [::c_uchar; 64],
+ }
+
+ pub struct af_alg_iv {
+ pub ivlen: u32,
+ pub iv: [::c_uchar; 0],
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for dirent {
+ fn eq(&self, other: &dirent) -> bool {
+ self.d_ino == other.d_ino
+ && self.d_off == other.d_off
+ && self.d_reclen == other.d_reclen
+ && self.d_type == other.d_type
+ && self
+ .d_name
+ .iter()
+ .zip(other.d_name.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+
+ impl Eq for dirent {}
+
+ impl ::fmt::Debug for dirent {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("dirent")
+ .field("d_ino", &self.d_ino)
+ .field("d_off", &self.d_off)
+ .field("d_reclen", &self.d_reclen)
+ .field("d_type", &self.d_type)
+ // FIXME: .field("d_name", &self.d_name)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for dirent {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.d_ino.hash(state);
+ self.d_off.hash(state);
+ self.d_reclen.hash(state);
+ self.d_type.hash(state);
+ self.d_name.hash(state);
+ }
+ }
+
+ impl PartialEq for dirent64 {
+ fn eq(&self, other: &dirent64) -> bool {
+ self.d_ino == other.d_ino
+ && self.d_off == other.d_off
+ && self.d_reclen == other.d_reclen
+ && self.d_type == other.d_type
+ && self
+ .d_name
+ .iter()
+ .zip(other.d_name.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+
+ impl Eq for dirent64 {}
+
+ impl ::fmt::Debug for dirent64 {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("dirent64")
+ .field("d_ino", &self.d_ino)
+ .field("d_off", &self.d_off)
+ .field("d_reclen", &self.d_reclen)
+ .field("d_type", &self.d_type)
+ // FIXME: .field("d_name", &self.d_name)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for dirent64 {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.d_ino.hash(state);
+ self.d_off.hash(state);
+ self.d_reclen.hash(state);
+ self.d_type.hash(state);
+ self.d_name.hash(state);
+ }
+ }
+
+ impl PartialEq for pthread_cond_t {
+ fn eq(&self, other: &pthread_cond_t) -> bool {
+ self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b)
+ }
+ }
+
+ impl Eq for pthread_cond_t {}
+
+ impl ::fmt::Debug for pthread_cond_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("pthread_cond_t")
+ // FIXME: .field("size", &self.size)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for pthread_cond_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.size.hash(state);
+ }
+ }
+
+ impl PartialEq for pthread_mutex_t {
+ fn eq(&self, other: &pthread_mutex_t) -> bool {
+ self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b)
+ }
+ }
+
+ impl Eq for pthread_mutex_t {}
+
+ impl ::fmt::Debug for pthread_mutex_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("pthread_mutex_t")
+ // FIXME: .field("size", &self.size)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for pthread_mutex_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.size.hash(state);
+ }
+ }
+
+ impl PartialEq for pthread_rwlock_t {
+ fn eq(&self, other: &pthread_rwlock_t) -> bool {
+ self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b)
+ }
+ }
+
+ impl Eq for pthread_rwlock_t {}
+
+ impl ::fmt::Debug for pthread_rwlock_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("pthread_rwlock_t")
+ // FIXME: .field("size", &self.size)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for pthread_rwlock_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.size.hash(state);
+ }
+ }
+
+ impl PartialEq for sockaddr_alg {
+ fn eq(&self, other: &sockaddr_alg) -> bool {
+ self.salg_family == other.salg_family
+ && self
+ .salg_type
+ .iter()
+ .zip(other.salg_type.iter())
+ .all(|(a, b)| a == b)
+ && self.salg_feat == other.salg_feat
+ && self.salg_mask == other.salg_mask
+ && self
+ .salg_name
+ .iter()
+ .zip(other.salg_name.iter())
+ .all(|(a, b)| a == b)
+ }
+ }
+
+ impl Eq for sockaddr_alg {}
+
+ impl ::fmt::Debug for sockaddr_alg {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("sockaddr_alg")
+ .field("salg_family", &self.salg_family)
+ .field("salg_type", &self.salg_type)
+ .field("salg_feat", &self.salg_feat)
+ .field("salg_mask", &self.salg_mask)
+ .field("salg_name", &&self.salg_name[..])
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for sockaddr_alg {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.salg_family.hash(state);
+ self.salg_type.hash(state);
+ self.salg_feat.hash(state);
+ self.salg_mask.hash(state);
+ self.salg_name.hash(state);
+ }
+ }
+
+ impl af_alg_iv {
+ fn as_slice(&self) -> &[u8] {
+ unsafe {
+ ::core::slice::from_raw_parts(
+ self.iv.as_ptr(),
+ self.ivlen as usize
+ )
+ }
+ }
+ }
+
+ impl PartialEq for af_alg_iv {
+ fn eq(&self, other: &af_alg_iv) -> bool {
+ *self.as_slice() == *other.as_slice()
+ }
+ }
+
+ impl Eq for af_alg_iv {}
+
+ impl ::fmt::Debug for af_alg_iv {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("af_alg_iv")
+ .field("iv", &self.as_slice())
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for af_alg_iv {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.as_slice().hash(state);
+ }
+ }
+ }
}
pub const ABDAY_1: ::nl_item = 0x20000;
@@ -1315,6 +1412,15 @@ pub const FALLOC_FL_UNSHARE_RANGE: ::c_int = 0x40;
pub const ENOATTR: ::c_int = ::ENODATA;
pub const SO_ORIGINAL_DST: ::c_int = 80;
+pub const IP_ORIGDSTADDR : ::c_int = 20;
+pub const IP_RECVORIGDSTADDR : ::c_int = IP_ORIGDSTADDR;
+pub const IPV6_ORIGDSTADDR : ::c_int = 74;
+pub const IPV6_RECVORIGDSTADDR : ::c_int = IPV6_ORIGDSTADDR;
+pub const IPV6_FLOWINFO: ::c_int = 11;
+pub const IPV6_FLOWLABEL_MGR: ::c_int = 32;
+pub const IPV6_FLOWINFO_SEND: ::c_int = 33;
+pub const IPV6_FLOWINFO_FLOWLABEL: ::c_int = 0x000fffff;
+pub const IPV6_FLOWINFO_PRIORITY: ::c_int = 0x0ff00000;
pub const IUTF8: ::tcflag_t = 0x00004000;
pub const CMSPAR: ::tcflag_t = 0o10000000000;
@@ -1696,7 +1802,92 @@ pub const SOF_TIMESTAMPING_SOFTWARE: ::c_uint = 1 << 4;
pub const SOF_TIMESTAMPING_SYS_HARDWARE: ::c_uint = 1 << 5;
pub const SOF_TIMESTAMPING_RAW_HARDWARE: ::c_uint = 1 << 6;
+// linux/if_alg.h
+pub const ALG_SET_KEY: ::c_int = 1;
+pub const ALG_SET_IV: ::c_int = 2;
+pub const ALG_SET_OP: ::c_int = 3;
+pub const ALG_SET_AEAD_ASSOCLEN: ::c_int = 4;
+pub const ALG_SET_AEAD_AUTHSIZE: ::c_int = 5;
+
+pub const ALG_OP_DECRYPT: ::c_int = 0;
+pub const ALG_OP_ENCRYPT: ::c_int = 1;
+
+// uapi/linux/inotify.h
+pub const IN_ACCESS: ::uint32_t = 0x0000_0001;
+pub const IN_MODIFY: ::uint32_t = 0x0000_0002;
+pub const IN_ATTRIB: ::uint32_t = 0x0000_0004;
+pub const IN_CLOSE_WRITE: ::uint32_t = 0x0000_0008;
+pub const IN_CLOSE_NOWRITE: ::uint32_t = 0x0000_0010;
+pub const IN_CLOSE: ::uint32_t = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE);
+pub const IN_OPEN: ::uint32_t = 0x0000_0020;
+pub const IN_MOVED_FROM: ::uint32_t = 0x0000_0040;
+pub const IN_MOVED_TO: ::uint32_t = 0x0000_0080;
+pub const IN_MOVE: ::uint32_t = (IN_MOVED_FROM | IN_MOVED_TO);
+pub const IN_CREATE: ::uint32_t = 0x0000_0100;
+pub const IN_DELETE: ::uint32_t = 0x0000_0200;
+pub const IN_DELETE_SELF: ::uint32_t = 0x0000_0400;
+pub const IN_MOVE_SELF: ::uint32_t = 0x0000_0800;
+pub const IN_UNMOUNT: ::uint32_t = 0x0000_2000;
+pub const IN_Q_OVERFLOW: ::uint32_t = 0x0000_4000;
+pub const IN_IGNORED: ::uint32_t = 0x0000_8000;
+pub const IN_ONLYDIR: ::uint32_t = 0x0100_0000;
+pub const IN_DONT_FOLLOW: ::uint32_t = 0x0200_0000;
+// pub const IN_EXCL_UNLINK: ::uint32_t = 0x0400_0000;
+
+// pub const IN_MASK_CREATE: ::uint32_t = 0x1000_0000;
+// pub const IN_MASK_ADD: ::uint32_t = 0x2000_0000;
+pub const IN_ISDIR: ::uint32_t = 0x4000_0000;
+pub const IN_ONESHOT: ::uint32_t = 0x8000_0000;
+
+pub const IN_ALL_EVENTS: ::uint32_t = (
+ IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE |
+ IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM |
+ IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF |
+ IN_MOVE_SELF
+);
+
+pub const IN_CLOEXEC: ::c_int = O_CLOEXEC;
+pub const IN_NONBLOCK: ::c_int = O_NONBLOCK;
+
+pub const FUTEX_WAIT: ::c_int = 0;
+pub const FUTEX_WAKE: ::c_int = 1;
+pub const FUTEX_FD: ::c_int = 2;
+pub const FUTEX_REQUEUE: ::c_int = 3;
+pub const FUTEX_CMP_REQUEUE: ::c_int = 4;
+pub const FUTEX_WAKE_OP: ::c_int = 5;
+pub const FUTEX_LOCK_PI: ::c_int = 6;
+pub const FUTEX_UNLOCK_PI: ::c_int = 7;
+pub const FUTEX_TRYLOCK_PI: ::c_int = 8;
+pub const FUTEX_WAIT_BITSET: ::c_int = 9;
+pub const FUTEX_WAKE_BITSET: ::c_int = 10;
+pub const FUTEX_WAIT_REQUEUE_PI: ::c_int = 11;
+pub const FUTEX_CMP_REQUEUE_PI: ::c_int = 12;
+
+pub const FUTEX_PRIVATE_FLAG: ::c_int = 128;
+pub const FUTEX_CLOCK_REALTIME: ::c_int = 256;
+pub const FUTEX_CMD_MASK: ::c_int =
+ !(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME);
+
f! {
+ pub fn CMSG_NXTHDR(mhdr: *const msghdr,
+ cmsg: *const cmsghdr) -> *mut cmsghdr {
+ if ((*cmsg).cmsg_len as usize) < ::mem::size_of::<cmsghdr>() {
+ return 0 as *mut cmsghdr;
+ };
+ let next = (cmsg as usize +
+ super::CMSG_ALIGN((*cmsg).cmsg_len as usize))
+ as *mut cmsghdr;
+ let max = (*mhdr).msg_control as usize
+ + (*mhdr).msg_controllen as usize;
+ if (next.offset(1)) as usize > max ||
+ next as usize + super::CMSG_ALIGN((*next).cmsg_len as usize) > max
+ {
+ 0 as *mut cmsghdr
+ } else {
+ next as *mut cmsghdr
+ }
+ }
+
pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
for slot in cpuset.bits.iter_mut() {
*slot = 0;
@@ -1704,21 +1895,23 @@ f! {
}
pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
+ let size_in_bits
+ = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
cpuset.bits[idx] |= 1 << offset;
()
}
pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
+ let size_in_bits
+ = 8 * ::mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
cpuset.bits[idx] &= !(1 << offset);
()
}
pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
- let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]);
+ let size_in_bits = 8 * ::mem::size_of_val(&cpuset.bits[0]);
let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
0 != (cpuset.bits[idx] & (1 << offset))
}
@@ -1979,7 +2172,7 @@ extern {
pub fn glob(pattern: *const c_char,
flags: ::c_int,
- errfunc: Option<extern fn(epath: *const c_char,
+ errfunc: ::Option<extern fn(epath: *const c_char,
errno: ::c_int) -> ::c_int>,
pglob: *mut ::glob_t) -> ::c_int;
pub fn globfree(pglob: *mut ::glob_t);
@@ -2008,9 +2201,9 @@ extern {
pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int;
pub fn vhangup() -> ::c_int;
- pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
+ pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
flags: ::c_int) -> ::c_int;
- pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut mmsghdr, vlen: ::c_uint,
+ pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
pub fn sync();
pub fn syscall(num: ::c_long, ...) -> ::c_long;
@@ -2104,7 +2297,7 @@ extern {
count: ::size_t) -> ::ssize_t;
pub fn sigsuspend(mask: *const ::sigset_t) -> ::c_int;
#[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")]
- pub fn getgrgid_r(uid: ::uid_t,
+ pub fn getgrgid_r(gid: ::gid_t,
grp: *mut ::group,
buf: *mut ::c_char,
buflen: ::size_t,
@@ -2152,9 +2345,9 @@ extern {
#[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
pub fn sigwait(set: *const sigset_t,
sig: *mut ::c_int) -> ::c_int;
- pub fn pthread_atfork(prepare: Option<unsafe extern fn()>,
- parent: Option<unsafe extern fn()>,
- child: Option<unsafe extern fn()>) -> ::c_int;
+ pub fn pthread_atfork(prepare: ::Option<unsafe extern fn()>,
+ parent: ::Option<unsafe extern fn()>,
+ child: ::Option<unsafe extern fn()>) -> ::c_int;
pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
pub fn getgrouplist(user: *const ::c_char,
group: ::gid_t,
@@ -2173,7 +2366,7 @@ extern {
f: extern fn(*mut ::c_void) -> *mut ::c_void,
value: *mut ::c_void) -> ::c_int;
pub fn dl_iterate_phdr(
- callback: Option<unsafe extern fn(
+ callback: ::Option<unsafe extern fn(
info: *mut ::dl_phdr_info,
size: ::size_t,
data: *mut ::c_void
@@ -2259,6 +2452,12 @@ extern {
nobj: ::size_t,
stream: *mut ::FILE
) -> ::size_t;
+ pub fn inotify_rm_watch(fd: ::c_int, wd: ::c_int) -> ::c_int;
+ pub fn inotify_init() -> ::c_int;
+ pub fn inotify_init1(flags: ::c_int) -> ::c_int;
+ pub fn inotify_add_watch(fd: ::c_int,
+ path: *const ::c_char,
+ mask: ::uint32_t) -> ::c_int;
}
cfg_if! {
@@ -2277,3 +2476,14 @@ cfg_if! {
pub use self::other::*;
}
}
+
+cfg_if! {
+ if #[cfg(libc_align)] {
+ #[macro_use]
+ mod align;
+ } else {
+ #[macro_use]
+ mod no_align;
+ }
+}
+expand_align!();
diff --git a/libc/src/unix/notbsd/linux/musl/b32/mips.rs b/libc/src/unix/notbsd/linux/musl/b32/mips.rs
index b0694d1..37430af 100644
--- a/libc/src/unix/notbsd/linux/musl/b32/mips.rs
+++ b/libc/src/unix/notbsd/linux/musl/b32/mips.rs
@@ -514,7 +514,6 @@ pub const SYS_mknod: ::c_long = 4000 + 14;
pub const SYS_chmod: ::c_long = 4000 + 15;
pub const SYS_lchown: ::c_long = 4000 + 16;
pub const SYS_break: ::c_long = 4000 + 17;
-pub const SYS_unused18: ::c_long = 4000 + 18;
pub const SYS_lseek: ::c_long = 4000 + 19;
pub const SYS_getpid: ::c_long = 4000 + 20;
pub const SYS_mount: ::c_long = 4000 + 21;
@@ -524,7 +523,6 @@ pub const SYS_getuid: ::c_long = 4000 + 24;
pub const SYS_stime: ::c_long = 4000 + 25;
pub const SYS_ptrace: ::c_long = 4000 + 26;
pub const SYS_alarm: ::c_long = 4000 + 27;
-pub const SYS_unused28: ::c_long = 4000 + 28;
pub const SYS_pause: ::c_long = 4000 + 29;
pub const SYS_utime: ::c_long = 4000 + 30;
pub const SYS_stty: ::c_long = 4000 + 31;
@@ -555,7 +553,6 @@ pub const SYS_fcntl: ::c_long = 4000 + 55;
pub const SYS_mpx: ::c_long = 4000 + 56;
pub const SYS_setpgid: ::c_long = 4000 + 57;
pub const SYS_ulimit: ::c_long = 4000 + 58;
-pub const SYS_unused59: ::c_long = 4000 + 59;
pub const SYS_umask: ::c_long = 4000 + 60;
pub const SYS_chroot: ::c_long = 4000 + 61;
pub const SYS_ustat: ::c_long = 4000 + 62;
@@ -578,9 +575,7 @@ pub const SYS_gettimeofday: ::c_long = 4000 + 78;
pub const SYS_settimeofday: ::c_long = 4000 + 79;
pub const SYS_getgroups: ::c_long = 4000 + 80;
pub const SYS_setgroups: ::c_long = 4000 + 81;
-pub const SYS_reserved82: ::c_long = 4000 + 82;
pub const SYS_symlink: ::c_long = 4000 + 83;
-pub const SYS_unused84: ::c_long = 4000 + 84;
pub const SYS_readlink: ::c_long = 4000 + 85;
pub const SYS_uselib: ::c_long = 4000 + 86;
pub const SYS_swapon: ::c_long = 4000 + 87;
@@ -605,7 +600,6 @@ pub const SYS_getitimer: ::c_long = 4000 + 105;
pub const SYS_stat: ::c_long = 4000 + 106;
pub const SYS_lstat: ::c_long = 4000 + 107;
pub const SYS_fstat: ::c_long = 4000 + 108;
-pub const SYS_unused109: ::c_long = 4000 + 109;
pub const SYS_iopl: ::c_long = 4000 + 110;
pub const SYS_vhangup: ::c_long = 4000 + 111;
pub const SYS_idle: ::c_long = 4000 + 112;
@@ -645,7 +639,6 @@ pub const SYS_writev: ::c_long = 4000 + 146;
pub const SYS_cacheflush: ::c_long = 4000 + 147;
pub const SYS_cachectl: ::c_long = 4000 + 148;
pub const SYS_sysmips: ::c_long = 4000 + 149;
-pub const SYS_unused150: ::c_long = 4000 + 150;
pub const SYS_getsid: ::c_long = 4000 + 151;
pub const SYS_fdatasync: ::c_long = 4000 + 152;
pub const SYS__sysctl: ::c_long = 4000 + 153;
@@ -714,7 +707,6 @@ pub const SYS_mincore: ::c_long = 4000 + 217;
pub const SYS_madvise: ::c_long = 4000 + 218;
pub const SYS_getdents64: ::c_long = 4000 + 219;
pub const SYS_fcntl64: ::c_long = 4000 + 220;
-pub const SYS_reserved221: ::c_long = 4000 + 221;
pub const SYS_gettid: ::c_long = 4000 + 222;
pub const SYS_readahead: ::c_long = 4000 + 223;
pub const SYS_setxattr: ::c_long = 4000 + 224;
diff --git a/libc/src/unix/notbsd/linux/musl/b32/x86.rs b/libc/src/unix/notbsd/linux/musl/b32/x86.rs
index b6ea8c1..8bfb60b 100644
--- a/libc/src/unix/notbsd/linux/musl/b32/x86.rs
+++ b/libc/src/unix/notbsd/linux/musl/b32/x86.rs
@@ -116,15 +116,6 @@ s! {
__private: [u32; 22]
}
- pub struct ucontext_t {
- pub uc_flags: ::c_ulong,
- pub uc_link: *mut ucontext_t,
- pub uc_stack: ::stack_t,
- pub uc_mcontext: mcontext_t,
- pub uc_sigmask: ::sigset_t,
- __private: [u8; 112],
- }
-
pub struct siginfo_t {
pub si_signo: ::c_int,
pub si_errno: ::c_int,
@@ -176,6 +167,62 @@ s! {
}
}
+s_no_extra_traits!{
+ pub struct ucontext_t {
+ pub uc_flags: ::c_ulong,
+ pub uc_link: *mut ucontext_t,
+ pub uc_stack: ::stack_t,
+ pub uc_mcontext: mcontext_t,
+ pub uc_sigmask: ::sigset_t,
+ __private: [u8; 112],
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for ucontext_t {
+ fn eq(&self, other: &ucontext_t) -> bool {
+ self.uc_flags == other.uc_flags
+ && self.uc_link == other.uc_link
+ && self.uc_stack == other.uc_stack
+ && self.uc_mcontext == other.uc_mcontext
+ && self.uc_sigmask == other.uc_sigmask
+ && self
+ .__private
+ .iter()
+ .zip(other.__private.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+
+ impl Eq for ucontext_t {}
+
+ impl ::fmt::Debug for ucontext_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("ucontext_t")
+ .field("uc_flags", &self.uc_flags)
+ .field("uc_link", &self.uc_link)
+ .field("uc_stack", &self.uc_stack)
+ .field("uc_mcontext", &self.uc_mcontext)
+ .field("uc_sigmask", &self.uc_sigmask)
+ // Ignore __private field
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for ucontext_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.uc_flags.hash(state);
+ self.uc_link.hash(state);
+ self.uc_stack.hash(state);
+ self.uc_mcontext.hash(state);
+ self.uc_sigmask.hash(state);
+ self.__private.hash(state);
+ }
+ }
+ }
+}
+
pub const SIGSTKSZ: ::size_t = 8192;
pub const MINSIGSTKSZ: ::size_t = 2048;
diff --git a/libc/src/unix/notbsd/linux/musl/b64/x86_64.rs b/libc/src/unix/notbsd/linux/musl/b64/x86_64.rs
index 0e0fcec..94c5d88 100644
--- a/libc/src/unix/notbsd/linux/musl/b64/x86_64.rs
+++ b/libc/src/unix/notbsd/linux/musl/b64/x86_64.rs
@@ -51,15 +51,6 @@ s! {
__private: [u64; 32],
}
- pub struct ucontext_t {
- pub uc_flags: ::c_ulong,
- pub uc_link: *mut ucontext_t,
- pub uc_stack: ::stack_t,
- pub uc_mcontext: mcontext_t,
- pub uc_sigmask: ::sigset_t,
- __private: [u8; 512],
- }
-
pub struct ipc_perm {
pub __ipc_perm_key: ::key_t,
pub uid: ::uid_t,
@@ -73,6 +64,62 @@ s! {
}
}
+s_no_extra_traits!{
+ pub struct ucontext_t {
+ pub uc_flags: ::c_ulong,
+ pub uc_link: *mut ucontext_t,
+ pub uc_stack: ::stack_t,
+ pub uc_mcontext: mcontext_t,
+ pub uc_sigmask: ::sigset_t,
+ __private: [u8; 512],
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for ucontext_t {
+ fn eq(&self, other: &ucontext_t) -> bool {
+ self.uc_flags == other.uc_flags
+ && self.uc_link == other.uc_link
+ && self.uc_stack == other.uc_stack
+ && self.uc_mcontext == other.uc_mcontext
+ && self.uc_sigmask == other.uc_sigmask
+ && self
+ .__private
+ .iter()
+ .zip(other.__private.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+
+ impl Eq for ucontext_t {}
+
+ impl ::fmt::Debug for ucontext_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("ucontext_t")
+ .field("uc_flags", &self.uc_flags)
+ .field("uc_link", &self.uc_link)
+ .field("uc_stack", &self.uc_stack)
+ .field("uc_mcontext", &self.uc_mcontext)
+ .field("uc_sigmask", &self.uc_sigmask)
+ // Ignore __private field
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for ucontext_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.uc_flags.hash(state);
+ self.uc_link.hash(state);
+ self.uc_stack.hash(state);
+ self.uc_mcontext.hash(state);
+ self.uc_sigmask.hash(state);
+ self.__private.hash(state);
+ }
+ }
+ }
+}
+
// Syscall table
pub const SYS_read: ::c_long = 0;
diff --git a/libc/src/unix/notbsd/linux/musl/mod.rs b/libc/src/unix/notbsd/linux/musl/mod.rs
index 5ab5d0f..4f4a3d8 100644
--- a/libc/src/unix/notbsd/linux/musl/mod.rs
+++ b/libc/src/unix/notbsd/linux/musl/mod.rs
@@ -37,7 +37,7 @@ s! {
pub sa_sigaction: ::sighandler_t,
pub sa_mask: ::sigset_t,
pub sa_flags: ::c_int,
- pub sa_restorer: ::dox::Option<extern fn()>,
+ pub sa_restorer: ::Option<extern fn()>,
}
pub struct statvfs {
@@ -78,7 +78,9 @@ s! {
pub l_len: ::off_t,
pub l_pid: ::pid_t,
}
+}
+s_no_extra_traits!{
pub struct sysinfo {
pub uptime: ::c_ulong,
pub loads: [::c_ulong; 3],
@@ -97,6 +99,75 @@ s! {
}
}
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for sysinfo {
+ fn eq(&self, other: &sysinfo) -> bool {
+ self.uptime == other.uptime
+ && self.loads == other.loads
+ && self.totalram == other.totalram
+ && self.freeram == other.freeram
+ && self.sharedram == other.sharedram
+ && self.bufferram == other.bufferram
+ && self.totalswap == other.totalswap
+ && self.freeswap == other.freeswap
+ && self.procs == other.procs
+ && self.pad == other.pad
+ && self.totalhigh == other.totalhigh
+ && self.freehigh == other.freehigh
+ && self.mem_unit == other.mem_unit
+ && self
+ .__reserved
+ .iter()
+ .zip(other.__reserved.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+
+ impl Eq for sysinfo {}
+
+ impl ::fmt::Debug for sysinfo {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("sysinfo")
+ .field("uptime", &self.uptime)
+ .field("loads", &self.loads)
+ .field("totalram", &self.totalram)
+ .field("freeram", &self.freeram)
+ .field("sharedram", &self.sharedram)
+ .field("bufferram", &self.bufferram)
+ .field("totalswap", &self.totalswap)
+ .field("freeswap", &self.freeswap)
+ .field("procs", &self.procs)
+ .field("pad", &self.pad)
+ .field("totalhigh", &self.totalhigh)
+ .field("freehigh", &self.freehigh)
+ .field("mem_unit", &self.mem_unit)
+ // FIXME: .field("__reserved", &self.__reserved)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for sysinfo {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.uptime.hash(state);
+ self.loads.hash(state);
+ self.totalram.hash(state);
+ self.freeram.hash(state);
+ self.sharedram.hash(state);
+ self.bufferram.hash(state);
+ self.totalswap.hash(state);
+ self.freeswap.hash(state);
+ self.procs.hash(state);
+ self.pad.hash(state);
+ self.totalhigh.hash(state);
+ self.freehigh.hash(state);
+ self.mem_unit.hash(state);
+ self.__reserved.hash(state);
+ }
+ }
+ }
+}
+
pub const SFD_CLOEXEC: ::c_int = 0x080000;
pub const NCCS: usize = 32;
diff --git a/libc/src/unix/notbsd/linux/no_align.rs b/libc/src/unix/notbsd/linux/no_align.rs
new file mode 100644
index 0000000..1f5f2ee
--- /dev/null
+++ b/libc/src/unix/notbsd/linux/no_align.rs
@@ -0,0 +1,80 @@
+macro_rules! expand_align {
+ () => {
+ s! {
+ pub struct pthread_mutexattr_t {
+ #[cfg(any(target_arch = "x86_64",
+ target_arch = "powerpc64",
+ target_arch = "mips64",
+ target_arch = "s390x",
+ target_arch = "sparc64",
+ all(target_arch = "aarch64",
+ target_env = "musl")))]
+ __align: [::c_int; 0],
+ #[cfg(not(any(target_arch = "x86_64",
+ target_arch = "powerpc64",
+ target_arch = "mips64",
+ target_arch = "s390x",
+ target_arch = "sparc64",
+ all(target_arch = "aarch64",
+ target_env = "musl"))))]
+ __align: [::c_long; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
+ }
+
+ pub struct pthread_rwlockattr_t {
+ #[cfg(target_env = "musl")]
+ __align: [::c_int; 0],
+ #[cfg(not(target_env = "musl"))]
+ __align: [::c_long; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T],
+ }
+
+ pub struct pthread_condattr_t {
+ __align: [::c_int; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
+ }
+ }
+
+ s_no_extra_traits! {
+ pub struct pthread_cond_t {
+ #[cfg(target_env = "musl")]
+ __align: [*const ::c_void; 0],
+ #[cfg(not(target_env = "musl"))]
+ __align: [::c_longlong; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_COND_T],
+ }
+
+ pub struct pthread_mutex_t {
+ #[cfg(any(target_arch = "mips",
+ target_arch = "arm",
+ target_arch = "powerpc",
+ all(target_arch = "x86_64",
+ target_pointer_width = "32")))]
+ __align: [::c_long; 0],
+ #[cfg(not(any(target_arch = "mips",
+ target_arch = "arm",
+ target_arch = "powerpc",
+ all(target_arch = "x86_64",
+ target_pointer_width = "32"))))]
+ __align: [::c_longlong; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
+ }
+
+ pub struct pthread_rwlock_t {
+ #[cfg(any(target_arch = "mips",
+ target_arch = "arm",
+ target_arch = "powerpc",
+ all(target_arch = "x86_64",
+ target_pointer_width = "32")))]
+ __align: [::c_long; 0],
+ #[cfg(not(any(target_arch = "mips",
+ target_arch = "arm",
+ target_arch = "powerpc",
+ all(target_arch = "x86_64",
+ target_pointer_width = "32"))))]
+ __align: [::c_longlong; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
+ }
+ }
+ }
+}
diff --git a/libc/src/unix/notbsd/linux/other/align.rs b/libc/src/unix/notbsd/linux/other/align.rs
new file mode 100644
index 0000000..4a0e074
--- /dev/null
+++ b/libc/src/unix/notbsd/linux/other/align.rs
@@ -0,0 +1,13 @@
+s! {
+ // FIXME this is actually a union
+ #[cfg_attr(target_pointer_width = "32",
+ repr(align(4)))]
+ #[cfg_attr(target_pointer_width = "64",
+ repr(align(8)))]
+ pub struct sem_t {
+ #[cfg(target_pointer_width = "32")]
+ __size: [::c_char; 16],
+ #[cfg(target_pointer_width = "64")]
+ __size: [::c_char; 32],
+ }
+}
diff --git a/libc/src/unix/notbsd/linux/other/b32/arm.rs b/libc/src/unix/notbsd/linux/other/b32/arm.rs
index a70af43..7f00d9a 100644
--- a/libc/src/unix/notbsd/linux/other/b32/arm.rs
+++ b/libc/src/unix/notbsd/linux/other/b32/arm.rs
@@ -136,9 +136,6 @@ pub const SO_RCVBUFFORCE: ::c_int = 33;
pub const FIOCLEX: ::c_ulong = 0x5451;
pub const FIONBIO: ::c_ulong = 0x5421;
-pub const PTRACE_GETFPXREGS: ::c_uint = 18;
-pub const PTRACE_SETFPXREGS: ::c_uint = 19;
-
pub const MCL_CURRENT: ::c_int = 0x0001;
pub const MCL_FUTURE: ::c_int = 0x0002;
diff --git a/libc/src/unix/notbsd/linux/other/b32/x86.rs b/libc/src/unix/notbsd/linux/other/b32/x86.rs
index 6c41718..e7c3b9a 100644
--- a/libc/src/unix/notbsd/linux/other/b32/x86.rs
+++ b/libc/src/unix/notbsd/linux/other/b32/x86.rs
@@ -31,22 +31,6 @@ s! {
pub st_space: [::c_long; 20],
}
- pub struct user_fpxregs_struct {
- pub cwd: ::c_ushort,
- pub swd: ::c_ushort,
- pub twd: ::c_ushort,
- pub fop: ::c_ushort,
- pub fip: ::c_long,
- pub fcs: ::c_long,
- pub foo: ::c_long,
- pub fos: ::c_long,
- pub mxcsr: ::c_long,
- __reserved: ::c_long,
- pub st_space: [::c_long; 32],
- pub xmm_space: [::c_long; 32],
- padding: [::c_long; 56],
- }
-
pub struct user_regs_struct {
pub ebx: ::c_long,
pub ecx: ::c_long,
@@ -92,15 +76,6 @@ s! {
pub cr2: ::c_ulong,
}
- pub struct ucontext_t {
- pub uc_flags: ::c_ulong,
- pub uc_link: *mut ucontext_t,
- pub uc_stack: ::stack_t,
- pub uc_mcontext: mcontext_t,
- pub uc_sigmask: ::sigset_t,
- __private: [u8; 112],
- }
-
pub struct ipc_perm {
pub __key: ::key_t,
pub uid: ::uid_t,
@@ -213,6 +188,133 @@ s! {
}
}
+s_no_extra_traits!{
+ pub struct user_fpxregs_struct {
+ pub cwd: ::c_ushort,
+ pub swd: ::c_ushort,
+ pub twd: ::c_ushort,
+ pub fop: ::c_ushort,
+ pub fip: ::c_long,
+ pub fcs: ::c_long,
+ pub foo: ::c_long,
+ pub fos: ::c_long,
+ pub mxcsr: ::c_long,
+ __reserved: ::c_long,
+ pub st_space: [::c_long; 32],
+ pub xmm_space: [::c_long; 32],
+ padding: [::c_long; 56],
+ }
+
+ pub struct ucontext_t {
+ pub uc_flags: ::c_ulong,
+ pub uc_link: *mut ucontext_t,
+ pub uc_stack: ::stack_t,
+ pub uc_mcontext: mcontext_t,
+ pub uc_sigmask: ::sigset_t,
+ __private: [u8; 112],
+ __ssp: [::c_ulong; 4],
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for user_fpxregs_struct {
+ fn eq(&self, other: &user_fpxregs_struct) -> bool {
+ self.cwd == other.cwd
+ && self.swd == other.swd
+ && self.twd == other.twd
+ && self.fop == other.fop
+ && self.fip == other.fip
+ && self.fcs == other.fcs
+ && self.foo == other.foo
+ && self.fos == other.fos
+ && self.mxcsr == other.mxcsr
+ // Ignore __reserved field
+ && self.st_space == other.st_space
+ && self.xmm_space == other.xmm_space
+ // Ignore padding field
+ }
+ }
+
+ impl Eq for user_fpxregs_struct {}
+
+ impl ::fmt::Debug for user_fpxregs_struct {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("user_fpxregs_struct")
+ .field("cwd", &self.cwd)
+ .field("swd", &self.swd)
+ .field("twd", &self.twd)
+ .field("fop", &self.fop)
+ .field("fip", &self.fip)
+ .field("fcs", &self.fcs)
+ .field("foo", &self.foo)
+ .field("fos", &self.fos)
+ .field("mxcsr", &self.mxcsr)
+ // Ignore __reserved field
+ .field("st_space", &self.st_space)
+ .field("xmm_space", &self.xmm_space)
+ // Ignore padding field
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for user_fpxregs_struct {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.cwd.hash(state);
+ self.swd.hash(state);
+ self.twd.hash(state);
+ self.fop.hash(state);
+ self.fip.hash(state);
+ self.fcs.hash(state);
+ self.foo.hash(state);
+ self.fos.hash(state);
+ self.mxcsr.hash(state);
+ // Ignore __reserved field
+ self.st_space.hash(state);
+ self.xmm_space.hash(state);
+ // Ignore padding field
+ }
+ }
+
+ impl PartialEq for ucontext_t {
+ fn eq(&self, other: &ucontext_t) -> bool {
+ self.uc_flags == other.uc_flags
+ && self.uc_link == other.uc_link
+ && self.uc_stack == other.uc_stack
+ && self.uc_mcontext == other.uc_mcontext
+ && self.uc_sigmask == other.uc_sigmask
+ // Ignore __private field
+ }
+ }
+
+ impl Eq for ucontext_t {}
+
+ impl ::fmt::Debug for ucontext_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("ucontext_t")
+ .field("uc_flags", &self.uc_flags)
+ .field("uc_link", &self.uc_link)
+ .field("uc_stack", &self.uc_stack)
+ .field("uc_mcontext", &self.uc_mcontext)
+ .field("uc_sigmask", &self.uc_sigmask)
+ // Ignore __private field
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for ucontext_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.uc_flags.hash(state);
+ self.uc_link.hash(state);
+ self.uc_stack.hash(state);
+ self.uc_mcontext.hash(state);
+ self.uc_sigmask.hash(state);
+ // Ignore __private field
+ }
+ }
+ }
+}
+
pub const O_DIRECT: ::c_int = 0x4000;
pub const O_DIRECTORY: ::c_int = 0x10000;
pub const O_NOFOLLOW: ::c_int = 0x20000;
diff --git a/libc/src/unix/notbsd/linux/other/b64/aarch64.rs b/libc/src/unix/notbsd/linux/other/b64/aarch64.rs
index d6e37ff..3bd2e02 100644
--- a/libc/src/unix/notbsd/linux/other/b64/aarch64.rs
+++ b/libc/src/unix/notbsd/linux/other/b64/aarch64.rs
@@ -786,7 +786,6 @@ pub const SYS_rt_tgsigqueueinfo: ::c_long = 240;
pub const SYS_perf_event_open: ::c_long = 241;
pub const SYS_accept4: ::c_long = 242;
pub const SYS_recvmmsg: ::c_long = 243;
-pub const SYS_arch_specific_syscall: ::c_long = 244;
pub const SYS_wait4: ::c_long = 260;
pub const SYS_prlimit64: ::c_long = 261;
pub const SYS_fanotify_init: ::c_long = 262;
@@ -818,7 +817,6 @@ pub const SYS_pwritev2: ::c_long = 287;
pub const SYS_pkey_mprotect: ::c_long = 288;
pub const SYS_pkey_alloc: ::c_long = 289;
pub const SYS_pkey_free: ::c_long = 290;
-pub const SYS_syscalls: ::c_long = 291;
#[link(name = "util")]
extern {
diff --git a/libc/src/unix/notbsd/linux/other/b64/sparc64.rs b/libc/src/unix/notbsd/linux/other/b64/sparc64.rs
index 325c793..5d26865 100644
--- a/libc/src/unix/notbsd/linux/other/b64/sparc64.rs
+++ b/libc/src/unix/notbsd/linux/other/b64/sparc64.rs
@@ -495,7 +495,7 @@ pub const VEOL2: usize = 6;
pub const VMIN: usize = 4;
pub const IEXTEN: ::tcflag_t = 0x8000;
pub const TOSTOP: ::tcflag_t = 0x100;
-pub const FLUSHO: ::tcflag_t = 0x2000;
+pub const FLUSHO: ::tcflag_t = 0x1000;
pub const EXTPROC: ::tcflag_t = 0x10000;
pub const TCGETS: ::c_ulong = 0x40245408;
pub const TCSETS: ::c_ulong = 0x80245409;
diff --git a/libc/src/unix/notbsd/linux/other/b64/x86_64.rs b/libc/src/unix/notbsd/linux/other/b64/x86_64.rs
index 0d7137e..79f27e0 100644
--- a/libc/src/unix/notbsd/linux/other/b64/x86_64.rs
+++ b/libc/src/unix/notbsd/linux/other/b64/x86_64.rs
@@ -112,20 +112,6 @@ s! {
__private: [u64; 12],
}
- pub struct user_fpregs_struct {
- pub cwd: ::c_ushort,
- pub swd: ::c_ushort,
- pub ftw: ::c_ushort,
- pub fop: ::c_ushort,
- pub rip: ::c_ulonglong,
- pub rdp: ::c_ulonglong,
- pub mxcsr: ::c_uint,
- pub mxcr_mask: ::c_uint,
- pub st_space: [::c_uint; 32],
- pub xmm_space: [::c_uint; 64],
- padding: [::c_uint; 24],
- }
-
pub struct user_regs_struct {
pub r15: ::c_ulonglong,
pub r14: ::c_ulonglong,
@@ -184,15 +170,6 @@ s! {
__private: [u64; 8],
}
- pub struct ucontext_t {
- pub uc_flags: ::c_ulong,
- pub uc_link: *mut ucontext_t,
- pub uc_stack: ::stack_t,
- pub uc_mcontext: mcontext_t,
- pub uc_sigmask: ::sigset_t,
- __private: [u8; 512],
- }
-
pub struct ipc_perm {
pub __key: ::key_t,
pub uid: ::uid_t,
@@ -232,6 +209,127 @@ s! {
}
}
+s_no_extra_traits! {
+ pub struct user_fpregs_struct {
+ pub cwd: ::c_ushort,
+ pub swd: ::c_ushort,
+ pub ftw: ::c_ushort,
+ pub fop: ::c_ushort,
+ pub rip: ::c_ulonglong,
+ pub rdp: ::c_ulonglong,
+ pub mxcsr: ::c_uint,
+ pub mxcr_mask: ::c_uint,
+ pub st_space: [::c_uint; 32],
+ pub xmm_space: [::c_uint; 64],
+ padding: [::c_uint; 24],
+ }
+
+ pub struct ucontext_t {
+ pub uc_flags: ::c_ulong,
+ pub uc_link: *mut ucontext_t,
+ pub uc_stack: ::stack_t,
+ pub uc_mcontext: mcontext_t,
+ pub uc_sigmask: ::sigset_t,
+ __private: [u8; 512],
+ __ssp: [::c_ulonglong; 4],
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for user_fpregs_struct {
+ fn eq(&self, other: &user_fpregs_struct) -> bool {
+ self.cwd == other.cwd
+ && self.swd == other.swd
+ && self.ftw == other.ftw
+ && self.fop == other.fop
+ && self.rip == other.rip
+ && self.rdp == other.rdp
+ && self.mxcsr == other.mxcsr
+ && self.mxcr_mask == other.mxcr_mask
+ && self.st_space == other.st_space
+ && self
+ .xmm_space
+ .iter()
+ .zip(other.xmm_space.iter())
+ .all(|(a,b)| a == b)
+ // Ignore padding field
+ }
+ }
+
+ impl Eq for user_fpregs_struct {}
+
+ impl ::fmt::Debug for user_fpregs_struct {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("user_fpregs_struct")
+ .field("cwd", &self.cwd)
+ .field("ftw", &self.ftw)
+ .field("fop", &self.fop)
+ .field("rip", &self.rip)
+ .field("rdp", &self.rdp)
+ .field("mxcsr", &self.mxcsr)
+ .field("mxcr_mask", &self.mxcr_mask)
+ .field("st_space", &self.st_space)
+ // FIXME: .field("xmm_space", &self.xmm_space)
+ // Ignore padding field
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for user_fpregs_struct {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.cwd.hash(state);
+ self.ftw.hash(state);
+ self.fop.hash(state);
+ self.rip.hash(state);
+ self.rdp.hash(state);
+ self.mxcsr.hash(state);
+ self.mxcr_mask.hash(state);
+ self.st_space.hash(state);
+ self.xmm_space.hash(state);
+ // Ignore padding field
+ }
+ }
+
+ impl PartialEq for ucontext_t {
+ fn eq(&self, other: &ucontext_t) -> bool {
+ self.uc_flags == other.uc_flags
+ && self.uc_link == other.uc_link
+ && self.uc_stack == other.uc_stack
+ && self.uc_mcontext == other.uc_mcontext
+ && self.uc_sigmask == other.uc_sigmask
+ // Ignore __private field
+ }
+ }
+
+ impl Eq for ucontext_t {}
+
+ impl ::fmt::Debug for ucontext_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("ucontext_t")
+ .field("uc_flags", &self.uc_flags)
+ .field("uc_link", &self.uc_link)
+ .field("uc_stack", &self.uc_stack)
+ .field("uc_mcontext", &self.uc_mcontext)
+ .field("uc_sigmask", &self.uc_sigmask)
+ // Ignore __private field
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for ucontext_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.uc_flags.hash(state);
+ self.uc_link.hash(state);
+ self.uc_stack.hash(state);
+ self.uc_mcontext.hash(state);
+ self.uc_sigmask.hash(state);
+ // Ignore __private field
+ }
+ }
+ }
+}
+
pub const TIOCGSOFTCAR: ::c_ulong = 0x5419;
pub const TIOCSSOFTCAR: ::c_ulong = 0x541A;
diff --git a/libc/src/unix/notbsd/linux/other/mod.rs b/libc/src/unix/notbsd/linux/other/mod.rs
index c1e3393..1a97d1c 100644
--- a/libc/src/unix/notbsd/linux/other/mod.rs
+++ b/libc/src/unix/notbsd/linux/other/mod.rs
@@ -29,49 +29,13 @@ s! {
pub tv_usec: ::int32_t,
}
- pub struct utmpx {
- pub ut_type: ::c_short,
- pub ut_pid: ::pid_t,
- pub ut_line: [::c_char; __UT_LINESIZE],
- pub ut_id: [::c_char; 4],
-
- pub ut_user: [::c_char; __UT_NAMESIZE],
- pub ut_host: [::c_char; __UT_HOSTSIZE],
- pub ut_exit: __exit_status,
-
- #[cfg(any(target_arch = "aarch64",
- target_arch = "sparc64",
- all(target_pointer_width = "32",
- not(target_arch = "x86_64"))))]
- pub ut_session: ::c_long,
- #[cfg(any(target_arch = "aarch64",
- target_arch = "sparc64",
- all(target_pointer_width = "32",
- not(target_arch = "x86_64"))))]
- pub ut_tv: ::timeval,
-
- #[cfg(not(any(target_arch = "aarch64",
- target_arch = "sparc64",
- all(target_pointer_width = "32",
- not(target_arch = "x86_64")))))]
- pub ut_session: ::int32_t,
- #[cfg(not(any(target_arch = "aarch64",
- target_arch = "sparc64",
- all(target_pointer_width = "32",
- not(target_arch = "x86_64")))))]
- pub ut_tv: __timeval,
-
- pub ut_addr_v6: [::int32_t; 4],
- __glibc_reserved: [::c_char; 20],
- }
-
pub struct sigaction {
pub sa_sigaction: ::sighandler_t,
pub sa_mask: ::sigset_t,
#[cfg(target_arch = "sparc64")]
__reserved0: ::c_int,
pub sa_flags: ::c_int,
- pub sa_restorer: ::dox::Option<extern fn()>,
+ pub sa_restorer: ::Option<extern fn()>,
}
pub struct stack_t {
@@ -84,6 +48,12 @@ s! {
pub si_signo: ::c_int,
pub si_errno: ::c_int,
pub si_code: ::c_int,
+ #[deprecated(
+ since="0.2.54",
+ note="Please leave a comment on \
+ https://github.com/rust-lang/libc/pull/1316 if you're using \
+ this field"
+ )]
pub _pad: [::c_int; 29],
#[cfg(target_arch = "x86_64")]
_align: [u64; 0],
@@ -157,20 +127,6 @@ s! {
pub l_pid: ::pid_t,
}
- // FIXME this is actually a union
- #[cfg_attr(all(feature = "align", target_pointer_width = "32"),
- repr(align(4)))]
- #[cfg_attr(all(feature = "align", target_pointer_width = "64"),
- repr(align(8)))]
- pub struct sem_t {
- #[cfg(target_pointer_width = "32")]
- __size: [::c_char; 16],
- #[cfg(target_pointer_width = "64")]
- __size: [::c_char; 32],
- #[cfg(not(feature = "align"))]
- __align: [::c_long; 0],
- }
-
pub struct mallinfo {
pub arena: ::c_int,
pub ordblks: ::c_int,
@@ -244,6 +200,113 @@ s! {
}
}
+impl siginfo_t {
+ pub unsafe fn si_addr(&self) -> *mut ::c_void {
+ #[repr(C)]
+ struct siginfo_sigfault {
+ _si_signo: ::c_int,
+ _si_errno: ::c_int,
+ _si_code: ::c_int,
+ si_addr: *mut ::c_void
+ }
+ (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr
+ }
+}
+
+s_no_extra_traits! {
+ pub struct utmpx {
+ pub ut_type: ::c_short,
+ pub ut_pid: ::pid_t,
+ pub ut_line: [::c_char; __UT_LINESIZE],
+ pub ut_id: [::c_char; 4],
+
+ pub ut_user: [::c_char; __UT_NAMESIZE],
+ pub ut_host: [::c_char; __UT_HOSTSIZE],
+ pub ut_exit: __exit_status,
+
+ #[cfg(any(target_arch = "aarch64",
+ all(target_pointer_width = "32",
+ not(target_arch = "x86_64"))))]
+ pub ut_session: ::c_long,
+ #[cfg(any(target_arch = "aarch64",
+ all(target_pointer_width = "32",
+ not(target_arch = "x86_64"))))]
+ pub ut_tv: ::timeval,
+
+ #[cfg(not(any(target_arch = "aarch64",
+ all(target_pointer_width = "32",
+ not(target_arch = "x86_64")))))]
+ pub ut_session: ::int32_t,
+ #[cfg(not(any(target_arch = "aarch64",
+ all(target_pointer_width = "32",
+ not(target_arch = "x86_64")))))]
+ pub ut_tv: __timeval,
+
+ pub ut_addr_v6: [::int32_t; 4],
+ __glibc_reserved: [::c_char; 20],
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for utmpx {
+ fn eq(&self, other: &utmpx) -> bool {
+ self.ut_type == other.ut_type
+ && self.ut_pid == other.ut_pid
+ && self.ut_line == other.ut_line
+ && self.ut_id == other.ut_id
+ && self.ut_user == other.ut_user
+ && self
+ .ut_host
+ .iter()
+ .zip(other.ut_host.iter())
+ .all(|(a,b)| a == b)
+ && self.ut_exit == other.ut_exit
+ && self.ut_session == other.ut_session
+ && self.ut_tv == other.ut_tv
+ && self.ut_addr_v6 == other.ut_addr_v6
+ && self.__glibc_reserved == other.__glibc_reserved
+ }
+ }
+
+ impl Eq for utmpx {}
+
+ impl ::fmt::Debug for utmpx {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("utmpx")
+ .field("ut_type", &self.ut_type)
+ .field("ut_pid", &self.ut_pid)
+ .field("ut_line", &self.ut_line)
+ .field("ut_id", &self.ut_id)
+ .field("ut_user", &self.ut_user)
+ // FIXME: .field("ut_host", &self.ut_host)
+ .field("ut_exit", &self.ut_exit)
+ .field("ut_session", &self.ut_session)
+ .field("ut_tv", &self.ut_tv)
+ .field("ut_addr_v6", &self.ut_addr_v6)
+ .field("__glibc_reserved", &self.__glibc_reserved)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for utmpx {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.ut_type.hash(state);
+ self.ut_pid.hash(state);
+ self.ut_line.hash(state);
+ self.ut_id.hash(state);
+ self.ut_user.hash(state);
+ self.ut_host.hash(state);
+ self.ut_exit.hash(state);
+ self.ut_session.hash(state);
+ self.ut_tv.hash(state);
+ self.ut_addr_v6.hash(state);
+ self.__glibc_reserved.hash(state);
+ }
+ }
+ }
+}
+
pub const __UT_LINESIZE: usize = 32;
pub const __UT_NAMESIZE: usize = 32;
pub const __UT_HOSTSIZE: usize = 256;
@@ -273,7 +336,6 @@ pub const SOL_PNPIPE: ::c_int = 275;
pub const SOL_RDS: ::c_int = 276;
pub const SOL_IUCV: ::c_int = 277;
pub const SOL_CAIF: ::c_int = 278;
-pub const SOL_ALG: ::c_int = 279;
pub const SOL_NFC: ::c_int = 280;
pub const SOL_XDP: ::c_int = 283;
@@ -622,24 +684,10 @@ pub const NFPROTO_INET: ::c_int = 1;
pub const NFPROTO_NETDEV: ::c_int = 5;
// linux/netfilter/nf_tables.h
-cfg_if!{
- if #[cfg(any(target_arch = "arm", target_arch = "powerpc",
- target_arch = "powerpc64", target_arch = "aarch64"))] {
- pub const NFT_TABLE_MAXNAMELEN: ::c_int = 32;
- pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 32;
- pub const NFT_SET_MAXNAMELEN: ::c_int = 32;
- pub const NFT_OBJ_MAXNAMELEN: ::c_int = 32;
- } else if #[cfg(target_arch = "sparc64")] {
- pub const NFT_TABLE_MAXNAMELEN: ::c_int = 32;
- pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 32;
- pub const NFT_SET_MAXNAMELEN: ::c_int = 32;
- } else {
- pub const NFT_TABLE_MAXNAMELEN: ::c_int = 256;
- pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 256;
- pub const NFT_SET_MAXNAMELEN: ::c_int = 256;
- pub const NFT_OBJ_MAXNAMELEN: ::c_int = 256;
- }
-}
+pub const NFT_TABLE_MAXNAMELEN: ::c_int = 256;
+pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 256;
+pub const NFT_SET_MAXNAMELEN: ::c_int = 256;
+pub const NFT_OBJ_MAXNAMELEN: ::c_int = 256;
pub const NFT_USERDATA_MAXLEN: ::c_int = 256;
pub const NFT_REG_VERDICT: ::c_int = 0;
@@ -698,11 +746,9 @@ cfg_if! {
pub const NFT_MSG_GETOBJ: ::c_int = 19;
pub const NFT_MSG_DELOBJ: ::c_int = 20;
pub const NFT_MSG_GETOBJ_RESET: ::c_int = 21;
- pub const NFT_MSG_MAX: ::c_int = 22;
- } else {
- pub const NFT_MSG_MAX: ::c_int = 18;
}
}
+pub const NFT_MSG_MAX: ::c_int = 25;
pub const NFT_SET_ANONYMOUS: ::c_int = 0x1;
pub const NFT_SET_CONSTANT: ::c_int = 0x2;
@@ -879,7 +925,7 @@ extern {
sz: ::c_int) -> ::c_int;
pub fn glob64(pattern: *const ::c_char,
flags: ::c_int,
- errfunc: ::dox::Option<extern fn(epath: *const ::c_char,
+ errfunc: ::Option<extern fn(epath: *const ::c_char,
errno: ::c_int)
-> ::c_int>,
pglob: *mut glob64_t) -> ::c_int;
@@ -939,3 +985,13 @@ cfg_if! {
// Unknown target_arch
}
}
+
+cfg_if! {
+ if #[cfg(libc_align)] {
+ mod align;
+ pub use self::align::*;
+ } else {
+ mod no_align;
+ pub use self::no_align::*;
+ }
+}
diff --git a/libc/src/unix/notbsd/linux/other/no_align.rs b/libc/src/unix/notbsd/linux/other/no_align.rs
new file mode 100644
index 0000000..e32bf67
--- /dev/null
+++ b/libc/src/unix/notbsd/linux/other/no_align.rs
@@ -0,0 +1,10 @@
+s! {
+ // FIXME this is actually a union
+ pub struct sem_t {
+ #[cfg(target_pointer_width = "32")]
+ __size: [::c_char; 16],
+ #[cfg(target_pointer_width = "64")]
+ __size: [::c_char; 32],
+ __align: [::c_long; 0],
+ }
+}
diff --git a/libc/src/unix/notbsd/linux/s390x/align.rs b/libc/src/unix/notbsd/linux/s390x/align.rs
new file mode 100644
index 0000000..21e2190
--- /dev/null
+++ b/libc/src/unix/notbsd/linux/s390x/align.rs
@@ -0,0 +1,10 @@
+s! {
+ // FIXME this is actually a union
+ #[cfg_attr(target_pointer_width = "32",
+ repr(align(4)))]
+ #[cfg_attr(target_pointer_width = "64",
+ repr(align(8)))]
+ pub struct sem_t {
+ __size: [::c_char; 32],
+ }
+}
diff --git a/libc/src/unix/notbsd/linux/s390x.rs b/libc/src/unix/notbsd/linux/s390x/mod.rs
index 9e3814f..d4cf956 100644
--- a/libc/src/unix/notbsd/linux/s390x.rs
+++ b/libc/src/unix/notbsd/linux/s390x/mod.rs
@@ -1,4 +1,4 @@
-use pthread_mutex_t;
+use ::pthread_mutex_t;
pub type blkcnt_t = i64;
pub type blksize_t = i64;
@@ -92,7 +92,7 @@ s! {
pub sa_sigaction: ::sighandler_t,
__glibc_reserved0: ::c_int,
pub sa_flags: ::c_int,
- pub sa_restorer: ::dox::Option<extern fn()>,
+ pub sa_restorer: ::Option<extern fn()>,
pub sa_mask: sigset_t,
}
@@ -246,28 +246,11 @@ s! {
pub l_pid: ::pid_t,
}
- // FIXME this is actually a union
- #[cfg_attr(all(feature = "align", target_pointer_width = "32"),
- repr(align(4)))]
- #[cfg_attr(all(feature = "align", target_pointer_width = "64"),
- repr(align(8)))]
- pub struct sem_t {
- __size: [::c_char; 32],
- #[cfg(not(feature = "align"))]
- __align: [::c_long; 0],
- }
-
pub struct __psw_t {
pub mask: u64,
pub addr: u64,
}
- // FIXME: This is actually a union.
- pub struct fpreg_t {
- pub d: ::c_double,
- // f: ::c_float,
- }
-
pub struct fpregset_t {
pub fpc: u32,
__pad: u32,
@@ -334,6 +317,41 @@ s! {
}
}
+s_no_extra_traits!{
+ // FIXME: This is actually a union.
+ pub struct fpreg_t {
+ pub d: ::c_double,
+ // f: ::c_float,
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for fpreg_t {
+ fn eq(&self, other: &fpreg_t) -> bool {
+ self.d == other.d
+ }
+ }
+
+ impl Eq for fpreg_t {}
+
+ impl ::fmt::Debug for fpreg_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("fpreg_t")
+ .field("d", &self.d)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for fpreg_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ let d: u64 = unsafe { ::mem::transmute(self.d) };
+ d.hash(state);
+ }
+ }
+ }
+}
+
pub const SFD_CLOEXEC: ::c_int = 0x080000;
pub const NCCS: usize = 32;
@@ -764,10 +782,6 @@ pub const PTRACE_POKEUSER: ::c_uint = 6;
pub const PTRACE_CONT: ::c_uint = 7;
pub const PTRACE_KILL: ::c_uint = 8;
pub const PTRACE_SINGLESTEP: ::c_uint = 9;
-pub const PTRACE_GETREGS: ::c_uint = 12;
-pub const PTRACE_SETREGS: ::c_uint = 13;
-pub const PTRACE_GETFPREGS: ::c_uint = 14;
-pub const PTRACE_SETFPREGS: ::c_uint = 15;
pub const PTRACE_ATTACH: ::c_uint = 16;
pub const PTRACE_DETACH: ::c_uint = 17;
pub const PTRACE_SYSCALL: ::c_uint = 24;
@@ -1304,7 +1318,7 @@ extern {
sz: ::c_int) -> ::c_int;
pub fn glob64(pattern: *const ::c_char,
flags: ::c_int,
- errfunc: ::dox::Option<extern fn(epath: *const ::c_char,
+ errfunc: ::Option<extern fn(epath: *const ::c_char,
errno: ::c_int)
-> ::c_int>,
pglob: *mut glob64_t) -> ::c_int;
@@ -1334,3 +1348,13 @@ extern {
pub fn swapcontext(uocp: *mut ucontext_t,
ucp: *const ucontext_t) -> ::c_int;
}
+
+cfg_if! {
+ if #[cfg(libc_align)] {
+ mod align;
+ pub use self::align::*;
+ } else {
+ mod no_align;
+ pub use self::no_align::*;
+ }
+}
diff --git a/libc/src/unix/notbsd/linux/s390x/no_align.rs b/libc/src/unix/notbsd/linux/s390x/no_align.rs
new file mode 100644
index 0000000..8909114
--- /dev/null
+++ b/libc/src/unix/notbsd/linux/s390x/no_align.rs
@@ -0,0 +1,7 @@
+s! {
+ // FIXME this is actually a union
+ pub struct sem_t {
+ __size: [::c_char; 32],
+ __align: [::c_long; 0],
+ }
+}
diff --git a/libc/src/unix/notbsd/mod.rs b/libc/src/unix/notbsd/mod.rs
index 668c25f..d0905e1 100644
--- a/libc/src/unix/notbsd/mod.rs
+++ b/libc/src/unix/notbsd/mod.rs
@@ -1,5 +1,3 @@
-use dox::mem;
-
pub type sa_family_t = u16;
pub type pthread_key_t = ::c_uint;
pub type speed_t = ::c_uint;
@@ -8,9 +6,23 @@ pub type clockid_t = ::c_int;
pub type key_t = ::c_int;
pub type id_t = ::c_uint;
+#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum timezone {}
+impl ::Copy for timezone {}
+impl ::Clone for timezone {
+ fn clone(&self) -> timezone { *self }
+}
s! {
+ pub struct in_addr {
+ pub s_addr: ::in_addr_t,
+ }
+
+ pub struct ip_mreq {
+ pub imr_multiaddr: in_addr,
+ pub imr_interface: in_addr,
+ }
+
pub struct sockaddr {
pub sa_family: sa_family_t,
pub sa_data: [::c_char; 14],
@@ -31,20 +43,6 @@ s! {
pub sin6_scope_id: u32,
}
- pub struct sockaddr_un {
- pub sun_family: sa_family_t,
- pub sun_path: [::c_char; 108]
- }
-
- pub struct sockaddr_storage {
- pub ss_family: sa_family_t,
- __ss_align: ::size_t,
- #[cfg(target_pointer_width = "32")]
- __ss_pad2: [u8; 128 - 2 * 4],
- #[cfg(target_pointer_width = "64")]
- __ss_pad2: [u8; 128 - 2 * 8],
- }
-
pub struct addrinfo {
pub ai_flags: ::c_int,
pub ai_family: ::c_int,
@@ -118,25 +116,6 @@ s! {
pub dli_saddr: *mut ::c_void,
}
- #[cfg_attr(any(all(target_arch = "x86",
- not(target_env = "musl"),
- not(target_os = "android")),
- target_arch = "x86_64"),
- repr(packed))]
- pub struct epoll_event {
- pub events: ::uint32_t,
- pub u64: ::uint64_t,
- }
-
- pub struct utsname {
- pub sysname: [::c_char; 65],
- pub nodename: [::c_char; 65],
- pub release: [::c_char; 65],
- pub version: [::c_char; 65],
- pub machine: [::c_char; 65],
- pub domainname: [::c_char; 65]
- }
-
pub struct lconv {
pub decimal_point: *mut ::c_char,
pub thousands_sep: *mut ::c_char,
@@ -228,6 +207,195 @@ s! {
pub ar_pln: u8,
pub ar_op: u16,
}
+
+ pub struct mmsghdr {
+ pub msg_hdr: ::msghdr,
+ pub msg_len: ::c_uint,
+ }
+}
+
+s_no_extra_traits!{
+ #[cfg_attr(
+ any(
+ all(
+ target_arch = "x86",
+ not(target_env = "musl"),
+ not(target_os = "android")),
+ target_arch = "x86_64"),
+ repr(packed))]
+ pub struct epoll_event {
+ pub events: ::uint32_t,
+ pub u64: ::uint64_t,
+ }
+
+ pub struct sockaddr_un {
+ pub sun_family: sa_family_t,
+ pub sun_path: [::c_char; 108]
+ }
+
+ pub struct sockaddr_storage {
+ pub ss_family: sa_family_t,
+ __ss_align: ::size_t,
+ #[cfg(target_pointer_width = "32")]
+ __ss_pad2: [u8; 128 - 2 * 4],
+ #[cfg(target_pointer_width = "64")]
+ __ss_pad2: [u8; 128 - 2 * 8],
+ }
+
+ pub struct utsname {
+ pub sysname: [::c_char; 65],
+ pub nodename: [::c_char; 65],
+ pub release: [::c_char; 65],
+ pub version: [::c_char; 65],
+ pub machine: [::c_char; 65],
+ pub domainname: [::c_char; 65]
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for epoll_event {
+ fn eq(&self, other: &epoll_event) -> bool {
+ self.events == other.events
+ && self.u64 == other.u64
+ }
+ }
+ impl Eq for epoll_event {}
+ impl ::fmt::Debug for epoll_event {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ let events = self.events;
+ let u64 = self.u64;
+ f.debug_struct("epoll_event")
+ .field("events", &events)
+ .field("u64", &u64)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for epoll_event {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ let events = self.events;
+ let u64 = self.u64;
+ events.hash(state);
+ u64.hash(state);
+ }
+ }
+
+ impl PartialEq for sockaddr_un {
+ fn eq(&self, other: &sockaddr_un) -> bool {
+ self.sun_family == other.sun_family
+ && self
+ .sun_path
+ .iter()
+ .zip(other.sun_path.iter())
+ .all(|(a, b)| a == b)
+ }
+ }
+ impl Eq for sockaddr_un {}
+ impl ::fmt::Debug for sockaddr_un {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("sockaddr_un")
+ .field("sun_family", &self.sun_family)
+ // FIXME: .field("sun_path", &self.sun_path)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for sockaddr_un {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.sun_family.hash(state);
+ self.sun_path.hash(state);
+ }
+ }
+
+ impl PartialEq for sockaddr_storage {
+ fn eq(&self, other: &sockaddr_storage) -> bool {
+ self.ss_family == other.ss_family
+ && self
+ .__ss_pad2
+ .iter()
+ .zip(other.__ss_pad2.iter())
+ .all(|(a, b)| a == b)
+ }
+ }
+
+ impl Eq for sockaddr_storage {}
+
+ impl ::fmt::Debug for sockaddr_storage {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("sockaddr_storage")
+ .field("ss_family", &self.ss_family)
+ .field("__ss_align", &self.__ss_align)
+ // FIXME: .field("__ss_pad2", &self.__ss_pad2)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for sockaddr_storage {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.ss_family.hash(state);
+ self.__ss_pad2.hash(state);
+ }
+ }
+
+ impl PartialEq for utsname {
+ fn eq(&self, other: &utsname) -> bool {
+ self.sysname
+ .iter()
+ .zip(other.sysname.iter())
+ .all(|(a, b)| a == b)
+ && self
+ .nodename
+ .iter()
+ .zip(other.nodename.iter())
+ .all(|(a, b)| a == b)
+ && self
+ .release
+ .iter()
+ .zip(other.release.iter())
+ .all(|(a, b)| a == b)
+ && self
+ .version
+ .iter()
+ .zip(other.version.iter())
+ .all(|(a, b)| a == b)
+ && self
+ .machine
+ .iter()
+ .zip(other.machine.iter())
+ .all(|(a, b)| a == b)
+ && self
+ .domainname
+ .iter()
+ .zip(other.domainname.iter())
+ .all(|(a, b)| a == b)
+ }
+ }
+
+ impl Eq for utsname {}
+
+ impl ::fmt::Debug for utsname {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("utsname")
+ // FIXME: .field("sysname", &self.sysname)
+ // FIXME: .field("nodename", &self.nodename)
+ // FIXME: .field("release", &self.release)
+ // FIXME: .field("version", &self.version)
+ // FIXME: .field("machine", &self.machine)
+ // FIXME: .field("domainname", &self.domainname)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for utsname {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.sysname.hash(state);
+ self.nodename.hash(state);
+ self.release.hash(state);
+ self.version.hash(state);
+ self.machine.hash(state);
+ self.domainname.hash(state);
+ }
+ }
+ }
}
// intentionally not public, only used for fd_set
@@ -514,6 +682,7 @@ pub const SOL_DCCP: ::c_int = 269;
pub const SOL_NETLINK: ::c_int = 270;
pub const SOL_TIPC: ::c_int = 271;
pub const SOL_BLUETOOTH: ::c_int = 274;
+pub const SOL_ALG: ::c_int = 279;
pub const AF_UNSPEC: ::c_int = 0;
pub const AF_UNIX: ::c_int = 1;
@@ -985,60 +1154,48 @@ pub const ARPHRD_IEEE802154: u16 = 804;
pub const ARPHRD_VOID: u16 = 0xFFFF;
pub const ARPHRD_NONE: u16 = 0xFFFE;
+fn CMSG_ALIGN(len: usize) -> usize {
+ len + ::mem::size_of::<usize>() - 1 & !(::mem::size_of::<usize>() - 1)
+}
+
f! {
pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr {
- if (*mhdr).msg_controllen as usize >= mem::size_of::<cmsghdr>() {
+ if (*mhdr).msg_controllen as usize >= ::mem::size_of::<cmsghdr>() {
(*mhdr).msg_control as *mut cmsghdr
} else {
0 as *mut cmsghdr
}
}
- pub fn CMSG_NXTHDR(mhdr: *const msghdr,
- cmsg: *const cmsghdr) -> *mut cmsghdr {
- if cmsg.is_null() {
- return CMSG_FIRSTHDR(mhdr);
- };
- let pad = mem::align_of::<cmsghdr>() - 1;
- let next = cmsg as usize + (*cmsg).cmsg_len as usize + pad & !pad;
- let max = (*mhdr).msg_control as usize
- + (*mhdr).msg_controllen as usize;
- if next < max {
- next as *mut cmsghdr
- } else {
- 0 as *mut cmsghdr
- }
- }
-
pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut ::c_uchar {
cmsg.offset(1) as *mut ::c_uchar
}
pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
- let pad = mem::align_of::<cmsghdr>() as ::c_uint - 1;
- mem::size_of::<cmsghdr>() as ::c_uint + ((length + pad) & !pad)
+ (CMSG_ALIGN(length as usize) + CMSG_ALIGN(::mem::size_of::<cmsghdr>()))
+ as ::c_uint
}
pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
- mem::size_of::<cmsghdr>() as ::c_uint + length
+ CMSG_ALIGN(::mem::size_of::<cmsghdr>()) as ::c_uint + length
}
pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
let fd = fd as usize;
- let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
+ let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
(*set).fds_bits[fd / size] &= !(1 << (fd % size));
return
}
pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
let fd = fd as usize;
- let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
+ let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0
}
pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
let fd = fd as usize;
- let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
+ let size = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
(*set).fds_bits[fd / size] |= 1 << (fd % size);
return
}
@@ -1103,6 +1260,12 @@ f! {
}
extern {
+ pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
+ pub fn sem_init(sem: *mut sem_t,
+ pshared: ::c_int,
+ value: ::c_uint)
+ -> ::c_int;
+
pub fn fdatasync(fd: ::c_int) -> ::c_int;
pub fn mincore(addr: *mut ::c_void, len: ::size_t,
vec: *mut ::c_uchar) -> ::c_int;
@@ -1220,6 +1383,11 @@ extern {
name: *mut ::c_char,
termp: *const termios,
winp: *const ::winsize) -> ::c_int;
+ pub fn forkpty(amaster: *mut ::c_int,
+ name: *mut ::c_char,
+ termp: *const termios,
+ winp: *const ::winsize) -> ::pid_t;
+ pub fn login_tty(fd: ::c_int) -> ::c_int;
pub fn execvpe(file: *const ::c_char, argv: *const *const ::c_char,
envp: *const *const ::c_char) -> ::c_int;
pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char,
@@ -1259,7 +1427,3 @@ cfg_if! {
// Unknown target_os
}
}
- // pub fn forkpty(amaster: *mut ::c_int,
- // name: *mut ::c_char,
- // termp: *const termios,
- // winp: *const ::winsize) -> ::pid_t;