Bindings for libc.

We consider the following specs reasonably normative with respect to interoperating with the C standard library (libc/msvcrt):

Despite having several names each, these are reasonably coherent point-in-time, list-of-definition sorts of specs. You can get each under a variety of names but will wind up with the same definition in each case.

Our interface to these libraries is complicated by the non-universality of conformance to any of them. About the only thing universally supported is the first (C95), beyond that definitions quickly become absent on various platforms.

We therefore wind up dividing our module-space up (mostly for the sake of sanity while editing, filling-in-details and eliminating duplication) into definitions common-to-all (held in modules named c95, c99, posix88, posix01 and posix08) and definitions that appear only on some platforms (named 'extra'). This would be things like significant OSX foundation kit, or win32 library kernel32.dll, or various fancy glibc, linux or BSD extensions.

In addition to the per-platform 'extra' modules, we define a module of 'common BSD' libc routines that never quite made it into POSIX but show up in multiple derived systems. This is the 4.4BSD r2 / 1995 release, the final one from Berkeley after the lawsuits died down and the CSRG dissolved.

Const BUFSIZ

uint

Const EOF

int

Const EXIT_FAILURE

int

Const EXIT_SUCCESS

int

Const FILENAME_MAX

uint

Const FOPEN_MAX

uint

Const F_OK

int

Const L_tmpnam

uint

Const O_APPEND

int

Const O_CREAT

int

Const O_EXCL

int

Const O_RDONLY

int

Const O_RDWR

int

Const O_TRUNC

int

Const O_WRONLY

int

Const RAND_MAX

int

Const R_OK

int

Const SEEK_CUR

int

Const SEEK_END

int

Const SEEK_SET

int

Const STDERR_FILENO

int

Const STDIN_FILENO

int

Const STDOUT_FILENO

int

Const S_IEXEC

int

Const S_IFBLK

int

Const S_IFCHR

int

Const S_IFDIR

int

Const S_IFIFO

int

Const S_IFMT

int

Const S_IFREG

int

Const S_IREAD

int

Const S_IRUSR

int

Const S_IRWXU

int

Const S_IWRITE

int

Const S_IWUSR

int

Const S_IXUSR

int

Const TMP_MAX

uint

Const W_OK

int

Const X_OK

int

Const _IOFBF

int

Const _IOLBF

int

Const _IONBF

int

Type c_char

type c_char = i8

Type c_double

type c_double = f64

Type c_float

type c_float = f32

Type c_int

type c_int = i32

Type c_long

type c_long = i64

Type c_longlong

type c_longlong = i64

Type c_schar

type c_schar = i8

Type c_short

type c_short = i16

Type c_uchar

type c_uchar = u8

Type c_uint

type c_uint = u32

Type c_ulong

type c_ulong = u64

Type c_ulonglong

type c_ulonglong = u64

Type c_ushort

type c_ushort = u16

Type clock_t

type clock_t = i64

Type dev_t

type dev_t = u64

Type ino_t

type ino_t = u64

Type intptr_t

type intptr_t = int

Type mode_t

type mode_t = u32

Type off_t

type off_t = i64

Type pid_t

type pid_t = i32

Type ptrdiff_t

type ptrdiff_t = i64

Type size_t

type size_t = u64

Type ssize_t

type ssize_t = i64

Type time_t

type time_t = i64

Type uintptr_t

type uintptr_t = uint

Enum DIR

Enum FILE

Enum c_void

Enum dirent

Enum fpos_t

Function abort

fn abort() -> !

Function abs

fn abs(i: c_int) -> c_int

Function access

fn access(path: *c_char, amode: c_int) -> c_int

Function atof

fn atof(s: *c_char) -> c_double

Function atoi

fn atoi(s: *c_char) -> c_int

Function calloc

fn calloc(nobj: size_t, size: size_t) -> *c_void

Function chdir

fn chdir(dir: *c_char) -> c_int

Function chmod

fn chmod(path: *c_char, mode: mode_t) -> c_int

Function close

fn close(fd: c_int) -> c_int

Function creat

fn creat(path: *c_char, mode: mode_t) -> c_int

Function dup

fn dup(fd: c_int) -> c_int

Function dup2

fn dup2(src: c_int, dst: c_int) -> c_int

Function execv

fn execv(prog: *c_char, argv: **c_char) -> c_int

Function execve

fn execve(prog: *c_char, argv: **c_char, envp: **c_char) -> c_int

Function execvp

fn execvp(c: *c_char, argv: **c_char) -> c_int

Function exit

fn exit(status: c_int) -> !

Function fclose

fn fclose(file: *FILE) -> c_int

Function fdopen

fn fdopen(fd: c_int, mode: *c_char) -> *FILE

Function feof

fn feof(stream: *FILE) -> c_int

Function ferror

fn ferror(stream: *FILE) -> c_int

Function fflush

fn fflush(file: *FILE) -> c_int

Function fgetc

fn fgetc(stream: *FILE) -> c_int

Function fgetpos

fn fgetpos(stream: *FILE, ptr: *fpos_t) -> c_int

Function fgets

fn fgets(buf: *mut c_char, n: c_int, stream: *FILE) -> *c_char

Function fileno

fn fileno(stream: *FILE) -> c_int

Function fopen

fn fopen(filename: *c_char, mode: *c_char) -> *FILE

Function fputc

fn fputc(c: c_int, stream: *FILE) -> c_int

Function fputs

fn fputs(s: *c_char, stream: *FILE) -> *c_char

Function fread

fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, stream: *FILE) ->
   size_t

Function free

fn free(p: *c_void)

Function freopen

fn freopen(filename: *c_char, mode: *c_char, file: *FILE) -> *FILE

Function fseek

fn fseek(stream: *FILE, offset: c_long, whence: c_int) -> c_int

Function fsetpos

fn fsetpos(stream: *FILE, ptr: *fpos_t) -> c_int

Function ftell

fn ftell(stream: *FILE) -> c_long

Function fwrite

fn fwrite(ptr: *c_void, size: size_t, nobj: size_t, stream: *FILE) -> size_t

Function getcwd

fn getcwd(buf: *c_char, size: size_t) -> *c_char

Function getenv

fn getenv(s: *c_char) -> *c_char

Function getpid

fn getpid() -> pid_t

Function isalnum

fn isalnum(c: c_int) -> c_int

Function isalpha

fn isalpha(c: c_int) -> c_int

Function isatty

fn isatty(fd: c_int) -> c_int

Function iscntrl

fn iscntrl(c: c_int) -> c_int

Function isdigit

fn isdigit(c: c_int) -> c_int

Function islower

fn islower(c: c_int) -> c_int

Function isprint

fn isprint(c: c_int) -> c_int

Function ispunct

fn ispunct(c: c_int) -> c_int

Function isspace

fn isspace(c: c_int) -> c_int

Function isupper

fn isupper(c: c_int) -> c_int

Function isxdigit

fn isxdigit(c: c_int) -> c_int

Function labs

fn labs(i: c_long) -> c_long

Function lseek

fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t

Function malloc

fn malloc(size: size_t) -> *c_void

Function memchr

fn memchr(cx: *c_void, c: c_int, n: size_t) -> *c_void

Function memcmp

fn memcmp(cx: *c_void, ct: *c_void, n: size_t) -> c_int

Function memcpy

fn memcpy(s: *c_void, ct: *c_void, n: size_t) -> *c_void

Function memmove

fn memmove(s: *c_void, ct: *c_void, n: size_t) -> *c_void

Function memset

fn memset(s: *c_void, c: c_int, n: size_t) -> *c_void

Function mkdir

fn mkdir(path: *c_char, mode: mode_t) -> c_int

Function open

fn open(path: *c_char, oflag: c_int, mode: c_int) -> c_int

Function pclose

fn pclose(stream: *FILE) -> c_int

Function perror

fn perror(s: *c_char)

Function pipe

fn pipe(fds: *mut c_int) -> c_int

Function popen

fn popen(command: *c_char, mode: *c_char) -> *FILE

Function puts

fn puts(s: *c_char) -> c_int

Function rand

fn rand() -> c_int

Function read

fn read(fd: c_int, buf: *mut c_void, count: size_t) -> ssize_t

Function realloc

fn realloc(p: *c_void, size: size_t) -> *c_void

Function remove

fn remove(filename: *c_char) -> c_int

Function rewind

fn rewind(stream: *FILE)

Function rmdir

fn rmdir(path: *c_char) -> c_int

Function setbuf

fn setbuf(stream: *FILE, buf: *c_char)

Function setvbuf

fn setvbuf(stream: *FILE, buffer: *c_char, mode: c_int, size: size_t) -> c_int

Function srand

fn srand(seed: c_uint)

Function strcat

fn strcat(s: *c_char, ct: *c_char) -> *c_char

Function strchr

fn strchr(cs: *c_char, c: c_int) -> *c_char

Function strcmp

fn strcmp(cs: *c_char, ct: *c_char) -> c_int

Function strcoll

fn strcoll(cs: *c_char, ct: *c_char) -> c_int

Function strcpy

fn strcpy(dst: *c_char, src: *c_char) -> *c_char

Function strcspn

fn strcspn(cs: *c_char, ct: *c_char) -> size_t

Function strerror

fn strerror(n: c_int) -> *c_char

Function strlen

fn strlen(cs: *c_char) -> size_t

Function strncat

fn strncat(s: *c_char, ct: *c_char, n: size_t) -> *c_char

Function strncmp

fn strncmp(cs: *c_char, ct: *c_char, n: size_t) -> c_int

Function strncpy

fn strncpy(dst: *c_char, src: *c_char, n: size_t) -> *c_char

Function strpbrk

fn strpbrk(cs: *c_char, ct: *c_char) -> *c_char

Function strrchr

fn strrchr(cs: *c_char, c: c_int) -> *c_char

Function strspn

fn strspn(cs: *c_char, ct: *c_char) -> size_t

Function strstr

fn strstr(cs: *c_char, ct: *c_char) -> *c_char

Function strtod

fn strtod(s: *c_char, endp: **c_char) -> c_double

Function strtok

fn strtok(s: *c_char, t: *c_char) -> *c_char

Function strtol

fn strtol(s: *c_char, endp: **c_char, base: c_int) -> c_long

Function strtoul

fn strtoul(s: *c_char, endp: **c_char, base: c_int) -> c_ulong

Function strxfrm

fn strxfrm(s: *c_char, ct: *c_char, n: size_t) -> size_t

Function system

fn system(s: *c_char) -> c_int

Function tmpfile

fn tmpfile() -> *FILE

Function tolower

fn tolower(c: c_char) -> c_char

Function toupper

fn toupper(c: c_char) -> c_char

Function ungetc

fn ungetc(c: c_int, stream: *FILE) -> c_int

Function write

fn write(fd: c_int, buf: *c_void, count: size_t) -> ssize_t