#
#
# Nimrod's Runtime Library
# (c) Copyright 2009 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
# Until std_arg!!
# done: ipc, pwd, stat, semaphore, sys/types, sys/utsname, pthread, unistd,
# statvfs, mman, time, wait, signal, nl_types, sched, spawn, select, ucontext,
# net/if, sys/socket, sys/uio, netinet/in, netinet/tcp, netdb
## This is a raw POSIX interface module. It does not not provide any
## convenience: cstrings are used instead of proper Nimrod strings and
## return codes indicate errors. If you want exceptions
## and a proper Nimrod-like interface, use the OS module or write a wrapper.
## Coding conventions:
## ALL types are named the same as in the POSIX standard except that they start
## with 'T' or 'P' (if they are pointers) and without the '_t' prefix to be
## consistent with Nimrod conventions. If an identifier is a Nimrod keyword
## the \`identifier\` notation is used.
##
## This library relies on the header files of your C compiler. Thus the
## resulting C code will just include and *not* define the
## symbols declared here.
const
hasSpawnH = defined(linux)
hasAioH = defined(linux)
const
C_IRUSR* = 0c000400 ## Read by owner.
C_IWUSR* = 0c000200 ## Write by owner.
C_IXUSR* = 0c000100 ## Execute by owner.
C_IRGRP* = 0c000040 ## Read by group.
C_IWGRP* = 0c000020 ## Write by group.
C_IXGRP* = 0c000010 ## Execute by group.
C_IROTH* = 0c000004 ## Read by others.
C_IWOTH* = 0c000002 ## Write by others.
C_IXOTH* = 0c000001 ## Execute by others.
C_ISUID* = 0c004000 ## Set user ID.
C_ISGID* = 0c002000 ## Set group ID.
C_ISVTX* = 0c001000 ## On directories, restricted deletion flag.
C_ISDIR* = 0c040000 ## Directory.
C_ISFIFO* = 0c010000 ##FIFO.
C_ISREG* = 0c100000 ## Regular file.
C_ISBLK* = 0c060000 ## Block special.
C_ISCHR* = 0c020000 ## Character special.
C_ISCTG* = 0c110000 ## Reserved.
C_ISLNK* = 0c120000 ## Symbolic link.
C_ISSOCK* = 0c140000 ## Socket.
MM_NULLLBL* = nil
MM_NULLSEV* = 0
MM_NULLMC* = 0
MM_NULLTXT* = nil
MM_NULLACT* = nil
MM_NULLTAG* = nil
STDERR_FILENO* = 2 ## File number of stderr;
STDIN_FILENO* = 0 ## File number of stdin;
STDOUT_FILENO* = 1 ## File number of stdout;
type
TDIR* {.importc: "DIR", header: "", final, pure.} = object
## A type representing a directory stream.
Tdirent* {.importc: "struct dirent",
header: "", final, pure.} = object ## dirent_t struct
d_ino*: TIno ## File serial number.
d_name*: array [0..255, char] ## Name of entry.
Tflock* {.importc: "flock", final, pure,
header: "".} = object ## flock type
l_type*: cshort ## Type of lock; F_RDLCK, F_WRLCK, F_UNLCK.
l_whence*: cshort ## Flag for starting offset.
l_start*: Toff ## Relative offset in bytes.
l_len*: Toff ## Size; if 0 then until EOF.
l_pid*: TPid ## Process ID of the process holding the lock;
## returned with F_GETLK.
Tfenv* {.importc: "fenv_t", header: "", final, pure.} =
object ## Represents the entire floating-point environment. The
## floating-point environment refers collectively to any
## floating-point status flags and control modes supported
## by the implementation.
Tfexcept* {.importc: "fexcept_t", header: "", final, pure.} =
object ## Represents the floating-point status flags collectively,
## including any status the implementation associates with the
## flags. A floating-point status flag is a system variable
## whose value is set (but never cleared) when a floating-point
## exception is raised, which occurs as a side effect of
## exceptional floating-point arithmetic to provide auxiliary
## information. A floating-point control mode is a system variable
## whose value may be set by the user to affect the subsequent
## behavior of floating-point arithmetic.
TFTW* {.importc: "struct FTW", header: "", final, pure.} = object
base*: cint
level*: cint
TGlob* {.importc: "glob_t", header: "",
final, pure.} = object ## glob_t
gl_pathc*: int ## Count of paths matched by pattern.
gl_pathv*: ptr cstring ## Pointer to a list of matched pathnames.
gl_offs*: int ## Slots to reserve at the beginning of gl_pathv.
TGroup* {.importc: "struct group", header: "",
final, pure.} = object ## struct group
gr_name*: cstring ## The name of the group.
gr_gid*: TGid ## Numerical group ID.
gr_mem*: cstringArray ## Pointer to a null-terminated array of character
## pointers to member names.
Ticonv* {.importc: "iconv_t", header: "", final, pure.} =
object ## Identifies the conversion from one codeset to another.
Tlconv* {.importc: "struct lconv", header: "", final, pure.} = object
currency_symbol*: cstring
decimal_point*: cstring
frac_digits*: char
grouping*: cstring
int_curr_symbol*: cstring
int_frac_digits*: char
int_n_cs_precedes*: char
int_n_sep_by_space*: char
int_n_sign_posn*: char
int_p_cs_precedes*: char
int_p_sep_by_space*: char
int_p_sign_posn*: char
mon_decimal_point*: cstring
mon_grouping*: cstring
mon_thousands_sep*: cstring
negative_sign*: cstring
n_cs_precedes*: char
n_sep_by_space*: char
n_sign_posn*: char
positive_sign*: cstring
p_cs_precedes*: char
p_sep_by_space*: char
p_sign_posn*: char
thousands_sep*: cstring
TMqd* {.importc: "mqd_t", header: "", final, pure.} = object
TMqAttr* {.importc: "struct mq_attr",
header: "",
final, pure.} = object ## message queue attribute
mq_flags*: int ## Message queue flags.
mq_maxmsg*: int ## Maximum number of messages.
mq_msgsize*: int ## Maximum message size.
mq_curmsgs*: int ## Number of messages currently queued.
TPasswd* {.importc: "struct passwd", header: "",
final, pure.} = object ## struct passwd
pw_name*: cstring ## User's login name.
pw_uid*: TUid ## Numerical user ID.
pw_gid*: TGid ## Numerical group ID.
pw_dir*: cstring ## Initial working directory.
pw_shell*: cstring ## Program to use as shell.
Tblkcnt* {.importc: "blkcnt_t", header: "".} = int
## used for file block counts
Tblksize* {.importc: "blksize_t", header: "".} = int
## used for block sizes
TClock* {.importc: "clock_t", header: "".} = int
TClockId* {.importc: "clockid_t", header: "".} = int
TDev* {.importc: "dev_t", header: "".} = int
Tfsblkcnt* {.importc: "fsblkcnt_t", header: "".} = int
Tfsfilcnt* {.importc: "fsfilcnt_t", header: "".} = int
TGid* {.importc: "gid_t", header: "".} = int
Tid* {.importc: "id_t", header: "".} = int
Tino* {.importc: "ino_t", header: "".} = int
TKey* {.importc: "key_t", header: "".} = int
TMode* {.importc: "mode_t", header: "".} = int
TNlink* {.importc: "nlink_t", header: "".} = int
TOff* {.importc: "off_t", header: "".} = int64
TPid* {.importc: "pid_t", header: "".} = int
Tpthread_attr* {.importc: "pthread_attr_t", header: "".} = int
Tpthread_barrier* {.importc: "pthread_barrier_t",
header: "".} = int
Tpthread_barrierattr* {.importc: "pthread_barrierattr_t",
header: "".} = int
Tpthread_cond* {.importc: "pthread_cond_t", header: "".} = int
Tpthread_condattr* {.importc: "pthread_condattr_t",
header: "".} = int
Tpthread_key* {.importc: "pthread_key_t", header: "".} = int
Tpthread_mutex* {.importc: "pthread_mutex_t", header: "".} = int
Tpthread_mutexattr* {.importc: "pthread_mutexattr_t",
header: "".} = int
Tpthread_once* {.importc: "pthread_once_t", header: "".} = int
Tpthread_rwlock* {.importc: "pthread_rwlock_t", header: "".} = int
Tpthread_rwlockattr* {.importc: "pthread_rwlockattr_t",
header: "".} = int
Tpthread_spinlock* {.importc: "pthread_spinlock_t",
header: "".} = int
Tpthread* {.importc: "pthread_t", header: "".} = int
Tsuseconds* {.importc: "suseconds_t", header: "".} = int
Ttime* {.importc: "time_t", header: "".} = int
Ttimer* {.importc: "timer_t", header: "".} = int
Ttrace_attr* {.importc: "trace_attr_t", header: "".} = int
Ttrace_event_id* {.importc: "trace_event_id_t",
header: "".} = int
Ttrace_event_set* {.importc: "trace_event_set_t",
header: "".} = int
Ttrace_id* {.importc: "trace_id_t", header: "".} = int
Tuid* {.importc: "uid_t", header: "".} = int
Tuseconds* {.importc: "useconds_t", header: "".} = int
Tutsname* {.importc: "struct utsname",
header: "",
final, pure.} = object ## struct utsname
sysname*, ## Name of this implementation of the operating system.
nodename*, ## Name of this node within the communications
## network to which this node is attached, if any.
release*, ## Current release level of this implementation.
version*, ## Current version level of this release.
machine*: array [0..255, char] ## Name of the hardware type on which the
## system is running.
TSem* {.importc: "sem_t", header: "", final, pure.} = object
Tipc_perm* {.importc: "struct ipc_perm",
header: "", final, pure.} = object ## struct ipc_perm
uid*: tuid ## Owner's user ID.
gid*: tgid ## Owner's group ID.
cuid*: Tuid ## Creator's user ID.
cgid*: Tgid ## Creator's group ID.
mode*: TMode ## Read/write permission.
TStat* {.importc: "struct stat",
header: "", final, pure.} = object ## struct stat
st_dev*: TDev ## Device ID of device containing file.
st_ino*: TIno ## File serial number.
st_mode*: TMode ## Mode of file (see below).
st_nlink*: tnlink ## Number of hard links to the file.
st_uid*: tuid ## User ID of file.
st_gid*: Tgid ## Group ID of file.
st_rdev*: TDev ## Device ID (if file is character or block special).
st_size*: TOff ## For regular files, the file size in bytes.
## For symbolic links, the length in bytes of the
## pathname contained in the symbolic link.
## For a shared memory object, the length in bytes.
## For a typed memory object, the length in bytes.
## For other file types, the use of this field is
## unspecified.
st_atime*: ttime ## Time of last access.
st_mtime*: ttime ## Time of last data modification.
st_ctime*: ttime ## Time of last status change.
st_blksize*: Tblksize ## A file system-specific preferred I/O block size
## for this object. In some file system types, this
## may vary from file to file.
st_blocks*: Tblkcnt ## Number of blocks allocated for this object.
TStatvfs* {.importc: "struct statvfs", header: "",
final, pure.} = object ## struct statvfs
f_bsize*: int ## File system block size.
f_frsize*: int ## Fundamental file system block size.
f_blocks*: Tfsblkcnt ## Total number of blocks on file system
## in units of f_frsize.
f_bfree*: Tfsblkcnt ## Total number of free blocks.
f_bavail*: Tfsblkcnt ## Number of free blocks available to
## non-privileged process.
f_files*: Tfsfilcnt ## Total number of file serial numbers.
f_ffree*: Tfsfilcnt ## Total number of free file serial numbers.
f_favail*: Tfsfilcnt ## Number of file serial numbers available to
## non-privileged process.
f_fsid*: int ## File system ID.
f_flag*: int ## Bit mask of f_flag values.
f_namemax*: int ## Maximum filename length.
Tposix_typed_mem_info* {.importc: "struct posix_typed_mem_info",
header: "", final, pure.} = object
posix_tmi_length*: int
Ttm* {.importc: "struct tm", header: "",
final, pure.} = object ## struct tm
tm_sec*: cint ## Seconds [0,60].
tm_min*: cint ## Minutes [0,59].
tm_hour*: cint ## Hour [0,23].
tm_mday*: cint ## Day of month [1,31].
tm_mon*: cint ## Month of year [0,11].
tm_year*: cint ## Years since 1900.
tm_wday*: cint ## Day of week [0,6] (Sunday =0).
tm_yday*: cint ## Day of year [0,365].
tm_isdst*: cint ## Daylight Savings flag.
Ttimespec* {.importc: "struct timespec",
header: "", final, pure.} = object ## struct timespec
tv_sec*: Ttime ## Seconds.
tv_nsec*: int ## Nanoseconds.
titimerspec* {.importc: "struct itimerspec", header: "",
final, pure.} = object ## struct itimerspec
it_interval*: ttimespec ## Timer period.
it_value*: ttimespec ## Timer expiration.
Tsig_atomic* {.importc: "sig_atomic_t", header: "".} = cint
## Possibly volatile-qualified integer type of an object that can be
## accessed as an atomic entity, even in the presence of asynchronous
## interrupts.
Tsigset* {.importc: "sigset_t", header: "", final, pure.} = object
TsigEvent* {.importc: "struct sigevent",
header: "", final, pure.} = object ## struct sigevent
sigev_notify*: cint ## Notification type.
sigev_signo*: cint ## Signal number.
sigev_value*: Tsigval ## Signal value.
sigev_notify_function*: proc (x: TSigval) {.noconv.} ## Notification function.
sigev_notify_attributes*: ptr Tpthreadattr ## Notification attributes.
TsigVal* {.importc: "union sigval",
header: "", final, pure.} = object ## struct sigval
sival_ptr*: pointer ## pointer signal value;
## integer signal value not defined!
TSigaction* {.importc: "struct sigaction",
header: "", final, pure.} = object ## struct sigaction
sa_handler*: proc (x: cint) {.noconv.} ## Pointer to a signal-catching
## function or one of the macros
## SIG_IGN or SIG_DFL.
sa_mask*: TsigSet ## Set of signals to be blocked during execution of
## the signal handling function.
sa_flags*: cint ## Special flags.
sa_sigaction*: proc (x: cint, y: var TSigInfo, z: pointer) {.noconv.}
TStack* {.importc: "stack_t",
header: "", final, pure.} = object ## stack_t
ss_sp*: pointer ## Stack base or pointer.
ss_size*: int ## Stack size.
ss_flags*: cint ## Flags.
TSigStack* {.importc: "struct sigstack",
header: "", final, pure.} = object ## struct sigstack
ss_onstack*: cint ## Non-zero when signal stack is in use.
ss_sp*: pointer ## Signal stack pointer.
TsigInfo* {.importc: "siginfo_t",
header: "", final, pure.} = object ## siginfo_t
si_signo*: cint ## Signal number.
si_code*: cint ## Signal code.
si_errno*: cint ## If non-zero, an errno value associated with
## this signal, as defined in .
si_pid*: tpid ## Sending process ID.
si_uid*: tuid ## Real user ID of sending process.
si_addr*: pointer ## Address of faulting instruction.
si_status*: cint ## Exit value or signal.
si_band*: int ## Band event for SIGPOLL.
si_value*: TSigval ## Signal value.
Tnl_item* {.importc: "nl_item", header: "".} = cint
Tnl_catd* {.importc: "nl_catd", header: "".} = cint
Tsched_param* {.importc: "struct sched_param",
header: "",
final, pure.} = object ## struct sched_param
sched_priority*: cint
sched_ss_low_priority*: cint ## Low scheduling priority for
## sporadic server.
sched_ss_repl_period*: ttimespec ## Replenishment period for
## sporadic server.
sched_ss_init_budget*: ttimespec ## Initial budget for sporadic server.
sched_ss_max_repl*: cint ## Maximum pending replenishments for
## sporadic server.
Ttimeval* {.importc: "struct timeval", header: "",
final, pure.} = object ## struct timeval
tv_sec*: ttime ## Seconds.
tv_usec*: tsuseconds ## Microseconds.
Tfd_set* {.importc: "struct fd_set", header: "",
final, pure.} = object
Tmcontext* {.importc: "mcontext_t", header: "",
final, pure.} = object
Tucontext* {.importc: "ucontext_t", header: "",
final, pure.} = object ## ucontext_t
uc_link*: ptr Tucontext ## Pointer to the context that is resumed
## when this context returns.
uc_sigmask*: Tsigset ## The set of signals that are blocked when this
## context is active.
uc_stack*: TStack ## The stack used by this context.
uc_mcontext*: Tmcontext ## A machine-specific representation of the saved
## context.
when hasAioH:
type
Taiocb* {.importc: "struct aiocb", header: "",
final, pure.} = object ## struct aiocb
aio_fildes*: cint ## File descriptor.
aio_offset*: TOff ## File offset.
aio_buf*: pointer ## Location of buffer.
aio_nbytes*: int ## Length of transfer.
aio_reqprio*: cint ## Request priority offset.
aio_sigevent*: TSigEvent ## Signal number and value.
aio_lio_opcode: cint ## Operation to be performed.
when hasSpawnH:
type
Tposix_spawnattr* {.importc: "posix_spawnattr_t",
header: "".} = cint
Tposix_spawn_file_actions* {.importc: "posix_spawn_file_actions_t",
header: "".} = cint
type
Tif_nameindex* {.importc: "struct if_nameindex", final,
pure, header: "".} = object ## struct if_nameindex
if_index*: cint ## Numeric index of the interface.
if_name*: cstring ## Null-terminated name of the interface.
TSocklen* {.importc: "socklen_t", header: "".} = cint
TSa_Family* {.importc: "sa_family_t", header: "".} = cint
TSockAddr* {.importc: "struct sockaddr", header: "",
pure, final.} = object ## struct sockaddr
sa_family*: Tsa_family ## Address family.
sa_data*: array [0..255, char] ## Socket address (variable-length data).
Tsockaddr_storage* {.importc: "struct sockaddr_storage",
header: "",
pure, final.} = object ## struct sockaddr_storage
ss_family*: Tsa_family ## Address family.
TIOVec* {.importc: "struct iovec", pure, final,
header: "".} = object ## struct iovec
iov_base*: pointer ## Base address of a memory region for input or output.
iov_len*: int ## The size of the memory pointed to by iov_base.
Tmsghdr* {.importc: "struct msghdr", pure, final,
header: "".} = object ## struct msghdr
msg_name*: pointer ## Optional address.
msg_namelen*: TSockLen ## Size of address.
msg_iov*: ptr TIOVec ## Scatter/gather array.
msg_iovlen*: cint ## Members in msg_iov.
msg_control*: pointer ## Ancillary data; see below.
msg_controllen*: TSockLen ## Ancillary data buffer len.
msg_flags*: cint ## Flags on received message.
Tcmsghdr* {.importc: "struct cmsghdr", pure, final,
header: "".} = object ## struct cmsghdr
cmsg_len*: TSockLen ## Data byte count, including the cmsghdr.
cmsg_level*: cint ## Originating protocol.
cmsg_type*: cint ## Protocol-specific type.
TLinger* {.importc: "struct linger", pure, final,
header: "".} = object ## struct linger
l_onoff*: cint ## Indicates whether linger option is enabled.
l_linger*: cint ## Linger time, in seconds.
TInPort* = int16 ## unsigned!
TInAddrScalar* = int32 ## unsigned!
TInAddr* {.importc: "struct in_addr", pure, final,
header: "".} = object ## struct in_addr
s_addr*: TInAddrScalar
Tsockaddr_in* {.importc: "struct sockaddr_in", pure, final,
header: "".} = object ## struct sockaddr_in
sin_family*: TSa_family ## AF_INET.
sin_port*: TInPort ## Port number.
sin_addr*: TInAddr ## IP address.
TIn6Addr* {.importc: "struct in6_addr", pure, final,
header: "".} = object ## struct in6_addr
s6_addr*: array [0..15, char]
Tsockaddr_in6* {.importc: "struct sockaddr_in6", pure, final,
header: "".} = object ## struct sockaddr_in6
sin6_family*: TSa_family ## AF_INET6.
sin6_port*: TInPort ## Port number.
sin6_flowinfo*: int32 ## IPv6 traffic class and flow information.
sin6_addr*: Tin6Addr ## IPv6 address.
sin6_scope_id*: int32 ## Set of interfaces for a scope.
Tipv6_mreq* {.importc: "struct ipv6_mreq", pure, final,
header: "".} = object ## struct ipv6_mreq
ipv6mr_multiaddr*: TIn6Addr ## IPv6 multicast address.
ipv6mr_interface*: cint ## Interface index.
Thostent* {.importc: "struct hostent", pure, final,
header: "".} = object ## struct hostent
h_name*: cstring ## Official name of the host.
h_aliases*: cstringArray ## A pointer to an array of pointers to
## alternative host names, terminated by a
## null pointer.
h_addrtype*: cint ## Address type.
h_length*: cint ## The length, in bytes, of the address.
h_addr_list*: cstringArray ## A pointer to an array of pointers to network
## addresses (in network byte order) for the
## host, terminated by a null pointer.
Tnetent* {.importc: "struct netent", pure, final,
header: "".} = object ## struct netent
n_name*: cstring ## Official, fully-qualified (including the
## domain) name of the host.
n_aliases*: cstringArray ## A pointer to an array of pointers to
## alternative network names, terminated by a
## null pointer.
n_addrtype*: cint ## The address type of the network.
n_net*: int32 ## The network number, in host byte order.
TProtoent* {.importc: "struct protoent", pure, final,
header: "".} = object ## struct protoent
p_name*: cstring ## Official name of the protocol.
p_aliases*: cstringArray ## A pointer to an array of pointers to
## alternative protocol names, terminated by
## a null pointer.
p_proto*: cint ## The protocol number.
TServent* {.importc: "struct servent", pure, final,
header: "".} = object ## struct servent
s_name*: cstring ## Official name of the service.
s_aliases*: cstringArray ## A pointer to an array of pointers to
## alternative service names, terminated by
## a null pointer.
s_port*: cint ## The port number at which the service
## resides, in network byte order.
s_proto*: cstring ## The name of the protocol to use when
## contacting the service.
Taddrinfo* {.importc: "struct addrinfo", pure, final,
header: "".} = object ## struct addrinfo
ai_flags*: cint ## Input flags.
ai_family*: cint ## Address family of socket.
ai_socktype*: cint ## Socket type.
ai_protocol*: cint ## Protocol of socket.
ai_addrlen*: TSockLen ## Length of socket address.
ai_addr*: ptr TSockAddr ## Socket address of socket.
ai_canonname*: cstring ## Canonical name of service location.
ai_next*: ptr TAddrInfo ## Pointer to next in list.
TPollfd* {.importc: "struct pollfd", pure, final,
header: "".} = object ## struct pollfd
fd*: cint ## The following descriptor being polled.
events*: cshort ## The input event flags (see below).
revents*: cshort ## The output event flags (see below).
Tnfds* {.importc: "nfds_t", header: "".} = cint
var
errno* {.importc, header: "".}: cint ## error variable
daylight* {.importc, header: "".}: cint
timezone* {.importc, header: "".}: int
# Constants as variables:
when hasAioH:
var
AIO_ALLDONE* {.importc, header: "".}: cint
## A return value indicating that none of the requested operations
## could be canceled since they are already complete.
AIO_CANCELED* {.importc, header: "".}: cint
## A return value indicating that all requested operations have
## been canceled.
AIO_NOTCANCELED* {.importc, header: "".}: cint
## A return value indicating that some of the requested operations could
## not be canceled since they are in progress.
LIO_NOP* {.importc, header: "".}: cint
## A lio_listio() element operation option indicating that no transfer is
## requested.
LIO_NOWAIT* {.importc, header: "".}: cint
## A lio_listio() synchronization operation indicating that the calling
## thread is to continue execution while the lio_listio() operation is
## being performed, and no notification is given when the operation is
## complete.
LIO_READ* {.importc, header: "".}: cint
## A lio_listio() element operation option requesting a read.
LIO_WAIT* {.importc, header: "".}: cint
## A lio_listio() synchronization operation indicating that the calling
## thread is to suspend until the lio_listio() operation is complete.
LIO_WRITE* {.importc, header: "".}: cint
## A lio_listio() element operation option requesting a write.
var
RTLD_LAZY* {.importc, header: "".}: cint
## Relocations are performed at an implementation-defined time.
RTLD_NOW* {.importc, header: "".}: cint
## Relocations are performed when the object is loaded.
RTLD_GLOBAL* {.importc, header: "".}: cint
## All symbols are available for relocation processing of other modules.
RTLD_LOCAL* {.importc, header: "".}: cint
## All symbols are not made available for relocation processing by
## other modules.
E2BIG* {.importc, header: "".}: cint
## Argument list too long.
EACCES* {.importc, header: "".}: cint
## Permission denied.
EADDRINUSE* {.importc, header: "".}: cint
## Address in use.
EADDRNOTAVAIL* {.importc, header: "".}: cint
## Address not available.
EAFNOSUPPORT* {.importc, header: "".}: cint
## Address family not supported.
EAGAIN* {.importc, header: "".}: cint
## Resource unavailable, try again (may be the same value as [EWOULDBLOCK]).
EALREADY* {.importc, header: "".}: cint
## Connection already in progress.
EBADF* {.importc, header: "".}: cint
## Bad file descriptor.
EBADMSG* {.importc, header: "".}: cint
## Bad message.
EBUSY* {.importc, header: "".}: cint
## Device or resource busy.
ECANCELED* {.importc, header: "".}: cint
## Operation canceled.
ECHILD* {.importc, header: "".}: cint
## No child processes.
ECONNABORTED* {.importc, header: "".}: cint
## Connection aborted.
ECONNREFUSED* {.importc, header: "".}: cint
## Connection refused.
ECONNRESET* {.importc, header: "".}: cint
## Connection reset.
EDEADLK* {.importc, header: "".}: cint
## Resource deadlock would occur.
EDESTADDRREQ* {.importc, header: "".}: cint
## Destination address required.
EDOM* {.importc, header: "".}: cint
## Mathematics argument out of domain of function.
EDQUOT* {.importc, header: "".}: cint
## Reserved.
EEXIST* {.importc, header: "".}: cint
## File exists.
EFAULT* {.importc, header: "".}: cint
## Bad address.
EFBIG* {.importc, header: "".}: cint
## File too large.
EHOSTUNREACH* {.importc, header: "".}: cint
## Host is unreachable.
EIDRM* {.importc, header: "".}: cint
## Identifier removed.
EILSEQ* {.importc, header: "".}: cint
## Illegal byte sequence.
EINPROGRESS* {.importc, header: "".}: cint
## Operation in progress.
EINTR* {.importc, header: "".}: cint
## Interrupted function.
EINVAL* {.importc, header: "".}: cint
## Invalid argument.
EIO* {.importc, header: "".}: cint
## I/O error.
EISCONN* {.importc, header: "".}: cint
## Socket is connected.
EISDIR* {.importc, header: "".}: cint
## Is a directory.
ELOOP* {.importc, header: "".}: cint
## Too many levels of symbolic links.
EMFILE* {.importc, header: "".}: cint
## Too many open files.
EMLINK* {.importc, header: "".}: cint
## Too many links.
EMSGSIZE* {.importc, header: "".}: cint
## Message too large.
EMULTIHOP* {.importc, header: "".}: cint
## Reserved.
ENAMETOOLONG* {.importc, header: "".}: cint
## Filename too long.
ENETDOWN* {.importc, header: "".}: cint
## Network is down.
ENETRESET* {.importc, header: "".}: cint
## Connection aborted by network.
ENETUNREACH* {.importc, header: "".}: cint
## Network unreachable.
ENFILE* {.importc, header: "".}: cint
## Too many files open in system.
ENOBUFS* {.importc, header: "".}: cint
## No buffer space available.
ENODATA* {.importc, header: "".}: cint
## No message is available on the STREAM head read queue.
ENODEV* {.importc, header: "".}: cint
## No such device.
ENOENT* {.importc, header: "".}: cint
## No such file or directory.
ENOEXEC* {.importc, header: "".}: cint
## Executable file format error.
ENOLCK* {.importc, header: "".}: cint
## No locks available.
ENOLINK* {.importc, header: "".}: cint
## Reserved.
ENOMEM* {.importc, header: "".}: cint
## Not enough space.
ENOMSG* {.importc, header: "".}: cint
## No message of the desired type.
ENOPROTOOPT* {.importc, header: "".}: cint
## Protocol not available.
ENOSPC* {.importc, header: "".}: cint
## No space left on device.
ENOSR* {.importc, header: "".}: cint
## No STREAM resources.
ENOSTR* {.importc, header: "".}: cint
## Not a STREAM.
ENOSYS* {.importc, header: "".}: cint
## Function not supported.
ENOTCONN* {.importc, header: "".}: cint
## The socket is not connected.
ENOTDIR* {.importc, header: "".}: cint
## Not a directory.
ENOTEMPTY* {.importc, header: "".}: cint
## Directory not empty.
ENOTSOCK* {.importc, header: "".}: cint
## Not a socket.
ENOTSUP* {.importc, header: "".}: cint
## Not supported.
ENOTTY* {.importc, header: "".}: cint
## Inappropriate I/O control operation.
ENXIO* {.importc, header: "".}: cint
## No such device or address.
EOPNOTSUPP* {.importc, header: "".}: cint
## Operation not supported on socket.
EOVERFLOW* {.importc, header: "".}: cint
## Value too large to be stored in data type.
EPERM* {.importc, header: "".}: cint
## Operation not permitted.
EPIPE* {.importc, header: "".}: cint
## Broken pipe.
EPROTO* {.importc, header: "".}: cint
## Protocol error.
EPROTONOSUPPORT* {.importc, header: "".}: cint
## Protocol not supported.
EPROTOTYPE* {.importc, header: "".}: cint
## Protocol wrong type for socket.
ERANGE* {.importc, header: "".}: cint
## Result too large.
EROFS* {.importc, header: "".}: cint
## Read-only file system.
ESPIPE* {.importc, header: "".}: cint
## Invalid seek.
ESRCH* {.importc, header: "".}: cint
## No such process.
ESTALE* {.importc, header: "".}: cint
## Reserved.
ETIME* {.importc, header: "".}: cint
## Stream ioctl() timeout.
ETIMEDOUT* {.importc, header: "".}: cint
## Connection timed out.
ETXTBSY* {.importc, header: "".}: cint
## Text file busy.
EWOULDBLOCK* {.importc, header: "".}: cint
## Operation would block (may be the same value as [EAGAIN]).
EXDEV* {.importc, header: "".}: cint
## Cross-device link.
F_DUPFD* {.importc, header: "".}: cint
## Duplicate file descriptor.
F_GETFD* {.importc, header: "".}: cint
## Get file descriptor flags.
F_SETFD* {.importc, header: "".}: cint
## Set file descriptor flags.
F_GETFL* {.importc, header: "".}: cint
## Get file status flags and file access modes.
F_SETFL* {.importc, header: "".}: cint
## Set file status flags.
F_GETLK* {.importc, header: "".}: cint
## Get record locking information.
F_SETLK* {.importc, header: "".}: cint
## Set record locking information.
F_SETLKW* {.importc, header: "".}: cint
## Set record locking information; wait if blocked.
F_GETOWN* {.importc, header: "".}: cint
## Get process or process group ID to receive SIGURG signals.
F_SETOWN* {.importc, header: "".}: cint
## Set process or process group ID to receive SIGURG signals.
FD_CLOEXEC* {.importc, header: "".}: cint
## Close the file descriptor upon execution of an exec family function.
F_RDLCK* {.importc, header: "".}: cint
## Shared or read lock.
F_UNLCK* {.importc, header: "".}: cint
## Unlock.
F_WRLCK* {.importc, header: "".}: cint
## Exclusive or write lock.
O_CREAT* {.importc, header: "".}: cint
## Create file if it does not exist.
O_EXCL* {.importc, header: "".}: cint
## Exclusive use flag.
O_NOCTTY* {.importc, header: "".}: cint
## Do not assign controlling terminal.
O_TRUNC* {.importc, header: "".}: cint
## Truncate flag.
O_APPEND* {.importc, header: "".}: cint
## Set append mode.
O_DSYNC* {.importc, header: "".}: cint
## Write according to synchronized I/O data integrity completion.
O_NONBLOCK* {.importc, header: "".}: cint
## Non-blocking mode.
O_RSYNC* {.importc, header: "".}: cint
## Synchronized read I/O operations.
O_SYNC* {.importc, header: "".}: cint
## Write according to synchronized I/O file integrity completion.
O_ACCMODE* {.importc, header: "".}: cint
## Mask for file access modes.
O_RDONLY* {.importc, header: "".}: cint
## Open for reading only.
O_RDWR* {.importc, header: "".}: cint
## Open for reading and writing.
O_WRONLY* {.importc, header: "".}: cint
## Open for writing only.
POSIX_FADV_NORMAL* {.importc, header: "".}: cint
## The application has no advice to give on its behavior with
## respect to the specified data. It is the default characteristic
## if no advice is given for an open file.
POSIX_FADV_SEQUENTIAL* {.importc, header: "".}: cint
## The application expects to access the specified data
# sequentially from lower offsets to higher offsets.
POSIX_FADV_RANDOM* {.importc, header: "".}: cint
## The application expects to access the specified data in a random order.
POSIX_FADV_WILLNEED* {.importc, header: "".}: cint
## The application expects to access the specified data in the near future.
POSIX_FADV_DONTNEED* {.importc, header: "".}: cint
## The application expects that it will not access the specified data
## in the near future.
POSIX_FADV_NOREUSE* {.importc, header: "".}: cint
## The application expects to access the specified data once and
## then not reuse it thereafter.
FE_DIVBYZERO* {.importc, header: "".}: cint
FE_INEXACT* {.importc, header: "".}: cint
FE_INVALID* {.importc, header: "".}: cint
FE_OVERFLOW* {.importc, header: "".}: cint
FE_UNDERFLOW* {.importc, header: "".}: cint
FE_ALL_EXCEPT* {.importc, header: "".}: cint
FE_DOWNWARD* {.importc, header: "".}: cint
FE_TONEAREST* {.importc, header: "".}: cint
FE_TOWARDZERO* {.importc, header: "".}: cint
FE_UPWARD* {.importc, header: "".}: cint
FE_DFL_ENV* {.importc, header: "".}: cint
MM_HARD* {.importc, header: "".}: cint
## Source of the condition is hardware.
MM_SOFT* {.importc, header: "".}: cint
## Source of the condition is software.
MM_FIRM* {.importc, header: "".}: cint
## Source of the condition is firmware.
MM_APPL* {.importc, header: "".}: cint
## Condition detected by application.
MM_UTIL* {.importc, header: "".}: cint
## Condition detected by utility.
MM_OPSYS* {.importc, header: "".}: cint
## Condition detected by operating system.
MM_RECOVER* {.importc, header: "".}: cint
## Recoverable error.
MM_NRECOV* {.importc, header: "".}: cint
## Non-recoverable error.
MM_HALT* {.importc, header: "".}: cint
## Error causing application to halt.
MM_ERROR* {.importc, header: "".}: cint
## Application has encountered a non-fatal fault.
MM_WARNING* {.importc, header: "".}: cint
## Application has detected unusual non-error condition.
MM_INFO* {.importc, header: "".}: cint
## Informative message.
MM_NOSEV* {.importc, header: "".}: cint
## No severity level provided for the message.
MM_PRINT* {.importc, header: "".}: cint
## Display message on standard error.
MM_CONSOLE* {.importc, header: "".}: cint
## Display message on system console.
MM_OK* {.importc, header: "".}: cint
## The function succeeded.
MM_NOTOK* {.importc, header: "