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 38 #[macro_use] 39 mod macros; 40 41 cfg_if! { 42 if #[cfg(feature = "rustc-dep-of-std")] { 43 extern crate rustc_std_workspace_core as core; 44 #[allow(unused_imports)] 45 use core::iter; 46 #[allow(unused_imports)] 47 use core::option; 48 } 49 } 50 51 cfg_if! { 52 if #[cfg(libc_priv_mod_use)] { 53 #[cfg(libc_core_cvoid)] 54 #[allow(unused_imports)] 55 use core::ffi; 56 #[allow(unused_imports)] 57 use core::fmt; 58 #[allow(unused_imports)] 59 use core::hash; 60 #[allow(unused_imports)] 61 use core::num; 62 #[allow(unused_imports)] 63 use core::mem; 64 #[doc(hidden)] 65 #[allow(unused_imports)] 66 use core::clone::Clone; 67 #[doc(hidden)] 68 #[allow(unused_imports)] 69 use core::marker::Copy; 70 #[doc(hidden)] 71 #[allow(unused_imports)] 72 use core::option::Option; 73 } else { 74 #[doc(hidden)] 75 #[allow(unused_imports)] 76 pub use core::fmt; 77 #[doc(hidden)] 78 #[allow(unused_imports)] 79 pub use core::hash; 80 #[doc(hidden)] 81 #[allow(unused_imports)] 82 pub use core::num; 83 #[doc(hidden)] 84 #[allow(unused_imports)] 85 pub use core::mem; 86 #[doc(hidden)] 87 #[allow(unused_imports)] 88 pub use core::clone::Clone; 89 #[doc(hidden)] 90 #[allow(unused_imports)] 91 pub use core::marker::Copy; 92 #[doc(hidden)] 93 #[allow(unused_imports)] 94 pub use core::option::Option; 95 } 96 } 97 98 cfg_if! { 99 if #[cfg(windows)] { 100 mod fixed_width_ints; 101 pub use fixed_width_ints::*; 102 103 mod windows; 104 pub use windows::*; 105 } else if #[cfg(target_os = "cloudabi")] { 106 mod fixed_width_ints; 107 pub use fixed_width_ints::*; 108 109 mod cloudabi; 110 pub use cloudabi::*; 111 } else if #[cfg(target_os = "fuchsia")] { 112 mod fixed_width_ints; 113 pub use fixed_width_ints::*; 114 115 mod fuchsia; 116 pub use fuchsia::*; 117 } else if #[cfg(target_os = "switch")] { 118 mod fixed_width_ints; 119 pub use fixed_width_ints::*; 120 121 mod switch; 122 pub use switch::*; 123 } else if #[cfg(target_os = "vxworks")] { 124 mod fixed_width_ints; 125 pub use fixed_width_ints::*; 126 127 mod vxworks; 128 pub use vxworks::*; 129 } else if #[cfg(unix)] { 130 mod fixed_width_ints; 131 pub use fixed_width_ints::*; 132 133 mod unix; 134 pub use unix::*; 135 } else if #[cfg(target_os = "hermit")] { 136 mod fixed_width_ints; 137 pub use fixed_width_ints::*; 138 139 mod hermit; 140 pub use hermit::*; 141 } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] { 142 mod fixed_width_ints; 143 pub use fixed_width_ints::*; 144 145 mod sgx; 146 pub use sgx::*; 147 } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] { 148 mod fixed_width_ints; 149 pub use fixed_width_ints::*; 150 151 mod wasi; 152 pub use wasi::*; 153 } else { 154 // non-supported targets: empty... 155 } 156 } 157