Skip to content
CryoCryo home
Stdlibffi

libc

import std::ffi::libc; · source

Types

The libc surface

// Declarations are grouped by the header they come from, one extern block per group:
extern "C" {
    function kill(pid: i32, sig: i32) -> i32;
    function raise(sig: i32) -> i32;
    function sigaction(sig: i32, act: u8*, oldact: u8*) -> i32;
    function sigprocmask(how: SigprocmaskHow, set: u8*, oldset: u8*) -> i32;
    // ...
}

// Closed sets are typed enums, variant names verbatim from the header:
type enum Whence : i32 {
    SEEK_SET  = 0;
    SEEK_CUR  = 1;
    SEEK_END  = 2;
    SEEK_DATA = 3;
    SEEK_HOLE = 4;
}

// Bit-flag families and error codes are plain constants:
const O_RDONLY: i32 = 0;
const O_WRONLY: i32 = 1;
const O_RDWR:   i32 = 2;
const EINTR:    i32 = 4;

// Layout-stable structs are real Cryo types:
type struct timespec {
    tv_sec:  i64;
    tv_nsec: i64;
}

function errno() -> i32;

A single home for every extern "C" the standard library needs — some 640 functions — plus broad coverage of the POSIX and glibc surface for downstream use. Modules call libc::read(...), libc::sin(...) and so on, which keeps the rest of the tree free of inline extern blocks.

Functions mirror the libc and POSIX headers verbatim — same names, same signatures, same errno semantics. Idiomatic wrappers that return Result, work in Slice<u8>, or retry on EINTR live at the call site, not here. io::fd is the canonical example.

Sections are grouped by header, so you can skim for a function the way you would in man 3 or /usr/include:

errno.h    signal.h     fcntl.h      sys/stat.h   sys/uio.h    unistd.h
stdio.h    stdlib.h     string.h     ctype.h      time.h       sys/wait.h
sys/socket.h  arpa/inet.h  netdb.h   sys/select.h poll.h       sys/mman.h
sys/epoll.h   sys/eventfd.h  sys/signalfd.h  dirent.h  pthread.h  termios.h
sys/ioctl.h   locale.h     pwd.h     grp.h        regex.h      math.h
dlfcn.h    sys/resource.h

Where glibc and msvcrt disagree — errno values above 34, the _O_* open flags, the errno accessor itself — the declarations are gated per target with ![target(unix)] / ![target(windows)], so one libc:: spelling resolves to the right symbol on each.

Typed enums and flag constants

The split is deliberate and worth knowing before you go looking for a name.

Closed sets of mutually exclusive values are type enum Name : i32, so they pass to libc as typed parameters and the compiler catches a wrong-family argument. Variant names are kept verbatim from the C header — ClockId::CLOCK_MONOTONIC, not ClockId::Monotonic — so call sites read like the man pages.

type enum Whence : i32 {
    SEEK_SET = 0;
    SEEK_CUR = 1;
    SEEK_END = 2;
    SEEK_DATA = 3;
    SEEK_HOLE = 4;
}

type enum ClockId : i32 {
    CLOCK_REALTIME = 0;
    CLOCK_MONOTONIC = 1;
    CLOCK_PROCESS_CPUTIME_ID = 2;
    CLOCK_THREAD_CPUTIME_ID = 3;
    CLOCK_MONOTONIC_RAW = 4;
    CLOCK_REALTIME_COARSE = 5;
    CLOCK_MONOTONIC_COARSE = 6;
    CLOCK_BOOTTIME = 7;
    CLOCK_REALTIME_ALARM = 8;
    CLOCK_BOOTTIME_ALARM = 9;
    CLOCK_TAI = 11;
}

type enum AddressFamily : i32 {
    AF_UNSPEC = 0;
    AF_UNIX = 1;
    AF_INET = 2;
    AF_AX25 = 3;
    AF_IPX = 4;
    AF_APPLETALK = 5;
    AF_NETROM = 6;
    AF_BRIDGE = 7;
    AF_ATMPVC = 8;
    AF_X25 = 9;
    AF_INET6 = 10;
    AF_NETLINK = 16;
    AF_PACKET = 17;
    AF_BLUETOOTH = 31;
}

type enum Protocol : i32 {
    IPPROTO_IP = 0;
    IPPROTO_ICMP = 1;
    IPPROTO_IGMP = 2;
    IPPROTO_TCP = 6;
    IPPROTO_UDP = 17;
    IPPROTO_IPV6 = 41;
    IPPROTO_GRE = 47;
    IPPROTO_ESP = 50;
    IPPROTO_AH = 51;
    IPPROTO_ICMPV6 = 58;
    IPPROTO_RAW = 255;
}

