98
98
#[ cfg( all( not( cross_platform_docs) , feature = "use_std" ) ) ]
99
99
extern crate std as core;
100
100
101
- #[ macro_use] mod macros ;
102
- mod dox ;
101
+ #[ macro_use]
102
+ mod macros ;
103
103
104
- /*
105
- * `c_void` should be defined for all targets except wasm .
106
- * /
107
- # [ cfg ( not ( all ( target_arch = "wasm32" , not ( target_os = "emscripten" ) ) ) ) ]
104
+ // Targets for which `libc` should not fail to compile, but be completely empty
105
+ // instead .
106
+ / /
107
+ // FIXME: `libc` should just fail to compile for these targets.
108
108
cfg_if ! {
109
- if #[ cfg( core_cvoid ) ] {
110
- pub use core :: ffi :: c_void ;
109
+ if #[ cfg( all ( target_arch = "wasm32" , not ( target_os = "emscripten" ) ) ) ] {
110
+ // libc is empty for wasm32-unknown-unknown ...
111
111
} else {
112
- // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help enable
113
- // more optimization opportunities around it recognizing things like
114
- // malloc/free.
115
- #[ repr( u8 ) ]
116
- pub enum c_void {
117
- // Two dummy variants so the #[repr] attribute can be used.
118
- #[ doc( hidden) ]
119
- __variant1,
120
- #[ doc( hidden) ]
121
- __variant2,
112
+ mod dox;
113
+
114
+ cfg_if! {
115
+ if #[ cfg( core_cvoid) ] {
116
+ pub use core:: ffi:: c_void;
117
+ } else {
118
+ // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help enable
119
+ // more optimization opportunities around it recognizing things like
120
+ // malloc/free.
121
+ #[ repr( u8 ) ]
122
+ pub enum c_void {
123
+ // Two dummy variants so the #[repr] attribute can be used.
124
+ #[ doc( hidden) ]
125
+ __variant1,
126
+ #[ doc( hidden) ]
127
+ __variant2,
128
+ }
129
+ }
122
130
}
123
- }
124
- }
125
131
126
- cfg_if ! {
127
- if #[ cfg( all( target_arch = "wasm32" , not( target_os = "emscripten" ) ) ) ] {
128
- // empty ...
129
- } else if #[ cfg( target_os = "switch" ) ] {
130
- // On the Switch, we only define some useful universal types for
131
- // convenience. Those can be found in the switch.rs file.
132
- } else {
133
132
pub type int8_t = i8 ;
134
133
pub type int16_t = i16 ;
135
134
pub type int32_t = i32 ;
@@ -284,6 +283,7 @@ cfg_if! {
284
283
285
284
// These are all inline functions on android, so they end up just being entirely
286
285
// missing on that platform.
286
+
287
287
#[ cfg( not( target_os = "android" ) ) ]
288
288
extern {
289
289
pub fn abs( i: c_int) -> c_int;
@@ -292,29 +292,29 @@ cfg_if! {
292
292
pub fn rand( ) -> c_int;
293
293
pub fn srand( seed: c_uint) ;
294
294
}
295
- }
296
- }
297
295
298
- cfg_if ! {
299
- if #[ cfg( windows) ] {
300
- mod windows;
301
- pub use windows:: * ;
302
- } else if #[ cfg( target_os = "redox" ) ] {
303
- mod redox;
304
- pub use redox:: * ;
305
- } else if #[ cfg( target_os = "cloudabi" ) ] {
306
- mod cloudabi;
307
- pub use cloudabi:: * ;
308
- } else if #[ cfg( target_os = "fuchsia" ) ] {
309
- mod fuchsia;
310
- pub use fuchsia:: * ;
311
- } else if #[ cfg( target_os = "switch" ) ] {
312
- mod switch;
313
- pub use switch:: * ;
314
- } else if #[ cfg( unix) ] {
315
- mod unix;
316
- pub use unix:: * ;
317
- } else {
318
- // Unknown target_family
296
+ cfg_if! {
297
+ if #[ cfg( windows) ] {
298
+ mod windows;
299
+ pub use windows:: * ;
300
+ } else if #[ cfg( target_os = "redox" ) ] {
301
+ mod redox;
302
+ pub use redox:: * ;
303
+ } else if #[ cfg( target_os = "cloudabi" ) ] {
304
+ mod cloudabi;
305
+ pub use cloudabi:: * ;
306
+ } else if #[ cfg( target_os = "fuchsia" ) ] {
307
+ mod fuchsia;
308
+ pub use fuchsia:: * ;
309
+ } else if #[ cfg( target_os = "switch" ) ] {
310
+ mod switch;
311
+ pub use switch:: * ;
312
+ } else if #[ cfg( unix) ] {
313
+ mod unix;
314
+ pub use unix:: * ;
315
+ } else {
316
+ // Unknown target_family
317
+ }
318
+ }
319
319
}
320
320
}
0 commit comments