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 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::ops; 40 #[allow(unused_imports)] 41 use core::option; 42 } 43 } 44 45 #[doc(hidden)] 46 #[allow(unused_imports)] 47 use core::clone::Clone; 48 #[allow(unused_imports)] 49 use core::ffi; 50 pub use core::ffi::c_void; 51 #[allow(unused_imports)] 52 use core::fmt; 53 #[allow(unused_imports)] 54 use core::hash; 55 #[doc(hidden)] 56 #[allow(unused_imports)] 57 use core::marker::{Copy, Send, Sync}; 58 #[allow(unused_imports)] 59 use core::mem; 60 #[allow(unused_imports)] 61 use core::num; 62 #[doc(hidden)] 63 #[allow(unused_imports)] 64 use core::option::Option; 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