type enum ShutdownHow : i32 {
    SHUT_RD = 0;
    SHUT_WR = 1;
    SHUT_RDWR = 2;
}

type enum DirentType : u8 {
    DT_UNKNOWN = 0;
    DT_FIFO = 1;
    DT_CHR = 2;
    DT_DIR = 4;
    DT_BLK = 6;
    DT_REG = 8;
    DT_LNK = 10;
    DT_SOCK = 12;
    DT_WHT = 14;
}

The full set: Whence, ClockId, ItimerWhich, AddressFamily, Protocol, SocketLevel, ShutdownHow, EpollOp, DirentType, MutexType, DetachState, CancelState, CancelType, LockType, FadviseAdvice, MadviseAdvice, BufferingMode, SigprocmaskHow, LocaleCategory, Resource, RusageWho, PriorityWhich, and the termios TcAction / TcQueue / TcFlow.

Bit-flag families stay as plain consts, because they get OR'd together and compared against return values, which a closed enum does not fit: O_*, S_IF*, POLL*, MAP_*, EPOLL*, AI_*, signal numbers, and errno codes.

C structs

Layout-stable POSIX structs are defined here as Cryo types with matching field order, so you can construct them directly:

type struct timespec {
    tv_sec:  i64;
    tv_nsec: i64;
}

type struct timeval {
    tv_sec:  i64;
    tv_usec: i64;
}

type struct tm {
    tm_sec:    i32;
    tm_min:    i32;
    tm_hour:   i32;
    tm_mday:   i32;
    tm_mon:    i32;
    tm_year:   i32;
    tm_wday:   i32;
    tm_yday:   i32;
    tm_isdst:  i32;
    tm_gmtoff: i64;
    tm_zone:   u8*;
}

type struct iovec {
    iov_base: u8*;
    iov_len:  u64;
}

type struct pollfd {
    fd:      i32;
    events:  i16;
    revents: i16;
}

type struct in_addr {
    s_addr: u32;
}

type struct in6_addr {
    s6_addr: [u8;
    16];
}

type struct rlimit {
    rlim_cur: u64;
    rlim_max: u64;
}

type struct winsize {
    ws_row:    u16;
    ws_col:    u16;
    ws_xpixel: u16;
    ws_ypixel: u16;
}

type struct regmatch_t {
    rm_so: i64;
    rm_eo: i64;
}

Platform-variant structs are treated as opaque byte buffers that you pack and unpack yourself — sockaddr_in, struct stat, addrinfo, epoll_event, struct termios, and the pthread_* family. The accompanying SIZEOF_* constants give the Linux x86-64 size so a u8[SIZEOF_X] buffer comes out the right length. net::addr::sockaddr does exactly this for sockaddr_in.

Errno, signal, mode, fcntl, epoll, and ioctl values are the Linux x86-64 / glibc ABI. Other platforms re-derive them from the corresponding headers.

Floating-point classification — isnan, isinf, finite, signbit, fpclassify — is deliberately not declared here. It is implemented in pure Cryo over the IEEE-754 bit pattern instead, since those are macros rather than exported symbols in most libcs.

Constants

