1 // Copyright 2012 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.
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.
12 * Bindings for the C standard library and other platform libraries
14 * This module contains bindings to the C standard library,
15 * organized into modules by their defining standard.
16 * Additionally, it contains some assorted platform-specific definitions.
17 * For convenience, most functions and types are reexported from `core::libc`,
18 * so `pub use core::libc::*` will import the available
19 * C bindings as appropriate for the target platform. The exact
20 * set of functions available are platform specific.
22 * *Note* Rustdoc does not indicate reexports currently. Also, because these
23 * definitions are platform-specific, some may not
24 * appear in the generated documentation.
26 * We consider the following specs reasonably normative with respect
27 * to interoperating with the C standard library (libc/msvcrt):
29 * * ISO 9899:1990 ('C95', 'ANSI C', 'Standard C'), NA1, 1995.
30 * * ISO 9899:1999 ('C99' or 'C9x').
31 * * ISO 9945:1988 / IEEE 1003.1-1988 ('POSIX.1').
32 * * ISO 9945:2001 / IEEE 1003.1-2001 ('POSIX:2001', 'SUSv3').
33 * * ISO 9945:2008 / IEEE 1003.1-2008 ('POSIX:2008', 'SUSv4').
35 * Note that any reference to the 1996 revision of POSIX, or any revs
36 * between 1990 (when '88 was approved at ISO) and 2001 (when the next
37 * actual revision-revision happened), are merely additions of other
38 * chapters (1b and 1c) outside the core interfaces.
40 * Despite having several names each, these are *reasonably* coherent
41 * point-in-time, list-of-definition sorts of specs. You can get each under a
42 * variety of names but will wind up with the same definition in each case.
44 * See standards(7) in linux-manpages for more details.
46 * Our interface to these libraries is complicated by the non-universality of
47 * conformance to any of them. About the only thing universally supported is
48 * the first (C95), beyond that definitions quickly become absent on various
51 * We therefore wind up dividing our module-space up (mostly for the sake of
52 * sanity while editing, filling-in-details and eliminating duplication) into
53 * definitions common-to-all (held in modules named c95, c99, posix88, posix01
54 * and posix08) and definitions that appear only on *some* platforms (named
55 * 'extra'). This would be things like significant OSX foundation kit, or
56 * win32 library kernel32.dll, or various fancy glibc, linux or BSD
59 * In addition to the per-platform 'extra' modules, we define a module of
60 * 'common BSD' libc routines that never quite made it into POSIX but show up
61 * in multiple derived systems. This is the 4.4BSD r2 / 1995 release, the
62 * final one from Berkeley after the lawsuits died down and the CSRG
66 #[allow(non_camel_case_types)];
68 // Initial glob-exports mean that all the contents of all the modules
69 // wind up exported, if you're interested in writing platform-specific code.
71 pub use libc::types::common::c95::*;
72 pub use libc::types::common::c99::*;
73 pub use libc::types::common::posix88::*;
74 pub use libc::types::common::posix01::*;
75 pub use libc::types::common::posix08::*;
76 pub use libc::types::common::bsd44::*;
77 pub use libc::types::os::common::posix01::*;
78 pub use libc::types::os::arch::c95::*;
79 pub use libc::types::os::arch::c99::*;
80 pub use libc::types::os::arch::posix88::*;
81 pub use libc::types::os::arch::posix01::*;
82 pub use libc::types::os::arch::posix08::*;
83 pub use libc::types::os::arch::bsd44::*;
84 pub use libc::types::os::arch::extra::*;
86 pub use libc::consts::os::c95::*;
87 pub use libc::consts::os::c99::*;
88 pub use libc::consts::os::posix88::*;
89 pub use libc::consts::os::posix01::*;
90 pub use libc::consts::os::posix08::*;
91 pub use libc::consts::os::bsd44::*;
92 pub use libc::consts::os::extra::*;
94 pub use libc::funcs::c95::ctype::*;
95 pub use libc::funcs::c95::stdio::*;
96 pub use libc::funcs::c95::stdlib::*;
97 pub use libc::funcs::c95::string::*;
99 pub use libc::funcs::posix88::stat_::*;
100 pub use libc::funcs::posix88::stdio::*;
101 pub use libc::funcs::posix88::fcntl::*;
102 pub use libc::funcs::posix88::dirent::*;
103 pub use libc::funcs::posix88::unistd::*;
105 pub use libc::funcs::posix01::stat_::*;
106 pub use libc::funcs::posix01::unistd::*;
107 pub use libc::funcs::posix01::glob::*;
108 pub use libc::funcs::posix08::unistd::*;
110 pub use libc::funcs::bsd44::*;
111 pub use libc::funcs::extra::*;
113 #[cfg(target_os = "win32")]
114 pub use libc::funcs::extra::kernel32::*;
115 #[cfg(target_os = "win32")]
116 pub use libc::funcs::extra::msvcrt::*;
118 // Explicit export lists for the intersection (provided here) mean that
119 // you can write more-platform-agnostic code if you stick to just these
122 pub use libc::types::common::c95::{FILE, c_void, fpos_t};
123 pub use libc::types::common::posix88::{DIR, dirent_t};
124 pub use libc::types::os::arch::c95::{c_char, c_double, c_float, c_int};
125 pub use libc::types::os::arch::c95::{c_long, c_short, c_uchar, c_ulong};
126 pub use libc::types::os::arch::c95::{c_ushort, clock_t, ptrdiff_t};
127 pub use libc::types::os::arch::c95::{size_t, time_t};
128 pub use libc::types::os::arch::c99::{c_longlong, c_ulonglong, intptr_t};
129 pub use libc::types::os::arch::c99::{uintptr_t};
130 pub use libc::types::os::arch::posix88::{dev_t, dirent_t, ino_t, mode_t};
131 pub use libc::types::os::arch::posix88::{off_t, pid_t, ssize_t};
133 pub use libc::consts::os::c95::{_IOFBF, _IOLBF, _IONBF, BUFSIZ, EOF};
134 pub use libc::consts::os::c95::{EXIT_FAILURE, EXIT_SUCCESS};
135 pub use libc::consts::os::c95::{FILENAME_MAX, FOPEN_MAX, L_tmpnam};
136 pub use libc::consts::os::c95::{RAND_MAX, SEEK_CUR, SEEK_END};
137 pub use libc::consts::os::c95::{SEEK_SET, TMP_MAX};
138 pub use libc::consts::os::posix88::{F_OK, O_APPEND, O_CREAT, O_EXCL};
139 pub use libc::consts::os::posix88::{O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY};
140 pub use libc::consts::os::posix88::{R_OK, S_IEXEC, S_IFBLK, S_IFCHR};
141 pub use libc::consts::os::posix88::{S_IFDIR, S_IFIFO, S_IFMT, S_IFREG};
142 pub use libc::consts::os::posix88::{S_IREAD, S_IRUSR, S_IRWXU, S_IWUSR};
143 pub use libc::consts::os::posix88::{STDERR_FILENO, STDIN_FILENO};
144 pub use libc::consts::os::posix88::{STDOUT_FILENO, W_OK, X_OK};
146 pub use libc::funcs::c95::ctype::{isalnum, isalpha, iscntrl, isdigit};
147 pub use libc::funcs::c95::ctype::{islower, isprint, ispunct, isspace};
148 pub use libc::funcs::c95::ctype::{isupper, isxdigit, tolower, toupper};
150 pub use libc::funcs::c95::stdio::{fclose, feof, ferror, fflush, fgetc};
151 pub use libc::funcs::c95::stdio::{fgetpos, fgets, fopen, fputc, fputs};
152 pub use libc::funcs::c95::stdio::{fread, freopen, fseek, fsetpos, ftell};
153 pub use libc::funcs::c95::stdio::{fwrite, perror, puts, remove, rewind};
154 pub use libc::funcs::c95::stdio::{setbuf, setvbuf, tmpfile, ungetc};
156 pub use libc::funcs::c95::stdlib::{abort, abs, atof, atoi, calloc, exit};
157 pub use libc::funcs::c95::stdlib::{free, getenv, labs, malloc, rand};
158 pub use libc::funcs::c95::stdlib::{realloc, srand, strtod, strtol};
159 pub use libc::funcs::c95::stdlib::{strtoul, system};
161 pub use libc::funcs::c95::string::{memchr, memcmp, memcpy, memmove};
162 pub use libc::funcs::c95::string::{memset, strcat, strchr, strcmp};
163 pub use libc::funcs::c95::string::{strcoll, strcpy, strcspn, strerror};
164 pub use libc::funcs::c95::string::{strlen, strncat, strncmp, strncpy};
165 pub use libc::funcs::c95::string::{strpbrk, strrchr, strspn, strstr};
166 pub use libc::funcs::c95::string::{strtok, strxfrm};
168 pub use libc::funcs::posix88::fcntl::{open, creat};
169 pub use libc::funcs::posix88::stat_::{chmod, fstat, mkdir, stat};
170 pub use libc::funcs::posix88::stdio::{fdopen, fileno, pclose, popen};
171 pub use libc::funcs::posix88::unistd::{access, chdir, close, dup, dup2};
172 pub use libc::funcs::posix88::unistd::{execv, execve, execvp, getcwd};
173 pub use libc::funcs::posix88::unistd::{getpid, isatty, lseek, pipe, read};
174 pub use libc::funcs::posix88::unistd::{rmdir, unlink, write};
179 // Types tend to vary *per architecture* so we pull their definitions out
182 // Standard types that are opaque or common, so are not per-target.
190 pub type int8_t = i8;
191 pub type int16_t = i16;
192 pub type int32_t = i32;
193 pub type int64_t = i64;
194 pub type uint8_t = u8;
195 pub type uint16_t = u16;
196 pub type uint32_t = u32;
197 pub type uint64_t = u64;
208 // Standard types that are scalar but vary by OS and arch.
210 #[cfg(target_os = "linux")]
211 #[cfg(target_os = "android")]
215 use libc::types::common::c95::{c_void};
216 use libc::types::os::arch::c95::{c_char, size_t};
231 #[cfg(target_arch = "x86")]
232 #[cfg(target_arch = "arm")]
233 #[cfg(target_arch = "mips")]
236 pub type c_char = i8;
237 pub type c_schar = i8;
238 pub type c_uchar = u8;
239 pub type c_short = i16;
240 pub type c_ushort = u16;
241 pub type c_int = i32;
242 pub type c_uint = u32;
243 pub type c_long = i32;
244 pub type c_ulong = u32;
245 pub type c_float = f32;
246 pub type c_double = f64;
247 pub type size_t = u32;
248 pub type ptrdiff_t = i32;
249 pub type clock_t = i32;
250 pub type time_t = i32;
251 pub type wchar_t = i32;
254 pub type c_longlong = i64;
255 pub type c_ulonglong = u64;
256 pub type intptr_t = int;
257 pub type uintptr_t = uint;
260 pub type off_t = i32;
261 pub type dev_t = u64;
262 pub type ino_t = u32;
263 pub type pid_t = i32;
264 pub type uid_t = u32;
265 pub type gid_t = u32;
266 pub type useconds_t = u32;
267 pub type mode_t = u32;
268 pub type ssize_t = i32;
271 use libc::types::os::arch::c95::{c_int, c_short, c_long,
273 use libc::types::os::arch::posix88::{dev_t, gid_t, ino_t};
274 use libc::types::os::arch::posix88::{mode_t, off_t};
275 use libc::types::os::arch::posix88::{uid_t};
277 pub type nlink_t = u32;
278 pub type blksize_t = i32;
279 pub type blkcnt_t = i32;
291 st_blksize: blksize_t,
294 st_atime_nsec: c_long,
296 st_mtime_nsec: c_long,
298 st_ctime_nsec: c_long,
308 #[cfg(target_arch = "x86_64")]
311 pub type c_char = i8;
312 pub type c_schar = i8;
313 pub type c_uchar = u8;
314 pub type c_short = i16;
315 pub type c_ushort = u16;
316 pub type c_int = i32;
317 pub type c_uint = u32;
318 pub type c_long = i64;
319 pub type c_ulong = u64;
320 pub type c_float = f32;
321 pub type c_double = f64;
322 pub type size_t = u64;
323 pub type ptrdiff_t = i64;
324 pub type clock_t = i64;
325 pub type time_t = i64;
326 pub type wchar_t = i32;
329 pub type c_longlong = i64;
330 pub type c_ulonglong = u64;
331 pub type intptr_t = int;
332 pub type uintptr_t = uint;
335 pub type off_t = i64;
336 pub type dev_t = u64;
337 pub type ino_t = u64;
338 pub type pid_t = i32;
339 pub type uid_t = u32;
340 pub type gid_t = u32;
341 pub type useconds_t = u32;
342 pub type mode_t = u32;
343 pub type ssize_t = i64;
346 use libc::types::os::arch::c95::{c_int, c_long, time_t};
347 use libc::types::os::arch::posix88::{dev_t, gid_t, ino_t};
348 use libc::types::os::arch::posix88::{mode_t, off_t};
349 use libc::types::os::arch::posix88::{uid_t};
351 pub type nlink_t = u64;
352 pub type blksize_t = i64;
353 pub type blkcnt_t = i64;
364 st_blksize: blksize_t,
367 st_atime_nsec: c_long,
369 st_mtime_nsec: c_long,
371 st_ctime_nsec: c_long,
372 __unused: [c_long, ..3],
384 #[cfg(target_os = "freebsd")]
388 use libc::types::common::c95::{c_void};
389 use libc::types::os::arch::c95::{c_char, c_int, size_t};
408 #[cfg(target_arch = "x86_64")]
411 pub type c_char = i8;
412 pub type c_schar = i8;
413 pub type c_uchar = u8;
414 pub type c_short = i16;
415 pub type c_ushort = u16;
416 pub type c_int = i32;
417 pub type c_uint = u32;
418 pub type c_long = i64;
419 pub type c_ulong = u64;
420 pub type c_float = f32;
421 pub type c_double = f64;
422 pub type size_t = u64;
423 pub type ptrdiff_t = i64;
424 pub type clock_t = i32;
425 pub type time_t = i64;
426 pub type wchar_t = i32;
429 pub type c_longlong = i64;
430 pub type c_ulonglong = u64;
431 pub type intptr_t = int;
432 pub type uintptr_t = uint;
435 pub type off_t = i64;
436 pub type dev_t = u32;
437 pub type ino_t = u32;
438 pub type pid_t = i32;
439 pub type uid_t = u32;
440 pub type gid_t = u32;
441 pub type useconds_t = u32;
442 pub type mode_t = u16;
443 pub type ssize_t = i64;
446 use libc::types::common::c99::{uint8_t, uint32_t, int32_t};
447 use libc::types::os::arch::c95::{c_long, time_t};
448 use libc::types::os::arch::posix88::{dev_t, gid_t, ino_t};
449 use libc::types::os::arch::posix88::{mode_t, off_t};
450 use libc::types::os::arch::posix88::{uid_t};
452 pub type nlink_t = u16;
453 pub type blksize_t = i64;
454 pub type blkcnt_t = i64;
455 pub type fflags_t = u32;
465 st_atime_nsec: c_long,
467 st_mtime_nsec: c_long,
469 st_ctime_nsec: c_long,
472 st_blksize: blksize_t,
476 st_birthtime: time_t,
477 st_birthtime_nsec: c_long,
478 __unused: [uint8_t, ..2],
490 #[cfg(target_os = "win32")]
494 use libc::types::os::arch::c95::{c_int, c_short};
495 use libc::types::os::arch::extra::{int64, time64_t};
496 use libc::types::os::arch::posix88::{dev_t, ino_t};
497 use libc::types::os::arch::posix88::mode_t;
499 // Note: this is the struct called stat64 in win32. Not stat,
517 #[cfg(target_arch = "x86")]
520 pub type c_char = i8;
521 pub type c_schar = i8;
522 pub type c_uchar = u8;
523 pub type c_short = i16;
524 pub type c_ushort = u16;
525 pub type c_int = i32;
526 pub type c_uint = u32;
527 pub type c_long = i32;
528 pub type c_ulong = u32;
529 pub type c_float = f32;
530 pub type c_double = f64;
531 pub type size_t = u32;
532 pub type ptrdiff_t = i32;
533 pub type clock_t = i32;
534 pub type time_t = i32;
535 pub type wchar_t = u16;
538 pub type c_longlong = i64;
539 pub type c_ulonglong = u64;
540 pub type intptr_t = int;
541 pub type uintptr_t = uint;
544 pub type off_t = i32;
545 pub type dev_t = u32;
546 pub type ino_t = i16;
547 pub type pid_t = i32;
548 pub type useconds_t = u32;
549 pub type mode_t = u16;
550 pub type ssize_t = i32;
559 use libc::types::common::c95::c_void;
560 use libc::types::os::arch::c95::{c_char, c_int, c_uint};
561 use libc::types::os::arch::c95::{c_long, c_ulong};
562 use libc::types::os::arch::c95::{wchar_t};
563 use libc::types::os::arch::c99::{c_ulonglong};
565 pub type BOOL = c_int;
567 pub type CCHAR = c_char;
568 pub type CHAR = c_char;
570 pub type DWORD = c_ulong;
571 pub type DWORDLONG = c_ulonglong;
573 pub type HANDLE = LPVOID;
574 pub type HMODULE = c_uint;
576 pub type LONG_PTR = c_long;
578 pub type LPCWSTR = *WCHAR;
579 pub type LPCSTR = *CHAR;
580 pub type LPCTSTR = *CHAR;
581 pub type LPTCH = *CHAR;
583 pub type LPWSTR = *mut WCHAR;
584 pub type LPSTR = *mut CHAR;
586 // Not really, but opaque to us.
587 pub type LPSECURITY_ATTRIBUTES = LPVOID;
589 pub type LPVOID = *mut c_void;
590 pub type LPWORD = *mut WORD;
592 pub type LRESULT = LONG_PTR;
593 pub type PBOOL = *mut BOOL;
594 pub type WCHAR = wchar_t;
597 pub type time64_t = i64;
598 pub type int64 = i64;
603 #[cfg(target_os = "macos")]
607 use libc::types::common::c95::{c_void};
608 use libc::types::os::arch::c95::{c_char, c_int, size_t};
627 #[cfg(target_arch = "x86")]
630 pub type c_char = i8;
631 pub type c_schar = i8;
632 pub type c_uchar = u8;
633 pub type c_short = i16;
634 pub type c_ushort = u16;
635 pub type c_int = i32;
636 pub type c_uint = u32;
637 pub type c_long = i32;
638 pub type c_ulong = u32;
639 pub type c_float = f32;
640 pub type c_double = f64;
641 pub type size_t = u32;
642 pub type ptrdiff_t = i32;
643 pub type clock_t = u32;
644 pub type time_t = i32;
645 pub type wchar_t = i32;
648 pub type c_longlong = i64;
649 pub type c_ulonglong = u64;
650 pub type intptr_t = int;
651 pub type uintptr_t = uint;
654 pub type off_t = i64;
655 pub type dev_t = i32;
656 pub type ino_t = u64;
657 pub type pid_t = i32;
658 pub type uid_t = u32;
659 pub type gid_t = u32;
660 pub type useconds_t = u32;
661 pub type mode_t = u16;
662 pub type ssize_t = i32;
665 use libc::types::common::c99::{int32_t, int64_t, uint32_t};
666 use libc::types::os::arch::c95::{c_long, time_t};
667 use libc::types::os::arch::posix88::{dev_t, gid_t, ino_t,
668 mode_t, off_t, uid_t};
670 pub type nlink_t = u16;
671 pub type blksize_t = i64;
672 pub type blkcnt_t = i32;
683 st_atime_nsec: c_long,
685 st_mtime_nsec: c_long,
687 st_ctime_nsec: c_long,
688 st_birthtime: time_t,
689 st_birthtime_nsec: c_long,
692 st_blksize: blksize_t,
696 st_qspare: [int64_t, ..2],
707 #[cfg(target_arch = "x86_64")]
710 pub type c_char = i8;
711 pub type c_schar = i8;
712 pub type c_uchar = u8;
713 pub type c_short = i16;
714 pub type c_ushort = u16;
715 pub type c_int = i32;
716 pub type c_uint = u32;
717 pub type c_long = i64;
718 pub type c_ulong = u64;
719 pub type c_float = f32;
720 pub type c_double = f64;
721 pub type size_t = u64;
722 pub type ptrdiff_t = i64;
723 pub type clock_t = u64;
724 pub type time_t = i64;
725 pub type wchar_t = i32;
728 pub type c_longlong = i64;
729 pub type c_ulonglong = u64;
730 pub type intptr_t = int;
731 pub type uintptr_t = uint;
734 pub type off_t = i64;
735 pub type dev_t = i32;
736 pub type ino_t = u64;
737 pub type pid_t = i32;
738 pub type uid_t = u32;
739 pub type gid_t = u32;
740 pub type useconds_t = u32;
741 pub type mode_t = u16;
742 pub type ssize_t = i64;
745 use libc::types::common::c99::{int32_t, int64_t};
746 use libc::types::common::c99::{uint32_t};
747 use libc::types::os::arch::c95::{c_long, time_t};
748 use libc::types::os::arch::posix88::{dev_t, gid_t, ino_t};
749 use libc::types::os::arch::posix88::{mode_t, off_t, uid_t};
751 pub type nlink_t = u16;
752 pub type blksize_t = i64;
753 pub type blkcnt_t = i32;
764 st_atime_nsec: c_long,
766 st_mtime_nsec: c_long,
768 st_ctime_nsec: c_long,
769 st_birthtime: time_t,
770 st_birthtime_nsec: c_long,
773 st_blksize: blksize_t,
777 st_qspare: [int64_t, ..2],
791 // Consts tend to vary per OS so we pull their definitions out
794 #[cfg(target_os = "win32")]
797 pub static EXIT_FAILURE : int = 1;
798 pub static EXIT_SUCCESS : int = 0;
799 pub static RAND_MAX : int = 32767;
800 pub static EOF : int = -1;
801 pub static SEEK_SET : int = 0;
802 pub static SEEK_CUR : int = 1;
803 pub static SEEK_END : int = 2;
804 pub static _IOFBF : int = 0;
805 pub static _IONBF : int = 4;
806 pub static _IOLBF : int = 64;
807 pub static BUFSIZ : uint = 512_u;
808 pub static FOPEN_MAX : uint = 20_u;
809 pub static FILENAME_MAX : uint = 260_u;
810 pub static L_tmpnam : uint = 16_u;
811 pub static TMP_MAX : uint = 32767_u;
816 pub static O_RDONLY : int = 0;
817 pub static O_WRONLY : int = 1;
818 pub static O_RDWR : int = 2;
819 pub static O_APPEND : int = 8;
820 pub static O_CREAT : int = 256;
821 pub static O_EXCL : int = 1024;
822 pub static O_TRUNC : int = 512;
823 pub static S_IFIFO : int = 4096;
824 pub static S_IFCHR : int = 8192;
825 pub static S_IFBLK : int = 12288;
826 pub static S_IFDIR : int = 16384;
827 pub static S_IFREG : int = 32768;
828 pub static S_IFMT : int = 61440;
829 pub static S_IEXEC : int = 64;
830 pub static S_IWRITE : int = 128;
831 pub static S_IREAD : int = 256;
832 pub static S_IRWXU : int = 448;
833 pub static S_IXUSR : int = 64;
834 pub static S_IWUSR : int = 128;
835 pub static S_IRUSR : int = 256;
836 pub static F_OK : int = 0;
837 pub static R_OK : int = 4;
838 pub static W_OK : int = 2;
839 pub static X_OK : int = 1;
840 pub static STDIN_FILENO : int = 0;
841 pub static STDOUT_FILENO : int = 1;
842 pub static STDERR_FILENO : int = 2;
851 pub static O_TEXT : int = 16384;
852 pub static O_BINARY : int = 32768;
853 pub static O_NOINHERIT: int = 128;
855 pub static ERROR_SUCCESS : int = 0;
856 pub static ERROR_INSUFFICIENT_BUFFER : int = 122;
857 pub static INVALID_HANDLE_VALUE: int = -1;
862 #[cfg(target_os = "linux")]
863 #[cfg(target_os = "android")]
866 pub static EXIT_FAILURE : int = 1;
867 pub static EXIT_SUCCESS : int = 0;
868 pub static RAND_MAX : int = 2147483647;
869 pub static EOF : int = -1;
870 pub static SEEK_SET : int = 0;
871 pub static SEEK_CUR : int = 1;
872 pub static SEEK_END : int = 2;
873 pub static _IOFBF : int = 0;
874 pub static _IONBF : int = 2;
875 pub static _IOLBF : int = 1;
876 pub static BUFSIZ : uint = 8192_u;
877 pub static FOPEN_MAX : uint = 16_u;
878 pub static FILENAME_MAX : uint = 4096_u;
879 pub static L_tmpnam : uint = 20_u;
880 pub static TMP_MAX : uint = 238328_u;
885 pub static O_RDONLY : int = 0;
886 pub static O_WRONLY : int = 1;
887 pub static O_RDWR : int = 2;
888 pub static O_APPEND : int = 1024;
889 pub static O_CREAT : int = 64;
890 pub static O_EXCL : int = 128;
891 pub static O_TRUNC : int = 512;
892 pub static S_IFIFO : int = 4096;
893 pub static S_IFCHR : int = 8192;
894 pub static S_IFBLK : int = 24576;
895 pub static S_IFDIR : int = 16384;
896 pub static S_IFREG : int = 32768;
897 pub static S_IFMT : int = 61440;
898 pub static S_IEXEC : int = 64;
899 pub static S_IWRITE : int = 128;
900 pub static S_IREAD : int = 256;
901 pub static S_IRWXU : int = 448;
902 pub static S_IXUSR : int = 64;
903 pub static S_IWUSR : int = 128;
904 pub static S_IRUSR : int = 256;
905 pub static F_OK : int = 0;
906 pub static R_OK : int = 4;
907 pub static W_OK : int = 2;
908 pub static X_OK : int = 1;
909 pub static STDIN_FILENO : int = 0;
910 pub static STDOUT_FILENO : int = 1;
911 pub static STDERR_FILENO : int = 2;
912 pub static F_LOCK : int = 1;
913 pub static F_TEST : int = 3;
914 pub static F_TLOCK : int = 2;
915 pub static F_ULOCK : int = 0;
916 pub static SIGHUP : int = 1;
917 pub static SIGINT : int = 2;
918 pub static SIGQUIT : int = 3;
919 pub static SIGILL : int = 4;
920 pub static SIGABRT : int = 6;
921 pub static SIGFPE : int = 8;
922 pub static SIGKILL : int = 9;
923 pub static SIGSEGV : int = 11;
924 pub static SIGPIPE : int = 13;
925 pub static SIGALRM : int = 14;
926 pub static SIGTERM : int = 15;
929 pub static SIGTRAP : int = 5;
931 pub static GLOB_ERR : int = 1 << 0;
932 pub static GLOB_MARK : int = 1 << 1;
933 pub static GLOB_NOSORT : int = 1 << 2;
934 pub static GLOB_DOOFFS : int = 1 << 3;
935 pub static GLOB_NOCHECK : int = 1 << 4;
936 pub static GLOB_APPEND : int = 1 << 5;
937 pub static GLOB_NOESCAPE : int = 1 << 6;
939 pub static GLOB_NOSPACE : int = 1;
940 pub static GLOB_ABORTED : int = 2;
941 pub static GLOB_NOMATCH : int = 3;
948 pub static O_RSYNC : int = 1052672;
949 pub static O_DSYNC : int = 4096;
950 pub static O_SYNC : int = 1052672;
954 #[cfg(target_os = "freebsd")]
957 pub static EXIT_FAILURE : int = 1;
958 pub static EXIT_SUCCESS : int = 0;
959 pub static RAND_MAX : int = 2147483647;
960 pub static EOF : int = -1;
961 pub static SEEK_SET : int = 0;
962 pub static SEEK_CUR : int = 1;
963 pub static SEEK_END : int = 2;
964 pub static _IOFBF : int = 0;
965 pub static _IONBF : int = 2;
966 pub static _IOLBF : int = 1;
967 pub static BUFSIZ : uint = 1024_u;
968 pub static FOPEN_MAX : uint = 20_u;
969 pub static FILENAME_MAX : uint = 1024_u;
970 pub static L_tmpnam : uint = 1024_u;
971 pub static TMP_MAX : uint = 308915776_u;
976 pub static O_RDONLY : int = 0;
977 pub static O_WRONLY : int = 1;
978 pub static O_RDWR : int = 2;
979 pub static O_APPEND : int = 8;
980 pub static O_CREAT : int = 512;
981 pub static O_EXCL : int = 2048;
982 pub static O_TRUNC : int = 1024;
983 pub static S_IFIFO : int = 4096;
984 pub static S_IFCHR : int = 8192;
985 pub static S_IFBLK : int = 24576;
986 pub static S_IFDIR : int = 16384;
987 pub static S_IFREG : int = 32768;
988 pub static S_IFMT : int = 61440;
989 pub static S_IEXEC : int = 64;
990 pub static S_IWRITE : int = 128;
991 pub static S_IREAD : int = 256;
992 pub static S_IRWXU : int = 448;
993 pub static S_IXUSR : int = 64;
994 pub static S_IWUSR : int = 128;
995 pub static S_IRUSR : int = 256;
996 pub static F_OK : int = 0;
997 pub static R_OK : int = 4;
998 pub static W_OK : int = 2;
999 pub static X_OK : int = 1;
1000 pub static STDIN_FILENO : int = 0;
1001 pub static STDOUT_FILENO : int = 1;
1002 pub static STDERR_FILENO : int = 2;
1003 pub static F_LOCK : int = 1;
1004 pub static F_TEST : int = 3;
1005 pub static F_TLOCK : int = 2;
1006 pub static F_ULOCK : int = 0;
1007 pub static SIGHUP : int = 1;
1008 pub static SIGINT : int = 2;
1009 pub static SIGQUIT : int = 3;
1010 pub static SIGILL : int = 4;
1011 pub static SIGABRT : int = 6;
1012 pub static SIGFPE : int = 8;
1013 pub static SIGKILL : int = 9;
1014 pub static SIGSEGV : int = 11;
1015 pub static SIGPIPE : int = 13;
1016 pub static SIGALRM : int = 14;
1017 pub static SIGTERM : int = 15;
1020 pub static SIGTRAP : int = 5;
1022 pub static GLOB_APPEND : int = 0x0001;
1023 pub static GLOB_DOOFFS : int = 0x0002;
1024 pub static GLOB_ERR : int = 0x0004;
1025 pub static GLOB_MARK : int = 0x0008;
1026 pub static GLOB_NOCHECK : int = 0x0010;
1027 pub static GLOB_NOSORT : int = 0x0020;
1028 pub static GLOB_NOESCAPE : int = 0x2000;
1030 pub static GLOB_NOSPACE : int = -1;
1031 pub static GLOB_ABORTED : int = -2;
1032 pub static GLOB_NOMATCH : int = -3;
1039 pub static O_SYNC : int = 128;
1040 pub static CTL_KERN: int = 1;
1041 pub static KERN_PROC: int = 14;
1042 pub static KERN_PROC_PATHNAME: int = 12;
1046 #[cfg(target_os = "macos")]
1049 pub static EXIT_FAILURE : int = 1;
1050 pub static EXIT_SUCCESS : int = 0;
1051 pub static RAND_MAX : int = 2147483647;
1052 pub static EOF : int = -1;
1053 pub static SEEK_SET : int = 0;
1054 pub static SEEK_CUR : int = 1;
1055 pub static SEEK_END : int = 2;
1056 pub static _IOFBF : int = 0;
1057 pub static _IONBF : int = 2;
1058 pub static _IOLBF : int = 1;
1059 pub static BUFSIZ : uint = 1024_u;
1060 pub static FOPEN_MAX : uint = 20_u;
1061 pub static FILENAME_MAX : uint = 1024_u;
1062 pub static L_tmpnam : uint = 1024_u;
1063 pub static TMP_MAX : uint = 308915776_u;
1068 pub static O_RDONLY : int = 0;
1069 pub static O_WRONLY : int = 1;
1070 pub static O_RDWR : int = 2;
1071 pub static O_APPEND : int = 8;
1072 pub static O_CREAT : int = 512;
1073 pub static O_EXCL : int = 2048;
1074 pub static O_TRUNC : int = 1024;
1075 pub static S_IFIFO : int = 4096;
1076 pub static S_IFCHR : int = 8192;
1077 pub static S_IFBLK : int = 24576;
1078 pub static S_IFDIR : int = 16384;
1079 pub static S_IFREG : int = 32768;
1080 pub static S_IFMT : int = 61440;
1081 pub static S_IEXEC : int = 64;
1082 pub static S_IWRITE : int = 128;
1083 pub static S_IREAD : int = 256;
1084 pub static S_IRWXU : int = 448;
1085 pub static S_IXUSR : int = 64;
1086 pub static S_IWUSR : int = 128;
1087 pub static S_IRUSR : int = 256;
1088 pub static F_OK : int = 0;
1089 pub static R_OK : int = 4;
1090 pub static W_OK : int = 2;
1091 pub static X_OK : int = 1;
1092 pub static STDIN_FILENO : int = 0;
1093 pub static STDOUT_FILENO : int = 1;
1094 pub static STDERR_FILENO : int = 2;
1095 pub static F_LOCK : int = 1;
1096 pub static F_TEST : int = 3;
1097 pub static F_TLOCK : int = 2;
1098 pub static F_ULOCK : int = 0;
1099 pub static SIGHUP : int = 1;
1100 pub static SIGINT : int = 2;
1101 pub static SIGQUIT : int = 3;
1102 pub static SIGILL : int = 4;
1103 pub static SIGABRT : int = 6;
1104 pub static SIGFPE : int = 8;
1105 pub static SIGKILL : int = 9;
1106 pub static SIGSEGV : int = 11;
1107 pub static SIGPIPE : int = 13;
1108 pub static SIGALRM : int = 14;
1109 pub static SIGTERM : int = 15;
1112 pub static SIGTRAP : int = 5;
1114 pub static GLOB_APPEND : int = 0x0001;
1115 pub static GLOB_DOOFFS : int = 0x0002;
1116 pub static GLOB_ERR : int = 0x0004;
1117 pub static GLOB_MARK : int = 0x0008;
1118 pub static GLOB_NOCHECK : int = 0x0010;
1119 pub static GLOB_NOSORT : int = 0x0020;
1120 pub static GLOB_NOESCAPE : int = 0x2000;
1122 pub static GLOB_NOSPACE : int = -1;
1123 pub static GLOB_ABORTED : int = -2;
1124 pub static GLOB_NOMATCH : int = -3;
1131 pub static O_DSYNC : int = 4194304;
1132 pub static O_SYNC : int = 128;
1133 pub static F_FULLFSYNC : int = 51;
1140 // Thankfull most of c95 is universally available and does not vary by OS
1141 // or anything. The same is not true of POSIX.
1147 use libc::types::os::arch::c95::{c_char, c_int};
1150 unsafe fn isalnum(c: c_int) -> c_int;
1151 unsafe fn isalpha(c: c_int) -> c_int;
1152 unsafe fn iscntrl(c: c_int) -> c_int;
1153 unsafe fn isdigit(c: c_int) -> c_int;
1154 unsafe fn isgraph(c: c_int) -> c_int;
1155 unsafe fn islower(c: c_int) -> c_int;
1156 unsafe fn isprint(c: c_int) -> c_int;
1157 unsafe fn ispunct(c: c_int) -> c_int;
1158 unsafe fn isspace(c: c_int) -> c_int;
1159 unsafe fn isupper(c: c_int) -> c_int;
1160 unsafe fn isxdigit(c: c_int) -> c_int;
1161 unsafe fn tolower(c: c_char) -> c_char;
1162 unsafe fn toupper(c: c_char) -> c_char;
1169 use libc::types::common::c95::{FILE, c_void, fpos_t};
1170 use libc::types::os::arch::c95::{c_char, c_int, c_long, size_t};
1173 unsafe fn fopen(filename: *c_char, mode: *c_char) -> *FILE;
1174 unsafe fn freopen(filename: *c_char, mode: *c_char,
1175 file: *FILE) -> *FILE;
1176 unsafe fn fflush(file: *FILE) -> c_int;
1177 unsafe fn fclose(file: *FILE) -> c_int;
1178 unsafe fn remove(filename: *c_char) -> c_int;
1179 unsafe fn rename(oldname: *c_char, newname: *c_char) -> c_int;
1180 unsafe fn tmpfile() -> *FILE;
1181 unsafe fn setvbuf(stream: *FILE, buffer: *c_char,
1182 mode: c_int, size: size_t) -> c_int;
1183 unsafe fn setbuf(stream: *FILE, buf: *c_char);
1184 // Omitted: printf and scanf variants.
1185 unsafe fn fgetc(stream: *FILE) -> c_int;
1187 unsafe fn fgets(buf: *mut c_char, n: c_int,
1188 stream: *FILE) -> *c_char;
1190 unsafe fn fputc(c: c_int, stream: *FILE) -> c_int;
1192 unsafe fn fputs(s: *c_char, stream: *FILE) -> *c_char;
1193 // Omitted: getc, getchar (might be macros).
1195 // Omitted: gets, so ridiculously unsafe that it should not
1198 // Omitted: putc, putchar (might be macros).
1199 unsafe fn puts(s: *c_char) -> c_int;
1200 unsafe fn ungetc(c: c_int, stream: *FILE) -> c_int;
1202 unsafe fn fread(ptr: *mut c_void, size: size_t,
1203 nobj: size_t, stream: *FILE) -> size_t;
1205 unsafe fn fwrite(ptr: *c_void, size: size_t,
1206 nobj: size_t, stream: *FILE) -> size_t;
1207 unsafe fn fseek(stream: *FILE, offset: c_long,
1208 whence: c_int) -> c_int;
1209 unsafe fn ftell(stream: *FILE) -> c_long;
1210 unsafe fn rewind(stream: *FILE);
1211 unsafe fn fgetpos(stream: *FILE, ptr: *fpos_t) -> c_int;
1212 unsafe fn fsetpos(stream: *FILE, ptr: *fpos_t) -> c_int;
1213 unsafe fn feof(stream: *FILE) -> c_int;
1214 unsafe fn ferror(stream: *FILE) -> c_int;
1215 unsafe fn perror(s: *c_char);
1222 use libc::types::common::c95::c_void;
1223 use libc::types::os::arch::c95::{c_char, c_double, c_int};
1224 use libc::types::os::arch::c95::{c_long, c_uint, c_ulong};
1225 use libc::types::os::arch::c95::{size_t};
1228 unsafe fn abs(i: c_int) -> c_int;
1229 unsafe fn labs(i: c_long) -> c_long;
1230 // Omitted: div, ldiv (return pub type incomplete).
1231 unsafe fn atof(s: *c_char) -> c_double;
1232 unsafe fn atoi(s: *c_char) -> c_int;
1233 unsafe fn strtod(s: *c_char, endp: **c_char) -> c_double;
1234 unsafe fn strtol(s: *c_char, endp: **c_char, base: c_int)
1236 unsafe fn strtoul(s: *c_char, endp: **c_char, base: c_int)
1239 unsafe fn calloc(nobj: size_t, size: size_t) -> *c_void;
1241 unsafe fn malloc(size: size_t) -> *c_void;
1243 unsafe fn realloc(p: *c_void, size: size_t) -> *c_void;
1245 unsafe fn free(p: *c_void);
1246 unsafe fn abort() -> !;
1247 unsafe fn exit(status: c_int) -> !;
1249 unsafe fn system(s: *c_char) -> c_int;
1250 unsafe fn getenv(s: *c_char) -> *c_char;
1251 // Omitted: bsearch, qsort
1252 unsafe fn rand() -> c_int;
1253 unsafe fn srand(seed: c_uint);
1260 use libc::types::common::c95::c_void;
1261 use libc::types::os::arch::c95::{c_char, c_int, size_t};
1262 use libc::types::os::arch::c95::{wchar_t};
1265 unsafe fn strcpy(dst: *c_char, src: *c_char) -> *c_char;
1266 unsafe fn strncpy(dst: *c_char, src: *c_char, n: size_t)
1268 unsafe fn strcat(s: *c_char, ct: *c_char) -> *c_char;
1269 unsafe fn strncat(s: *c_char, ct: *c_char, n: size_t)
1271 unsafe fn strcmp(cs: *c_char, ct: *c_char) -> c_int;
1272 unsafe fn strncmp(cs: *c_char, ct: *c_char, n: size_t)
1274 unsafe fn strcoll(cs: *c_char, ct: *c_char) -> c_int;
1275 unsafe fn strchr(cs: *c_char, c: c_int) -> *c_char;
1276 unsafe fn strrchr(cs: *c_char, c: c_int) -> *c_char;
1277 unsafe fn strspn(cs: *c_char, ct: *c_char) -> size_t;
1278 unsafe fn strcspn(cs: *c_char, ct: *c_char) -> size_t;
1279 unsafe fn strpbrk(cs: *c_char, ct: *c_char) -> *c_char;
1280 unsafe fn strstr(cs: *c_char, ct: *c_char) -> *c_char;
1281 unsafe fn strlen(cs: *c_char) -> size_t;
1282 unsafe fn strerror(n: c_int) -> *c_char;
1283 unsafe fn strtok(s: *c_char, t: *c_char) -> *c_char;
1284 unsafe fn strxfrm(s: *c_char, ct: *c_char, n: size_t)
1286 unsafe fn wcslen(buf: *wchar_t) -> size_t;
1288 // These are fine to execute on the Rust stack. They must be,
1289 // in fact, because LLVM generates calls to them!
1292 unsafe fn memcpy(s: *c_void, ct: *c_void, n: size_t)
1296 unsafe fn memmove(s: *c_void, ct: *c_void, n: size_t)
1300 unsafe fn memcmp(cx: *c_void, ct: *c_void, n: size_t)
1304 unsafe fn memchr(cx: *c_void, c: c_int, n: size_t) -> *c_void;
1307 unsafe fn memset(s: *c_void, c: c_int, n: size_t) -> *c_void;
1312 // Microsoft helpfully underscore-qualifies all of its POSIX-like symbols
1313 // to make sure you don't use them accidentally. It also randomly deviates
1314 // from the exact signatures you might otherwise expect, and omits much,
1315 // so be careful when trying to write portable code; it won't always work
1316 // with the same POSIX functions and types as other platforms.
1318 #[cfg(target_os = "win32")]
1323 use libc::types::os::common::posix01::stat;
1324 use libc::types::os::arch::c95::{c_int, c_char};
1327 #[link_name = "_chmod"]
1328 unsafe fn chmod(path: *c_char, mode: c_int) -> c_int;
1330 #[link_name = "_mkdir"]
1331 unsafe fn mkdir(path: *c_char) -> c_int;
1333 #[link_name = "_fstat64"]
1334 unsafe fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
1336 #[link_name = "_stat64"]
1337 unsafe fn stat(path: *c_char, buf: *mut stat) -> c_int;
1344 use libc::types::common::c95::FILE;
1345 use libc::types::os::arch::c95::{c_int, c_char};
1348 #[link_name = "_popen"]
1349 unsafe fn popen(command: *c_char, mode: *c_char) -> *FILE;
1351 #[link_name = "_pclose"]
1352 unsafe fn pclose(stream: *FILE) -> c_int;
1354 #[link_name = "_fdopen"]
1356 unsafe fn fdopen(fd: c_int, mode: *c_char) -> *FILE;
1358 #[link_name = "_fileno"]
1359 unsafe fn fileno(stream: *FILE) -> c_int;
1366 use libc::types::os::arch::c95::{c_int, c_char};
1368 #[link_name = "_open"]
1369 unsafe fn open(path: *c_char, oflag: c_int, mode: c_int)
1372 #[link_name = "_creat"]
1373 unsafe fn creat(path: *c_char, mode: c_int) -> c_int;
1380 // Not supplied at all.
1386 use libc::types::common::c95::c_void;
1387 use libc::types::os::arch::c95::{c_int, c_uint, c_char,
1389 use libc::types::os::arch::c99::intptr_t;
1392 #[link_name = "_access"]
1393 unsafe fn access(path: *c_char, amode: c_int) -> c_int;
1395 #[link_name = "_chdir"]
1396 unsafe fn chdir(dir: *c_char) -> c_int;
1398 #[link_name = "_close"]
1399 unsafe fn close(fd: c_int) -> c_int;
1401 #[link_name = "_dup"]
1402 unsafe fn dup(fd: c_int) -> c_int;
1404 #[link_name = "_dup2"]
1405 unsafe fn dup2(src: c_int, dst: c_int) -> c_int;
1407 #[link_name = "_execv"]
1408 unsafe fn execv(prog: *c_char, argv: **c_char) -> intptr_t;
1410 #[link_name = "_execve"]
1411 unsafe fn execve(prog: *c_char, argv: **c_char,
1412 envp: **c_char) -> c_int;
1414 #[link_name = "_execvp"]
1415 unsafe fn execvp(c: *c_char, argv: **c_char) -> c_int;
1417 #[link_name = "_execvpe"]
1418 unsafe fn execvpe(c: *c_char, argv: **c_char,
1419 envp: **c_char) -> c_int;
1421 #[link_name = "_getcwd"]
1422 unsafe fn getcwd(buf: *c_char, size: size_t) -> *c_char;
1424 #[link_name = "_getpid"]
1425 unsafe fn getpid() -> c_int;
1427 #[link_name = "_isatty"]
1428 unsafe fn isatty(fd: c_int) -> c_int;
1430 #[link_name = "_lseek"]
1431 unsafe fn lseek(fd: c_int, offset: c_long, origin: c_int)
1434 #[link_name = "_pipe"]
1435 unsafe fn pipe(fds: *mut c_int, psize: c_uint,
1436 textmode: c_int) -> c_int;
1438 #[link_name = "_read"]
1440 unsafe fn read(fd: c_int, buf: *mut c_void, count: c_uint)
1443 #[link_name = "_rmdir"]
1444 unsafe fn rmdir(path: *c_char) -> c_int;
1446 #[link_name = "_unlink"]
1447 unsafe fn unlink(c: *c_char) -> c_int;
1449 #[link_name = "_write"]
1451 unsafe fn write(fd: c_int, buf: *c_void, count: c_uint)
1458 #[cfg(target_os = "linux")]
1459 #[cfg(target_os = "android")]
1460 #[cfg(target_os = "macos")]
1461 #[cfg(target_os = "freebsd")]
1464 use libc::types::os::arch::c95::{c_char, c_int};
1465 use libc::types::os::arch::posix01::stat;
1466 use libc::types::os::arch::posix88::mode_t;
1471 unsafe fn chmod(path: *c_char, mode: mode_t) -> c_int;
1472 unsafe fn fchmod(fd: c_int, mode: mode_t) -> c_int;
1474 #[cfg(target_os = "linux")]
1475 #[cfg(target_os = "freebsd")]
1476 #[cfg(target_os = "android")]
1477 unsafe fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
1479 #[cfg(target_os = "macos")]
1480 #[link_name = "fstat64"]
1481 unsafe fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
1483 unsafe fn mkdir(path: *c_char, mode: mode_t) -> c_int;
1484 unsafe fn mkfifo(path: *c_char, mode: mode_t) -> c_int;
1486 #[cfg(target_os = "linux")]
1487 #[cfg(target_os = "freebsd")]
1488 #[cfg(target_os = "android")]
1489 unsafe fn stat(path: *c_char, buf: *mut stat) -> c_int;
1491 #[cfg(target_os = "macos")]
1492 #[link_name = "stat64"]
1493 unsafe fn stat(path: *c_char, buf: *mut stat) -> c_int;
1500 use libc::types::common::c95::FILE;
1501 use libc::types::os::arch::c95::{c_char, c_int};
1504 unsafe fn popen(command: *c_char, mode: *c_char) -> *FILE;
1505 unsafe fn pclose(stream: *FILE) -> c_int;
1506 unsafe fn fdopen(fd: c_int, mode: *c_char) -> *FILE;
1507 unsafe fn fileno(stream: *FILE) -> c_int;
1514 use libc::types::os::arch::c95::{c_char, c_int};
1515 use libc::types::os::arch::posix88::mode_t;
1518 unsafe fn open(path: *c_char, oflag: c_int, mode: c_int)
1520 unsafe fn creat(path: *c_char, mode: mode_t) -> c_int;
1521 unsafe fn fcntl(fd: c_int, cmd: c_int) -> c_int;
1528 use libc::types::common::posix88::{DIR, dirent_t};
1529 use libc::types::os::arch::c95::{c_char, c_int, c_long};
1531 // NB: On OS X opendir and readdir have two versions,
1532 // one for 32-bit kernelspace and one for 64.
1533 // We should be linking to the 64-bit ones, called
1534 // opendir$INODE64, etc. but for some reason rustc
1535 // doesn't link it correctly on i686, so we're going
1536 // through a C function that mysteriously does work.
1537 pub unsafe fn opendir(dirname: *c_char) -> *DIR {
1538 rust_opendir(dirname)
1540 pub unsafe fn readdir(dirp: *DIR) -> *dirent_t {
1545 unsafe fn rust_opendir(dirname: *c_char) -> *DIR;
1546 unsafe fn rust_readdir(dirp: *DIR) -> *dirent_t;
1550 unsafe fn closedir(dirp: *DIR) -> c_int;
1551 unsafe fn rewinddir(dirp: *DIR);
1552 unsafe fn seekdir(dirp: *DIR, loc: c_long);
1553 unsafe fn telldir(dirp: *DIR) -> c_long;
1560 use libc::types::common::c95::c_void;
1561 use libc::types::os::arch::c95::{c_char, c_int, c_long, c_uint};
1562 use libc::types::os::arch::c95::{size_t};
1563 use libc::types::os::arch::posix88::{gid_t, off_t, pid_t};
1564 use libc::types::os::arch::posix88::{ssize_t, uid_t};
1567 unsafe fn access(path: *c_char, amode: c_int) -> c_int;
1568 unsafe fn alarm(seconds: c_uint) -> c_uint;
1569 unsafe fn chdir(dir: *c_char) -> c_int;
1570 unsafe fn chown(path: *c_char, uid: uid_t, gid: gid_t)
1572 unsafe fn close(fd: c_int) -> c_int;
1573 unsafe fn dup(fd: c_int) -> c_int;
1574 unsafe fn dup2(src: c_int, dst: c_int) -> c_int;
1575 unsafe fn execv(prog: *c_char, argv: **c_char) -> c_int;
1576 unsafe fn execve(prog: *c_char,
1580 unsafe fn execvp(c: *c_char, argv: **c_char) -> c_int;
1581 unsafe fn fork() -> pid_t;
1582 unsafe fn fpathconf(filedes: c_int, name: c_int) -> c_long;
1583 unsafe fn getcwd(buf: *c_char, size: size_t) -> *c_char;
1584 unsafe fn getegid() -> gid_t;
1585 unsafe fn geteuid() -> uid_t;
1586 unsafe fn getgid() -> gid_t ;
1587 unsafe fn getgroups(ngroups_max: c_int, groups: *mut gid_t)
1589 unsafe fn getlogin() -> *c_char;
1590 unsafe fn getopt(argc: c_int, argv: **c_char, optstr: *c_char)
1592 unsafe fn getpgrp() -> pid_t;
1593 unsafe fn getpid() -> pid_t;
1594 unsafe fn getppid() -> pid_t;
1595 unsafe fn getuid() -> uid_t;
1596 unsafe fn isatty(fd: c_int) -> c_int;
1597 unsafe fn link(src: *c_char, dst: *c_char) -> c_int;
1598 unsafe fn lseek(fd: c_int, offset: off_t, whence: c_int)
1600 unsafe fn pathconf(path: *c_char, name: c_int) -> c_long;
1601 unsafe fn pause() -> c_int;
1602 unsafe fn pipe(fds: *mut c_int) -> c_int;
1604 unsafe fn read(fd: c_int, buf: *mut c_void,
1605 count: size_t) -> ssize_t;
1606 unsafe fn rmdir(path: *c_char) -> c_int;
1607 unsafe fn setgid(gid: gid_t) -> c_int;
1608 unsafe fn setpgid(pid: pid_t, pgid: pid_t) -> c_int;
1609 unsafe fn setsid() -> pid_t;
1610 unsafe fn setuid(uid: uid_t) -> c_int;
1611 unsafe fn sleep(secs: c_uint) -> c_uint;
1612 unsafe fn sysconf(name: c_int) -> c_long;
1613 unsafe fn tcgetpgrp(fd: c_int) -> pid_t;
1614 unsafe fn ttyname(fd: c_int) -> *c_char;
1615 unsafe fn unlink(c: *c_char) -> c_int;
1617 unsafe fn write(fd: c_int, buf: *c_void, count: size_t)
1625 use libc::types::os::arch::c95::{c_int};
1626 use libc::types::os::arch::posix88::{pid_t};
1629 unsafe fn kill(pid: pid_t, sig: c_int) -> c_int;
1634 #[cfg(target_os = "linux")]
1635 #[cfg(target_os = "android")]
1636 #[cfg(target_os = "macos")]
1637 #[cfg(target_os = "freebsd")]
1642 use libc::types::os::arch::c95::{c_char, c_int};
1643 use libc::types::os::arch::posix01::stat;
1646 #[cfg(target_os = "linux")]
1647 #[cfg(target_os = "freebsd")]
1648 #[cfg(target_os = "android")]
1649 unsafe fn lstat(path: *c_char, buf: *mut stat) -> c_int;
1651 #[cfg(target_os = "macos")]
1652 #[link_name = "lstat64"]
1653 unsafe fn lstat(path: *c_char, buf: *mut stat) -> c_int;
1660 use libc::types::os::arch::c95::{c_char, c_int, size_t};
1661 use libc::types::os::arch::posix88::{ssize_t};
1664 unsafe fn readlink(path: *c_char, buf: *mut c_char,
1665 bufsz: size_t) -> ssize_t;
1667 unsafe fn fsync(fd: c_int) -> c_int;
1669 #[cfg(target_os = "linux")]
1670 #[cfg(target_os = "android")]
1671 unsafe fn fdatasync(fd: c_int) -> c_int;
1673 unsafe fn setenv(name: *c_char, val: *c_char,
1674 overwrite: c_int) -> c_int;
1675 unsafe fn unsetenv(name: *c_char) -> c_int;
1676 unsafe fn putenv(string: *c_char) -> c_int;
1678 unsafe fn symlink(path1: *c_char, path2: *c_char) -> c_int;
1685 use libc::types::os::arch::c95::{c_int};
1686 use libc::types::os::arch::posix88::{pid_t};
1689 unsafe fn waitpid(pid: pid_t,
1699 use libc::types::common::c95::{c_void};
1700 use libc::types::os::arch::c95::{c_char, c_int};
1701 use libc::types::os::common::posix01::{glob_t};
1704 unsafe fn glob(pattern: *c_char, flags: c_int,
1705 errfunc: *c_void, // XXX callback
1706 pglob: *mut glob_t);
1707 unsafe fn globfree(pglob: *mut glob_t);
1712 #[cfg(target_os = "win32")]
1725 #[cfg(target_os = "win32")]
1726 #[cfg(target_os = "linux")]
1727 #[cfg(target_os = "android")]
1728 #[cfg(target_os = "macos")]
1729 #[cfg(target_os = "freebsd")]
1736 #[cfg(target_os = "macos")]
1737 #[cfg(target_os = "freebsd")]
1739 use libc::types::common::c95::{c_void};
1740 use libc::types::os::arch::c95::{c_char, c_int, c_uint, size_t};
1744 unsafe fn sysctl(name: *c_int, namelen: c_uint,
1745 oldp: *mut c_void, oldlenp: *mut size_t,
1746 newp: *c_void, newlen: size_t) -> c_int;
1748 unsafe fn sysctlbyname(name: *c_char,
1749 oldp: *mut c_void, oldlenp: *mut size_t,
1750 newp: *c_void, newlen: size_t) -> c_int;
1752 unsafe fn sysctlnametomib(name: *c_char, mibp: *mut c_int,
1753 sizep: *mut size_t) -> c_int;
1758 #[cfg(target_os = "linux")]
1759 #[cfg(target_os = "android")]
1760 #[cfg(target_os = "win32")]
1764 #[cfg(target_os = "macos")]
1767 use libc::types::os::arch::c95::{c_char, c_int};
1771 unsafe fn _NSGetExecutablePath(buf: *mut c_char,
1777 #[cfg(target_os = "freebsd")]
1781 #[cfg(target_os = "linux")]
1782 #[cfg(target_os = "android")]
1787 #[cfg(target_os = "win32")]
1791 use libc::types::os::arch::c95::{c_uint};
1792 use libc::types::os::arch::extra::{BOOL, DWORD, HMODULE};
1793 use libc::types::os::arch::extra::{LPCWSTR, LPWSTR, LPTCH};
1794 use libc::types::os::arch::extra::{LPSECURITY_ATTRIBUTES};
1795 use libc::types::os::arch::extra::{HANDLE};
1798 pub extern "stdcall" {
1799 unsafe fn GetEnvironmentVariableW(n: LPCWSTR,
1803 unsafe fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR)
1805 unsafe fn GetEnvironmentStringsA() -> LPTCH;
1806 unsafe fn FreeEnvironmentStringsA(env_ptr: LPTCH) -> BOOL;
1808 unsafe fn GetModuleFileNameW(hModule: HMODULE,
1812 unsafe fn CreateDirectoryW(lpPathName: LPCWSTR,
1813 lpSecurityAttributes:
1814 LPSECURITY_ATTRIBUTES)
1816 unsafe fn CopyFileW(lpExistingFileName: LPCWSTR,
1817 lpNewFileName: LPCWSTR,
1818 bFailIfExists: BOOL)
1820 unsafe fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL;
1821 unsafe fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL;
1822 unsafe fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL;
1824 unsafe fn GetLastError() -> DWORD;
1825 unsafe fn FindFirstFileW(fileName: *u16,
1826 findFileData: HANDLE)
1828 unsafe fn FindNextFileW(findFile: HANDLE,
1829 findFileData: HANDLE)
1831 unsafe fn FindClose(findFile: HANDLE) -> BOOL;
1832 unsafe fn CloseHandle(hObject: HANDLE) -> BOOL;
1833 unsafe fn TerminateProcess(hProcess: HANDLE, uExitCode: c_uint) -> BOOL;
1838 use libc::types::os::arch::c95::c_int;
1843 #[link_name = "_commit"]
1844 unsafe fn commit(fd: c_int) -> c_int;
1854 // indent-tabs-mode: nil
1855 // c-basic-offset: 4
1856 // buffer-file-coding-system: utf-8-unix