1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Crate docs

#![allow(bad_style, overflowing_literals, improper_ctypes)]
#![crate_type = "rlib"]
#![crate_name = "libc_interface"]
#![cfg_attr(cross_platform_docs, feature(no_core, lang_items, const_fn))]
#![cfg_attr(cross_platform_docs, no_core)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
       html_favicon_url = "https://doc.rust-lang.org/favicon.ico")]

#![cfg_attr(all(target_os = "linux", target_arch = "x86_64"), doc(
    html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-linux-gnu"
))]
#![cfg_attr(all(target_os = "linux", target_arch = "x86"), doc(
    html_root_url = "https://rust-lang.github.io/libc/i686-unknown-linux-gnu"
))]
#![cfg_attr(all(target_os = "linux", target_arch = "arm"), doc(
    html_root_url = "https://rust-lang.github.io/libc/arm-unknown-linux-gnueabihf"
))]
#![cfg_attr(all(target_os = "linux", target_arch = "mips"), doc(
    html_root_url = "https://rust-lang.github.io/libc/mips-unknown-linux-gnu"
))]
#![cfg_attr(all(target_os = "linux", target_arch = "aarch64"), doc(
    html_root_url = "https://rust-lang.github.io/libc/aarch64-unknown-linux-gnu"
))]
#![cfg_attr(all(target_os = "linux", target_env = "musl"), doc(
    html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-linux-musl"
))]
#![cfg_attr(all(target_os = "macos", target_arch = "x86_64"), doc(
    html_root_url = "https://rust-lang.github.io/libc/x86_64-apple-darwin"
))]
#![cfg_attr(all(target_os = "macos", target_arch = "x86"), doc(
    html_root_url = "https://rust-lang.github.io/libc/i686-apple-darwin"
))]
#![cfg_attr(all(windows, target_arch = "x86_64", target_env = "gnu"), doc(
    html_root_url = "https://rust-lang.github.io/libc/x86_64-pc-windows-gnu"
))]
#![cfg_attr(all(windows, target_arch = "x86", target_env = "gnu"), doc(
    html_root_url = "https://rust-lang.github.io/libc/i686-pc-windows-gnu"
))]
#![cfg_attr(all(windows, target_arch = "x86_64", target_env = "msvc"), doc(
    html_root_url = "https://rust-lang.github.io/libc/x86_64-pc-windows-msvc"
))]
#![cfg_attr(all(windows, target_arch = "x86", target_env = "msvc"), doc(
    html_root_url = "https://rust-lang.github.io/libc/i686-pc-windows-msvc"
))]
#![cfg_attr(target_os = "android", doc(
    html_root_url = "https://rust-lang.github.io/libc/arm-linux-androideabi"
))]
#![cfg_attr(target_os = "freebsd", doc(
    html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-freebsd"
))]
#![cfg_attr(target_os = "openbsd", doc(
    html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-openbsd"
))]
#![cfg_attr(target_os = "bitrig", doc(
    html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-bitrig"
))]
#![cfg_attr(target_os = "netbsd", doc(
    html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-netbsd"
))]
#![cfg_attr(target_os = "dragonfly", doc(
    html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-dragonfly"
))]
#![cfg_attr(target_os = "solaris", doc(
    html_root_url = "https://rust-lang.github.io/libc/x86_64-sun-solaris"
))]
#![cfg_attr(all(target_os = "emscripten", target_arch = "asmjs"), doc(
    html_root_url = "https://rust-lang.github.io/libc/asmjs-unknown-emscripten"
))]
#![cfg_attr(all(target_os = "emscripten", target_arch = "wasm32"), doc(
    html_root_url = "https://rust-lang.github.io/libc/wasm32-unknown-emscripten"
))]
#![cfg_attr(all(target_os = "linux", target_arch = "sparc64"), doc(
    html_root_url = "https://rust-lang.github.io/libc/sparc64-unknown-linux-gnu"
))]

// Attributes needed when building as part of the standard library
#![cfg_attr(feature = "stdbuild", feature(staged_api, cfg_target_vendor))]
#![cfg_attr(feature = "stdbuild", feature(link_cfg, repr_packed))]
#![cfg_attr(feature = "stdbuild", allow(warnings))]
#![cfg_attr(feature = "stdbuild", unstable(feature = "libc",
                               reason = "use `libc` from crates.io",
                               issue = "27783"))]

#![no_std]

#[macro_use] mod macros;
mod dox;

cfg_if! {
    if #[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] {
        // empty ...
    } else {

        pub use ::core::ffi::c_void;

        pub type int8_t = i8;
        pub type int16_t = i16;
        pub type int32_t = i32;
        pub type int64_t = i64;
        pub type uint8_t = u8;
        pub type uint16_t = u16;
        pub type uint32_t = u32;
        pub type uint64_t = u64;

        pub type c_schar = i8;
        pub type c_uchar = u8;
        pub type c_short = i16;
        pub type c_ushort = u16;
        pub type c_int = i32;
        pub type c_uint = u32;
        pub type c_long = isize;
        pub type c_ulong = usize;
        pub type c_longlong = i64;
        pub type c_ulonglong = u64;
        pub type intmax_t = i64;
        pub type uintmax_t = u64;
        pub type c_float = f32;
        pub type c_double = f64;

        pub type size_t = usize;
        pub type ptrdiff_t = isize;
        pub type intptr_t = isize;
        pub type uintptr_t = usize;
        pub type ssize_t = isize;

        pub enum FILE {}
        pub enum fpos_t {} // TODO: fill this out with a struct

        pub const INT_MIN: c_int = -2147483648;
        pub const INT_MAX: c_int = 2147483647;
    }
}

cfg_if! {
    if #[cfg(windows)] {
        mod windows;
        pub use windows::*;
    } else if #[cfg(target_os = "redox")] {
        mod redox;
        pub use redox::*;
    } else if #[cfg(target_os = "cloudabi")] {
        mod cloudabi;
        pub use cloudabi::*;
    } else if #[cfg(target_os = "fuchsia")] {
        mod fuchsia;
        pub use fuchsia::*;
    } else if #[cfg(unix)] {
        mod unix;
        pub use unix::*;
    } else {
        // Unknown target_family
    }
}