const STDIN_FILENO:     i32 = 0;
const STDOUT_FILENO:    i32 = 1;
const STDERR_FILENO:    i32 = 2;
const EPERM:            i32 = 1;
const ENOENT:           i32 = 2;
const ESRCH:            i32 = 3;
const EINTR:            i32 = 4;
const EIO:              i32 = 5;
const ENXIO:            i32 = 6;
const E2BIG:            i32 = 7;
const ENOEXEC:          i32 = 8;
const EBADF:            i32 = 9;
const ECHILD:           i32 = 10;
const EAGAIN:           i32 = 11;
const EWOULDBLOCK:      i32 = 11;
const ENOMEM:           i32 = 12;
const EACCES:           i32 = 13;
const EFAULT:           i32 = 14;
const ENOTBLK:          i32 = 15;
const EBUSY:            i32 = 16;
const EEXIST:           i32 = 17;
const EXDEV:            i32 = 18;
const ENODEV:           i32 = 19;
const ENOTDIR:          i32 = 20;
const EISDIR:           i32 = 21;
const EINVAL:           i32 = 22;
const ENFILE:           i32 = 23;
const EMFILE:           i32 = 24;
const ENOTTY:           i32 = 25;
const ETXTBSY:          i32 = 26;
const EFBIG:            i32 = 27;
const ENOSPC:           i32 = 28;
const ESPIPE:           i32 = 29;
const EROFS:            i32 = 30;
const EMLINK:           i32 = 31;
const EPIPE:            i32 = 32;
const EDOM:             i32 = 33;
const ERANGE:           i32 = 34;
const EDEADLK:          i32 = 35;
const ENAMETOOLONG:     i32 = 36;
const ENOLCK:           i32 = 37;
const ENOSYS:           i32 = 38;
const ENOTEMPTY:        i32 = 39;
const ELOOP:            i32 = 40;
const ENOMSG:           i32 = 42;
const EIDRM:            i32 = 43;
const ECHRNG:           i32 = 44;
const ENOSTR:           i32 = 60;
const ENODATA:          i32 = 61;
const ETIME:            i32 = 62;
const ENOSR:            i32 = 63;
const ENOLINK:          i32 = 67;
const EPROTO:           i32 = 71;
const EMULTIHOP:        i32 = 72;
const EBADMSG:          i32 = 74;
const EOVERFLOW:        i32 = 75;
const EILSEQ:           i32 = 84;
const ENOTSOCK:         i32 = 88;
const EDESTADDRREQ:     i32 = 89;
const EMSGSIZE:         i32 = 90;
const EPROTOTYPE:       i32 = 91;
const ENOPROTOOPT:      i32 = 92;
const EPROTONOSUPPORT:  i32 = 93;
const ESOCKTNOSUPPORT:  i32 = 94;
const EOPNOTSUPP:       i32 = 95;
const ENOTSUP:          i32 = 95;
const EPFNOSUPPORT:     i32 = 96;
const EAFNOSUPPORT:     i32 = 97;
const EADDRINUSE:       i32 = 98;
const EADDRNOTAVAIL:    i32 = 99;
const ENETDOWN:         i32 = 100;
const ENETUNREACH:      i32 = 101;
const ENETRESET:        i32 = 102;
const ECONNABORTED:     i32 = 103;
const ECONNRESET:       i32 = 104;
const ENOBUFS:          i32 = 105;
const EISCONN:          i32 = 106;
const ENOTCONN:         i32 = 107;
const ESHUTDOWN:        i32 = 108;
const ETOOMANYREFS:     i32 = 109;
const ETIMEDOUT:        i32 = 110;
const ECONNREFUSED:     i32 = 111;
const EHOSTDOWN:        i32 = 112;
const EHOSTUNREACH:     i32 = 113;
const EALREADY:         i32 = 114;
const EINPROGRESS:      i32 = 115;
const ESTALE:           i32 = 116;
const EDQUOT:           i32 = 122;
const ECANCELED:        i32 = 125;
const EOWNERDEAD:       i32 = 130;
const ENOTRECOVERABLE:  i32 = 131;
const SIGHUP:           i32 = 1;
const SIGINT:           i32 = 2;
const SIGQUIT:          i32 = 3;
const SIGILL:           i32 = 4;
const SIGTRAP:          i32 = 5;
const SIGABRT:          i32 = 6;
const SIGIOT:           i32 = 6;
const SIGBUS:           i32 = 7;
const SIGFPE:           i32 = 8;
const SIGKILL:          i32 = 9;
const SIGUSR1:          i32 = 10;
const SIGSEGV:          i32 = 11;
const SIGUSR2:          i32 = 12;
const SIGPIPE:          i32 = 13;
const SIGALRM:          i32 = 14;
const SIGTERM:          i32 = 15;
const SIGSTKFLT:        i32 = 16;
const SIGCHLD:          i32 = 17;
const SIGCONT:          i32 = 18;
const SIGSTOP:          i32 = 19;
const SIGTSTP:          i32 = 20;
const SIGTTIN:          i32 = 21;
const SIGTTOU:          i32 = 22;
const SIGURG:           i32 = 23;
const SIGXCPU:          i32 = 24;
const SIGXFSZ:          i32 = 25;
const SIGVTALRM:        i32 = 26;
const SIGPROF:          i32 = 27;
const SIGWINCH:         i32 = 28;
const SIGIO:            i32 = 29;
const SIGPOLL:          i32 = 29;
const SIGPWR:           i32 = 30;
const SIGSYS:           i32 = 31;
const SIG_DFL:          u64 = 0;
const SIG_IGN:          u64 = 1;
const SIG_ERR:          i64 = -1;
const SA_NOCLDSTOP:     i32 = 1;
const SA_NOCLDWAIT:     i32 = 2;
const SA_SIGINFO:       i32 = 4;
const SA_ONSTACK:       i32 = 1 << 27;
const SA_RESTART:       i32 = 1 << 28;
const SA_NODEFER:       i32 = 1 << 30;
const SA_RESETHAND:     i32 = 1 << 31;
const SIZEOF_SIGSET_T:  u64 = 128;
const SIZEOF_SIGACTION: u64 = 152;
const O_RDONLY:         i32 = 0;
const O_WRONLY:         i32 = 1;
const O_RDWR:           i32 = 2;
const O_ACCMODE:        i32 = 3;

