| 1 | //! libc - Raw FFI bindings to platforms' system libraries |
| 2 | #![crate_name = "libc"] |
| 3 | #![crate_type = "rlib"] |
| 4 | #![allow( |
| 5 | renamed_and_removed_lints, // Keep this order. |
| 6 | unknown_lints, // Keep this order. |
| 7 | nonstandard_style, |
| 8 | overflowing_literals, |
| 9 | unused_macros, |
| 10 | unused_macro_rules, |
| 11 | )] |
| 12 | #![warn( |
| 13 | missing_copy_implementations, |
| 14 | missing_debug_implementations, |
| 15 | safe_packed_borrows |
| 16 | )] |
| 17 | // Prepare for a future upgrade |
| 18 | #![warn(rust_2024_compatibility)] |
| 19 | // Things missing for 2024 that are blocked on MSRV or breakage |
| 20 | #![allow( |
| 21 | missing_unsafe_on_extern, |
| 22 | edition_2024_expr_fragment_specifier, |
| 23 | // Allowed globally, the warning is enabled in individual modules as we work through them |
| 24 | unsafe_op_in_unsafe_fn |
| 25 | )] |
| 26 | #![cfg_attr(libc_deny_warnings, deny(warnings))] |
| 27 | // Attributes needed when building as part of the standard library |
| 28 | #![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))] |
| 29 | #![cfg_attr(feature = "rustc-dep-of-std", allow(internal_features))] |
| 30 | // DIFF(1.0): The thread local references that raise this lint were removed in 1.0 |
| 31 | #![cfg_attr(feature = "rustc-dep-of-std", allow(static_mut_refs))] |
| 32 | #![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)] |
| 33 | #![cfg_attr(feature = "rustc-dep-of-std", no_core)] |
| 34 | |
| 35 | #[macro_use] |
| 36 | mod macros; |
| 37 | mod new; |
| 38 | |
| 39 | cfg_if! { |
| 40 | if #[cfg(feature = "rustc-dep-of-std")] { |
| 41 | extern crate rustc_std_workspace_core as core; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | pub use core::ffi::c_void; |
| 46 | |
| 47 | #[allow(unused_imports)] // needed while the module is empty on some platforms |
| 48 | pub use new::*; |
| 49 | |
| 50 | cfg_if! { |
| 51 | if #[cfg(windows)] { |
| 52 | mod primitives; |
| 53 | pub use crate::primitives::*; |
| 54 | |
| 55 | mod windows; |
| 56 | pub use crate::windows::*; |
| 57 | |
| 58 | prelude!(); |
| 59 | } else if #[cfg(target_os = "fuchsia")] { |
| 60 | mod primitives; |
| 61 | pub use crate::primitives::*; |
| 62 | |
| 63 | mod fuchsia; |
| 64 | pub use crate::fuchsia::*; |
| 65 | |
| 66 | prelude!(); |
| 67 | } else if #[cfg(target_os = "switch")] { |
| 68 | mod primitives; |
| 69 | pub use primitives::*; |
| 70 | |
| 71 | mod switch; |
| 72 | pub use switch::*; |
| 73 | |
| 74 | prelude!(); |
| 75 | } else if #[cfg(target_os = "psp")] { |
| 76 | mod primitives; |
| 77 | pub use primitives::*; |
| 78 | |
| 79 | mod psp; |
| 80 | pub use crate::psp::*; |
| 81 | |
| 82 | prelude!(); |
| 83 | } else if #[cfg(target_os = "vxworks")] { |
| 84 | mod primitives; |
| 85 | pub use crate::primitives::*; |
| 86 | |
| 87 | mod vxworks; |
| 88 | pub use crate::vxworks::*; |
| 89 | |
| 90 | prelude!(); |
| 91 | } else if #[cfg(target_os = "qurt")] { |
| 92 | mod primitives; |
| 93 | pub use crate::primitives::*; |
| 94 | |
| 95 | mod qurt; |
| 96 | pub use crate::qurt::*; |
| 97 | |
| 98 | prelude!(); |
| 99 | } else if #[cfg(target_os = "solid_asp3")] { |
| 100 | mod primitives; |
| 101 | pub use crate::primitives::*; |
| 102 | |
| 103 | mod solid; |
| 104 | pub use crate::solid::*; |
| 105 | |
| 106 | prelude!(); |
| 107 | } else if #[cfg(unix)] { |
| 108 | mod primitives; |
| 109 | pub use crate::primitives::*; |
| 110 | |
| 111 | mod unix; |
| 112 | pub use crate::unix::*; |
| 113 | |
| 114 | prelude!(); |
| 115 | } else if #[cfg(target_os = "hermit")] { |
| 116 | mod primitives; |
| 117 | pub use crate::primitives::*; |
| 118 | |
| 119 | mod hermit; |
| 120 | pub use crate::hermit::*; |
| 121 | |
| 122 | prelude!(); |
| 123 | } else if #[cfg(target_os = "teeos")] { |
| 124 | mod primitives; |
| 125 | pub use primitives::*; |
| 126 | |
| 127 | mod teeos; |
| 128 | pub use teeos::*; |
| 129 | |
| 130 | prelude!(); |
| 131 | } else if #[cfg(target_os = "trusty")] { |
| 132 | mod primitives; |
| 133 | pub use crate::primitives::*; |
| 134 | |
| 135 | mod trusty; |
| 136 | pub use crate::trusty::*; |
| 137 | |
| 138 | prelude!(); |
| 139 | } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] { |
| 140 | mod primitives; |
| 141 | pub use crate::primitives::*; |
| 142 | |
| 143 | mod sgx; |
| 144 | pub use crate::sgx::*; |
| 145 | |
| 146 | prelude!(); |
| 147 | } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] { |
| 148 | mod primitives; |
| 149 | pub use crate::primitives::*; |
| 150 | |
| 151 | mod wasi; |
| 152 | pub use crate::wasi::*; |
| 153 | |
| 154 | prelude!(); |
| 155 | } else if #[cfg(target_os = "xous")] { |
| 156 | mod primitives; |
| 157 | pub use crate::primitives::*; |
| 158 | |
| 159 | mod xous; |
| 160 | pub use crate::xous::*; |
| 161 | |
| 162 | prelude!(); |
| 163 | } else { |
| 164 | // non-supported targets: empty... |
| 165 | } |
| 166 | } |