1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT 2 // file at the top-level directory of this distribution and at 3 // http://rust-lang.org/COPYRIGHT. 4 // 5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or 6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license 7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your 8 // option. This file may not be copied, modified, or distributed 9 // except according to those terms. 10 //! libc - Raw FFI bindings to platforms' system libraries 11 //! 12 //! [Documentation for other platforms][pd]. 13 //! 14 //! [pd]: https://rust-lang.github.io/libc/#platform-specific-documentation 15 #![crate_name = "libc"] 16 #![crate_type = "rlib"] 17 #![cfg_attr(libc_deny_warnings, deny(warnings))] 18 #![allow( 19 bad_style, 20 overflowing_literals, 21 improper_ctypes, 22 unknown_lints, 23 redundant_semicolon 24 )] 25 // Attributes needed when building as part of the standard library 26 #![cfg_attr( 27 feature = "rustc-dep-of-std", 28 feature(cfg_target_vendor, link_cfg, no_core) 29 )] 30 #![cfg_attr(libc_thread_local, feature(thread_local))] 31 // Enable extra lints: 32 #![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))] 33 #![deny(missing_copy_implementations, safe_packed_borrows)] 34 #![no_std] 35 #![cfg_attr(feature = "rustc-dep-of-std", no_core)] 36 #![cfg_attr(target_os = "redox", feature(static_nobundle))] 37 #![cfg_attr(libc_const_extern_fn, feature(const_extern_fn))] 38 39 #[macro_use] 40 mod macros; 41 42 cfg_if! { 43 if #[cfg(feature = "rustc-dep-of-std")] { 44 extern crate rustc_std_workspace_core as core; 45 #[allow(unused_imports)] 46 use core::iter; 47 #[allow(unused_imports)] 48 use core::option; 49 } 50 } 51 52 cfg_if! { 53 if #[cfg(libc_priv_mod_use)] { 54 #[cfg(libc_core_cvoid)] 55 #[allow(unused_imports)] 56 use core::ffi; 57 #[allow(unused_imports)] 58 use core::fmt; 59 #[allow(unused_imports)] 60 use core::hash; 61 #[allow(unused_imports)] 62 use core::num; 63 #[allow(unused_imports)] 64 use core::mem; 65 #[doc(hidden)] 66 #[allow(unused_imports)] 67 use core::clone::Clone; 68 #[doc(hidden)] 69 #[allow(unused_imports)] 70 use core::marker::Copy; 71 #[doc(hidden)] 72 #[allow(unused_imports)] 73 use core::option::Option; 74 } else { 75 #[doc(hidden)] 76 #[allow(unused_imports)] 77 pub use core::fmt; 78 #[doc(hidden)] 79 #[allow(unused_imports)] 80 pub use core::hash; 81 #[doc(hidden)] 82 #[allow(unused_imports)] 83 pub use core::num; 84 #[doc(hidden)] 85 #[allow(unused_imports)] 86 pub use core::mem; 87 #[doc(hidden)] 88 #[allow(unused_imports)] 89 pub use core::clone::Clone; 90 #[doc(hidden)] 91 #[allow(unused_imports)] 92 pub use core::marker::Copy; 93 #[doc(hidden)] 94 #[allow(unused_imports)] 95 pub use core::option::Option; 96 } 97 } 98 99 cfg_if! { 100 if #[cfg(windows)] { 101 mod fixed_width_ints; 102 pub use fixed_width_ints::*; 103 104 mod windows; 105 pub use windows::*; 106 } else if #[cfg(target_os = "cloudabi")] { 107 mod fixed_width_ints; 108 pub use fixed_width_ints::*; 109 110 mod cloudabi; 111 pub use cloudabi::*; 112 } else if #[cfg(target_os = "fuchsia")] { 113 mod fixed_width_ints; 114 pub use fixed_width_ints::*; 115 116 mod fuchsia; 117 pub use fuchsia::*; 118 } else if #[cfg(target_os = "switch")] { 119 mod fixed_width_ints; 120 pub use fixed_width_ints::*; 121 122 mod switch; 123 pub use switch::*; 124 } else if #[cfg(target_os = "vxworks")] { 125 mod fixed_width_ints; 126 pub use fixed_width_ints::*; 127 128 mod vxworks; 129 pub use vxworks::*; 130 } else if #[cfg(unix)] { 131 mod fixed_width_ints; 132 pub use fixed_width_ints::*; 133 134 mod unix; 135 pub use unix::*; 136 } else if #[cfg(target_os = "hermit")] { 137 mod fixed_width_ints; 138 pub use fixed_width_ints::*; 139 140 mod hermit; 141 pub use hermit::*; 142 } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] { 143 mod fixed_width_ints; 144 pub use fixed_width_ints::*; 145 146 mod sgx; 147 pub use sgx::*; 148 } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] { 149 mod fixed_width_ints; 150 pub use fixed_width_ints::*; 151 152 mod wasi; 153 pub use wasi::*; 154 } else { 155 // non-supported targets: empty... 156 } 157 } 158