#
#
# Nim's Runtime Library
# (c) Copyright 2012 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 Nim strings and
## return codes indicate errors. If you want exceptions
## and a proper Nim-like interface, use the OS module or write a wrapper.
##
## For high-level wrappers specialized for Linux and BSDs see:
## `posix_utils `_
##
## 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' suffix to be
## consistent with Nim conventions. If an identifier is a Nim keyword
## the \`identifier\` notation is used.
##
## This library relies on the header files of your C compiler. The
## resulting C code will just `#include ` and *not* define the
## symbols declared here.
# Dead code elimination ensures that we don't accidentally generate #includes
# for files that might not exist on a specific platform! The user will get an
# error only if they actually try to use the missing declaration
when defined(nimHasStyleChecks):
{.push styleChecks: off.}
when defined(nimPreviewSlimSystem):
import std/syncio
# TODO these constants don't seem to be fetched from a header file for unknown
# platforms - where do they come from and why are they here?
when false:
const
C_IRUSR = 0o000400 ## Read by owner.
C_IWUSR = 0o000200 ## Write by owner.
C_IXUSR = 0o000100 ## Execute by owner.
C_IRGRP = 0o000040 ## Read by group.
C_IWGRP = 0o000020 ## Write by group.
C_IXGRP = 0o000010 ## Execute by group.
C_IROTH = 0o000004 ## Read by others.
C_IWOTH = 0o000002 ## Write by others.
C_IXOTH = 0o000001 ## Execute by others.
C_ISUID = 0o004000 ## Set user ID.
C_ISGID = 0o002000 ## Set group ID.
C_ISVTX = 0o001000 ## On directories, restricted deletion flag.
C_ISDIR = 0o040000 ## Directory.
C_ISFIFO = 0o010000 ##FIFO.
C_ISREG = 0o100000 ## Regular file.
C_ISBLK = 0o060000 ## Block special.
C_ISCHR = 0o020000 ## Character special.
C_ISCTG = 0o110000 ## Reserved.
C_ISLNK = 0o120000 ## Symbolic link.
C_ISSOCK = 0o140000 ## Socket.
const
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;
DT_UNKNOWN* = 0 ## Unknown file type.
DT_FIFO* = 1 ## Named pipe, or FIFO.
DT_CHR* = 2 ## Character device.
DT_DIR* = 4 ## Directory.
DT_BLK* = 6 ## Block device.
DT_REG* = 8 ## Regular file.
DT_LNK* = 10 ## Symbolic link.
DT_SOCK* = 12 ## UNIX domain socket.
DT_WHT* = 14
# Special types
type Sighandler = proc (a: cint) {.noconv.}
const StatHasNanoseconds* = defined(linux) or defined(freebsd) or
defined(osx) or defined(openbsd) or defined(dragonfly) or defined(haiku) ## \
## Boolean flag that indicates if the system supports nanosecond time
## resolution in the fields of `Stat`. Note that the nanosecond based fields
## (`Stat.st_atim`, `Stat.st_mtim` and `Stat.st_ctim`) can be accessed
## without checking this flag, because this module defines fallback procs
## when they are not available.
# Platform specific stuff
when (defined(linux) and not defined(android)) and defined(amd64):
include posix_linux_amd64
elif defined(openbsd) and defined(amd64):
include posix_openbsd_amd64
elif (defined(macos) or defined(macosx) or defined(bsd)) and defined(cpu64):
include posix_macos_amd64
elif defined(nintendoswitch):
include posix_nintendoswitch
elif defined(haiku):
include posix_haiku
else:
include posix_other
# There used to be this name in posix.nim a long time ago, not sure why!
when StatHasNanoseconds:
proc st_atime*(s: Stat): Time {.inline.} =
## Second-granularity time of last access.
result = s.st_atim.tv_sec
proc st_mtime*(s: Stat): Time {.inline.} =
## Second-granularity time of last data modification.
result = s.st_mtim.tv_sec
proc st_ctime*(s: Stat): Time {.inline.} =
## Second-granularity time of last status change.
result = s.st_ctim.tv_sec
else:
proc st_atim*(s: Stat): Timespec {.inline.} =
## Nanosecond-granularity time of last access.
result.tv_sec = s.st_atime
proc st_mtim*(s: Stat): Timespec {.inline.} =
## Nanosecond-granularity time of last data modification.
result.tv_sec = s.st_mtime
proc st_ctim*(s: Stat): Timespec {.inline.} =
## Nanosecond-granularity time of last data modification.
result.tv_sec = s.st_ctime
when hasAioH:
proc aio_cancel*(a1: cint, a2: ptr Taiocb): cint {.importc, header: "".}
proc aio_error*(a1: ptr Taiocb): cint {.importc, header: "".}
proc aio_fsync*(a1: cint, a2: ptr Taiocb): cint {.importc, header: "".}
proc aio_read*(a1: ptr Taiocb): cint {.importc, header: "".}
proc aio_return*(a1: ptr Taiocb): int {.importc, header: "".}
proc aio_suspend*(a1: ptr ptr Taiocb, a2: cint, a3: ptr Timespec): cint {.
importc, header: "".}
proc aio_write*(a1: ptr Taiocb): cint {.importc, header: "".}
proc lio_listio*(a1: cint, a2: ptr ptr Taiocb, a3: cint,
a4: ptr SigEvent): cint {.importc, header: "".}
# arpa/inet.h
proc htonl*(a1: uint32): uint32 {.importc, header: "".}
proc htons*(a1: uint16): uint16 {.importc, header: "".}
proc ntohl*(a1: uint32): uint32 {.importc, header: "".}
proc ntohs*(a1: uint16): uint16 {.importc, header: "".}
when not defined(zephyr):
proc inet_addr*(a1: cstring): InAddrT {.importc, header: "".}
proc inet_ntoa*(a1: InAddr): cstring {.importc, header: "".}
proc inet_ntop*(a1: cint, a2: pointer | ptr InAddr | ptr In6Addr, a3: cstring, a4: int32): cstring {.
importc:"(char *)$1", header: "".}
proc inet_pton*(a1: cint, a2: cstring, a3: pointer | ptr InAddr | ptr In6Addr): cint {.
importc, header: "".}
var
in6addr_any* {.importc, header: "".}: In6Addr
in6addr_loopback* {.importc, header: "".}: In6Addr
proc IN6ADDR_ANY_INIT* (): In6Addr {.importc, header: "".}
proc IN6ADDR_LOOPBACK_INIT* (): In6Addr {.importc, header: "".}
# dirent.h
proc closedir*(a1: ptr DIR): cint {.importc, header: "".}
proc opendir*(a1: cstring): ptr DIR {.importc, header: "", sideEffect.}
proc readdir*(a1: ptr DIR): ptr Dirent {.importc, header: "", sideEffect.}
proc readdir_r*(a1: ptr DIR, a2: ptr Dirent, a3: ptr ptr Dirent): cint {.
importc, header: "", sideEffect.}
proc rewinddir*(a1: ptr DIR) {.importc, header: "".}
proc seekdir*(a1: ptr DIR, a2: int) {.importc, header: "".}
proc telldir*(a1: ptr DIR): int {.importc, header: "".}
# dlfcn.h
proc dlclose*(a1: pointer): cint {.importc, header: "", sideEffect.}
proc dlerror*(): cstring {.importc, header: "", sideEffect.}
proc dlopen*(a1: cstring, a2: cint): pointer {.importc, header: "", sideEffect.}
proc dlsym*(a1: pointer, a2: cstring): pointer {.importc, header: "", sideEffect.}
proc creat*(a1: cstring, a2: Mode): cint {.importc, header: "", sideEffect.}
proc fcntl*(a1: cint | SocketHandle, a2: cint): cint {.varargs, importc, header: "", sideEffect.}
proc openImpl(a1: cstring, a2: cint): cint {.varargs, importc: "open", header: "", sideEffect.}
proc open*(a1: cstring, a2: cint, mode: Mode | cint = 0.Mode): cint {.inline.} =
# prevents bug #17888
openImpl(a1, a2, mode)
proc posix_fadvise*(a1: cint, a2, a3: Off, a4: cint): cint {.
importc, header: "".}
proc posix_fallocate*(a1: cint, a2, a3: Off): cint {.
importc, header: "".}
when not defined(haiku) and not defined(openbsd):
proc fmtmsg*(a1: int, a2: cstring, a3: cint,
a4, a5, a6: cstring): cint {.importc, header: "".}
proc fnmatch*(a1, a2: cstring, a3: cint): cint {.importc, header: "".}
proc ftw*(a1: cstring,
a2: proc (x1: cstring, x2: ptr Stat, x3: cint): cint {.noconv.},
a3: cint): cint {.importc, header: "".}
when not (defined(linux) and defined(amd64)) and not defined(nintendoswitch):
proc nftw*(a1: cstring,
a2: proc (x1: cstring, x2: ptr Stat,
x3: cint, x4: ptr FTW): cint {.noconv.},
a3: cint,
a4: cint): cint {.importc, header: "".}
proc glob*(a1: cstring, a2: cint,
a3: proc (x1: cstring, x2: cint): cint {.noconv.},
a4: ptr Glob): cint {.importc, header: "", sideEffect.}
## Filename globbing. Use `os.walkPattern() `_ and similar.
proc globfree*(a1: ptr Glob) {.importc, header: "".}
proc getgrgid*(a1: Gid): ptr Group {.importc, header: "".}
proc getgrnam*(a1: cstring): ptr Group {.importc, header: "".}
proc getgrgid_r*(a1: Gid, a2: ptr Group, a3: cstring, a4: int,
a5: ptr ptr Group): cint {.importc, header: "".}
proc getgrnam_r*(a1: cstring, a2: ptr Group, a3: cstring,
a4: int, a5: ptr ptr Group): cint {.
importc, header: "".}
proc getgrent*(): ptr Group {.importc, header: "".}
proc endgrent*() {.importc, header: "".}
proc setgrent*() {.importc, header: "".}
proc iconv_open*(a1, a2: cstring): Iconv {.importc, header: "".}
proc iconv*(a1: Iconv, a2: var cstring, a3: var int, a4: var cstring,
a5: var int): int {.importc, header: "".}
proc iconv_close*(a1: Iconv): cint {.importc, header: "".}
proc nl_langinfo*(a1: Nl_item): cstring {.importc, header: "".}
proc basename*(a1: cstring): cstring {.importc, header: "".}
proc dirname*(a1: cstring): cstring {.importc, header: "".}
proc localeconv*(): ptr Lconv {.importc, header: "".}
proc setlocale*(a1: cint, a2: cstring): cstring {.
importc, header: "", sideEffect.}
proc strfmon*(a1: cstring, a2: int, a3: cstring): int {.varargs,
importc, header: "".}
when not defined(nintendoswitch):
proc mq_close*(a1: Mqd): cint {.importc, header: "".}
proc mq_getattr*(a1: Mqd, a2: ptr MqAttr): cint {.
importc, header: "".}
proc mq_notify*(a1: Mqd, a2: ptr SigEvent): cint {.
importc, header: "".}
proc mq_open*(a1: cstring, a2: cint): Mqd {.
varargs, importc, header: "".}
proc mq_receive*(a1: Mqd, a2: cstring, a3: int, a4: var int): int {.
importc, header: "".}
proc mq_send*(a1: Mqd, a2: cstring, a3: int, a4: int): cint {.
importc, header: "".}
proc mq_setattr*(a1: Mqd, a2, a3: ptr MqAttr): cint {.
importc, header: "".}
proc mq_timedreceive*(a1: Mqd, a2: cstring, a3: int, a4: int,
a5: ptr Timespec): int {.importc, header: "".}
proc mq_timedsend*(a1: Mqd, a2: cstring, a3: int, a4: int,
a5: ptr Timespec): cint {.importc, header: "".}
proc mq_unlink*(a1: cstring): cint {.importc, header: "".}
proc getpwnam*(a1: cstring): ptr Passwd {.importc, header: "".}
proc getpwuid*(a1: Uid): ptr Passwd {.importc, header: "".}
proc getpwnam_r*(a1: cstring, a2: ptr Passwd, a3: cstring, a4: int,
a5: ptr ptr Passwd): cint {.importc, header: "".}
proc getpwuid_r*(a1: Uid, a2: ptr Passwd, a3: cstring,
a4: int, a5: ptr ptr Passwd): cint {.importc, header: "".}
proc endpwent*() {.importc, header: "".}
proc getpwent*(): ptr Passwd {.importc, header: "".}
proc setpwent*() {.importc, header: "".}
proc uname*(a1: var Utsname): cint {.importc, header: "".}
proc strerror*(errnum: cint): cstring {.importc, header: "".}
proc pthread_atfork*(a1, a2, a3: proc () {.noconv.}): cint {.
importc, header: "".}
proc pthread_attr_destroy*(a1: ptr Pthread_attr): cint {.
importc, header: "".}
proc pthread_attr_getdetachstate*(a1: ptr Pthread_attr, a2: cint): cint {.
importc, header: "".}
proc pthread_attr_getguardsize*(a1: ptr Pthread_attr, a2: var cint): cint {.
importc, header: "".}
proc pthread_attr_getinheritsched*(a1: ptr Pthread_attr,
a2: var cint): cint {.importc, header: "".}
proc pthread_attr_getschedparam*(a1: ptr Pthread_attr,
a2: ptr Sched_param): cint {.importc, header: "".}
proc pthread_attr_getschedpolicy*(a1: ptr Pthread_attr,
a2: var cint): cint {.importc, header: "".}
proc pthread_attr_getscope*(a1: ptr Pthread_attr,
a2: var cint): cint {.importc, header: "".}
proc pthread_attr_getstack*(a1: ptr Pthread_attr,
a2: var pointer, a3: var int): cint {.importc, header: "".}
proc pthread_attr_getstackaddr*(a1: ptr Pthread_attr,
a2: var pointer): cint {.importc, header: "".}
proc pthread_attr_getstacksize*(a1: ptr Pthread_attr,
a2: var int): cint {.importc, header: "".}
proc pthread_attr_init*(a1: ptr Pthread_attr): cint {.
importc, header: "".}
proc pthread_attr_setdetachstate*(a1: ptr Pthread_attr, a2: cint): cint {.
importc, header: "".}
proc pthread_attr_setguardsize*(a1: ptr Pthread_attr, a2: int): cint {.
importc, header: "".}
proc pthread_attr_setinheritsched*(a1: ptr Pthread_attr, a2: cint): cint {.
importc, header: "".}
proc pthread_attr_setschedparam*(a1: ptr Pthread_attr,
a2: ptr Sched_param): cint {.importc, header: "".}
proc pthread_attr_setschedpolicy*(a1: ptr Pthread_attr, a2: cint): cint {.
importc, header: "".}
proc pthread_attr_setscope*(a1: ptr Pthread_attr, a2: cint): cint {.importc,
header: "".}
proc pthread_attr_setstack*(a1: ptr Pthread_attr, a2: pointer, a3: int): cint {.
importc, header: "".}
proc pthread_attr_setstackaddr*(a1: ptr Pthread_attr, a2: pointer): cint {.
importc, header: "".}
proc pthread_attr_setstacksize*(a1: ptr Pthread_attr, a2: int): cint {.
importc, header: "".}
proc pthread_barrier_destroy*(a1: ptr Pthread_barrier): cint {.
importc, header: "".}
proc pthread_barrier_init*(a1: ptr Pthread_barrier,
a2: ptr Pthread_barrierattr, a3: cint): cint {.
importc, header: "".}
proc pthread_barrier_wait*(a1: ptr Pthread_barrier): cint {.
importc, header: "".}
proc pthread_barrierattr_destroy*(a1: ptr Pthread_barrierattr): cint {.
importc, header: "".}
proc pthread_barrierattr_getpshared*(
a1: ptr Pthread_barrierattr, a2: var cint): cint {.
importc, header: "".}
proc pthread_barrierattr_init*(a1: ptr Pthread_barrierattr): cint {.
importc, header: "".}
proc pthread_barrierattr_setpshared*(a1: ptr Pthread_barrierattr,
a2: cint): cint {.importc, header: "".}
proc pthread_cancel*(a1: Pthread): cint {.importc, header: "".}
proc pthread_cleanup_push*(a1: proc (x: pointer) {.noconv.}, a2: pointer) {.
importc, header: "".}
proc pthread_cleanup_pop*(a1: cint) {.importc, header: "".}
proc pthread_cond_broadcast*(a1: ptr Pthread_cond): cint {.
importc, header: "".}
proc pthread_cond_destroy*(a1: ptr Pthread_cond): cint {.importc, header: "".}
proc pthread_cond_init*(a1: ptr Pthread_cond,
a2: ptr Pthread_condattr): cint {.importc, header: "".}
proc pthread_cond_signal*(a1: ptr Pthread_cond): cint {.importc, header: "".}
proc pthread_cond_timedwait*(a1: ptr Pthread_cond,
a2: ptr Pthread_mutex, a3: ptr Timespec): cint {.importc, header: "".}
proc pthread_cond_wait*(a1: ptr Pthread_cond,
a2: ptr Pthread_mutex): cint {.importc, header: "".}
proc pthread_condattr_destroy*(a1: ptr Pthread_condattr): cint {.importc, header: "".}
proc pthread_condattr_getclock*(a1: ptr Pthread_condattr,
a2: var ClockId): cint {.importc, header: "".}
proc pthread_condattr_getpshared*(a1: ptr Pthread_condattr,
a2: var cint): cint {.importc, header: "".}
proc pthread_condattr_init*(a1: ptr Pthread_condattr): cint {.importc, header: "".}
proc pthread_condattr_setclock*(a1: ptr Pthread_condattr,a2: ClockId): cint {.importc, header: "".}
proc pthread_condattr_setpshared*(a1: ptr Pthread_condattr, a2: cint): cint {.importc, header: "".}
proc pthread_create*(a1: ptr Pthread, a2: ptr Pthread_attr,
a3: proc (x: pointer): pointer {.noconv.}, a4: pointer): cint {.importc, header: "".}
proc pthread_detach*(a1: Pthread): cint {.importc, header: "".}
proc pthread_equal*(a1, a2: Pthread): cint {.importc, header: "".}
proc pthread_exit*(a1: pointer) {.importc, header: "".}
proc pthread_getconcurrency*(): cint {.importc, header: "".}
proc pthread_getcpuclockid*(a1: Pthread, a2: var ClockId): cint {.importc, header: "".}
proc pthread_getschedparam*(a1: Pthread, a2: var cint,
a3: ptr Sched_param): cint {.importc, header: "".}
proc pthread_getspecific*(a1: Pthread_key): pointer {.importc, header: "".}
proc pthread_join*(a1: Pthread, a2: ptr pointer): cint {.importc, header: "".}
proc pthread_key_create*(a1: ptr Pthread_key, a2: proc (x: pointer) {.noconv.}): cint {.importc, header: "".}
proc pthread_key_delete*(a1: Pthread_key): cint {.importc, header: "".}
proc pthread_mutex_destroy*(a1: ptr Pthread_mutex): cint {.importc, header: "".}
proc pthread_mutex_getprioceiling*(a1: ptr Pthread_mutex,
a2: var cint): cint {.importc, header: "".}
proc pthread_mutex_init*(a1: ptr Pthread_mutex,
a2: ptr Pthread_mutexattr): cint {.importc, header: "".}
proc pthread_mutex_lock*(a1: ptr Pthread_mutex): cint {.importc, header: "".}
proc pthread_mutex_setprioceiling*(a1: ptr Pthread_mutex,a2: cint,
a3: var cint): cint {.importc, header: "".}
proc pthread_mutex_timedlock*(a1: ptr Pthread_mutex,
a2: ptr Timespec): cint {.importc, header: "".}
proc pthread_mutex_trylock*(a1: ptr Pthread_mutex): cint {.importc, header: "".}
proc pthread_mutex_unlock*(a1: ptr Pthread_mutex): cint {.importc, header: "".}
proc pthread_mutexattr_destroy*(a1: ptr Pthread_mutexattr): cint {.importc, header: "".}
proc pthread_mutexattr_getprioceiling*(
a1: ptr Pthread_mutexattr, a2: var cint): cint {.importc, header: "".}
proc pthread_mutexattr_getprotocol*(a1: ptr Pthread_mutexattr,
a2: var cint): cint {.importc, header: "".}
proc pthread_mutexattr_getpshared*(a1: ptr Pthread_mutexattr,
a2: var cint): cint {.importc, header: "".}
proc pthread_mutexattr_gettype*(a1: ptr Pthread_mutexattr,
a2: var cint): cint {.importc, header: "".}
proc pthread_mutexattr_init*(a1: ptr Pthread_mutexattr): cint {.importc, header: "".}
proc pthread_mutexattr_setprioceiling*(a1: ptr Pthread_mutexattr, a2: cint): cint {.importc, header: "".}
proc pthread_mutexattr_setprotocol*(a1: ptr Pthread_mutexattr, a2: cint): cint {.importc, header: "".}
proc pthread_mutexattr_setpshared*(a1: ptr Pthread_mutexattr, a2: cint): cint {.importc, header: "".}
proc pthread_mutexattr_settype*(a1: ptr Pthread_mutexattr, a2: cint): cint {.importc, header: "".}
proc pthread_once*(a1: ptr Pthread_once, a2: proc () {.noconv.}): cint {.importc, header: "".}
proc pthread_rwlock_destroy*(a1: ptr Pthread_rwlock): cint {.importc, header: "".}
proc pthread_rwlock_init*(a1: ptr Pthread_rwlock,
a2: ptr Pthread_rwlockattr): cint {.importc, header: "".}
proc pthread_rwlock_rdlock*(a1: ptr Pthread_rwlock): cint {.importc, header: "".}
proc pthread_rwlock_timedrdlock*(a1: ptr Pthread_rwlock,
a2: ptr Timespec): cint {.importc, header: "".}
proc pthread_rwlock_timedwrlock*(a1: ptr Pthread_rwlock,
a2: ptr Timespec): cint {.importc, header: "".}
proc pthread_rwlock_tryrdlock*(a1: ptr Pthread_rwlock): cint {.importc, header: "".}
proc pthread_rwlock_trywrlock*(a1: ptr Pthread_rwlock): cint {.importc, header: "".}
proc pthread_rwlock_unlock*(a1: ptr Pthread_rwlock): cint {.importc, header: "".}
proc pthread_rwlock_wrlock*(a1: ptr Pthread_rwlock): cint {.importc, header: "".}
proc pthread_rwlockattr_destroy*(a1: ptr Pthread_rwlockattr): cint {.importc, header: "".}
proc pthread_rwlockattr_getpshared*(
a1: ptr Pthread_rwlockattr, a2: var cint): cint {.importc, header: "".}
proc pthread_rwlockattr_init*(a1: ptr Pthread_rwlockattr): cint {.importc, header: "".}
proc pthread_rwlockattr_setpshared*(a1: ptr Pthread_rwlockattr, a2: cint): cint {.importc, header: "".}
proc pthread_self*(): Pthread {.importc, header: "".}
proc pthread_setcancelstate*(a1: cint, a2: var cint): cint {.importc, header: "".}
proc pthread_setcanceltype*(a1: cint, a2: var cint): cint {.importc, header: "".}
proc pthread_setconcurrency*(a1: cint): cint {.importc, header: "".}
proc pthread_setschedparam*(a1: Pthread, a2: cint,
a3: ptr Sched_param): cint {.importc, header: "".}
proc pthread_setschedprio*(a1: Pthread, a2: cint): cint {.
importc, header: "".}
proc pthread_setspecific*(a1: Pthread_key, a2: pointer): cint {.
importc, header: "".}
proc pthread_spin_destroy*(a1: ptr Pthread_spinlock): cint {.
importc, header: "".}
proc pthread_spin_init*(a1: ptr Pthread_spinlock, a2: cint): cint {.
importc, header: "".}
proc pthread_spin_lock*(a1: ptr Pthread_spinlock): cint {.
importc, header: "".}
proc pthread_spin_trylock*(a1: ptr Pthread_spinlock): cint{.
importc, header: "".}
proc pthread_spin_unlock*(a1: ptr Pthread_spinlock): cint {.
importc, header: "".}
proc pthread_testcancel*() {.importc, header: "".}
proc exitnow*(code: int) {.importc: "_exit", header: "".}
proc access*(a1: cstring, a2: cint): cint {.importc, header: "".}
proc alarm*(a1: cint): cint {.importc, header: "".}
proc chdir*(a1: cstring): cint {.importc, header: "".}
proc chown*(a1: cstring, a2: Uid, a3: Gid): cint {.importc, header: "".}
proc close*(a1: cint | SocketHandle): cint {.importc, header: "".}
proc confstr*(a1: cint, a2: cstring, a3: int): int {.importc, header: "".}
proc crypt*(a1, a2: cstring): cstring {.importc, header: "".}
proc ctermid*(a1: cstring): cstring {.importc, header: "".}
proc dup*(a1: cint): cint {.importc, header: "".}
proc dup2*(a1, a2: cint): cint {.importc, header: "".}
proc encrypt*(a1: array[0..63, char], a2: cint) {.importc, header: "".}
proc execl*(a1, a2: cstring): cint {.varargs, importc, header: "", sideEffect.}
proc execle*(a1, a2: cstring): cint {.varargs, importc, header: "", sideEffect.}
proc execlp*(a1, a2: cstring): cint {.varargs, importc, header: "", sideEffect.}
proc execv*(a1: cstring, a2: cstringArray): cint {.importc, header: "", sideEffect.}
proc execve*(a1: cstring, a2, a3: cstringArray): cint {.
importc, header: "", sideEffect.}
proc execvp*(a1: cstring, a2: cstringArray): cint {.importc, header: "", sideEffect.}
proc execvpe*(a1: cstring, a2: cstringArray, a3: cstringArray): cint {.importc, header: "", sideEffect.}
proc fchown*(a1: cint, a2: Uid, a3: Gid): cint {.importc, header: "", sideEffect.}
proc fchdir*(a1: cint): cint {.importc, header: "", sideEffect.}
proc fdatasync*(a1: cint): cint {.importc, header: "".}
proc fork*(): Pid {.importc, header: "", sideEffect.}
proc fpathconf*(a1, a2: cint): int {.importc, header: "".}
proc fsync*(a1: cint): cint {.importc, header: "".}
## synchronize a file's buffer cache to the storage device
proc ftruncate*(a1: cint, a2: Off): cint {.importc, header: "".}
proc getcwd*(a1: cstring, a2: int): cstring {.importc, header: "", sideEffect.}
proc getuid*(): Uid {.importc, header: "", sideEffect.}
## returns the real user ID of the calling process
proc geteuid*(): Uid {.importc, header: "", sideEffect.}
## returns the effective user ID of the calling process
proc getgid*(): Gid {.importc, header: "", sideEffect.}
## returns the real group ID of the calling process
proc getegid*(): Gid {.importc, header: "", sideEffect.}
## returns the effective group ID of the calling process
proc getgroups*(a1: cint, a2: ptr array[0..255, Gid]): cint {.
importc, header: "".}
proc gethostid*(): int {.importc, header: "", sideEffect.}
proc gethostname*(a1: cstring, a2: int): cint {.importc, header: "", sideEffect.}
proc getlogin*(): cstring {.importc, header: "", sideEffect.}
proc getlogin_r*(a1: cstring, a2: int): cint {.importc, header: "", sideEffect.}
proc getopt*(a1: cint, a2: cstringArray, a3: cstring): cint {.
importc, header: "".}
proc getpgid*(a1: Pid): Pid {.importc, header: "".}
proc getpgrp*(): Pid {.importc, header: "".}
proc getpid*(): Pid {.importc, header: "", sideEffect.}
## returns the process ID (PID) of the calling process
proc getppid*(): Pid {.importc, header: "", sideEffect.}
## returns the process ID of the parent of the calling process
proc getsid*(a1: Pid): Pid {.importc, header: "", sideEffect.}
## returns the session ID of the calling process
proc getwd*(a1: cstring): cstring {.importc, header: "".}
proc isatty*(a1: cint): cint {.importc, header: "".}
proc lchown*(a1: cstring, a2: Uid, a3: Gid): cint {.importc, header: "".}
proc link*(a1, a2: cstring): cint {.importc, header: "".}
proc lockf*(a1, a2: cint, a3: Off): cint {.importc, header: "".}
proc lseek*(a1: cint, a2: Off, a3: cint): Off {.importc, header: "".}
proc nice*(a1: cint): cint {.importc, header: "".}
proc pathconf*(a1: cstring, a2: cint): int {.importc, header: "".}
proc pause*(): cint {.importc, header: "".}
proc pclose*(a: File): cint {.importc, header: "".}
proc pipe*(a: array[0..1, cint]): cint {.importc, header: "".}
proc popen*(a1, a2: cstring): File {.importc, header: "".}
proc pread*(a1: cint, a2: pointer, a3: int, a4: Off): int {.
importc, header: "".}
proc pwrite*(a1: cint, a2: pointer, a3: int, a4: Off): int {.
importc, header: "".}
proc read*(a1: cint, a2: pointer, a3: int): int {.importc, header: "".}
proc readlink*(a1, a2: cstring, a3: int): int {.importc, header: "".}
proc ioctl*(f: FileHandle, device: uint): int {.importc: "ioctl",
header: "", varargs, tags: [WriteIOEffect].}
## A system call for device-specific input/output operations and other
## operations which cannot be expressed by regular system calls
proc rmdir*(a1: cstring): cint {.importc, header: "".}
proc setegid*(a1: Gid): cint {.importc, header: "".}
proc seteuid*(a1: Uid): cint {.importc, header: "".}
proc setgid*(a1: Gid): cint {.importc, header: "".}
proc setpgid*(a1, a2: Pid): cint {.importc, header: "".}
proc setpgrp*(): Pid {.importc, header: "".}
proc setregid*(a1, a2: Gid): cint {.importc, header: "".}
proc setreuid*(a1, a2: Uid): cint {.importc, header: "".}
proc setsid*(): Pid {.importc, header: "".}
proc setuid*(a1: Uid): cint {.importc, header: "".}
proc sleep*(a1: cint): cint {.importc, header: "".}
proc swab*(a1, a2: pointer, a3: int) {.importc, header: "".}
proc symlink*(a1, a2: cstring): cint {.importc, header: "".}
proc sync*() {.importc, header: "".}
proc sysconf*(a1: cint): int {.importc, header: "".}
proc tcgetpgrp*(a1: cint): Pid {.importc, header: "".}
proc tcsetpgrp*(a1: cint, a2: Pid): cint {.importc, header: "".}
proc truncate*(a1: cstring, a2: Off): cint {.importc, header: "