![target(unix)]
const O_CREAT: i32 = 64;

![target(windows)]
const O_CREAT: i32 = 256;

![target(unix)]
const O_EXCL: i32 = 128;

![target(windows)]
const O_EXCL: i32 = 1024;

const O_NOCTTY: i32 = 256;
const O_TRUNC:  i32 = 512;

![target(unix)]
const O_APPEND: i32 = 1024;

![target(windows)]
const O_APPEND: i32 = 8;

const O_NONBLOCK:  i32 = 2048;
const O_NDELAY:    i32 = 2048;
const O_DSYNC:     i32 = 4096;
const O_ASYNC:     i32 = 8192;
const O_DIRECT:    i32 = 16384;
const O_LARGEFILE: i32 = 32768;
const O_DIRECTORY: i32 = 65536;
const O_NOFOLLOW:  i32 = 131072;
const O_NOATIME:   i32 = 262144;
const O_CLOEXEC:   i32 = 524288;
const O_SYNC:      i32 = 1052672;
const O_PATH:      i32 = 2097152;
const O_TMPFILE:   i32 = 4259840;

![target(unix)]
const O_BINARY: i32 = 0;

![target(windows)]
const O_BINARY: i32 = 32768;

const O_RANDOM:                     i32 = 16;
const O_SEQUENTIAL:                 i32 = 32;
const O_TEMPORARY:                  i32 = 64;
const O_NOINHERIT:                  i32 = 128;
const O_SHORT_LIVED:                i32 = 4096;
const O_TEXT:                       i32 = 16384;
const F_DUPFD:                      i32 = 0;
const F_GETFD:                      i32 = 1;
const F_SETFD:                      i32 = 2;
const F_GETFL:                      i32 = 3;
const F_SETFL:                      i32 = 4;
const F_GETLK:                      i32 = 5;
const F_SETLK:                      i32 = 6;
const F_SETLKW:                     i32 = 7;
const F_SETOWN:                     i32 = 8;
const F_GETOWN:                     i32 = 9;
const F_SETSIG:                     i32 = 10;
const F_GETSIG:                     i32 = 11;
const F_DUPFD_CLOEXEC:              i32 = 1030;
const FD_CLOEXEC:                   i32 = 1;
const AT_FDCWD:                     i32 = -100;
const AT_SYMLINK_NOFOLLOW:          i32 = 256;
const AT_REMOVEDIR:                 i32 = 512;
const AT_EACCESS:                   i32 = 512;
const AT_SYMLINK_FOLLOW:            i32 = 1024;
const AT_NO_AUTOMOUNT:              i32 = 2048;
const AT_EMPTY_PATH:                i32 = 4096;
const SIZEOF_STAT:                  u64 = 144;
const S_IFMT:                       u32 = 0xF000;
const S_IFSOCK:                     u32 = 0xC000;
const S_IFLNK:                      u32 = 0xA000;
const S_IFREG:                      u32 = 0x8000;
const S_IFBLK:                      u32 = 0x6000;
const S_IFDIR:                      u32 = 0x4000;
const S_IFCHR:                      u32 = 0x2000;
const S_IFIFO:                      u32 = 0x1000;
const S_ISUID:                      u32 = 0x800;
const S_ISGID:                      u32 = 0x400;
const S_ISVTX:                      u32 = 0x200;
const S_IRWXU:                      u32 = 0x1C0;
const S_IRUSR:                      u32 = 0x100;
const S_IWUSR:                      u32 = 0x80;
const S_IXUSR:                      u32 = 0x40;
const S_IRWXG:                      u32 = 0x38;
const S_IRGRP:                      u32 = 0x20;
const S_IWGRP:                      u32 = 0x10;
const S_IXGRP:                      u32 = 0x8;
const S_IRWXO:                      u32 = 0x7;
const S_IROTH:                      u32 = 0x4;
const S_IWOTH:                      u32 = 0x2;
const S_IXOTH:                      u32 = 0x1;
const F_OK:                         i32 = 0;
const X_OK:                         i32 = 1;
const W_OK:                         i32 = 2;
const R_OK:                         i32 = 4;
const _SC_PAGESIZE:                 i32 = 30;
const _SC_NPROCESSORS_CONF:         i32 = 83;
const _SC_NPROCESSORS_ONLN:         i32 = 84;
const _SC_OPEN_MAX:                 i32 = 4;
const _SC_CHILD_MAX:                i32 = 1;
const _SC_CLK_TCK:                  i32 = 2;
const _SC_ARG_MAX:                  i32 = 0;
const _SC_HOST_NAME_MAX:            i32 = 180;
const _SC_LOGIN_NAME_MAX:           i32 = 71;
const EOF:                          i32 = -1;
const BUFSIZ:                       u64 = 8192;
const L_tmpnam:                     u64 = 20;
const RAND_MAX:                     i32 = 2147483647;
const EXIT_SUCCESS:                 i32 = 0;
const EXIT_FAILURE:                 i32 = 1;
const TIMER_ABSTIME:                i32 = 1;
const CLOCKS_PER_SEC:               i64 = 1000000;
const TFD_NONBLOCK:                 i32 = 2048;
const TFD_CLOEXEC:                  i32 = 524288;
const TFD_TIMER_ABSTIME:            i32 = 1;
const TFD_TIMER_CANCEL_ON_SET:      i32 = 2;
const WNOHANG:                      i32 = 1;
const WUNTRACED:                    i32 = 2;
const WSTOPPED:                     i32 = 2;
const WEXITED:                      i32 = 4;
const WCONTINUED:                   i32 = 8;
const WNOWAIT:                      i32 = 16777216;
const PF_UNSPEC:                    i32 = 0;
const PF_UNIX:                      i32 = 1;
const PF_INET:                      i32 = 2;
const PF_INET6:                     i32 = 10;
const PF_PACKET:                    i32 = 17;
const SOCK_STREAM:                  i32 = 1;
const SOCK_DGRAM:                   i32 = 2;
const SOCK_RAW:                     i32 = 3;
const SOCK_RDM:                     i32 = 4;
const SOCK_SEQPACKET:               i32 = 5;
const SOCK_DCCP:                    i32 = 6;
const SOCK_PACKET:                  i32 = 10;
const SOCK_CLOEXEC:                 i32 = 524288;
const SOCK_NONBLOCK:                i32 = 2048;
const SO_DEBUG:                     i32 = 1;
const SO_REUSEADDR:                 i32 = 2;
const SO_TYPE:                      i32 = 3;
const SO_ERROR:                     i32 = 4;
const SO_DONTROUTE:                 i32 = 5;
const SO_BROADCAST:                 i32 = 6;
const SO_SNDBUF:                    i32 = 7;
const SO_RCVBUF:                    i32 = 8;
const SO_KEEPALIVE:                 i32 = 9;
const SO_OOBINLINE:                 i32 = 10;
const SO_LINGER:                    i32 = 13;
const SO_REUSEPORT:                 i32 = 15;
const SO_RCVLOWAT:                  i32 = 18;
const SO_SNDLOWAT:                  i32 = 19;
const SO_RCVTIMEO:                  i32 = 20;
const SO_SNDTIMEO:                  i32 = 21;
const SO_ACCEPTCONN:                i32 = 30;
const SO_BINDTODEVICE:              i32 = 25;
const IP_TTL:                       i32 = 2;
const IP_MULTICAST_IF:              i32 = 32;
const IP_MULTICAST_TTL:             i32 = 33;
const IP_MULTICAST_LOOP:            i32 = 34;
const IP_ADD_MEMBERSHIP:            i32 = 35;
const IP_DROP_MEMBERSHIP:           i32 = 36;
const IPV6_UNICAST_HOPS:            i32 = 16;
const IPV6_MULTICAST_IF:            i32 = 17;
const IPV6_MULTICAST_HOPS:          i32 = 18;
const IPV6_MULTICAST_LOOP:          i32 = 19;
const IPV6_ADD_MEMBERSHIP:          i32 = 20;
const IPV6_DROP_MEMBERSHIP:         i32 = 21;
const IPV6_V6ONLY:                  i32 = 26;
const TCP_NODELAY:                  i32 = 1;
const TCP_MAXSEG:                   i32 = 2;
const TCP_CORK:                     i32 = 3;
const TCP_KEEPIDLE:                 i32 = 4;
const TCP_KEEPINTVL:                i32 = 5;
const TCP_KEEPCNT:                  i32 = 6;
const TCP_INFO:                     i32 = 11;
const TCP_USER_TIMEOUT:             i32 = 18;
const TCP_FASTOPEN:                 i32 = 23;
const MSG_OOB:                      i32 = 1;
const MSG_PEEK:                     i32 = 2;
const MSG_DONTROUTE:                i32 = 4;
const MSG_CTRUNC:                   i32 = 8;
const MSG_TRUNC:                    i32 = 32;
const MSG_DONTWAIT:                 i32 = 64;
const MSG_EOR:                      i32 = 128;
const MSG_WAITALL:                  i32 = 256;
const MSG_NOSIGNAL:                 i32 = 16384;
const MSG_MORE:                     i32 = 32768;
const MSG_CMSG_CLOEXEC:             i32 = 1073741824;
const SIZEOF_SOCKADDR_IN:           u64 = 16;
const SIZEOF_SOCKADDR_IN6:          u64 = 28;
const SIZEOF_SOCKADDR_STORAGE:      u64 = 128;
const SIZEOF_SOCKADDR_UN:           u64 = 110;
const INADDR_ANY:                   u32 = 0;
const INADDR_LOOPBACK:              u32 = 2130706433;
const INADDR_BROADCAST:             u32 = 4294967295;
const INADDR_NONE:                  u32 = 4294967295;
const INET_ADDRSTRLEN:              u64 = 16;
const INET6_ADDRSTRLEN:             u64 = 46;
const SIZEOF_ADDRINFO:              u64 = 48;
const AI_PASSIVE:                   i32 = 1;
const AI_CANONNAME:                 i32 = 2;
const AI_NUMERICHOST:               i32 = 4;
const AI_V4MAPPED:                  i32 = 8;
const AI_ALL:                       i32 = 16;
const AI_ADDRCONFIG:                i32 = 32;
const AI_NUMERICSERV:               i32 = 1024;
const NI_NUMERICHOST:               i32 = 1;
const NI_NUMERICSERV:               i32 = 2;
const NI_NOFQDN:                    i32 = 4;
const NI_NAMEREQD:                  i32 = 8;
const NI_DGRAM:                     i32 = 16;
const NI_MAXHOST:                   u64 = 1025;
const NI_MAXSERV:                   u64 = 32;
const EAI_BADFLAGS:                 i32 = -1;
const EAI_NONAME:                   i32 = -2;
const EAI_AGAIN:                    i32 = -3;
const EAI_FAIL:                     i32 = -4;
const EAI_FAMILY:                   i32 = -6;
const EAI_SOCKTYPE:                 i32 = -7;
const EAI_SERVICE:                  i32 = -8;
const EAI_MEMORY:                   i32 = -10;
const EAI_SYSTEM:                   i32 = -11;
const EAI_OVERFLOW:                 i32 = -12;
const EAI_NODATA:                   i32 = -5;
const EAI_ADDRFAMILY:               i32 = -9;
const EAI_INPROGRESS:               i32 = -100;
const EAI_CANCELED:                 i32 = -101;
const FD_SETSIZE:                   u64 = 1024;
const SIZEOF_FD_SET:                u64 = 128;
const POLLIN:                       i16 = 1;
const POLLPRI:                      i16 = 2;
const POLLOUT:                      i16 = 4;
const POLLERR:                      i16 = 8;
const POLLHUP:                      i16 = 16;
const POLLNVAL:                     i16 = 32;
const POLLRDNORM:                   i16 = 64;
const POLLRDBAND:                   i16 = 128;
const POLLWRNORM:                   i16 = 256;
const POLLWRBAND:                   i16 = 512;
const POLLMSG:                      i16 = 1024;
const POLLREMOVE:                   i16 = 4096;
const POLLRDHUP:                    i16 = 8192;
const MAP_FAILED_VALUE:             i64 = -1;
const PROT_NONE:                    i32 = 0;
const PROT_READ:                    i32 = 1;
const PROT_WRITE:                   i32 = 2;
const PROT_EXEC:                    i32 = 4;
const PROT_GROWSDOWN:               i32 = 0x01000000;
const PROT_GROWSUP:                 i32 = 0x02000000;
const MAP_SHARED:                   i32 = 1;
const MAP_PRIVATE:                  i32 = 2;
const MAP_SHARED_VALIDATE:          i32 = 3;
const MAP_FIXED:                    i32 = 16;
const MAP_ANONYMOUS:                i32 = 32;
const MAP_ANON:                     i32 = 32;
const MAP_GROWSDOWN:                i32 = 256;
const MAP_DENYWRITE:                i32 = 2048;
const MAP_EXECUTABLE:               i32 = 4096;
const MAP_LOCKED:                   i32 = 8192;
const MAP_NORESERVE:                i32 = 16384;
const MAP_POPULATE:                 i32 = 32768;
const MAP_NONBLOCK:                 i32 = 65536;
const MAP_STACK:                    i32 = 131072;
const MAP_HUGETLB:                  i32 = 262144;
const MAP_SYNC:                     i32 = 524288;
const MAP_FIXED_NOREPLACE:          i32 = 1048576;
const MS_ASYNC:                     i32 = 1;
const MS_INVALIDATE:                i32 = 2;
const MS_SYNC:                      i32 = 4;
const MCL_CURRENT:                  i32 = 1;
const MCL_FUTURE:                   i32 = 2;
const MCL_ONFAULT:                  i32 = 4;
const MFD_CLOEXEC:                  u32 = 1;
const MFD_ALLOW_SEALING:            u32 = 2;
const MFD_HUGETLB:                  u32 = 4;
const SIZEOF_EPOLL_EVENT:           u64 = 12;
const EPOLLIN:                      u32 = 1;
const EPOLLPRI:                     u32 = 2;
const EPOLLOUT:                     u32 = 4;
const EPOLLRDNORM:                  u32 = 64;
const EPOLLRDBAND:                  u32 = 128;
const EPOLLWRNORM:                  u32 = 256;
const EPOLLWRBAND:                  u32 = 512;
const EPOLLMSG:                     u32 = 1024;
const EPOLLERR:                     u32 = 8;
const EPOLLHUP:                     u32 = 16;
const EPOLLRDHUP:                   u32 = 8192;
const EPOLLEXCLUSIVE:               u32 = 268435456;
const EPOLLWAKEUP:                  u32 = 536870912;
const EPOLLONESHOT:                 u32 = 1073741824;
const EPOLLET:                      u32 = 2147483648;
const EPOLL_CLOEXEC:                i32 = 524288;
const EFD_SEMAPHORE:                i32 = 1;
const EFD_CLOEXEC:                  i32 = 524288;
const EFD_NONBLOCK:                 i32 = 2048;
const SFD_CLOEXEC:                  i32 = 524288;
const SFD_NONBLOCK:                 i32 = 2048;
const SIZEOF_SIGNALFD_SIGINFO:      u64 = 128;
const SIZEOF_PTHREAD_T:             u64 = 8;
const SIZEOF_PTHREAD_ATTR_T:        u64 = 56;
const SIZEOF_PTHREAD_MUTEX_T:       u64 = 40;
const SIZEOF_PTHREAD_MUTEXATTR_T:   u64 = 4;
const SIZEOF_PTHREAD_COND_T:        u64 = 48;
const SIZEOF_PTHREAD_CONDATTR_T:    u64 = 4;
const SIZEOF_PTHREAD_RWLOCK_T:      u64 = 56;
const SIZEOF_PTHREAD_RWLOCKATTR_T:  u64 = 8;
const SIZEOF_PTHREAD_BARRIER_T:     u64 = 32;
const SIZEOF_PTHREAD_BARRIERATTR_T: u64 = 4;
const SIZEOF_PTHREAD_KEY_T:         u64 = 4;
const SIZEOF_PTHREAD_ONCE_T:        u64 = 4;
const SIZEOF_PTHREAD_SPINLOCK_T:    u64 = 4;
const SIZEOF_TERMIOS:               u64 = 60;
const NCCS:                         u64 = 32;
const VINTR:                        u64 = 0;
const VQUIT:                        u64 = 1;
const VERASE:                       u64 = 2;
const VKILL:                        u64 = 3;
const VEOF:                         u64 = 4;
const VTIME:                        u64 = 5;
const VMIN:                         u64 = 6;
const VSWTC:                        u64 = 7;
const VSTART:                       u64 = 8;
const VSTOP:                        u64 = 9;
const VSUSP:                        u64 = 10;
const VEOL:                         u64 = 11;
const VREPRINT:                     u64 = 12;
const VDISCARD:                     u64 = 13;
const VWERASE:                      u64 = 14;
const VLNEXT:                       u64 = 15;
const VEOL2:                        u64 = 16;
const IGNBRK:                       u32 = 1;
const BRKINT:                       u32 = 2;
const IGNPAR:                       u32 = 4;
const PARMRK:                       u32 = 8;
const INPCK:                        u32 = 16;
const ISTRIP:                       u32 = 32;
const INLCR:                        u32 = 64;
const IGNCR:                        u32 = 128;
const ICRNL:                        u32 = 256;
const IUCLC:                        u32 = 512;
const IXON:                         u32 = 1024;
const IXANY:                        u32 = 2048;
const IXOFF:                        u32 = 4096;
const IMAXBEL:                      u32 = 8192;
const IUTF8:                        u32 = 16384;
const OPOST:                        u32 = 1;
const ONLCR:                        u32 = 4;
const OCRNL:                        u32 = 8;
const ONOCR:                        u32 = 16;
const ONLRET:                       u32 = 32;
const ISIG:                         u32 = 1;
const ICANON:                       u32 = 2;
const ECHO:                         u32 = 8;
const ECHOE:                        u32 = 16;
const ECHOK:                        u32 = 32;
const ECHONL:                       u32 = 64;
const NOFLSH:                       u32 = 128;
const TOSTOP:                       u32 = 256;
const IEXTEN:                       u32 = 32768;
const CSIZE:                        u32 = 48;
const CS5:                          u32 = 0;
const CS6:                          u32 = 16;
const CS7:                          u32 = 32;
const CS8:                          u32 = 48;
const CSTOPB:                       u32 = 64;
const CREAD:                        u32 = 128;
const PARENB:                       u32 = 256;
const PARODD:                       u32 = 512;
const HUPCL:                        u32 = 1024;
const CLOCAL:                       u32 = 2048;
const B0:                           u32 = 0;
const B50:                          u32 = 1;
const B75:                          u32 = 2;
const B110:                         u32 = 3;
const B134:                         u32 = 4;
const B150:                         u32 = 5;
const B200:                         u32 = 6;
const B300:                         u32 = 7;
const B600:                         u32 = 8;
const B1200:                        u32 = 9;
const B1800:                        u32 = 10;
const B2400:                        u32 = 11;
const B4800:                        u32 = 12;
const B9600:                        u32 = 13;
const B19200:                       u32 = 14;
const B38400:                       u32 = 15;
const B57600:                       u32 = 4097;
const B115200:                      u32 = 4098;
const B230400:                      u32 = 4099;
const B460800:                      u32 = 4100;
const B500000:                      u32 = 4101;
const B576000:                      u32 = 4102;
const B921600:                      u32 = 4103;
const B1000000:                     u32 = 4104;
const TIOCGWINSZ:                   u64 = 21523;
const TIOCSWINSZ:                   u64 = 21524;
const TIOCSCTTY:                    u64 = 21518;
const TIOCNOTTY:                    u64 = 21538;
const TIOCGPGRP:                    u64 = 21519;
const TIOCSPGRP:                    u64 = 21520;
const FIONBIO:                      u64 = 21537;
const FIONREAD:                     u64 = 21531;
const FIOCLEX:                      u64 = 21585;
const FIONCLEX:                     u64 = 21584;
const SIZEOF_PASSWD:                u64 = 48;
const SIZEOF_GROUP:                 u64 = 32;
const SIZEOF_REGEX_T:               u64 = 64;
const SIZEOF_REGMATCH_T:            u64 = 16;
const REG_EXTENDED:                 i32 = 1;
const REG_ICASE:                    i32 = 2;
const REG_NOSUB:                    i32 = 4;
const REG_NEWLINE:                  i32 = 8;
const REG_NOTBOL:                   i32 = 1;
const REG_NOTEOL:                   i32 = 2;
const REG_NOMATCH:                  i32 = 1;
const REG_BADPAT:                   i32 = 2;
const REG_ECOLLATE:                 i32 = 3;
const REG_ECTYPE:                   i32 = 4;
const REG_EESCAPE:                  i32 = 5;
const REG_ESUBREG:                  i32 = 6;
const REG_EBRACK:                   i32 = 7;
const REG_EPAREN:                   i32 = 8;
const REG_EBRACE:                   i32 = 9;
const REG_BADBR:                    i32 = 10;
const REG_ERANGE:                   i32 = 11;
const REG_ESPACE:                   i32 = 12;
const REG_BADRPT:                   i32 = 13;
const RTLD_LAZY:                    i32 = 1;
const RTLD_NOW:                     i32 = 2;
const RTLD_BINDING_MASK:            i32 = 3;
const RTLD_NOLOAD:                  i32 = 4;
const RTLD_DEEPBIND:                i32 = 8;
const RTLD_GLOBAL:                  i32 = 256;
const RTLD_LOCAL:                   i32 = 0;
const RTLD_NODELETE:                i32 = 4096;
const RLIM_INFINITY:                u64 = 18446744073709551615;