xref: /rust-libc-0.2.174/src/lib.rs (revision 71e47b8d)
1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10 //! libc - Raw FFI bindings to platforms' system libraries
11 //!
12 //! [Documentation for other platforms][pd].
13 //!
14 //! [pd]: https://rust-lang.github.io/libc/#platform-specific-documentation
15 #![crate_name = "libc"]
16 #![crate_type = "rlib"]
17 #![cfg_attr(libc_deny_warnings, deny(warnings))]
18 #![allow(bad_style, overflowing_literals, improper_ctypes, unknown_lints)]
19 // FIXME: this is due to a rustc bug
20 #![allow(redundant_semicolon)]
21 // Attributes needed when building as part of the standard library
22 #![cfg_attr(
23     feature = "rustc-dep-of-std",
24     feature(cfg_target_vendor, link_cfg, no_core)
25 )]
26 #![cfg_attr(libc_thread_local, feature(thread_local))]
27 // Enable extra lints:
28 #![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))]
29 #![deny(missing_copy_implementations, safe_packed_borrows)]
30 #![no_std]
31 #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
32 #![cfg_attr(target_os = "redox", feature(static_nobundle))]
33 
34 #[macro_use]
35 mod macros;
36 
37 cfg_if! {
38     if #[cfg(feature = "rustc-dep-of-std")] {
39         extern crate rustc_std_workspace_core as core;
40         #[allow(unused_imports)]
41         use core::iter;
42         #[allow(unused_imports)]
43         use core::option;
44     }
45 }
46 
47 cfg_if! {
48     if #[cfg(libc_priv_mod_use)] {
49         #[cfg(libc_core_cvoid)]
50         #[allow(unused_imports)]
51         use core::ffi;
52         #[allow(unused_imports)]
53         use core::fmt;
54         #[allow(unused_imports)]
55         use core::hash;
56         #[allow(unused_imports)]
57         use core::num;
58         #[allow(unused_imports)]
59         use core::mem;
60         #[doc(hidden)]
61         #[allow(unused_imports)]
62         use core::clone::Clone;
63         #[doc(hidden)]
64         #[allow(unused_imports)]
65         use core::marker::Copy;
66         #[doc(hidden)]
67         #[allow(unused_imports)]
68         use core::option::Option;
69     } else {
70         #[doc(hidden)]
71         #[allow(unused_imports)]
72         pub use core::fmt;
73         #[doc(hidden)]
74         #[allow(unused_imports)]
75         pub use core::hash;
76         #[doc(hidden)]
77         #[allow(unused_imports)]
78         pub use core::num;
79         #[doc(hidden)]
80         #[allow(unused_imports)]
81         pub use core::mem;
82         #[doc(hidden)]
83         #[allow(unused_imports)]
84         pub use core::clone::Clone;
85         #[doc(hidden)]
86         #[allow(unused_imports)]
87         pub use core::marker::Copy;
88         #[doc(hidden)]
89         #[allow(unused_imports)]
90         pub use core::option::Option;
91     }
92 }
93 
94 cfg_if! {
95     if #[cfg(windows)] {
96         mod fixed_width_ints;
97         pub use fixed_width_ints::*;
98 
99         mod windows;
100         pub use windows::*;
101     } else if #[cfg(target_os = "cloudabi")] {
102         mod fixed_width_ints;
103         pub use fixed_width_ints::*;
104 
105         mod cloudabi;
106         pub use cloudabi::*;
107     } else if #[cfg(target_os = "fuchsia")] {
108         mod fixed_width_ints;
109         pub use fixed_width_ints::*;
110 
111         mod fuchsia;
112         pub use fuchsia::*;
113     } else if #[cfg(target_os = "switch")] {
114         mod fixed_width_ints;
115         pub use fixed_width_ints::*;
116 
117         mod switch;
118         pub use switch::*;
119     } else if #[cfg(target_os = "vxworks")] {
120         mod fixed_width_ints;
121         pub use fixed_width_ints::*;
122 
123         mod vxworks;
124         pub use vxworks::*;
125     } else if #[cfg(unix)] {
126         mod fixed_width_ints;
127         pub use fixed_width_ints::*;
128 
129         mod unix;
130         pub use unix::*;
131     } else if #[cfg(target_os = "hermit")] {
132         mod fixed_width_ints;
133         pub use fixed_width_ints::*;
134 
135         mod hermit;
136         pub use hermit::*;
137     } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
138         mod fixed_width_ints;
139         pub use fixed_width_ints::*;
140 
141         mod sgx;
142         pub use sgx::*;
143     } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
144         mod fixed_width_ints;
145         pub use fixed_width_ints::*;
146 
147         mod wasi;
148         pub use wasi::*;
149     } else {
150         // non-supported targets: empty...
151     }
152 }
153