blob: 8ee87eabafb3de8b37696f14a86d9a8aaa1d7fe9 [file] [log] [blame]
Alex Crichtondafaca92015-09-09 21:50:47 -07001// 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 Crichton95b18b72015-09-17 10:06:58 -070011//! Crate docs
12
Alex Crichtondafaca92015-09-09 21:50:47 -070013#![allow(bad_style, raw_pointer_derive)]
Alex Crichton24abc4f2015-09-16 23:54:56 -070014#![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 Crichton730a17f2015-09-17 10:05:36 -070019#![cfg_attr(all(target_os = "linux", target_arch = "x86_64"), doc(
20 html_root_url = "http://alexcrichton.com/libc/x86_64-unknown-linux-gnu"
21))]
22#![cfg_attr(all(target_os = "linux", target_arch = "x86"), doc(
23 html_root_url = "http://alexcrichton.com/libc/i686-unknown-linux-gnu"
24))]
25#![cfg_attr(all(target_os = "linux", target_arch = "arm"), doc(
26 html_root_url = "http://alexcrichton.com/libc/arm-unknown-linux-gnueabihf"
27))]
28#![cfg_attr(all(target_os = "linux", target_arch = "mips"), doc(
29 html_root_url = "http://alexcrichton.com/libc/mips-unknown-linux-gnu"
30))]
31#![cfg_attr(all(target_os = "linux", target_env = "musl"), doc(
32 html_root_url = "http://alexcrichton.com/libc/x86_64-unknown-linux-musl"
33))]
34#![cfg_attr(all(target_os = "macos", target_arch = "x86_64"), doc(
35 html_root_url = "http://alexcrichton.com/libc/x86_64-apple-darwin"
36))]
37#![cfg_attr(all(target_os = "macos", target_arch = "x86"), doc(
38 html_root_url = "http://alexcrichton.com/libc/i686-apple-darwin"
39))]
40#![cfg_attr(all(windows, target_arch = "x86_64", target_env = "gnu"), doc(
41 html_root_url = "http://alexcrichton.com/libc/x86_64-pc-windows-gnu"
42))]
Alex Crichton611e9a32015-09-17 10:06:19 -070043#![cfg_attr(all(windows, target_arch = "x86", target_env = "gnu"), doc(
Alex Crichton730a17f2015-09-17 10:05:36 -070044 html_root_url = "http://alexcrichton.com/libc/i686-pc-windows-gnu"
45))]
46#![cfg_attr(all(windows, target_arch = "x86_64", target_env = "msvc"), doc(
47 html_root_url = "http://alexcrichton.com/libc/x86_64-pc-windows-msvc"
48))]
Alex Crichton611e9a32015-09-17 10:06:19 -070049#![cfg_attr(all(windows, target_arch = "x86", target_env = "msvc"), doc(
Alex Crichton730a17f2015-09-17 10:05:36 -070050 html_root_url = "http://alexcrichton.com/libc/i686-pc-windows-msvc"
51))]
52#![cfg_attr(all(target_os = "android"), doc(
53 html_root_url = "http://alexcrichton.com/libc/arm-linux-androideabi"
54))]
Alex Crichtondafaca92015-09-09 21:50:47 -070055
Alex Crichton5d6cf052015-09-11 14:52:34 -070056#[macro_use] mod macros;
Alex Crichton24abc4f2015-09-16 23:54:56 -070057mod dox;
Alex Crichton31504842015-09-10 23:43:41 -070058
Alex Crichton5d6cf052015-09-11 14:52:34 -070059#[repr(u8)]
60pub enum c_void {
Alex Crichton9f2b1012015-09-16 23:32:21 -070061 // Two dummy variants so the #[repr] attribute can be used
62 #[doc(hidden)]
Alex Crichton5d6cf052015-09-11 14:52:34 -070063 __variant1,
Alex Crichton9f2b1012015-09-16 23:32:21 -070064 #[doc(hidden)]
Alex Crichton5d6cf052015-09-11 14:52:34 -070065 __variant2,
66}
Alex Crichtondafaca92015-09-09 21:50:47 -070067
Alex Crichton5d6cf052015-09-11 14:52:34 -070068pub type int8_t = i8;
69pub type int16_t = i16;
70pub type int32_t = i32;
71pub type int64_t = i64;
72pub type uint8_t = u8;
73pub type uint16_t = u16;
74pub type uint32_t = u32;
75pub type uint64_t = u64;
Alex Crichtondafaca92015-09-09 21:50:47 -070076
Alex Crichton5d6cf052015-09-11 14:52:34 -070077pub enum FILE {}
78pub enum fpos_t {}
79pub enum DIR {}
80pub enum dirent {}
Alex Crichtondafaca92015-09-09 21:50:47 -070081
Alex Crichton5d6cf052015-09-11 14:52:34 -070082extern {
83 pub fn isalnum(c: c_int) -> c_int;
84 pub fn isalpha(c: c_int) -> c_int;
85 pub fn iscntrl(c: c_int) -> c_int;
86 pub fn isdigit(c: c_int) -> c_int;
87 pub fn isgraph(c: c_int) -> c_int;
88 pub fn islower(c: c_int) -> c_int;
89 pub fn isprint(c: c_int) -> c_int;
90 pub fn ispunct(c: c_int) -> c_int;
91 pub fn isspace(c: c_int) -> c_int;
92 pub fn isupper(c: c_int) -> c_int;
93 pub fn isxdigit(c: c_int) -> c_int;
94 pub fn tolower(c: c_int) -> c_int;
95 pub fn toupper(c: c_int) -> c_int;
Alex Crichtondafaca92015-09-09 21:50:47 -070096
Alex Crichton5d6cf052015-09-11 14:52:34 -070097 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
98 link_name = "fopen$UNIX2003")]
99 pub fn fopen(filename: *const c_char,
100 mode: *const c_char) -> *mut FILE;
101 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
102 link_name = "freopen$UNIX2003")]
103 pub fn freopen(filename: *const c_char, mode: *const c_char,
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700104 file: *mut FILE) -> *mut FILE;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700105 pub fn fflush(file: *mut FILE) -> c_int;
106 pub fn fclose(file: *mut FILE) -> c_int;
107 pub fn remove(filename: *const c_char) -> c_int;
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700108 pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700109 pub fn tmpfile() -> *mut FILE;
110 pub fn setvbuf(stream: *mut FILE,
111 buffer: *mut c_char,
112 mode: c_int,
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700113 size: size_t) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700114 pub fn setbuf(stream: *mut FILE, buf: *mut c_char);
Alex Crichton5d6cf052015-09-11 14:52:34 -0700115 pub fn fgetc(stream: *mut FILE) -> c_int;
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700116 pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700117 pub fn fputc(c: c_int, stream: *mut FILE) -> c_int;
118 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
119 link_name = "fputs$UNIX2003")]
120 pub fn fputs(s: *const c_char, stream: *mut FILE)-> c_int;
121 pub fn puts(s: *const c_char) -> c_int;
122 pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int;
123 pub fn fread(ptr: *mut c_void,
124 size: size_t,
125 nobj: size_t,
126 stream: *mut FILE)
127 -> size_t;
128 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
129 link_name = "fwrite$UNIX2003")]
130 pub fn fwrite(ptr: *const c_void,
131 size: size_t,
132 nobj: size_t,
133 stream: *mut FILE)
134 -> size_t;
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700135 pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700136 pub fn ftell(stream: *mut FILE) -> c_long;
137 pub fn rewind(stream: *mut FILE);
138 pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int;
139 pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int;
140 pub fn feof(stream: *mut FILE) -> c_int;
141 pub fn ferror(stream: *mut FILE) -> c_int;
142 pub fn perror(s: *const c_char);
Alex Crichton5d6cf052015-09-11 14:52:34 -0700143 pub fn atoi(s: *const c_char) -> c_int;
144 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
145 link_name = "strtod$UNIX2003")]
Alex Crichtonbfc6ebc2015-09-11 15:29:40 -0700146 pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700147 pub fn strtol(s: *const c_char,
148 endp: *mut *mut c_char, base: c_int) -> c_long;
149 pub fn strtoul(s: *const c_char, endp: *mut *mut c_char,
150 base: c_int) -> c_ulong;
151 pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
152 pub fn malloc(size: size_t) -> *mut c_void;
153 pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
154 pub fn free(p: *mut c_void);
155 pub fn exit(status: c_int) -> !;
156 pub fn _exit(status: c_int) -> !;
157 pub fn atexit(cb: extern fn()) -> c_int;
158 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
159 link_name = "system$UNIX2003")]
160 pub fn system(s: *const c_char) -> c_int;
161 pub fn getenv(s: *const c_char) -> *mut c_char;
Alex Crichtondafaca92015-09-09 21:50:47 -0700162
Alex Crichton5d6cf052015-09-11 14:52:34 -0700163 pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char;
164 pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t)
165 -> *mut c_char;
166 pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char;
167 pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char;
168 pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int;
169 pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int;
170 pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int;
171 pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char;
172 pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char;
173 pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t;
174 pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t;
175 pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char;
176 pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
177 pub fn strlen(cs: *const c_char) -> size_t;
178 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
179 link_name = "strerror$UNIX2003")]
180 pub fn strerror(n: c_int) -> *mut c_char;
181 pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char;
182 pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t;
183 pub fn wcslen(buf: *const wchar_t) -> size_t;
Alex Crichtondafaca92015-09-09 21:50:47 -0700184
Alex Crichton5d6cf052015-09-11 14:52:34 -0700185 pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int;
186 pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
Alex Crichtondafaca92015-09-09 21:50:47 -0700187}
Alex Crichtond3d77922015-09-11 17:03:39 -0700188
189// These are all inline functions on android
190#[cfg(not(target_os = "android"))]
191extern {
192 pub fn abs(i: c_int) -> c_int;
193 pub fn atof(s: *const c_char) -> c_double;
194 pub fn labs(i: c_long) -> c_long;
195 pub fn rand() -> c_int;
196 pub fn srand(seed: c_uint);
197}
Alex Crichton50a42e22015-09-15 14:27:15 -0700198
199cfg_if! {
200 if #[cfg(windows)] {
201 mod windows;
202 pub use windows::*;
203 } else {
204 mod unix;
205 pub use unix::*;
206 }
207}