libc_interface/
lib.rs

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
11//! Crate docs
12
13#![allow(bad_style, overflowing_literals, improper_ctypes)]
14#![crate_type = "rlib"]
15#![crate_name = "libc_interface"]
16#![cfg_attr(cross_platform_docs, feature(no_core, lang_items, const_fn))]
17#![cfg_attr(cross_platform_docs, no_core)]
18#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
19       html_favicon_url = "https://doc.rust-lang.org/favicon.ico")]
20
21#![cfg_attr(all(target_os = "linux", target_arch = "x86_64"), doc(
22    html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-linux-gnu"
23))]
24#![cfg_attr(all(target_os = "linux", target_arch = "x86"), doc(
25    html_root_url = "https://rust-lang.github.io/libc/i686-unknown-linux-gnu"
26))]
27#![cfg_attr(all(target_os = "linux", target_arch = "arm"), doc(
28    html_root_url = "https://rust-lang.github.io/libc/arm-unknown-linux-gnueabihf"
29))]
30#![cfg_attr(all(target_os = "linux", target_arch = "mips"), doc(
31    html_root_url = "https://rust-lang.github.io/libc/mips-unknown-linux-gnu"
32))]
33#![cfg_attr(all(target_os = "linux", target_arch = "aarch64"), doc(
34    html_root_url = "https://rust-lang.github.io/libc/aarch64-unknown-linux-gnu"
35))]
36#![cfg_attr(all(target_os = "linux", target_env = "musl"), doc(
37    html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-linux-musl"
38))]
39#![cfg_attr(all(target_os = "macos", target_arch = "x86_64"), doc(
40    html_root_url = "https://rust-lang.github.io/libc/x86_64-apple-darwin"
41))]
42#![cfg_attr(all(target_os = "macos", target_arch = "x86"), doc(
43    html_root_url = "https://rust-lang.github.io/libc/i686-apple-darwin"
44))]
45#![cfg_attr(all(windows, target_arch = "x86_64", target_env = "gnu"), doc(
46    html_root_url = "https://rust-lang.github.io/libc/x86_64-pc-windows-gnu"
47))]
48#![cfg_attr(all(windows, target_arch = "x86", target_env = "gnu"), doc(
49    html_root_url = "https://rust-lang.github.io/libc/i686-pc-windows-gnu"
50))]
51#![cfg_attr(all(windows, target_arch = "x86_64", target_env = "msvc"), doc(
52    html_root_url = "https://rust-lang.github.io/libc/x86_64-pc-windows-msvc"
53))]
54#![cfg_attr(all(windows, target_arch = "x86", target_env = "msvc"), doc(
55    html_root_url = "https://rust-lang.github.io/libc/i686-pc-windows-msvc"
56))]
57#![cfg_attr(target_os = "android", doc(
58    html_root_url = "https://rust-lang.github.io/libc/arm-linux-androideabi"
59))]
60#![cfg_attr(target_os = "freebsd", doc(
61    html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-freebsd"
62))]
63#![cfg_attr(target_os = "openbsd", doc(
64    html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-openbsd"
65))]
66#![cfg_attr(target_os = "bitrig", doc(
67    html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-bitrig"
68))]
69#![cfg_attr(target_os = "netbsd", doc(
70    html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-netbsd"
71))]
72#![cfg_attr(target_os = "dragonfly", doc(
73    html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-dragonfly"
74))]
75#![cfg_attr(target_os = "solaris", doc(
76    html_root_url = "https://rust-lang.github.io/libc/x86_64-sun-solaris"
77))]
78#![cfg_attr(all(target_os = "emscripten", target_arch = "asmjs"), doc(
79    html_root_url = "https://rust-lang.github.io/libc/asmjs-unknown-emscripten"
80))]
81#![cfg_attr(all(target_os = "emscripten", target_arch = "wasm32"), doc(
82    html_root_url = "https://rust-lang.github.io/libc/wasm32-unknown-emscripten"
83))]
84#![cfg_attr(all(target_os = "linux", target_arch = "sparc64"), doc(
85    html_root_url = "https://rust-lang.github.io/libc/sparc64-unknown-linux-gnu"
86))]
87
88// Attributes needed when building as part of the standard library
89#![cfg_attr(feature = "stdbuild", feature(staged_api, cfg_target_vendor))]
90#![cfg_attr(feature = "stdbuild", feature(link_cfg, repr_packed))]
91#![cfg_attr(feature = "stdbuild", allow(warnings))]
92#![cfg_attr(feature = "stdbuild", unstable(feature = "libc",
93                               reason = "use `libc` from crates.io",
94                               issue = "27783"))]
95
96#![no_std]
97
98#[macro_use] mod macros;
99mod dox;
100
101cfg_if! {
102    if #[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] {
103        // empty ...
104    } else {
105
106        pub use ::core::ffi::c_void;
107
108        pub type int8_t = i8;
109        pub type int16_t = i16;
110        pub type int32_t = i32;
111        pub type int64_t = i64;
112        pub type uint8_t = u8;
113        pub type uint16_t = u16;
114        pub type uint32_t = u32;
115        pub type uint64_t = u64;
116
117        pub type c_schar = i8;
118        pub type c_uchar = u8;
119        pub type c_short = i16;
120        pub type c_ushort = u16;
121        pub type c_int = i32;
122        pub type c_uint = u32;
123        pub type c_long = isize;
124        pub type c_ulong = usize;
125        pub type c_longlong = i64;
126        pub type c_ulonglong = u64;
127        pub type intmax_t = i64;
128        pub type uintmax_t = u64;
129        pub type c_float = f32;
130        pub type c_double = f64;
131
132        pub type size_t = usize;
133        pub type ptrdiff_t = isize;
134        pub type intptr_t = isize;
135        pub type uintptr_t = usize;
136        pub type ssize_t = isize;
137
138        pub enum FILE {}
139        pub enum fpos_t {} // TODO: fill this out with a struct
140
141        pub const INT_MIN: c_int = -2147483648;
142        pub const INT_MAX: c_int = 2147483647;
143    }
144}
145
146cfg_if! {
147    if #[cfg(windows)] {
148        mod windows;
149        pub use windows::*;
150    } else if #[cfg(target_os = "redox")] {
151        mod redox;
152        pub use redox::*;
153    } else if #[cfg(target_os = "cloudabi")] {
154        mod cloudabi;
155        pub use cloudabi::*;
156    } else if #[cfg(target_os = "fuchsia")] {
157        mod fuchsia;
158        pub use fuchsia::*;
159    } else if #[cfg(unix)] {
160        mod unix;
161        pub use unix::*;
162    } else {
163        // Unknown target_family
164    }
165}