• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //! libc - Raw FFI bindings to platforms' system libraries
2 //!
3 //! [Documentation for other platforms][pd].
4 //!
5 //! [pd]: https://rust-lang.github.io/libc/#platform-specific-documentation
6 #![crate_name = "libc"]
7 #![crate_type = "rlib"]
8 #![allow(
9     renamed_and_removed_lints, // Keep this order.
10     unknown_lints, // Keep this order.
11     bad_style,
12     overflowing_literals,
13     improper_ctypes,
14     // This lint is renamed but we run CI for old stable rustc so should be here.
15     redundant_semicolon,
16     redundant_semicolons
17 )]
18 #![cfg_attr(libc_deny_warnings, deny(warnings))]
19 // Attributes needed when building as part of the standard library
20 #![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))]
21 #![cfg_attr(libc_thread_local, feature(thread_local))]
22 // Enable extra lints:
23 #![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))]
24 #![deny(missing_copy_implementations, safe_packed_borrows)]
25 #![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)]
26 #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
27 #![cfg_attr(
28     any(feature = "rustc-dep-of-std", target_os = "redox"),
29     feature(static_nobundle)
30 )]
31 #![cfg_attr(libc_const_extern_fn, feature(const_extern_fn))]
32 
33 // ANDROID: Use std to allow building as a dylib.
34 extern crate std;
35 
36 #[macro_use]
37 mod macros;
38 
39 cfg_if! {
40     if #[cfg(feature = "rustc-dep-of-std")] {
41         extern crate rustc_std_workspace_core as core;
42         #[allow(unused_imports)]
43         use core::iter;
44         #[allow(unused_imports)]
45         use core::ops;
46         #[allow(unused_imports)]
47         use core::option;
48     }
49 }
50 
51 cfg_if! {
52     if #[cfg(libc_priv_mod_use)] {
53         #[cfg(libc_core_cvoid)]
54         #[allow(unused_imports)]
55         use core::ffi;
56         #[allow(unused_imports)]
57         use core::fmt;
58         #[allow(unused_imports)]
59         use core::hash;
60         #[allow(unused_imports)]
61         use core::num;
62         #[allow(unused_imports)]
63         use core::mem;
64         #[doc(hidden)]
65         #[allow(unused_imports)]
66         use core::clone::Clone;
67         #[doc(hidden)]
68         #[allow(unused_imports)]
69         use core::marker::Copy;
70         #[doc(hidden)]
71         #[allow(unused_imports)]
72         use core::option::Option;
73     } else {
74         #[doc(hidden)]
75         #[allow(unused_imports)]
76         pub use core::fmt;
77         #[doc(hidden)]
78         #[allow(unused_imports)]
79         pub use core::hash;
80         #[doc(hidden)]
81         #[allow(unused_imports)]
82         pub use core::num;
83         #[doc(hidden)]
84         #[allow(unused_imports)]
85         pub use core::mem;
86         #[doc(hidden)]
87         #[allow(unused_imports)]
88         pub use core::clone::Clone;
89         #[doc(hidden)]
90         #[allow(unused_imports)]
91         pub use core::marker::Copy;
92         #[doc(hidden)]
93         #[allow(unused_imports)]
94         pub use core::option::Option;
95     }
96 }
97 
98 cfg_if! {
99     if #[cfg(windows)] {
100         mod fixed_width_ints;
101         pub use fixed_width_ints::*;
102 
103         mod windows;
104         pub use windows::*;
105     } else if #[cfg(target_os = "fuchsia")] {
106         mod fixed_width_ints;
107         pub use fixed_width_ints::*;
108 
109         mod fuchsia;
110         pub use fuchsia::*;
111     } else if #[cfg(target_os = "switch")] {
112         mod fixed_width_ints;
113         pub use fixed_width_ints::*;
114 
115         mod switch;
116         pub use switch::*;
117     } else if #[cfg(target_os = "psp")] {
118         mod fixed_width_ints;
119         pub use fixed_width_ints::*;
120 
121         mod psp;
122         pub use psp::*;
123     } else if #[cfg(target_os = "vxworks")] {
124         mod fixed_width_ints;
125         pub use fixed_width_ints::*;
126 
127         mod vxworks;
128         pub use vxworks::*;
129     } else if #[cfg(unix)] {
130         mod fixed_width_ints;
131         pub use fixed_width_ints::*;
132 
133         mod unix;
134         pub use unix::*;
135     } else if #[cfg(target_os = "hermit")] {
136         mod fixed_width_ints;
137         pub use fixed_width_ints::*;
138 
139         mod hermit;
140         pub use hermit::*;
141     } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
142         mod fixed_width_ints;
143         pub use fixed_width_ints::*;
144 
145         mod sgx;
146         pub use sgx::*;
147     } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
148         mod fixed_width_ints;
149         pub use fixed_width_ints::*;
150 
151         mod wasi;
152         pub use wasi::*;
153     } else {
154         // non-supported targets: empty...
155     }
156 }
157