aboutsummaryrefslogtreecommitdiff
path: root/libc/src/fuchsia
diff options
context:
space:
mode:
Diffstat (limited to 'libc/src/fuchsia')
-rw-r--r--libc/src/fuchsia/align.rs142
-rw-r--r--libc/src/fuchsia/mod.rs549
-rw-r--r--libc/src/fuchsia/no_align.rs129
-rw-r--r--libc/src/fuchsia/x86_64.rs62
4 files changed, 682 insertions, 200 deletions
diff --git a/libc/src/fuchsia/align.rs b/libc/src/fuchsia/align.rs
new file mode 100644
index 0000000..bc97275
--- /dev/null
+++ b/libc/src/fuchsia/align.rs
@@ -0,0 +1,142 @@
+macro_rules! expand_align {
+ () => {
+ s! {
+ #[cfg_attr(
+ any(
+ target_pointer_width = "32",
+ target_arch = "x86_64"
+ ),
+ repr(align(4)))]
+ #[cfg_attr(
+ not(any(
+ target_pointer_width = "32",
+ target_arch = "x86_64"
+ )),
+ repr(align(8)))]
+ pub struct pthread_mutexattr_t {
+ size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
+ }
+
+ #[cfg_attr(target_pointer_width = "32",
+ repr(align(4)))]
+ #[cfg_attr(target_pointer_width = "64",
+ repr(align(8)))]
+ 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(all(target_pointer_width = "32",
+ any(target_arch = "arm",
+ target_arch = "x86_64")),
+ repr(align(4)))]
+ #[cfg_attr(any(target_pointer_width = "64",
+ not(any(target_arch = "arm",
+ target_arch = "x86_64"))),
+ repr(align(8)))]
+ pub struct pthread_mutex_t {
+ size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
+ }
+
+ #[cfg_attr(all(target_pointer_width = "32",
+ any(target_arch = "arm",
+ target_arch = "x86_64")),
+ repr(align(4)))]
+ #[cfg_attr(any(target_pointer_width = "64",
+ not(any(target_arch = "arm",
+ target_arch = "x86_64"))),
+ repr(align(8)))]
+ pub struct pthread_rwlock_t {
+ size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
+ }
+
+ #[cfg_attr(target_pointer_width = "32",
+ repr(align(4)))]
+ #[cfg_attr(target_pointer_width = "64",
+ repr(align(8)))]
+ #[cfg_attr(target_arch = "x86",
+ repr(align(4)))]
+ #[cfg_attr(not(target_arch = "x86"),
+ 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);
+ }
+ }
+
+ 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);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/libc/src/fuchsia/mod.rs b/libc/src/fuchsia/mod.rs
index e785fab..cef48e5 100644
--- a/libc/src/fuchsia/mod.rs
+++ b/libc/src/fuchsia/mod.rs
@@ -3,8 +3,6 @@
//! More functions and definitions can be found in the more specific modules
//! according to the platform in question.
-use dox::{mem, Option};
-
// PUB_TYPE
pub type int8_t = i8;
@@ -100,10 +98,30 @@ pub type c_ulong = u64;
// FIXME: why are these uninhabited types? that seems... wrong?
// Presumably these should be `()` or an `extern type` (when that stabilizes).
+#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum timezone {}
+impl ::Copy for timezone {}
+impl ::Clone for timezone {
+ fn clone(&self) -> timezone { *self }
+}
+#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum DIR {}
+impl ::Copy for DIR {}
+impl ::Clone for DIR {
+ fn clone(&self) -> DIR { *self }
+}
+#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum locale_t {}
+impl ::Copy for locale_t {}
+impl ::Clone for locale_t {
+ fn clone(&self) -> locale_t { *self }
+}
+#[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 }
+}
// PUB_STRUCT
@@ -182,9 +200,6 @@ s! {
pub ru_nivcsw: c_long,
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
__pad14: u32,
-
- #[cfg(any(target_env = "musl", target_os = "emscripten"))]
- __reserved: [c_long; 16],
}
pub struct in_addr {
@@ -292,7 +307,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 termios {
@@ -314,23 +329,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 ucred {
pub pid: ::pid_t,
pub uid: ::uid_t,
@@ -357,17 +355,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,
- __ss_pad2: [u8; 128 - 2 * 8],
- }
-
pub struct addrinfo {
pub ai_flags: ::c_int,
pub ai_family: ::c_int,
@@ -437,15 +424,6 @@ s! {
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,
@@ -482,22 +460,6 @@ s! {
pub __pad: [::c_char; 56 - 3 * 8 /* 8 == sizeof(long) */],
}
- 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,
@@ -526,122 +488,6 @@ s! {
pub ifa_data: *mut ::c_void
}
- #[cfg_attr(all(feature = "align",
- target_pointer_width = "32",
- any(target_arch = "arm",
- target_arch = "x86_64")),
- repr(align(4)))]
- #[cfg_attr(all(feature = "align",
- any(target_pointer_width = "64",
- not(any(target_arch = "arm",
- target_arch = "x86_64")))),
- repr(align(8)))]
- pub struct pthread_mutex_t {
- #[cfg(all(not(feature = "align"),
- any(target_arch = "arm",
- all(target_arch = "x86_64",
- target_pointer_width = "32"))))]
- __align: [::c_long; 0],
- #[cfg(not(any(feature = "align",
- target_arch = "arm",
- 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 = "arm",
- target_arch = "x86_64")),
- repr(align(4)))]
- #[cfg_attr(all(feature = "align",
- any(target_pointer_width = "64",
- not(any(target_arch = "arm",
- target_arch = "x86_64")))),
- repr(align(8)))]
- pub struct pthread_rwlock_t {
- #[cfg(all(not(feature = "align"),
- any(target_arch = "arm",
- all(target_arch = "x86_64",
- target_pointer_width = "32"))))]
- __align: [::c_long; 0],
- #[cfg(not(any(feature = "align",
- target_arch = "arm",
- 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",
- 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",
- 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",
- all(target_arch = "aarch64", target_env = "musl"))))]
- __align: [::c_int; 0],
- #[cfg(all(not(features = "align"),
- not(any(target_arch = "x86_64",
- 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,
@@ -1075,6 +921,302 @@ s! {
}
}
+s_no_extra_traits! {
+ 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 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,
+ __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]
+ }
+
+ 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],
+ }
+}
+
+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);
+ }
+ }
+
+ 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_align == other.__ss_align
+ && 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_align.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)
+ }
+ }
+ 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)
+ .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);
+ }
+ }
+
+ 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);
+ }
+ }
+ }
+}
+
// PUB_CONST
pub const INT_MIN: c_int = -2147483648;
@@ -1701,7 +1843,7 @@ pub const WEXITED: ::c_int = 0x00000004;
pub const WCONTINUED: ::c_int = 0x00000008;
pub const WNOWAIT: ::c_int = 0x01000000;
-// Options set using PTRACE_SETOPTIONS.
+// ::Options set using PTRACE_SETOPTIONS.
pub const PTRACE_O_TRACESYSGOOD: ::c_int = 0x00000001;
pub const PTRACE_O_TRACEFORK: ::c_int = 0x00000002;
pub const PTRACE_O_TRACEVFORK: ::c_int = 0x00000004;
@@ -2920,20 +3062,20 @@ cfg_if! {
f! {
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
}
@@ -2987,21 +3129,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))
}
@@ -3042,8 +3186,18 @@ f! {
#[link(name = "fdio")]
extern {}
+#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum FILE {}
+impl ::Copy for FILE {}
+impl ::Clone for FILE {
+ fn clone(&self) -> FILE { *self }
+}
+#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum fpos_t {} // TODO: fill this out with a struct
+impl ::Copy for fpos_t {}
+impl ::Clone for fpos_t {
+ fn clone(&self) -> fpos_t { *self }
+}
extern {
pub fn isalnum(c: c_int) -> c_int;
@@ -3371,7 +3525,7 @@ extern {
pub fn pthread_detach(thread: ::pthread_t) -> ::c_int;
pub fn sched_yield() -> ::c_int;
pub fn pthread_key_create(key: *mut pthread_key_t,
- dtor: Option<unsafe extern fn(*mut ::c_void)>)
+ dtor: ::Option<unsafe extern fn(*mut ::c_void)>)
-> ::c_int;
pub fn pthread_key_delete(key: pthread_key_t) -> ::c_int;
pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void;
@@ -3876,7 +4030,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);
@@ -4014,7 +4168,7 @@ extern {
offset: *mut off_t,
count: ::size_t) -> ::ssize_t;
pub fn sigsuspend(mask: *const ::sigset_t) -> ::c_int;
- pub fn getgrgid_r(uid: ::uid_t,
+ pub fn getgrgid_r(gid: ::gid_t,
grp: *mut ::group,
buf: *mut ::c_char,
buflen: ::size_t,
@@ -4049,9 +4203,9 @@ extern {
result: *mut *mut passwd) -> ::c_int;
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,
@@ -4068,7 +4222,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
@@ -4090,13 +4244,26 @@ cfg_if! {
}
cfg_if! {
- if #[cfg(core_cvoid)] {
- pub use core::ffi::c_void;
+ if #[cfg(libc_align)] {
+ #[macro_use]
+ mod align;
+ } else {
+ #[macro_use]
+ mod no_align;
+ }
+}
+expand_align!();
+
+cfg_if! {
+ if #[cfg(libc_core_cvoid)] {
+ pub use ::ffi::c_void;
} else {
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help
// enable more optimization opportunities around it recognizing things
// like malloc/free.
#[repr(u8)]
+ #[allow(missing_copy_implementations)]
+ #[allow(missing_debug_implementations)]
pub enum c_void {
// Two dummy variants so the #[repr] attribute can be used.
#[doc(hidden)]
diff --git a/libc/src/fuchsia/no_align.rs b/libc/src/fuchsia/no_align.rs
new file mode 100644
index 0000000..437da97
--- /dev/null
+++ b/libc/src/fuchsia/no_align.rs
@@ -0,0 +1,129 @@
+macro_rules! expand_align {
+ () => {
+ s! {
+ pub struct pthread_mutexattr_t {
+ #[cfg(target_arch = "x86_64")]
+ __align: [::c_int; 0],
+ #[cfg(not(target_arch = "x86_64"))]
+ __align: [::c_long; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
+ }
+
+ pub struct pthread_rwlockattr_t {
+ __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_mutex_t {
+ #[cfg(any(target_arch = "arm",
+ all(target_arch = "x86_64",
+ target_pointer_width = "32")))]
+ __align: [::c_long; 0],
+ #[cfg(not(any(target_arch = "arm",
+ all(target_arch = "x86_64",
+ target_pointer_width = "32"))))]
+ __align: [::c_longlong; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
+ }
+
+ pub struct pthread_rwlock_t {
+ __align: [::c_long; 0],
+ __align: [::c_longlong; 0],
+ size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
+ }
+
+ pub struct pthread_cond_t {
+ __align: [*const ::c_void; 0],
+ #[cfg(not(target_env = "musl"))]
+ __align: [::c_longlong; 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 {
+ // Ignore __align field
+ 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")
+ // Ignore __align field
+ // FIXME: .field("size", &self.size)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for pthread_cond_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ // Ignore __align field
+ self.size.hash(state);
+ }
+ }
+
+ impl PartialEq for pthread_mutex_t {
+ fn eq(&self, other: &pthread_mutex_t) -> bool {
+ // Ignore __align field
+ 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")
+ // Ignore __align field
+ // FIXME: .field("size", &self.size)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for pthread_mutex_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ // Ignore __align field
+ self.size.hash(state);
+ }
+ }
+
+ impl PartialEq for pthread_rwlock_t {
+ fn eq(&self, other: &pthread_rwlock_t) -> bool {
+ // Ignore __align field
+ 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")
+ // Ignore __align field
+ // FIXME: .field("size", &self.size)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for pthread_rwlock_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ // Ignore __align field
+ self.size.hash(state);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/libc/src/fuchsia/x86_64.rs b/libc/src/fuchsia/x86_64.rs
index 2e4eccc..eb22099 100644
--- a/libc/src/fuchsia/x86_64.rs
+++ b/libc/src/fuchsia/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,59 @@ 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)
+ // FIXME: .field("__private", &self.__private)
+ .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;