Alex Crichton | dafaca9 | 2015-09-09 21:50:47 -0700 | [diff] [blame] | 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 | |
Alex Crichton | 95b18b7 | 2015-09-17 10:06:58 -0700 | [diff] [blame] | 11 | //! Crate docs |
| 12 | |
Alex Crichton | 1791046 | 2015-09-22 19:11:04 -0700 | [diff] [blame] | 13 | #![allow(bad_style, raw_pointer_derive, improper_ctypes)] |
Alex Crichton | 24abc4f | 2015-09-16 23:54:56 -0700 | [diff] [blame] | 14 | #![cfg_attr(dox, feature(no_core, lang_items))] |
| 15 | #![cfg_attr(dox, no_core)] |
| 16 | #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", |
| 17 | html_favicon_url = "https://doc.rust-lang.org/favicon.ico")] |
| 18 | |
Alex Crichton | 730a17f | 2015-09-17 10:05:36 -0700 | [diff] [blame] | 19 | #![cfg_attr(all(target_os = "linux", target_arch = "x86_64"), doc( |
Alex Crichton | 13418a5 | 2015-10-29 11:54:12 -0700 | [diff] [blame] | 20 | html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-linux-gnu" |
Alex Crichton | 730a17f | 2015-09-17 10:05:36 -0700 | [diff] [blame] | 21 | ))] |
| 22 | #![cfg_attr(all(target_os = "linux", target_arch = "x86"), doc( |
Alex Crichton | 13418a5 | 2015-10-29 11:54:12 -0700 | [diff] [blame] | 23 | html_root_url = "https://doc.rust-lang.org/libc/i686-unknown-linux-gnu" |
Alex Crichton | 730a17f | 2015-09-17 10:05:36 -0700 | [diff] [blame] | 24 | ))] |
| 25 | #![cfg_attr(all(target_os = "linux", target_arch = "arm"), doc( |
Alex Crichton | 13418a5 | 2015-10-29 11:54:12 -0700 | [diff] [blame] | 26 | html_root_url = "https://doc.rust-lang.org/libc/arm-unknown-linux-gnueabihf" |
Alex Crichton | 730a17f | 2015-09-17 10:05:36 -0700 | [diff] [blame] | 27 | ))] |
| 28 | #![cfg_attr(all(target_os = "linux", target_arch = "mips"), doc( |
Alex Crichton | 13418a5 | 2015-10-29 11:54:12 -0700 | [diff] [blame] | 29 | html_root_url = "https://doc.rust-lang.org/libc/mips-unknown-linux-gnu" |
Alex Crichton | 730a17f | 2015-09-17 10:05:36 -0700 | [diff] [blame] | 30 | ))] |
Alex Crichton | d13e1e4 | 2015-09-17 17:29:18 -0700 | [diff] [blame] | 31 | #![cfg_attr(all(target_os = "linux", target_arch = "aarch64"), doc( |
Alex Crichton | 13418a5 | 2015-10-29 11:54:12 -0700 | [diff] [blame] | 32 | html_root_url = "https://doc.rust-lang.org/libc/aarch64-unknown-linux-gnu" |
Alex Crichton | d13e1e4 | 2015-09-17 17:29:18 -0700 | [diff] [blame] | 33 | ))] |
Alex Crichton | 730a17f | 2015-09-17 10:05:36 -0700 | [diff] [blame] | 34 | #![cfg_attr(all(target_os = "linux", target_env = "musl"), doc( |
Alex Crichton | 13418a5 | 2015-10-29 11:54:12 -0700 | [diff] [blame] | 35 | html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-linux-musl" |
Alex Crichton | 730a17f | 2015-09-17 10:05:36 -0700 | [diff] [blame] | 36 | ))] |
| 37 | #![cfg_attr(all(target_os = "macos", target_arch = "x86_64"), doc( |
Alex Crichton | 13418a5 | 2015-10-29 11:54:12 -0700 | [diff] [blame] | 38 | html_root_url = "https://doc.rust-lang.org/libc/x86_64-apple-darwin" |
Alex Crichton | 730a17f | 2015-09-17 10:05:36 -0700 | [diff] [blame] | 39 | ))] |
| 40 | #![cfg_attr(all(target_os = "macos", target_arch = "x86"), doc( |
Alex Crichton | 13418a5 | 2015-10-29 11:54:12 -0700 | [diff] [blame] | 41 | html_root_url = "https://doc.rust-lang.org/libc/i686-apple-darwin" |
Alex Crichton | 730a17f | 2015-09-17 10:05:36 -0700 | [diff] [blame] | 42 | ))] |
| 43 | #![cfg_attr(all(windows, target_arch = "x86_64", target_env = "gnu"), doc( |
Alex Crichton | 13418a5 | 2015-10-29 11:54:12 -0700 | [diff] [blame] | 44 | html_root_url = "https://doc.rust-lang.org/libc/x86_64-pc-windows-gnu" |
Alex Crichton | 730a17f | 2015-09-17 10:05:36 -0700 | [diff] [blame] | 45 | ))] |
Alex Crichton | 611e9a3 | 2015-09-17 10:06:19 -0700 | [diff] [blame] | 46 | #![cfg_attr(all(windows, target_arch = "x86", target_env = "gnu"), doc( |
Alex Crichton | 13418a5 | 2015-10-29 11:54:12 -0700 | [diff] [blame] | 47 | html_root_url = "https://doc.rust-lang.org/libc/i686-pc-windows-gnu" |
Alex Crichton | 730a17f | 2015-09-17 10:05:36 -0700 | [diff] [blame] | 48 | ))] |
| 49 | #![cfg_attr(all(windows, target_arch = "x86_64", target_env = "msvc"), doc( |
Alex Crichton | 13418a5 | 2015-10-29 11:54:12 -0700 | [diff] [blame] | 50 | html_root_url = "https://doc.rust-lang.org/libc/x86_64-pc-windows-msvc" |
Alex Crichton | 730a17f | 2015-09-17 10:05:36 -0700 | [diff] [blame] | 51 | ))] |
Alex Crichton | 611e9a3 | 2015-09-17 10:06:19 -0700 | [diff] [blame] | 52 | #![cfg_attr(all(windows, target_arch = "x86", target_env = "msvc"), doc( |
Alex Crichton | 13418a5 | 2015-10-29 11:54:12 -0700 | [diff] [blame] | 53 | html_root_url = "https://doc.rust-lang.org/libc/i686-pc-windows-msvc" |
Alex Crichton | 730a17f | 2015-09-17 10:05:36 -0700 | [diff] [blame] | 54 | ))] |
| 55 | #![cfg_attr(all(target_os = "android"), doc( |
Alex Crichton | 13418a5 | 2015-10-29 11:54:12 -0700 | [diff] [blame] | 56 | html_root_url = "https://doc.rust-lang.org/libc/arm-linux-androideabi" |
Alex Crichton | 730a17f | 2015-09-17 10:05:36 -0700 | [diff] [blame] | 57 | ))] |
Alex Crichton | dafaca9 | 2015-09-09 21:50:47 -0700 | [diff] [blame] | 58 | |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 59 | #[macro_use] mod macros; |
Alex Crichton | 24abc4f | 2015-09-16 23:54:56 -0700 | [diff] [blame] | 60 | mod dox; |
Alex Crichton | 3150484 | 2015-09-10 23:43:41 -0700 | [diff] [blame] | 61 | |
Alex Crichton | d5c4e55 | 2015-10-29 15:46:16 -0700 | [diff] [blame^] | 62 | // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help enable |
| 63 | // more optimization opportunities around it recognizing things like |
| 64 | // malloc/free. |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 65 | #[repr(u8)] |
| 66 | pub enum c_void { |
Alex Crichton | d5c4e55 | 2015-10-29 15:46:16 -0700 | [diff] [blame^] | 67 | // Two dummy variants so the #[repr] attribute can be used. |
Alex Crichton | 9f2b101 | 2015-09-16 23:32:21 -0700 | [diff] [blame] | 68 | #[doc(hidden)] |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 69 | __variant1, |
Alex Crichton | 9f2b101 | 2015-09-16 23:32:21 -0700 | [diff] [blame] | 70 | #[doc(hidden)] |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 71 | __variant2, |
| 72 | } |
Alex Crichton | dafaca9 | 2015-09-09 21:50:47 -0700 | [diff] [blame] | 73 | |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 74 | pub type int8_t = i8; |
| 75 | pub type int16_t = i16; |
| 76 | pub type int32_t = i32; |
| 77 | pub type int64_t = i64; |
| 78 | pub type uint8_t = u8; |
| 79 | pub type uint16_t = u16; |
| 80 | pub type uint32_t = u32; |
| 81 | pub type uint64_t = u64; |
Alex Crichton | dafaca9 | 2015-09-09 21:50:47 -0700 | [diff] [blame] | 82 | |
Alex Crichton | 1791046 | 2015-09-22 19:11:04 -0700 | [diff] [blame] | 83 | pub type c_schar = i8; |
| 84 | pub type c_uchar = u8; |
| 85 | pub type c_short = i16; |
| 86 | pub type c_ushort = u16; |
| 87 | pub type c_int = i32; |
| 88 | pub type c_uint = u32; |
| 89 | pub type c_float = f32; |
| 90 | pub type c_double = f64; |
| 91 | pub type c_longlong = i64; |
| 92 | pub type c_ulonglong = u64; |
| 93 | pub type intmax_t = i64; |
| 94 | pub type uintmax_t = u64; |
| 95 | |
| 96 | pub type size_t = usize; |
| 97 | pub type ptrdiff_t = isize; |
| 98 | pub type intptr_t = isize; |
| 99 | pub type uintptr_t = usize; |
| 100 | pub type ssize_t = isize; |
| 101 | |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 102 | pub enum FILE {} |
| 103 | pub enum fpos_t {} |
| 104 | pub enum DIR {} |
| 105 | pub enum dirent {} |
Alex Crichton | dafaca9 | 2015-09-09 21:50:47 -0700 | [diff] [blame] | 106 | |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 107 | extern { |
| 108 | pub fn isalnum(c: c_int) -> c_int; |
| 109 | pub fn isalpha(c: c_int) -> c_int; |
| 110 | pub fn iscntrl(c: c_int) -> c_int; |
| 111 | pub fn isdigit(c: c_int) -> c_int; |
| 112 | pub fn isgraph(c: c_int) -> c_int; |
| 113 | pub fn islower(c: c_int) -> c_int; |
| 114 | pub fn isprint(c: c_int) -> c_int; |
| 115 | pub fn ispunct(c: c_int) -> c_int; |
| 116 | pub fn isspace(c: c_int) -> c_int; |
| 117 | pub fn isupper(c: c_int) -> c_int; |
| 118 | pub fn isxdigit(c: c_int) -> c_int; |
| 119 | pub fn tolower(c: c_int) -> c_int; |
| 120 | pub fn toupper(c: c_int) -> c_int; |
Alex Crichton | dafaca9 | 2015-09-09 21:50:47 -0700 | [diff] [blame] | 121 | |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 122 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
| 123 | link_name = "fopen$UNIX2003")] |
| 124 | pub fn fopen(filename: *const c_char, |
| 125 | mode: *const c_char) -> *mut FILE; |
| 126 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
| 127 | link_name = "freopen$UNIX2003")] |
| 128 | pub fn freopen(filename: *const c_char, mode: *const c_char, |
Alex Crichton | bfc6ebc | 2015-09-11 15:29:40 -0700 | [diff] [blame] | 129 | file: *mut FILE) -> *mut FILE; |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 130 | pub fn fflush(file: *mut FILE) -> c_int; |
| 131 | pub fn fclose(file: *mut FILE) -> c_int; |
| 132 | pub fn remove(filename: *const c_char) -> c_int; |
Alex Crichton | bfc6ebc | 2015-09-11 15:29:40 -0700 | [diff] [blame] | 133 | pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 134 | pub fn tmpfile() -> *mut FILE; |
| 135 | pub fn setvbuf(stream: *mut FILE, |
| 136 | buffer: *mut c_char, |
| 137 | mode: c_int, |
Alex Crichton | bfc6ebc | 2015-09-11 15:29:40 -0700 | [diff] [blame] | 138 | size: size_t) -> c_int; |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 139 | pub fn setbuf(stream: *mut FILE, buf: *mut c_char); |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 140 | pub fn fgetc(stream: *mut FILE) -> c_int; |
Alex Crichton | bfc6ebc | 2015-09-11 15:29:40 -0700 | [diff] [blame] | 141 | pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 142 | pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; |
| 143 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
| 144 | link_name = "fputs$UNIX2003")] |
| 145 | pub fn fputs(s: *const c_char, stream: *mut FILE)-> c_int; |
| 146 | pub fn puts(s: *const c_char) -> c_int; |
| 147 | pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; |
| 148 | pub fn fread(ptr: *mut c_void, |
| 149 | size: size_t, |
| 150 | nobj: size_t, |
| 151 | stream: *mut FILE) |
| 152 | -> size_t; |
| 153 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
| 154 | link_name = "fwrite$UNIX2003")] |
| 155 | pub fn fwrite(ptr: *const c_void, |
| 156 | size: size_t, |
| 157 | nobj: size_t, |
| 158 | stream: *mut FILE) |
| 159 | -> size_t; |
Alex Crichton | bfc6ebc | 2015-09-11 15:29:40 -0700 | [diff] [blame] | 160 | pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 161 | pub fn ftell(stream: *mut FILE) -> c_long; |
| 162 | pub fn rewind(stream: *mut FILE); |
| 163 | pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; |
| 164 | pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; |
| 165 | pub fn feof(stream: *mut FILE) -> c_int; |
| 166 | pub fn ferror(stream: *mut FILE) -> c_int; |
| 167 | pub fn perror(s: *const c_char); |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 168 | pub fn atoi(s: *const c_char) -> c_int; |
| 169 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
| 170 | link_name = "strtod$UNIX2003")] |
Alex Crichton | bfc6ebc | 2015-09-11 15:29:40 -0700 | [diff] [blame] | 171 | pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 172 | pub fn strtol(s: *const c_char, |
| 173 | endp: *mut *mut c_char, base: c_int) -> c_long; |
| 174 | pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, |
| 175 | base: c_int) -> c_ulong; |
| 176 | pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; |
| 177 | pub fn malloc(size: size_t) -> *mut c_void; |
| 178 | pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; |
| 179 | pub fn free(p: *mut c_void); |
| 180 | pub fn exit(status: c_int) -> !; |
| 181 | pub fn _exit(status: c_int) -> !; |
| 182 | pub fn atexit(cb: extern fn()) -> c_int; |
| 183 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
| 184 | link_name = "system$UNIX2003")] |
| 185 | pub fn system(s: *const c_char) -> c_int; |
| 186 | pub fn getenv(s: *const c_char) -> *mut c_char; |
Alex Crichton | dafaca9 | 2015-09-09 21:50:47 -0700 | [diff] [blame] | 187 | |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 188 | pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; |
| 189 | pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) |
| 190 | -> *mut c_char; |
| 191 | pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; |
| 192 | pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char; |
| 193 | pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; |
| 194 | pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; |
| 195 | pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; |
| 196 | pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; |
| 197 | pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; |
| 198 | pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; |
| 199 | pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; |
| 200 | pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; |
| 201 | pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; |
| 202 | pub fn strlen(cs: *const c_char) -> size_t; |
| 203 | #[cfg_attr(all(target_os = "macos", target_arch = "x86"), |
| 204 | link_name = "strerror$UNIX2003")] |
| 205 | pub fn strerror(n: c_int) -> *mut c_char; |
| 206 | pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; |
| 207 | pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; |
| 208 | pub fn wcslen(buf: *const wchar_t) -> size_t; |
Alex Crichton | dafaca9 | 2015-09-09 21:50:47 -0700 | [diff] [blame] | 209 | |
Alex Crichton | 5d6cf05 | 2015-09-11 14:52:34 -0700 | [diff] [blame] | 210 | pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; |
| 211 | pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; |
Alex Crichton | dafaca9 | 2015-09-09 21:50:47 -0700 | [diff] [blame] | 212 | } |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 213 | |
Alex Crichton | d5c4e55 | 2015-10-29 15:46:16 -0700 | [diff] [blame^] | 214 | // These are all inline functions on android, so they end up just being entirely |
| 215 | // missing on that platform. |
Alex Crichton | d3d7792 | 2015-09-11 17:03:39 -0700 | [diff] [blame] | 216 | #[cfg(not(target_os = "android"))] |
| 217 | extern { |
| 218 | pub fn abs(i: c_int) -> c_int; |
| 219 | pub fn atof(s: *const c_char) -> c_double; |
| 220 | pub fn labs(i: c_long) -> c_long; |
| 221 | pub fn rand() -> c_int; |
| 222 | pub fn srand(seed: c_uint); |
| 223 | } |
Alex Crichton | 50a42e2 | 2015-09-15 14:27:15 -0700 | [diff] [blame] | 224 | |
| 225 | cfg_if! { |
| 226 | if #[cfg(windows)] { |
| 227 | mod windows; |
| 228 | pub use windows::*; |
| 229 | } else { |
| 230 | mod unix; |
| 231 | pub use unix::*; |
| 232 | } |
| 233 | } |