honeybadger

cosmopolitan libc

your build-once run-anywhere c library

Can I Use a System Call?

Cosmopolitan Libc wraps system calls to provide high-level access to binary kernel interfaces. Linux is the gold standard for our suppport. However, if your program works on Linux, then it might not work on other platforms depending on which functions you use. The following table should help illuminate the portability of functions.

Function Linux FreeBSD OpenBSD NetBSD MacOS Windows Metal
read best best best best best ok good
write best best best best best ok good
pread best best best best best ok zipos
pwrite best best best best best ok zipos
readv best best best best best ok best
writev best best best best best ok best
preadv 2009+ v2.1+ v2.1+ v2.1+ v2.1+ v2.1+ v2.1+
pwritev 2009+ v2.1+ v2.1+ v2.1+ v2.1+ v2.1+ v2.1+
close best best best best best slow best
fstatat best best best best best smudged best
fstat best best best best best spotty best
statfs best best best best best best fault
fstatfs best best best best best best fault
_Exit best best best best best best reset
_Exit1 best best rc=0 rc=0 rc=0 best reset
fork best best slow best best slow fault
vfork best best fork best fork fork fault
clone best thread thread thread thread thread enosys
futexes best sched_yield good sched_yield select millis n/a
tls %fs %fs %fs %fs %gs %gs %fs
arch_prctl best best restricted best restricted forbidden best
fsgsbase finally works forbidden forbidden forbidden broken best
fopenat
O_RDONLY
best best best best best best zipos
fopenat
O_RDWR
best best best best best best todo
fopenat
O_TMPFILE
best einval einval einval einval einval einval
mmap
MAP_PRIVATE
best best best best best no cow best
mmap
MAP_SHARED
best best best best best best best
mmap
MAP_STACK
fast+safe fast+safe safe safe safe faked safe
mmap
MAP_POPULATE
best best ignored ignored ignored ignored ignored
mmap
MAP_CONCEAL
ignored best best best ignored ignored ignored
poll best best best best best polling best
select best best best best best polling fault
pselect best best best best best polling fault
ppoll best best best best non-atomic polling best
lseek best best best best best best best
pledge 2.6.23+ enosys best enosys enosys enosys fault
unveil 5.13+ enosys best enosys enosys enosys fault
msync best best best best best partial todo
mprotect best best best best best best todo
munmap best best best best best best best
sigaction
ucontext_t
best best best best best best enosys
sigprocmask best best best best best simulated no-op
sigsuspend best best best best best simulated no-op
sigpending best best best best best simulated no-op
clock_gettime
REALTIME
fastest good good good gettimeofday fastest enosys
clock_gettime
MONOTONIC
fastest good good good rdtsc rdtsc enosys
clock_getres kinda good good ok faked rdtsc enosys
ioctl
TCGETS
best best best best best ok wip
ioctl
TCSETS
best best best best best ok wip
ioctl
TIOCGWINSZ
best best best best best good wip
ioctl
FIOCLEX
best best best best best best wip
ioctl
FIONBIO
best best best best best best fault
ioctl
SIOCGIFCONF
best best best best best best fault
ioctl
SIOCGIFADDR
best best best best best best fault
ioctl
SIOCGIFNETMASK
best best best best best best fault
ioctl
SIOCGIFBRDADDR
best best best best best best fault
ioctl
SIOCGIFDSTADDR
best best best best best best fault
ioctl
SIOCGIFFLAGS
best best best best best best fault
openpty v2.0+ v2.1+ v2.1+ v2.1+ v2.1+ enosys enosys
ptsname v2.0+ v2.1+ hairy v2.1+ v2.1+ enosys enosys
flock good good good good good good fault
sync notest notest notest notest notest flush fault
fsync notest notest notest notest notest flush fault
fdatasync notest notest notest notest notest flush fault
sync_file_range notest fdatasync fdatasync fdatasync fdatasync fdatasync fault
copy_file_range 5.9+ 13+ enosys enosys enosys enosys fault
sendfile best best enosys enosys best best enosys
splice 5.9+ enosys enosys enosys enosys enosys fault
closefrom 5.9+ best best enosys enosys enosys enosys
close_range 5.9+ 13+ enosys enosys enosys enosys enosys
fadvise best best enosys best enosys most enosys
posix_fadvise best best enosys best enosys most enosys
truncate best best best best best best fault
ftruncate best best best best best best fault
faccessat best best best best best best fault
pipe best best best best best best fault
pipe2 2008+ best best best non-atomic best fault
socketpair best best best best best best fault
getcwd best best best best best best fault
chdir best best best best best hairy fault
fchdir best best best best best hairy fault
renameat best best best best best best fault
mkdirat best best best best best best fault
linkat best best best best best admin-only fault
unlinkat best best best best best hairy fault
readlinkat best best best best best best fault
sched_yield best best best best select best no-op
memfd_create best enosys enosys enosys enosys enosys fault
sys_mremap best enosys enosys good enosys enosys enosys
mincore best best enosys best best enosys fault
madvise best best best best best some fault
dup best best best best best best fault
dup2 best best best best best best fault
dup3 2008+ non-atomic best best non-atomic best fault
fcntl
F_DUPFD
best best best best best best fault
fcntl
F_DUPFD_CLOEXEC
2008+ best best best best best fault
fcntl
Advisory Locks
good good good good good best (v2.1) fault
fcntl
F_GETFL
best best best best best best fault
fcntl
F_SETFL
best best best best best einval fault
fcntl
F_GETFD
best best best best best best fault
fcntl
F_SETFD
best best best best best best fault
nanosleep best best best best micros millis enosys
setitimer best best best best best kludge fault
gettid best good good good good good fault
getpid best best best best best best fault
getppid best best best best best slow fault
getrandom 2014+ sysctl getentropy sysctl getentropy SysFun036 rdrand
umask best best best best best no-op fault
issetugid best best best best best best zero
setuid best best best best best no-op fault
setgid best best best best best no-op fault
setreuid best best best best best enosys fault
setregid best best best best best enosys fault
setresuid best best best faked faked enosys fault
setresgid best best best faked faked enosys fault
socket best best best best best best fault
bind best best best best best good fault
connect best best best best best good fault
accept best best best best best good fault
accept4 2009+ best best best non-atomic good fault
sendto best best best best best good fault
recvfrom best best best best best good fault
sendmsg good ok ok ok ok ok fault
recvmsg good ok ok ok ok ok fault
shutdown best best best best good best fault
getsockname best best best best best best fault
getpeername best best best best best best fault
getsockopt best narrow narrow narrow narrow narrow fault
setsockopt
SO_TYPE
best best best best best best fault
setsockopt
SO_DEBUG
best best best best best best fault
setsockopt
SO_ERROR
best best best best best best fault
setsockopt
SO_BROADCAST
best best best best best best fault
setsockopt
SO_REUSEADDR
best best best best best n/a fault
setsockopt
SO_REUSEPORT
superior best best best best best fault
setsockopt
SO_KEEPALIVE
best best best best best best fault
setsockopt
SO_ACCEPTCONN
best best best best best best fault
setsockopt
SO_DONTROUTE
best best best best best best fault
setsockopt
SO_SNDBUF
best best best best best best fault
setsockopt
SO_RCVBUF
best best best best best best fault
setsockopt
SO_SNDLOWAT
best best best best best best fault
setsockopt
SO_RCVLOWAT
best best best best best best fault
setsockopt
TCP_NODELAY
best best best best best best fault
setsockopt
TCP_CORK
best best best best best best fault
setsockopt
TCP_FASTOPEN
best best enopro enopro enopro best enosys
setsockopt
TCP_QUICKACK
best enopro enopro enopro enopro enopro fault
execve best best best best best kludge fault
wait4 best best best best best messy fault
kill best best best best best limited fault
tkill best ok ok ok ok ok fault
tgkill best enosys enosys enosys enosys enosys fault
uname best best best best best best enosys
fchmodat best best best best best enosys fault
fchownat best best best best best enosys fault
chroot works works works works works enosys fault
mount notest notest notest notest notest enosys fault
reboot notest notest notest notest notest notest fault
utimensat 2008+ 1e-9 1e-9 1e-9 1e-6 1e-7 fault
sched_setaffinity best none none broken none best fault
sched_getaffinity best none none broken none ugly fault
sched_setscheduler best good none good none none fault
sched_getscheduler best good none good none none fault
sched_setparam best good none good none none fault
sched_getparam best good none good none none fault
sched_get_priority_max best best none best none none fault
sched_get_priority_min best best none best none none fault
sched_rr_get_interval best best none none none none fault
epoll best enosys enosys enosys enosys wepoll fault
clock cgt cgt cgt cgt getrusage gpt fault
getrusage some best best best best some fault
setrlimit best ok ok ok ok RLIMIT_AS fault
opendir best best best best best best fault
gethostname best best best best best best fault
getlogin_r getenv sys sys sys sys sys enoent
login_tty best best best best best enosys enosys