• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 macro_rules! expand_align {
2     () => {
3         s! {
4             pub struct pthread_mutexattr_t {
5                 #[cfg(target_arch = "x86_64")]
6                 __align: [::c_int; 0],
7                 #[cfg(not(target_arch = "x86_64"))]
8                 __align: [::c_long; 0],
9                 size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
10             }
11 
12             pub struct pthread_rwlockattr_t {
13                 __align: [::c_long; 0],
14                 size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T],
15             }
16 
17             pub struct pthread_condattr_t {
18                 __align: [::c_int; 0],
19                 size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
20             }
21         }
22 
23         s_no_extra_traits! {
24             pub struct pthread_mutex_t {
25                 #[cfg(any(target_arch = "arm",
26                           all(target_arch = "x86_64",
27                               target_pointer_width = "32")))]
28                 __align: [::c_long; 0],
29                 #[cfg(not(any(target_arch = "arm",
30                               all(target_arch = "x86_64",
31                                   target_pointer_width = "32"))))]
32                 __align: [::c_longlong; 0],
33                 size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T],
34             }
35 
36             pub struct pthread_rwlock_t {
37                 __align: [::c_long; 0],
38                 __align: [::c_longlong; 0],
39                 size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T],
40             }
41 
42             pub struct pthread_cond_t {
43                 __align: [*const ::c_void; 0],
44                 #[cfg(not(target_env = "musl"))]
45                 __align: [::c_longlong; 0],
46                 size: [u8; ::__SIZEOF_PTHREAD_COND_T],
47             }
48         }
49 
50         cfg_if! {
51             if #[cfg(feature = "extra_traits")] {
52                 impl PartialEq for pthread_cond_t {
53                     fn eq(&self, other: &pthread_cond_t) -> bool {
54                         // Ignore __align field
55                         self.size
56                             .iter()
57                             .zip(other.size.iter())
58                             .all(|(a,b)| a == b)
59                     }
60                 }
61                 impl Eq for pthread_cond_t {}
62                 impl ::fmt::Debug for pthread_cond_t {
63                     fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
64                         f.debug_struct("pthread_cond_t")
65                             // Ignore __align field
66                             // FIXME: .field("size", &self.size)
67                             .finish()
68                     }
69                 }
70                 impl ::hash::Hash for pthread_cond_t {
71                     fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
72                         // Ignore __align field
73                         self.size.hash(state);
74                     }
75                 }
76 
77                 impl PartialEq for pthread_mutex_t {
78                     fn eq(&self, other: &pthread_mutex_t) -> bool {
79                         // Ignore __align field
80                         self.size
81                             .iter()
82                             .zip(other.size.iter())
83                             .all(|(a,b)| a == b)
84                     }
85                 }
86                 impl Eq for pthread_mutex_t {}
87                 impl ::fmt::Debug for pthread_mutex_t {
88                     fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
89                         f.debug_struct("pthread_mutex_t")
90                             // Ignore __align field
91                             // FIXME: .field("size", &self.size)
92                             .finish()
93                     }
94                 }
95                 impl ::hash::Hash for pthread_mutex_t {
96                     fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
97                         // Ignore __align field
98                         self.size.hash(state);
99                     }
100                 }
101 
102                 impl PartialEq for pthread_rwlock_t {
103                     fn eq(&self, other: &pthread_rwlock_t) -> bool {
104                         // Ignore __align field
105                         self.size
106                             .iter()
107                             .zip(other.size.iter())
108                             .all(|(a,b)| a == b)
109                     }
110                 }
111                 impl Eq for pthread_rwlock_t {}
112                 impl ::fmt::Debug for pthread_rwlock_t {
113                     fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
114                         f.debug_struct("pthread_rwlock_t")
115                             // Ignore __align field
116                             // FIXME: .field("size", &self.size)
117                             .finish()
118                     }
119                 }
120                 impl ::hash::Hash for pthread_rwlock_t {
121                     fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
122                         // Ignore __align field
123                         self.size.hash(state);
124                     }
125                 }
126             }
127         }
128     };
129 }
130