Skip to content

Commit 9769c03

Browse files
committed
Add extra traits for fuchsia datatypes
1 parent a12c383 commit 9769c03

File tree

4 files changed

+445
-13
lines changed

4 files changed

+445
-13
lines changed

src/fuchsia/align.rs

+69-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ macro_rules! expand_align {
3232
}
3333

3434
s_no_extra_traits! {
35-
#[allow(missing_debug_implementations)]
3635
#[cfg_attr(all(target_pointer_width = "32",
3736
any(target_arch = "arm",
3837
target_arch = "x86_64")),
@@ -45,7 +44,6 @@ macro_rules! expand_align {
4544
size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
4645
}
4746

48-
#[allow(missing_debug_implementations)]
4947
#[cfg_attr(all(target_pointer_width = "32",
5048
any(target_arch = "arm",
5149
target_arch = "x86_64")),
@@ -58,7 +56,6 @@ macro_rules! expand_align {
5856
size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
5957
}
6058

61-
#[allow(missing_debug_implementations)]
6259
#[cfg_attr(target_pointer_width = "32",
6360
repr(align(4)))]
6461
#[cfg_attr(target_pointer_width = "64",
@@ -71,5 +68,74 @@ macro_rules! expand_align {
7168
size: [u8; ::__SIZEOF_PTHREAD_COND_T],
7269
}
7370
}
71+
72+
cfg_if! {
73+
if #[cfg(feature = "extra_traits")] {
74+
impl PartialEq for pthread_cond_t {
75+
fn eq(&self, other: &pthread_cond_t) -> bool {
76+
self.size
77+
.iter()
78+
.zip(other.size.iter())
79+
.all(|(a,b)| a == b)
80+
}
81+
}
82+
impl Eq for pthread_cond_t {}
83+
impl ::fmt::Debug for pthread_cond_t {
84+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
85+
// FIXME: .field("size", &self.size)
86+
.finish()
87+
}
88+
}
89+
impl ::hash::Hash for pthread_cond_t {
90+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
91+
self.size.hash(state);
92+
}
93+
}
94+
95+
impl PartialEq for pthread_mutex_t {
96+
fn eq(&self, other: &pthread_mutex_t) -> bool {
97+
self.size
98+
.iter()
99+
.zip(other.size.iter())
100+
.all(|(a,b)| a == b)
101+
}
102+
}
103+
impl Eq for pthread_mutex_t {}
104+
impl ::fmt::Debug for pthread_mutex_t {
105+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
106+
f.debug_struct("pthread_mutex_t")
107+
// FIXME: .field("size", &self.size)
108+
.finish()
109+
}
110+
}
111+
impl ::hash::Hash for pthread_mutex_t {
112+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
113+
self.size.hash(state);
114+
}
115+
}
116+
117+
impl PartialEq for pthread_rwlock_t {
118+
fn eq(&self, other: &pthread_rwlock_t) -> bool {
119+
self.size
120+
.iter()
121+
.zip(other.size.iter())
122+
.all(|(a,b)| a == b)
123+
}
124+
}
125+
impl Eq for pthread_rwlock_t {}
126+
impl ::fmt::Debug for pthread_rwlock_t {
127+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
128+
f.debug_struct("pthread_rwlock_t")
129+
// FIXME: .field("size", &self.size)
130+
.finish()
131+
}
132+
}
133+
impl ::hash::Hash for pthread_rwlock_t {
134+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
135+
self.size.hash(state);
136+
}
137+
}
138+
}
139+
}
74140
}
75141
}

0 commit comments

Comments
 (0)