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 bad_style, 8 overflowing_literals, 9 improper_ctypes, 10 // This lint is renamed but we run CI for old stable rustc so should be here. 11 redundant_semicolon, 12 redundant_semicolons, 13 unused_macros, 14 unused_macro_rules, 15 // FIXME: temporarily allow dead_code to fix CI: 16 // - https://github.com/rust-lang/libc/issues/3740 17 // - https://github.com/rust-lang/rust/pull/126456 18 dead_code, 19 )] 20 #![cfg_attr(libc_deny_warnings, deny(warnings))] 21 // Attributes needed when building as part of the standard library 22 #![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))] 23 #![cfg_attr(libc_thread_local, feature(thread_local))] 24 // Enable extra lints: 25 #![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))] 26 #![deny(missing_copy_implementations, safe_packed_borrows)] 27 #![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)] 28 #![cfg_attr(feature = "rustc-dep-of-std", no_core)] 29 #![cfg_attr(libc_const_extern_fn_unstable, feature(const_extern_fn))] 30 31 #[macro_use] 32 mod macros; 33 34 cfg_if! { 35 if #[cfg(feature = "rustc-dep-of-std")] { 36 extern crate rustc_std_workspace_core as core; 37 #[allow(unused_imports)] 38 use core::iter; 39 #[allow(unused_imports)] 40 use core::ops; 41 #[allow(unused_imports)] 42 use core::option; 43 } 44 } 45 46 #[doc(hidden)] 47 #[allow(unused_imports)] 48 use core::clone::Clone; 49 #[allow(unused_imports)] 50 use core::fmt; 51 #[allow(unused_imports)] 52 use core::hash; 53 #[doc(hidden)] 54 #[allow(unused_imports)] 55 use core::marker::{Copy, Send, Sync}; 56 #[allow(unused_imports)] 57 use core::mem; 58 #[allow(unused_imports)] 59 use core::num; 60 #[doc(hidden)] 61 #[allow(unused_imports)] 62 use core::option::Option; 63 64 pub use core::ffi::c_void; 65 66 cfg_if! { 67 if #[cfg(windows)] { 68 mod fixed_width_ints; 69 pub use fixed_width_ints::*; 70 71 mod windows; 72 pub use windows::*; 73 } else if #[cfg(target_os = "fuchsia")] { 74 mod fixed_width_ints; 75 pub use fixed_width_ints::*; 76 77 mod fuchsia; 78 pub use fuchsia::*; 79 } else if #[cfg(target_os = "switch")] { 80 mod fixed_width_ints; 81 pub use fixed_width_ints::*; 82 83 mod switch; 84 pub use switch::*; 85 } else if #[cfg(target_os = "psp")] { 86 mod fixed_width_ints; 87 pub use fixed_width_ints::*; 88 89 mod psp; 90 pub use psp::*; 91 } else if #[cfg(target_os = "vxworks")] { 92 mod fixed_width_ints; 93 pub use fixed_width_ints::*; 94 95 mod vxworks; 96 pub use vxworks::*; 97 } else if #[cfg(target_os = "solid_asp3")] { 98 mod fixed_width_ints; 99 pub use fixed_width_ints::*; 100 101 mod solid; 102 pub use solid::*; 103 } else if #[cfg(unix)] { 104 mod fixed_width_ints; 105 pub use fixed_width_ints::*; 106 107 mod unix; 108 pub use unix::*; 109 } else if #[cfg(target_os = "hermit")] { 110 mod fixed_width_ints; 111 pub use fixed_width_ints::*; 112 113 mod hermit; 114 pub use hermit::*; 115 } else if #[cfg(target_os = "teeos")] { 116 mod fixed_width_ints; 117 pub use fixed_width_ints::*; 118 119 mod teeos; 120 pub use teeos::*; 121 } else if #[cfg(target_os = "trusty")] { 122 mod fixed_width_ints; 123 pub use fixed_width_ints::*; 124 125 mod trusty; 126 pub use trusty::*; 127 } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] { 128 mod fixed_width_ints; 129 pub use fixed_width_ints::*; 130 131 mod sgx; 132 pub use sgx::*; 133 } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] { 134 mod fixed_width_ints; 135 pub use fixed_width_ints::*; 136 137 mod wasi; 138 pub use wasi::*; 139 } else if #[cfg(target_os = "xous")] { 140 mod fixed_width_ints; 141 pub use fixed_width_ints::*; 142 143 mod xous; 144 pub use xous::*; 145 } else { 146 // non-supported targets: empty... 147 } 148 } 149