| 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 (libc_thread_local, feature(thread_local))] |
| 30 | #![cfg_attr (feature = "rustc-dep-of-std" , allow(internal_features))] |
| 31 | // DIFF(1.0): The thread local references that raise this lint were removed in 1.0 |
| 32 | #![cfg_attr (feature = "rustc-dep-of-std" , allow(static_mut_refs))] |
| 33 | #![cfg_attr (not(feature = "rustc-dep-of-std" ), no_std)] |
| 34 | #![cfg_attr (feature = "rustc-dep-of-std" , no_core)] |
| 35 | |
| 36 | #[macro_use ] |
| 37 | mod macros; |
| 38 | mod new; |
| 39 | |
| 40 | cfg_if! { |
| 41 | if #[cfg(feature = "rustc-dep-of-std" )] { |
| 42 | extern crate rustc_std_workspace_core as core; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | pub use core::ffi::c_void; |
| 47 | |
| 48 | #[allow (unused_imports)] // needed while the module is empty on some platforms |
| 49 | pub use new::*; |
| 50 | |
| 51 | cfg_if! { |
| 52 | if #[cfg(windows)] { |
| 53 | mod primitives; |
| 54 | pub use crate::primitives::*; |
| 55 | |
| 56 | mod windows; |
| 57 | pub use crate::windows::*; |
| 58 | |
| 59 | prelude!(); |
| 60 | } else if #[cfg(target_os = "fuchsia" )] { |
| 61 | mod primitives; |
| 62 | pub use crate::primitives::*; |
| 63 | |
| 64 | mod fuchsia; |
| 65 | pub use crate::fuchsia::*; |
| 66 | |
| 67 | prelude!(); |
| 68 | } else if #[cfg(target_os = "switch" )] { |
| 69 | mod primitives; |
| 70 | pub use primitives::*; |
| 71 | |
| 72 | mod switch; |
| 73 | pub use switch::*; |
| 74 | |
| 75 | prelude!(); |
| 76 | } else if #[cfg(target_os = "psp" )] { |
| 77 | mod primitives; |
| 78 | pub use primitives::*; |
| 79 | |
| 80 | mod psp; |
| 81 | pub use crate::psp::*; |
| 82 | |
| 83 | prelude!(); |
| 84 | } else if #[cfg(target_os = "vxworks" )] { |
| 85 | mod primitives; |
| 86 | pub use crate::primitives::*; |
| 87 | |
| 88 | mod vxworks; |
| 89 | pub use crate::vxworks::*; |
| 90 | |
| 91 | prelude!(); |
| 92 | } else if #[cfg(target_os = "solid_asp3" )] { |
| 93 | mod primitives; |
| 94 | pub use crate::primitives::*; |
| 95 | |
| 96 | mod solid; |
| 97 | pub use crate::solid::*; |
| 98 | |
| 99 | prelude!(); |
| 100 | } else if #[cfg(unix)] { |
| 101 | mod primitives; |
| 102 | pub use crate::primitives::*; |
| 103 | |
| 104 | mod unix; |
| 105 | pub use crate::unix::*; |
| 106 | |
| 107 | prelude!(); |
| 108 | } else if #[cfg(target_os = "hermit" )] { |
| 109 | mod primitives; |
| 110 | pub use crate::primitives::*; |
| 111 | |
| 112 | mod hermit; |
| 113 | pub use crate::hermit::*; |
| 114 | |
| 115 | prelude!(); |
| 116 | } else if #[cfg(target_os = "teeos" )] { |
| 117 | mod primitives; |
| 118 | pub use primitives::*; |
| 119 | |
| 120 | mod teeos; |
| 121 | pub use teeos::*; |
| 122 | |
| 123 | prelude!(); |
| 124 | } else if #[cfg(target_os = "trusty" )] { |
| 125 | mod primitives; |
| 126 | pub use crate::primitives::*; |
| 127 | |
| 128 | mod trusty; |
| 129 | pub use crate::trusty::*; |
| 130 | |
| 131 | prelude!(); |
| 132 | } else if #[cfg(all(target_env = "sgx" , target_vendor = "fortanix" ))] { |
| 133 | mod primitives; |
| 134 | pub use crate::primitives::*; |
| 135 | |
| 136 | mod sgx; |
| 137 | pub use crate::sgx::*; |
| 138 | |
| 139 | prelude!(); |
| 140 | } else if #[cfg(any(target_env = "wasi" , target_os = "wasi" ))] { |
| 141 | mod primitives; |
| 142 | pub use crate::primitives::*; |
| 143 | |
| 144 | mod wasi; |
| 145 | pub use crate::wasi::*; |
| 146 | |
| 147 | prelude!(); |
| 148 | } else if #[cfg(target_os = "xous" )] { |
| 149 | mod primitives; |
| 150 | pub use crate::primitives::*; |
| 151 | |
| 152 | mod xous; |
| 153 | pub use crate::xous::*; |
| 154 | |
| 155 | prelude!(); |
| 156 | } else { |
| 157 | // non-supported targets: empty... |
| 158 | } |
| 159 | } |
| 160 | |