1#[allow(unused_macros)]
10macro_rules! cfg_if {
11 ($(
13 if #[cfg($($meta:meta),*)] { $($it:item)* }
14 ) else * else {
15 $($it2:item)*
16 }) => {
17 cfg_if! {
18 @__items
19 () ;
20 $( ( ($($meta),*) ($($it)*) ), )*
21 ( () ($($it2)*) ),
22 }
23 };
24
25 (
27 if #[cfg($($i_met:meta),*)] { $($i_it:item)* }
28 $(
29 else if #[cfg($($e_met:meta),*)] { $($e_it:item)* }
30 )*
31 ) => {
32 cfg_if! {
33 @__items
34 () ;
35 ( ($($i_met),*) ($($i_it)*) ),
36 $( ( ($($e_met),*) ($($e_it)*) ), )*
37 ( () () ),
38 }
39 };
40
41 (@__items ($($not:meta,)*) ; ) => {};
46 (@__items ($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ),
47 $($rest:tt)*) => {
48 cfg_if! { @__apply cfg(all($($m,)* not(any($($not),*)))), $($it)* }
52
53 cfg_if! { @__items ($($not,)* $($m,)*) ; $($rest)* }
57 };
58
59 (@__apply $m:meta, $($it:item)*) => {
61 $(#[$m] $it)*
62 };
63}
64
65#[allow(unused_macros)]
66macro_rules! s {
67 ($($(#[$attr:meta])* pub $t:ident $i:ident { $($field:tt)* })*) => ($(
68 s!(it: $(#[$attr])* pub $t $i { $($field)* });
69 )*);
70 (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => (
71 compile_error!("unions cannot derive extra traits, use s_no_extra_traits instead");
72 );
73 (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => (
74 __item! {
75 #[repr(C)]
76 #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
77 #[allow(deprecated)]
78 $(#[$attr])*
79 pub struct $i { $($field)* }
80 }
81 #[allow(deprecated)]
82 impl ::Copy for $i {}
83 #[allow(deprecated)]
84 impl ::Clone for $i {
85 fn clone(&self) -> $i { *self }
86 }
87 );
88}
89
90#[allow(unused_macros)]
91macro_rules! s_no_extra_traits {
92 ($($(#[$attr:meta])* pub $t:ident $i:ident { $($field:tt)* })*) => ($(
93 s_no_extra_traits!(it: $(#[$attr])* pub $t $i { $($field)* });
94 )*);
95 (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => (
96 cfg_if! {
97 if #[cfg(libc_union)] {
98 __item! {
99 #[repr(C)]
100 $(#[$attr])*
101 pub union $i { $($field)* }
102 }
103
104 impl ::Copy for $i {}
105 impl ::Clone for $i {
106 fn clone(&self) -> $i { *self }
107 }
108 }
109 }
110 );
111 (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => (
112 __item! {
113 #[repr(C)]
114 $(#[$attr])*
115 pub struct $i { $($field)* }
116 }
117 impl ::Copy for $i {}
118 impl ::Clone for $i {
119 fn clone(&self) -> $i { *self }
120 }
121 );
122}
123
124cfg_if! {
152 if #[cfg(libc_const_extern_fn)] {
153 #[allow(unused_macros)]
154 macro_rules! f {
155 ($(pub $({$constness:ident})* fn $i:ident(
156 $($arg:ident: $argty:ty),*
157 ) -> $ret:ty {
158 $($body:stmt);*
159 })*) => ($(
160 #[inline]
161 pub $($constness)* unsafe extern fn $i($($arg: $argty),*
162 ) -> $ret {
163 $($body);*
164 }
165 )*)
166 }
167
168 #[allow(unused_macros)]
169 macro_rules! const_fn {
170 ($($({$constness:ident})* fn $i:ident(
171 $($arg:ident: $argty:ty),*
172 ) -> $ret:ty {
173 $($body:stmt);*
174 })*) => ($(
175 #[inline]
176 $($constness)* fn $i($($arg: $argty),*
177 ) -> $ret {
178 $($body);*
179 }
180 )*)
181 }
182
183 } else {
184 #[allow(unused_macros)]
185 macro_rules! f {
186 ($(pub $({$constness:ident})* fn $i:ident(
187 $($arg:ident: $argty:ty),*
188 ) -> $ret:ty {
189 $($body:stmt);*
190 })*) => ($(
191 #[inline]
192 pub unsafe extern fn $i($($arg: $argty),*
193 ) -> $ret {
194 $($body);*
195 }
196 )*)
197 }
198
199 #[allow(unused_macros)]
200 macro_rules! const_fn {
201 ($($({$constness:ident})* fn $i:ident(
202 $($arg:ident: $argty:ty),*
203 ) -> $ret:ty {
204 $($body:stmt);*
205 })*) => ($(
206 #[inline]
207 fn $i($($arg: $argty),*
208 ) -> $ret {
209 $($body);*
210 }
211 )*)
212 }
213 }
214}
215
216#[allow(unused_macros)]
217macro_rules! __item {
218 ($i:item) => {
219 $i
220 };
221}
222
223#[allow(unused_macros)]
224macro_rules! align_const {
225 ($($(#[$attr:meta])*
226 pub const $name:ident : $t1:ty
227 = $t2:ident { $($field:tt)* };)*) => ($(
228 #[cfg(libc_align)]
229 $(#[$attr])*
230 pub const $name : $t1 = $t2 {
231 $($field)*
232 };
233 #[cfg(not(libc_align))]
234 $(#[$attr])*
235 pub const $name : $t1 = $t2 {
236 $($field)*
237 __align: [],
238 };
239 )*)
240}
241
242#[allow(unused_macros)]
244macro_rules! deprecated_mach {
245 (pub const $id:ident: $ty:ty = $expr:expr;) => {
246 #[deprecated(
247 since = "0.2.55",
248 note = "Use the `mach` crate instead",
249 )]
250 #[allow(deprecated)]
251 pub const $id: $ty = $expr;
252 };
253 ($(pub const $id:ident: $ty:ty = $expr:expr;)*) => {
254 $(
255 deprecated_mach!(
256 pub const $id: $ty = $expr;
257 );
258 )*
259 };
260 (pub type $id:ident = $ty:ty;) => {
261 #[deprecated(
262 since = "0.2.55",
263 note = "Use the `mach` crate instead",
264 )]
265 #[allow(deprecated)]
266 pub type $id = $ty;
267 };
268 ($(pub type $id:ident = $ty:ty;)*) => {
269 $(
270 deprecated_mach!(
271 pub type $id = $ty;
272 );
273 )*
274 }
275}