Crate libc[stability] [-] [+] [src]

Bindings for the C standard library and other platform libraries

NOTE: These are architecture and libc specific. On Linux, these bindings are only correct for glibc.

This module contains bindings to the C standard library, organized into modules by their defining standard. Additionally, it contains some assorted platform-specific definitions. For convenience, most functions and types are reexported, so use libc::* will import the available C bindings as appropriate for the target platform. The exact set of functions available are platform specific.

Note: Because these definitions are platform-specific, some may not appear in the generated documentation.

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

Note that any reference to the 1996 revision of POSIX, or any revs between 1990 (when '88 was approved at ISO) and 2001 (when the next actual revision-revision happened), are merely additions of other chapters (1b and 1c) outside the core interfaces.

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.

See standards(7) in linux-manpages for more details.

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 Windows 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.

Reexports

pub use types::common::c95::{FILE, c_void, fpos_t};
pub use types::common::c99::{int8_t, int16_t, int32_t, int64_t};
pub use types::common::c99::{uint8_t, uint16_t, uint32_t, uint64_t};
pub use types::common::posix88::{DIR, dirent_t};
pub use types::os::common::posix01::{timeval};
pub use types::os::common::bsd44::{addrinfo, in_addr, in6_addr, sockaddr_storage};
pub use types::os::common::bsd44::{ip_mreq, ip6_mreq, sockaddr, sockaddr_un};
pub use types::os::common::bsd44::{sa_family_t, sockaddr_in, sockaddr_in6, socklen_t};
pub use types::os::arch::c95::{c_char, c_double, c_float, c_int, c_uint};
pub use types::os::arch::c95::{c_long, c_short, c_uchar, c_ulong, wchar_t};
pub use types::os::arch::c95::{c_ushort, clock_t, ptrdiff_t, c_schar};
pub use types::os::arch::c95::{size_t, time_t, suseconds_t};
pub use types::os::arch::c99::{c_longlong, c_ulonglong};
pub use types::os::arch::c99::{intptr_t, uintptr_t};
pub use types::os::arch::c99::{intmax_t, uintmax_t};
pub use types::os::arch::posix88::{dev_t, ino_t, mode_t};
pub use types::os::arch::posix88::{off_t, pid_t, ssize_t};
pub use consts::os::c95::{_IOFBF, _IOLBF, _IONBF, BUFSIZ, EOF};
pub use consts::os::c95::{EXIT_FAILURE, EXIT_SUCCESS};
pub use consts::os::c95::{FILENAME_MAX, FOPEN_MAX, L_tmpnam};
pub use consts::os::c95::{RAND_MAX, SEEK_CUR, SEEK_END};
pub use consts::os::c95::{SEEK_SET, TMP_MAX};
pub use consts::os::posix88::{F_OK, O_APPEND, O_CREAT, O_EXCL};
pub use consts::os::posix88::{O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY};
pub use consts::os::posix88::{R_OK, S_IEXEC, S_IFBLK, S_IFCHR};
pub use consts::os::posix88::{S_IFDIR, S_IFIFO, S_IFMT, S_IFREG, S_IFLNK};
pub use consts::os::posix88::{S_IREAD, S_IRUSR, S_IRWXU, S_IWUSR};
pub use consts::os::posix88::{STDERR_FILENO, STDIN_FILENO, S_IXUSR};
pub use consts::os::posix88::{STDOUT_FILENO, W_OK, X_OK};
pub use consts::os::bsd44::{AF_INET, AF_INET6, SOCK_STREAM, SOCK_DGRAM, SOCK_RAW};
pub use consts::os::bsd44::{IPPROTO_IP, IPPROTO_IPV6, IPPROTO_TCP, TCP_NODELAY};
pub use consts::os::bsd44::{SOL_SOCKET, SO_KEEPALIVE, SO_ERROR};
pub use consts::os::bsd44::{SO_REUSEADDR, SO_BROADCAST, SHUT_WR, IP_MULTICAST_LOOP};
pub use consts::os::bsd44::{IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP};
pub use consts::os::bsd44::{IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP};
pub use consts::os::bsd44::{IP_MULTICAST_TTL, IP_TTL, IP_HDRINCL, SHUT_RD};
pub use consts::os::extra::{IPPROTO_RAW};
pub use funcs::c95::ctype::{isalnum, isalpha, iscntrl, isdigit};
pub use funcs::c95::ctype::{islower, isprint, ispunct, isspace};
pub use funcs::c95::ctype::{isupper, isxdigit, tolower, toupper};
pub use funcs::c95::stdio::{fclose, feof, ferror, fflush, fgetc};
pub use funcs::c95::stdio::{fgetpos, fgets, fopen, fputc, fputs};
pub use funcs::c95::stdio::{fread, freopen, fseek, fsetpos, ftell};
pub use funcs::c95::stdio::{fwrite, perror, puts, remove, rename, rewind};
pub use funcs::c95::stdio::{setbuf, setvbuf, tmpfile, ungetc};
pub use funcs::c95::stdlib::{abs, atof, atoi, calloc, exit, _exit, atexit};
pub use funcs::c95::stdlib::{free, getenv, labs, malloc, rand};
pub use funcs::c95::stdlib::{realloc, srand, strtod, strtol};
pub use funcs::c95::stdlib::{strtoul, system};
pub use funcs::c95::string::{memchr, memcmp};
pub use funcs::c95::string::{strcat, strchr, strcmp};
pub use funcs::c95::string::{strcoll, strcpy, strcspn, strerror};
pub use funcs::c95::string::{strlen, strncat, strncmp, strncpy};
pub use funcs::c95::string::{strpbrk, strrchr, strspn, strstr};
pub use funcs::c95::string::{strtok, strxfrm};
pub use funcs::posix88::fcntl::{open, creat};
pub use funcs::posix88::stat_::{chmod, fstat, mkdir, stat};
pub use funcs::posix88::stdio::{fdopen, fileno, pclose, popen};
pub use funcs::posix88::unistd::{access, chdir, close, dup, dup2};
pub use funcs::posix88::unistd::{execv, execve, execvp, getcwd};
pub use funcs::posix88::unistd::{getpid, isatty, lseek, pipe, read};
pub use funcs::posix88::unistd::{rmdir, unlink, write};
pub use funcs::bsd43::{socket, setsockopt, bind, send, recv, recvfrom};
pub use funcs::bsd43::{listen, sendto, accept, connect, getpeername, getsockname};
pub use funcs::bsd43::{shutdown};
pub use consts::os::sysconf::{_SC_PAGESIZE};
pub use consts::os::posix88::{PROT_READ, PROT_WRITE, PROT_EXEC};
pub use consts::os::posix88::{MAP_FIXED, MAP_FILE, MAP_ANON, MAP_PRIVATE, MAP_FAILED};
pub use consts::os::posix88::{EACCES, EBADF, EINVAL, ENODEV, ENOMEM};
pub use consts::os::posix88::{ECONNREFUSED, ECONNRESET, EPERM, EPIPE};
pub use consts::os::posix88::{ENOTCONN, ECONNABORTED, EADDRNOTAVAIL, EINTR};
pub use consts::os::posix88::{EADDRINUSE, ENOENT, EISDIR, EAGAIN, EWOULDBLOCK};
pub use consts::os::posix88::{ECANCELED, SIGINT, EINPROGRESS};
pub use consts::os::posix88::{ENOSYS, ENOTTY, ETIMEDOUT, EMFILE};
pub use consts::os::posix88::{SIGTERM, SIGKILL, SIGPIPE, PROT_NONE};
pub use consts::os::posix01::{SIG_IGN, F_GETFL, F_SETFL};
pub use consts::os::bsd44::{AF_UNIX};
pub use consts::os::extra::{O_NONBLOCK};
pub use types::os::common::posix01::{pthread_t, timespec, timezone};
pub use types::os::arch::posix88::{uid_t, gid_t};
pub use types::os::arch::posix01::{pthread_attr_t};
pub use types::os::arch::posix01::{stat, utimbuf};
pub use types::os::common::bsd44::{ifaddrs};
pub use funcs::posix88::unistd::{sysconf, setgid, setsid, setuid, pread, pwrite};
pub use funcs::posix88::unistd::{getgid, getuid, getsid};
pub use funcs::posix88::unistd::{_PC_NAME_MAX, utime, nanosleep, pathconf, link};
pub use funcs::posix88::unistd::{chown};
pub use funcs::posix88::mman::{mmap, munmap, mprotect};
pub use funcs::posix88::dirent::{opendir, readdir_r, closedir};
pub use funcs::posix88::fcntl::{fcntl};
pub use funcs::posix88::net::{if_nametoindex};
pub use funcs::posix01::stat_::{lstat};
pub use funcs::posix01::unistd::{fsync, ftruncate};
pub use funcs::posix01::unistd::{readlink, symlink};
pub use funcs::bsd43::{getifaddrs, freeifaddrs};
pub use consts::os::posix01::{CLOCK_REALTIME, CLOCK_MONOTONIC};
pub use funcs::posix01::unistd::{fdatasync};
pub use types::os::arch::extra::{sockaddr_ll};
pub use consts::os::extra::{AF_PACKET};
pub use consts::os::extra::{MAP_STACK};

Modules

consts
funcs
types