xref: /rust-libc-0.2.174/src/lib.rs (revision 9f1db178)
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(not(feature = "rustc-dep-of-std"), deny(warnings))]
18 #![allow(bad_style, overflowing_literals, improper_ctypes, unknown_lints)]
19 // Attributes needed when building as part of the standard library
20 #![cfg_attr(
21     feature = "rustc-dep-of-std",
22     feature(cfg_target_vendor, link_cfg, no_core)
23 )]
24 // Enable extra lints:
25 #![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))]
26 #![deny(missing_copy_implementations, safe_packed_borrows)]
27 #![no_std]
28 #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
29 
30 #[macro_use]
31 mod macros;
32 
33 cfg_if! {
34     if #[cfg(feature = "rustc-dep-of-std")] {
35         extern crate rustc_std_workspace_core as core;
36         #[allow(unused_imports)]
37         use core::iter;
38         #[allow(unused_imports)]
39         use core::option;
40     }
41 }
42 
43 cfg_if! {
44     if #[cfg(libc_priv_mod_use)] {
45         #[cfg(libc_core_cvoid)]
46         #[allow(unused_imports)]
47         use core::ffi;
48         #[allow(unused_imports)]
49         use core::fmt;
50         #[allow(unused_imports)]
51         use core::hash;
52         #[allow(unused_imports)]
53         use core::num;
54         #[allow(unused_imports)]
55         use core::mem;
56         #[doc(hidden)]
57         #[allow(unused_imports)]
58         use core::clone::Clone;
59         #[doc(hidden)]
60         #[allow(unused_imports)]
61         use core::marker::Copy;
62         #[doc(hidden)]
63         #[allow(unused_imports)]
64         use core::option::Option;
65     } else {
66         #[doc(hidden)]
67         #[allow(unused_imports)]
68         pub use core::fmt;
69         #[doc(hidden)]
70         #[allow(unused_imports)]
71         pub use core::hash;
72         #[doc(hidden)]
73         #[allow(unused_imports)]
74         pub use core::num;
75         #[doc(hidden)]
76         #[allow(unused_imports)]
77         pub use core::mem;
78         #[doc(hidden)]
79         #[allow(unused_imports)]
80         pub use core::clone::Clone;
81         #[doc(hidden)]
82         #[allow(unused_imports)]
83         pub use core::marker::Copy;
84         #[doc(hidden)]
85         #[allow(unused_imports)]
86         pub use core::option::Option;
87     }
88 }
89 
90 cfg_if! {
91     if #[cfg(windows)] {
92         mod windows;
93         pub use windows::*;
94     } else if #[cfg(target_os = "redox")] {
95         mod redox;
96         pub use redox::*;
97     } else if #[cfg(target_os = "cloudabi")] {
98         mod cloudabi;
99         pub use cloudabi::*;
100     } else if #[cfg(target_os = "fuchsia")] {
101         mod fuchsia;
102         pub use fuchsia::*;
103     } else if #[cfg(target_os = "switch")] {
104         mod switch;
105         pub use switch::*;
106     } else if #[cfg(unix)] {
107         mod unix;
108         pub use unix::*;
109     } else if #[cfg(target_os = "hermit")] {
110         mod hermit;
111         pub use hermit::*;
112     } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
113         mod sgx;
114         pub use sgx::*;
115     } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
116         mod wasi;
117         pub use wasi::*;
118     } else {
119         // non-supported targets: empty...
120     }
121 }
122