aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/abis
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-07 17:28:00 -0500
committerIan Moffett <ian@osmora.org>2024-03-07 17:28:32 -0500
commitbd5969fc876a10b18613302db7087ef3c40f18e1 (patch)
tree7c2b8619afe902abf99570df2873fbdf40a4d1a1 /lib/mlibc/abis
parenta95b38b1b92b172e6cc4e8e56a88a30cc65907b0 (diff)
lib: Add mlibc
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/abis')
-rw-r--r--lib/mlibc/abis/aero/auxv.h9
-rw-r--r--lib/mlibc/abis/dripos/auxv.h8
-rw-r--r--lib/mlibc/abis/dripos/errno.h149
-rw-r--r--lib/mlibc/abis/hyra/auxv.h16
-rw-r--r--lib/mlibc/abis/ironclad/access.h9
-rw-r--r--lib/mlibc/abis/ironclad/auxv.h8
-rw-r--r--lib/mlibc/abis/ironclad/blkcnt_t.h7
-rw-r--r--lib/mlibc/abis/ironclad/blksize_t.h8
-rw-r--r--lib/mlibc/abis/ironclad/clockid_t.h7
-rw-r--r--lib/mlibc/abis/ironclad/dev_t.h6
-rw-r--r--lib/mlibc/abis/ironclad/epoll.h6
-rw-r--r--lib/mlibc/abis/ironclad/errno.h126
-rw-r--r--lib/mlibc/abis/ironclad/fcntl.h79
-rw-r--r--lib/mlibc/abis/ironclad/fsblkcnt_t.h8
-rw-r--r--lib/mlibc/abis/ironclad/fsfilcnt_t.h8
-rw-r--r--lib/mlibc/abis/ironclad/gid_t.h6
-rw-r--r--lib/mlibc/abis/ironclad/in.h168
-rw-r--r--lib/mlibc/abis/ironclad/ino_t.h7
-rw-r--r--lib/mlibc/abis/ironclad/inotify.h7
-rw-r--r--lib/mlibc/abis/ironclad/ioctls.h13
-rw-r--r--lib/mlibc/abis/ironclad/limits.h14
-rw-r--r--lib/mlibc/abis/ironclad/mode_t.h6
-rw-r--r--lib/mlibc/abis/ironclad/mqueue.h20
-rw-r--r--lib/mlibc/abis/ironclad/msg.h39
-rw-r--r--lib/mlibc/abis/ironclad/nlink_t.h6
-rw-r--r--lib/mlibc/abis/ironclad/packet.h6
-rw-r--r--lib/mlibc/abis/ironclad/pid_t.h6
-rw-r--r--lib/mlibc/abis/ironclad/poll.h16
-rw-r--r--lib/mlibc/abis/ironclad/ptrace.h56
-rw-r--r--lib/mlibc/abis/ironclad/reboot.h12
-rw-r--r--lib/mlibc/abis/ironclad/resource.h53
-rw-r--r--lib/mlibc/abis/ironclad/seek-whence.h8
-rw-r--r--lib/mlibc/abis/ironclad/shm.h21
-rw-r--r--lib/mlibc/abis/ironclad/signal.h192
-rw-r--r--lib/mlibc/abis/ironclad/socket.h165
-rw-r--r--lib/mlibc/abis/ironclad/socklen_t.h6
-rw-r--r--lib/mlibc/abis/ironclad/stat.h69
-rw-r--r--lib/mlibc/abis/ironclad/statfs.h28
-rw-r--r--lib/mlibc/abis/ironclad/statvfs.h30
-rw-r--r--lib/mlibc/abis/ironclad/suseconds_t.h8
-rw-r--r--lib/mlibc/abis/ironclad/termios.h116
-rw-r--r--lib/mlibc/abis/ironclad/time.h15
-rw-r--r--lib/mlibc/abis/ironclad/uid_t.h6
-rw-r--r--lib/mlibc/abis/ironclad/utsname.h12
-rw-r--r--lib/mlibc/abis/ironclad/vm-flags.h46
-rw-r--r--lib/mlibc/abis/ironclad/wait.h25
-rw-r--r--lib/mlibc/abis/ironclad/xattr.h21
-rw-r--r--lib/mlibc/abis/lemon/auxv.h9
-rw-r--r--lib/mlibc/abis/linux/access.h9
-rw-r--r--lib/mlibc/abis/linux/auxv.h13
-rw-r--r--lib/mlibc/abis/linux/blkcnt_t.h8
-rw-r--r--lib/mlibc/abis/linux/blksize_t.h8
-rw-r--r--lib/mlibc/abis/linux/clockid_t.h7
-rw-r--r--lib/mlibc/abis/linux/dev_t.h10
-rw-r--r--lib/mlibc/abis/linux/epoll.h6
-rw-r--r--lib/mlibc/abis/linux/errno.h143
-rw-r--r--lib/mlibc/abis/linux/fcntl.h89
-rw-r--r--lib/mlibc/abis/linux/fsblkcnt_t.h8
-rw-r--r--lib/mlibc/abis/linux/fsfilcnt_t.h8
-rw-r--r--lib/mlibc/abis/linux/gid_t.h8
-rw-r--r--lib/mlibc/abis/linux/in.h217
-rw-r--r--lib/mlibc/abis/linux/ino_t.h10
-rw-r--r--lib/mlibc/abis/linux/inotify.h9
-rw-r--r--lib/mlibc/abis/linux/ioctls.h15
-rw-r--r--lib/mlibc/abis/linux/limits.h9
-rw-r--r--lib/mlibc/abis/linux/mode_t.h8
-rw-r--r--lib/mlibc/abis/linux/mqueue.h21
-rw-r--r--lib/mlibc/abis/linux/msg.h39
-rw-r--r--lib/mlibc/abis/linux/nlink_t.h8
-rw-r--r--lib/mlibc/abis/linux/packet.h6
-rw-r--r--lib/mlibc/abis/linux/pid_t.h8
-rw-r--r--lib/mlibc/abis/linux/poll.h16
-rw-r--r--lib/mlibc/abis/linux/ptrace.h59
-rw-r--r--lib/mlibc/abis/linux/reboot.h12
-rw-r--r--lib/mlibc/abis/linux/resource.h53
-rw-r--r--lib/mlibc/abis/linux/seek-whence.h10
-rw-r--r--lib/mlibc/abis/linux/shm.h25
-rw-r--r--lib/mlibc/abis/linux/signal.h496
-rw-r--r--lib/mlibc/abis/linux/socket.h299
-rw-r--r--lib/mlibc/abis/linux/socklen_t.h6
-rw-r--r--lib/mlibc/abis/linux/stat.h123
-rw-r--r--lib/mlibc/abis/linux/statfs.h28
-rw-r--r--lib/mlibc/abis/linux/statvfs.h29
-rw-r--r--lib/mlibc/abis/linux/suseconds_t.h8
-rw-r--r--lib/mlibc/abis/linux/termios.h155
-rw-r--r--lib/mlibc/abis/linux/time.h15
-rw-r--r--lib/mlibc/abis/linux/uid_t.h8
-rw-r--r--lib/mlibc/abis/linux/utsname.h13
-rw-r--r--lib/mlibc/abis/linux/vm-flags.h70
-rw-r--r--lib/mlibc/abis/linux/vt.h76
-rw-r--r--lib/mlibc/abis/linux/wait.h28
-rw-r--r--lib/mlibc/abis/linux/xattr.h21
-rw-r--r--lib/mlibc/abis/lyre/statvfs.h35
-rw-r--r--lib/mlibc/abis/managarm/auxv.h16
-rw-r--r--lib/mlibc/abis/mlibc/access.h9
-rw-r--r--lib/mlibc/abis/mlibc/blkcnt_t.h7
-rw-r--r--lib/mlibc/abis/mlibc/blksize_t.h9
-rw-r--r--lib/mlibc/abis/mlibc/clockid_t.h7
-rw-r--r--lib/mlibc/abis/mlibc/dev_t.h8
-rw-r--r--lib/mlibc/abis/mlibc/epoll.h6
-rw-r--r--lib/mlibc/abis/mlibc/errno.h126
-rw-r--r--lib/mlibc/abis/mlibc/fcntl.h76
-rw-r--r--lib/mlibc/abis/mlibc/gid_t.h8
-rw-r--r--lib/mlibc/abis/mlibc/in.h168
-rw-r--r--lib/mlibc/abis/mlibc/ino_t.h9
-rw-r--r--lib/mlibc/abis/mlibc/inotify.h7
-rw-r--r--lib/mlibc/abis/mlibc/limits.h14
-rw-r--r--lib/mlibc/abis/mlibc/mode_t.h8
-rw-r--r--lib/mlibc/abis/mlibc/nlink_t.h8
-rw-r--r--lib/mlibc/abis/mlibc/packet.h6
-rw-r--r--lib/mlibc/abis/mlibc/pid_t.h8
-rw-r--r--lib/mlibc/abis/mlibc/poll.h16
-rw-r--r--lib/mlibc/abis/mlibc/ptrace.h56
-rw-r--r--lib/mlibc/abis/mlibc/resource.h53
-rw-r--r--lib/mlibc/abis/mlibc/seek-whence.h10
-rw-r--r--lib/mlibc/abis/mlibc/signal.h195
-rw-r--r--lib/mlibc/abis/mlibc/socket.h165
-rw-r--r--lib/mlibc/abis/mlibc/stat.h69
-rw-r--r--lib/mlibc/abis/mlibc/termios.h118
-rw-r--r--lib/mlibc/abis/mlibc/time.h15
-rw-r--r--lib/mlibc/abis/mlibc/uid_t.h8
-rw-r--r--lib/mlibc/abis/mlibc/utsname.h17
-rw-r--r--lib/mlibc/abis/mlibc/vm-flags.h46
-rw-r--r--lib/mlibc/abis/mlibc/wait.h30
124 files changed, 5216 insertions, 0 deletions
diff --git a/lib/mlibc/abis/aero/auxv.h b/lib/mlibc/abis/aero/auxv.h
new file mode 100644
index 0000000..a196fb5
--- /dev/null
+++ b/lib/mlibc/abis/aero/auxv.h
@@ -0,0 +1,9 @@
+#ifndef _ABIBITS_AUXV_H
+#define _ABIBITS_AUXV_H
+
+#define AT_EXECPATH 15
+#define AT_SECURE 23
+#define AT_RANDOM 25
+#define AT_EXECFN 31
+
+#endif // _ABIBITS_AUXV_H
diff --git a/lib/mlibc/abis/dripos/auxv.h b/lib/mlibc/abis/dripos/auxv.h
new file mode 100644
index 0000000..4e93ed3
--- /dev/null
+++ b/lib/mlibc/abis/dripos/auxv.h
@@ -0,0 +1,8 @@
+#ifndef _ABIBITS_AUXV_H
+#define _ABIBITS_AUXV_H
+
+#define AT_SECURE 23
+#define AT_RANDOM 25
+#define AT_EXECFN 31
+
+#endif
diff --git a/lib/mlibc/abis/dripos/errno.h b/lib/mlibc/abis/dripos/errno.h
new file mode 100644
index 0000000..0375024
--- /dev/null
+++ b/lib/mlibc/abis/dripos/errno.h
@@ -0,0 +1,149 @@
+#ifndef _ABIBITS_ERRNO_H
+#define _ABIBITS_ERRNO_H
+
+#define EPERM 1 /* Operation not permitted */
+#define ENOENT 2 /* No such file or directory */
+#define ESRCH 3 /* No such process */
+#define EINTR 4 /* Interrupted system call */
+#define EIO 5 /* Input/output error */
+#define ENXIO 6 /* Device not configured */
+#define E2BIG 7 /* Argument list too long */
+#define ENOEXEC 8 /* Exec format error */
+#define EBADF 9 /* Bad file descriptor */
+#define ECHILD 10 /* No child processes */
+#define EDEADLK 11 /* Resource deadlock avoided */
+ /* 11 was EAGAIN */
+
+#define ENOMEM 12 /* Cannot allocate memory */
+#define EACCES 13 /* Permission denied */
+#define EFAULT 14 /* Bad address */
+
+#define ENOTBLK 15 /* Block device required */
+#define EBUSY 16 /* Device busy */
+
+#define EEXIST 17 /* File exists */
+#define EXDEV 18 /* Cross-device link */
+#define ENODEV 19 /* Operation not supported by device */
+#define ENOTDIR 20 /* Not a directory */
+#define EISDIR 21 /* Is a directory */
+#define EINVAL 22 /* Invalid argument */
+#define ENFILE 23 /* Too many open files in system */
+#define EMFILE 24 /* Too many open files */
+#define ENOTTY 25 /* Inappropriate ioctl for device */
+
+#define ETXTBSY 26 /* Text file busy */
+
+#define EFBIG 27 /* File too large */
+#define ENOSPC 28 /* No space left on device */
+#define ESPIPE 29 /* Illegal seek */
+#define EROFS 30 /* Read-only file system */
+#define EMLINK 31 /* Too many links */
+#define EPIPE 32 /* Broken pipe */
+
+/* math software */
+#define EDOM 33 /* Numerical argument out of domain */
+#define ERANGE 34 /* Result too large */
+
+/* non-blocking and interrupt i/o */
+#define EAGAIN 35 /* Resource temporarily unavailable */
+
+#define EWOULDBLOCK EAGAIN /* Operation would block */
+#define EINPROGRESS 36 /* Operation now in progress */
+#define EALREADY 37 /* Operation already in progress */
+
+/* ipc/network software -- argument errors */
+#define ENOTSOCK 38 /* Socket operation on non-socket */
+#define EDESTADDRREQ 39 /* Destination address required */
+#define EMSGSIZE 40 /* Message too long */
+#define EPROTOTYPE 41 /* Protocol wrong type for socket */
+#define ENOPROTOOPT 42 /* Protocol not available */
+#define EPROTONOSUPPORT 43 /* Protocol not supported */
+#define ESOCKTNOSUPPORT 44 /* Socket type not supported */
+#define EOPNOTSUPP 45 /* Operation not supported on socket */
+#define EPFNOSUPPORT 46 /* Protocol family not supported */
+#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */
+#define EADDRINUSE 48 /* Address already in use */
+#define EADDRNOTAVAIL 49 /* Can't assign requested address */
+
+/* ipc/network software -- operational errors */
+#define ENETDOWN 50 /* Network is down */
+#define ENETUNREACH 51 /* Network is unreachable */
+#define ENETRESET 52 /* Network dropped connection on reset */
+#define ECONNABORTED 53 /* Software caused connection abort */
+#define ECONNRESET 54 /* Connection reset by peer */
+#define ENOBUFS 55 /* No buffer space available */
+#define EISCONN 56 /* Socket is already connected */
+#define ENOTCONN 57 /* Socket is not connected */
+#define ESHUTDOWN 58 /* Can't send after socket shutdown */
+#define ETOOMANYREFS 59 /* Too many references: can't splice */
+#define ETIMEDOUT 60 /* Connection timed out */
+#define ECONNREFUSED 61 /* Connection refused */
+
+#define ELOOP 62 /* Too many levels of symbolic links */
+
+#define ENAMETOOLONG 63 /* File name too long */
+
+/* should be rearranged */
+#define EHOSTDOWN 64 /* Host is down */
+#define EHOSTUNREACH 65 /* No route to host */
+#define ENOTEMPTY 66 /* Directory not empty */
+
+/* quotas & mush */
+#define EPROCLIM 67 /* Too many processes */
+#define EUSERS 68 /* Too many users */
+#define EDQUOT 69 /* Disc quota exceeded */
+
+/* Network File System */
+#define ESTALE 70 /* Stale NFS file handle */
+#define EREMOTE 71 /* Too many levels of remote in path */
+#define EBADRPC 72 /* RPC struct is bad */
+#define ERPCMISMATCH 73 /* RPC version wrong */
+#define EPROGUNAVAIL 74 /* RPC prog. not avail */
+#define EPROGMISMATCH 75 /* Program version wrong */
+#define EPROCUNAVAIL 76 /* Bad procedure for program */
+
+
+#define ENOLCK 77 /* No locks available */
+#define ENOSYS 78 /* Function not implemented */
+
+#define EFTYPE 79 /* Inappropriate file type or format */
+#define EOVERFLOW 80
+#define EILSEQ 81
+
+#define EBADMSG 82
+#define ECANCELED 83
+#define EIDRM 84
+#define EMULTIHOP 85
+#define ENOLINK 86
+#define ENOMSG 87
+#define ENOTRECOVERABLE 88
+#define ENOTSUP 89
+#define EOWNERDEAD 90
+#define EPROTO 91
+#define ENODATA 92
+#define ETIME 93
+#define ENOKEY 94
+#define EBADFD 95
+#define ENOMEDIUM 96
+#define ENONET 97
+#define ESTRPIPE 98
+#define EREMOTEIO 99
+#define ERFKILL 100
+#define EBADR 101
+#define EUNATCH 102
+#define EMEDIUMTYPE 103
+#define EKEYREJECTED 104
+#define EUCLEAN 105
+#define EBADSLT 106
+#define ENOANO 107
+#define ENOCSI 108
+#define ENOSTR 109
+#define ENOPKG 110
+#define EKEYREVOKED 111
+#define EXFULL 112
+#define ELNRNG 113
+#define ENOTUNIQ 114
+#define ERESTART 115
+#define ENOTSUP 116
+
+#endif
diff --git a/lib/mlibc/abis/hyra/auxv.h b/lib/mlibc/abis/hyra/auxv.h
new file mode 100644
index 0000000..92fa648
--- /dev/null
+++ b/lib/mlibc/abis/hyra/auxv.h
@@ -0,0 +1,16 @@
+#ifndef _ABIBITS_AUXV_H
+#define _ABIBITS_AUXV_H
+
+#define AT_NULL 0
+#define AT_IGNORE 1
+#define AT_EXECFD 2
+#define AT_PHDR 3
+#define AT_PHENT 4
+#define AT_PHNUM 5
+#define AT_PAGESZ 6
+#define AT_BASE 7
+#define AT_FLAGS 8
+#define AT_ENTRY 9
+#define AT_SECURE 10
+
+#endif // _ABIBITS_AUXV_H
diff --git a/lib/mlibc/abis/ironclad/access.h b/lib/mlibc/abis/ironclad/access.h
new file mode 100644
index 0000000..bc19728
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/access.h
@@ -0,0 +1,9 @@
+#ifndef _ABIBITS_ACCESS_H
+#define _ABIBITS_ACCESS_H
+
+#define F_OK 1
+#define R_OK 2
+#define W_OK 4
+#define X_OK 8
+
+#endif // _ABIBITS_ACCESS_H
diff --git a/lib/mlibc/abis/ironclad/auxv.h b/lib/mlibc/abis/ironclad/auxv.h
new file mode 100644
index 0000000..4e93ed3
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/auxv.h
@@ -0,0 +1,8 @@
+#ifndef _ABIBITS_AUXV_H
+#define _ABIBITS_AUXV_H
+
+#define AT_SECURE 23
+#define AT_RANDOM 25
+#define AT_EXECFN 31
+
+#endif
diff --git a/lib/mlibc/abis/ironclad/blkcnt_t.h b/lib/mlibc/abis/ironclad/blkcnt_t.h
new file mode 100644
index 0000000..51c1519
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/blkcnt_t.h
@@ -0,0 +1,7 @@
+#ifndef _ABIBITS_BLKCNT_T_H
+#define _ABIBITS_BLKCNT_T_H
+
+// TODO: use int64_t?
+typedef long blkcnt_t;
+
+#endif // _ABIBITS_BLKCNT_T_H
diff --git a/lib/mlibc/abis/ironclad/blksize_t.h b/lib/mlibc/abis/ironclad/blksize_t.h
new file mode 100644
index 0000000..9f87294
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/blksize_t.h
@@ -0,0 +1,8 @@
+#ifndef _ABIBITS_BLKSIZE_T_H
+#define _ABIBITS_BLKSIZE_T_H
+
+// TODO: use int64_t?
+typedef long blksize_t;
+
+#endif // _ABIBITS_BLKSIZE_T_H
+
diff --git a/lib/mlibc/abis/ironclad/clockid_t.h b/lib/mlibc/abis/ironclad/clockid_t.h
new file mode 100644
index 0000000..c3932ef
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/clockid_t.h
@@ -0,0 +1,7 @@
+#ifndef _ABIBITS_CLOCKID_T_H
+#define _ABIBITS_CLOCKID_T_H
+
+typedef long clockid_t;
+
+#endif /* _ABIBITS_CLOCKID_T_H */
+
diff --git a/lib/mlibc/abis/ironclad/dev_t.h b/lib/mlibc/abis/ironclad/dev_t.h
new file mode 100644
index 0000000..0b63fe5
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/dev_t.h
@@ -0,0 +1,6 @@
+#ifndef _ABIBITS_DEV_T_H
+#define _ABIBITS_DEV_T_H
+
+typedef unsigned long dev_t;
+
+#endif // _ABIBITS_DEV_T_H
diff --git a/lib/mlibc/abis/ironclad/epoll.h b/lib/mlibc/abis/ironclad/epoll.h
new file mode 100644
index 0000000..49969d5
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/epoll.h
@@ -0,0 +1,6 @@
+#ifndef _ABIBITS_EPOLL_H
+#define _ABIBITS_EPOLL_H
+
+#define EPOLL_CLOEXEC 1
+
+#endif // _ABIBITS_EPOLL_H
diff --git a/lib/mlibc/abis/ironclad/errno.h b/lib/mlibc/abis/ironclad/errno.h
new file mode 100644
index 0000000..f8c7203
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/errno.h
@@ -0,0 +1,126 @@
+#ifndef _ABIBITS_ERRNO_H
+#define _ABIBITS_ERRNO_H
+
+#define EDOM 1
+#define EILSEQ 2
+#define ERANGE 3
+
+#define E2BIG 1001
+#define EACCES 1002
+#define EADDRINUSE 1003
+#define EADDRNOTAVAIL 1004
+#define EAFNOSUPPORT 1005
+#define EAGAIN 1006
+#define EALREADY 1007
+#define EBADF 1008
+#define EBADMSG 1009
+#define EBUSY 1010
+#define ECANCELED 1011
+#define ECHILD 1012
+#define ECONNABORTED 1013
+#define ECONNREFUSED 1014
+#define ECONNRESET 1015
+#define EDEADLK 1016
+#define EDESTADDRREQ 1017
+#define EDQUOT 1018
+#define EEXIST 1019
+#define EFAULT 1020
+#define EFBIG 1021
+#define EHOSTUNREACH 1022
+#define EIDRM 1023
+#define EINPROGRESS 1024
+#define EINTR 1025
+#define EINVAL 1026
+#define EIO 1027
+#define EISCONN 1028
+#define EISDIR 1029
+#define ELOOP 1030
+#define EMFILE 1031
+#define EMLINK 1032
+#define EMSGSIZE 1034
+#define EMULTIHOP 1035
+#define ENAMETOOLONG 1036
+#define ENETDOWN 1037
+#define ENETRESET 1038
+#define ENETUNREACH 1039
+#define ENFILE 1040
+#define ENOBUFS 1041
+#define ENODEV 1042
+#define ENOENT 1043
+#define ENOEXEC 1044
+#define ENOLCK 1045
+#define ENOLINK 1046
+#define ENOMEM 1047
+#define ENOMSG 1048
+#define ENOPROTOOPT 1049
+#define ENOSPC 1050
+#define ENOSYS 1051
+#define ENOTCONN 1052
+#define ENOTDIR 1053
+#define ENOTEMPTY 1054
+#define ENOTRECOVERABLE 1055
+#define ENOTSOCK 1056
+#define ENOTSUP 1057
+#define ENOTTY 1058
+#define ENXIO 1059
+#define EOPNOTSUPP 1060
+#define EOVERFLOW 1061
+#define EOWNERDEAD 1062
+#define EPERM 1063
+#define EPIPE 1064
+#define EPROTO 1065
+#define EPROTONOSUPPORT 1066
+#define EPROTOTYPE 1067
+#define EROFS 1068
+#define ESPIPE 1069
+#define ESRCH 1070
+#define ESTALE 1071
+#define ETIMEDOUT 1072
+#define ETXTBSY 1073
+#define EWOULDBLOCK EAGAIN
+#define EXDEV 1075
+#define ENODATA 1076
+#define ETIME 1077
+#define ENOKEY 1078
+#define ESHUTDOWN 1079
+#define EHOSTDOWN 1080
+#define EBADFD 1081
+#define ENOMEDIUM 1082
+#define ENOTBLK 1083
+#define ENONET 1084
+#define EPFNOSUPPORT 1085
+#define ESOCKTNOSUPPORT 1086
+#define ESTRPIPE 1087
+#define EREMOTEIO 1088
+#define ERFKILL 1089
+#define EBADR 1090
+#define EUNATCH 1091
+#define EMEDIUMTYPE 1092
+#define EREMOTE 1093
+#define EKEYREJECTED 1094
+#define EUCLEAN 1095
+#define EBADSLT 1096
+#define ENOANO 1097
+#define ENOCSI 1098
+#define ENOSTR 1099
+#define ETOOMANYREFS 1100
+#define ENOPKG 1101
+#define EKEYREVOKED 1102
+#define EXFULL 1103
+#define ELNRNG 1104
+#define ENOTUNIQ 1105
+#define ERESTART 1106
+#define EUSERS 1107
+#define ECHRNG 1108
+#define ELIBBAD 1109
+#define EL2HLT 1110
+#define EL3HLT 1111
+#define EKEYEXPIRED 1112
+#define ECOMM 1113
+#define EBADE 1114
+#define EHWPOISON 1115
+#define EBADRQC 1116
+
+#define EIEIO 1524152434
+
+#endif // _ABIBITS_ERRNO_H
diff --git a/lib/mlibc/abis/ironclad/fcntl.h b/lib/mlibc/abis/ironclad/fcntl.h
new file mode 100644
index 0000000..10188de
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/fcntl.h
@@ -0,0 +1,79 @@
+#ifndef _ABIBITS_FCNTL_H
+#define _ABIBITS_FCNTL_H
+
+// Flags supported by the kernel.
+#define O_ACCMODE 0b000011
+#define O_RDONLY 00000001
+#define O_WRONLY 0b000010
+#define O_RDWR 0b000011
+#define O_APPEND 0b000100
+#define O_CLOEXEC 0b001000
+#define O_NOFOLLOW 0b010000
+#define O_NONBLOCK 0b100000
+
+// Flags emulated by userland, we just have to make sure they dont overlap with
+// kernel flags.
+#define O_CREAT 0b0010000000
+#define O_EXCL 0b0100000000
+#define O_TRUNC 0b1000000000
+
+// Stubbed flags, the value really doesnt matter as long as they dont overlap
+// with usable ones.
+// Implemented here as some software needs them to compile.
+#define O_SEARCH 0b000000000010000000000
+#define O_EXEC 0b000000000100000000000
+#define O_NOCTTY 0b000000001000000000000
+#define O_DSYNC 0b000000010000000000000
+#define O_RSYNC 0b000000100000000000000
+#define O_SYNC 0b000001000000000000000
+#define O_PATH 0b000010000000000000000
+#define O_DIRECTORY 0b000100000000000000000
+#define O_LARGEFILE 0b001000000000000000000
+#define O_NOATIME 0b010000000000000000000
+#define O_TMPFILE 0b100000000000000000000
+
+// Fcntl flags.
+#define FD_CLOEXEC 1
+#define F_DUPFD 1
+#define F_DUPFD_CLOEXEC 2
+#define F_GETFD 3
+#define F_SETFD 4
+#define F_GETFL 5
+#define F_SETFL 6
+#define F_GETPIPE_SZ 7
+#define F_SETPIPE_SZ 8
+#define F_GETLK 9
+#define F_SETLK 10
+#define F_SETLKW 11
+
+#define F_RDLCK 1
+#define F_UNLCK 2
+#define F_WRLCK 3
+
+// Stubbed fcntl flags.
+#define F_GETOWN 10
+#define F_SETOWN 11
+
+#define F_SEAL_SHRINK 0x0002
+#define F_SEAL_GROW 0x0004
+#define F_SEAL_WRITE 0x0008
+#define F_SEAL_SEAL 0x0010
+#define F_ADD_SEALS 1033
+#define F_GET_SEALS 1034
+
+// At flags.
+#define AT_REMOVEDIR 500
+#define AT_EACCESS 512
+#define AT_FDCWD 0x7FFFFFFF
+#define AT_EMPTY_PATH 1
+#define AT_SYMLINK_FOLLOW 0
+#define AT_SYMLINK_NOFOLLOW 2
+
+#define POSIX_FADV_NORMAL 1
+#define POSIX_FADV_SEQUENTIAL 2
+#define POSIX_FADV_NOREUSE 3
+#define POSIX_FADV_DONTNEED 4
+#define POSIX_FADV_WILLNEED 5
+#define POSIX_FADV_RANDOM 6
+
+#endif // _ABIBITS_FCNTL_H
diff --git a/lib/mlibc/abis/ironclad/fsblkcnt_t.h b/lib/mlibc/abis/ironclad/fsblkcnt_t.h
new file mode 100644
index 0000000..0d74456
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/fsblkcnt_t.h
@@ -0,0 +1,8 @@
+#ifndef _ABIBITS_FSBLKCNT_T_H
+#define _ABIBITS_FSBLKCNT_T_H
+
+#include <bits/types.h>
+
+typedef __mlibc_uint64 fsblkcnt_t;
+
+#endif /* _ABIBITS_FSBLKCNT_T_H */
diff --git a/lib/mlibc/abis/ironclad/fsfilcnt_t.h b/lib/mlibc/abis/ironclad/fsfilcnt_t.h
new file mode 100644
index 0000000..1abda9a
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/fsfilcnt_t.h
@@ -0,0 +1,8 @@
+#ifndef _ABIBITS_FSFILCNT_T_H
+#define _ABIBITS_FSFILCNT_T_H
+
+#include <bits/types.h>
+
+typedef __mlibc_uint64 fsfilcnt_t;
+
+#endif /* _ABIBITS_FSFILCNT_T_H */
diff --git a/lib/mlibc/abis/ironclad/gid_t.h b/lib/mlibc/abis/ironclad/gid_t.h
new file mode 100644
index 0000000..252321f
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/gid_t.h
@@ -0,0 +1,6 @@
+#ifndef _ABIBITS_GID_T_H
+#define _ABIBITS_GID_T_H
+
+typedef unsigned int gid_t;
+
+#endif // _ABIBITS_GID_T_H
diff --git a/lib/mlibc/abis/ironclad/in.h b/lib/mlibc/abis/ironclad/in.h
new file mode 100644
index 0000000..3c736e3
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/in.h
@@ -0,0 +1,168 @@
+#ifndef _ABIBITS_IN_H
+#define _ABIBITS_IN_H
+
+#include <bits/posix/in_addr_t.h>
+#include <bits/posix/in_port_t.h>
+#include <abi-bits/socket.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct in_addr {
+ in_addr_t s_addr;
+};
+
+struct sockaddr_in {
+ sa_family_t sin_family;
+ in_port_t sin_port;
+ struct in_addr sin_addr;
+ uint8_t pad[8];
+};
+#define sin_zero pad /* for BSD Unix compatibility */
+
+struct in6_addr {
+ union {
+ uint8_t __s6_addr[16];
+ uint16_t __s6_addr16[8];
+ uint32_t __s6_addr32[4];
+ } __in6_union;
+};
+#define s6_addr __in6_union.__s6_addr
+#define s6_addr16 __in6_union.__s6_addr16
+#define s6_addr32 __in6_union.__s6_addr32
+
+struct in6_pktinfo {
+ struct in6_addr ipi6_addr;
+ uint32_t ipi6_ifindex;
+};
+
+struct sockaddr_in6 {
+ sa_family_t sin6_family;
+ in_port_t sin6_port;
+ uint32_t sin6_flowinfo;
+ struct in6_addr sin6_addr;
+ uint32_t sin6_scope_id;
+};
+
+struct ipv6_mreq {
+ struct in6_addr ipv6mr_multiaddr;
+ unsigned ipv6mr_interface;
+};
+
+struct ip_mreq {
+ struct in_addr imr_multiaddr;
+ struct in_addr imr_interface;
+};
+
+struct ip_mreq_source {
+ struct in_addr imr_multiaddr;
+ struct in_addr imr_interface;
+ struct in_addr imr_sourceaddr;
+};
+
+struct ip_mreqn {
+ struct in_addr imr_multiaddr;
+ struct in_addr imr_address;
+ int imr_ifindex;
+};
+
+struct in_pktinfo {
+ unsigned int ipi_ifindex;
+ struct in_addr ipi_spec_dst;
+ struct in_addr ipi_addr;
+};
+
+struct group_source_req {
+ uint32_t gsr_interface;
+ struct sockaddr_storage gsr_group;
+ struct sockaddr_storage gsr_source;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
+#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
+
+#define IPPROTO_IP 1
+#define IPPROTO_IPV6 2
+#define IPPROTO_ICMP 3
+#define IPPROTO_RAW 4
+#define IPPROTO_TCP 5
+#define IPPROTO_UDP 6
+#define IPPROTO_IGMP 7
+#define IPPROTO_IPIP 8
+#define IPPROTO_DCCP 33
+#define IPPROTO_ROUTING 43
+#define IPPROTO_GRE 47
+#define IPPROTO_ESP 50
+#define IPPROTO_AH 51
+#define IPPROTO_ICMPV6 58
+#define IPPROTO_DSTOPTS 60
+#define IPPROTO_COMP 108
+#define IPPROTO_SCTP 132
+#define IPPROTO_UDPLITE 136
+#define IPPROTO_MAX 256
+
+#define INADDR_ANY ((in_addr_t)0x00000000)
+#define INADDR_BROADCAST ((in_addr_t)0xffffffff)
+#define INADDR_LOOPBACK ((in_addr_t)0x7f000001)
+#define INADDR_NONE ((in_addr_t)0xffffffff)
+
+#define INET_ADDRSTRLEN 16
+
+#define INET6_ADDRSTRLEN 46
+
+#define IPV6_JOIN_GROUP 1
+#define IPV6_LEAVE_GROUP 2
+#define IPV6_MULTICAST_HOPS 3
+#define IPV6_MULTICAST_IF 4
+#define IPV6_MULTICAST_LOOP 5
+#define IPV6_UNICAST_HOPS 6
+#define IPV6_V6ONLY 7
+#define IPV6_PMTUDISC_DONT 8
+#define IPV6_PMTUDISC_DO 9
+#define IPV6_MTU 10
+#define IPV6_2292PKTOPTIONS 11
+#define IPV6_MTU_DISCOVER 23
+#define IPV6_RECVERR 25
+#define IPV6_RECVPKTINFO 49
+#define IPV6_PKTINFO 50
+#define IPV6_RECVHOPLIMIT 51
+#define IPV6_HOPLIMIT 52
+#define IPV6_TCLASS 67
+
+#define IP_TOS 1
+#define IP_TTL 2
+#define IP_OPTIONS 4
+#define IP_PMTUDISC_OMIT 5
+#define IP_PKTINFO 8
+#define IP_PKTOPTIONS 9
+#define IP_MTU_DISCOVER 10
+#define IP_RECVERR 11
+#define IP_RECVTTL 12
+#define IP_UNICAST_IF 13
+#define IP_MTU 14
+
+#define IP_DEFAULT_MULTICAST_TTL 1
+#define IP_MULTICAST_IF 32
+#define IP_MULTICAST_TTL 33
+#define IP_MULTICAST_LOOP 34
+#define IP_ADD_MEMBERSHIP 35
+#define IP_DROP_MEMBERSHIP 36
+#define IP_UNBLOCK_SOURCE 37
+#define IP_BLOCK_SOURCE 38
+#define IP_ADD_SOURCE_MEMBERSHIP 39
+#define IP_DROP_SOURCE_MEMBERSHIP 40
+#define MCAST_JOIN_SOURCE_GROUP 46
+#define MCAST_LEAVE_SOURCE_GROUP 47
+
+#define IP_PMTUDISC_DONT 0
+#define IP_PMTUDISC_DO 2
+
+#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
+#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
+
+#endif // _ABIBITS_IN_H
diff --git a/lib/mlibc/abis/ironclad/ino_t.h b/lib/mlibc/abis/ironclad/ino_t.h
new file mode 100644
index 0000000..264d888
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/ino_t.h
@@ -0,0 +1,7 @@
+#ifndef _ABIBITS_INO_T_H
+#define _ABIBITS_INO_T_H
+
+// TODO: use (u)int64_t?
+typedef long ino_t;
+
+#endif // _ABIBITS_INO_T_H
diff --git a/lib/mlibc/abis/ironclad/inotify.h b/lib/mlibc/abis/ironclad/inotify.h
new file mode 100644
index 0000000..38c9c77
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/inotify.h
@@ -0,0 +1,7 @@
+#ifndef _ABIBITS_INOTIFY_H
+#define _ABIBITS_INOTIFY_H
+
+#define IN_CLOEXEC 1
+#define IN_NONBLOCK 2
+
+#endif // _ABIBITS_INOTIFY_H
diff --git a/lib/mlibc/abis/ironclad/ioctls.h b/lib/mlibc/abis/ironclad/ioctls.h
new file mode 100644
index 0000000..c39abb5
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/ioctls.h
@@ -0,0 +1,13 @@
+#ifndef _ABIBITS_IOCTLS_H
+#define _ABIBITS_IOCTLS_H
+
+#define SIOCPROTOPRIVATE 0x89E0
+#define SIOCGIFNAME 0x8910
+#define SIOCGIFCONF 0x8912
+#define SIOCGIFFLAGS 0x8913
+#define SIOCSIFFLAGS 0x8914
+#define SIOCGIFINDEX 0x8933
+#define SIOCATMARK 0x8905
+#define SIOCGIFHWADDR 0x8927
+
+#endif /* _ABIBITS_IOCTLS_H */
diff --git a/lib/mlibc/abis/ironclad/limits.h b/lib/mlibc/abis/ironclad/limits.h
new file mode 100644
index 0000000..6aac622
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/limits.h
@@ -0,0 +1,14 @@
+#ifndef _ABIBITS_LIMITS_H
+#define _ABIBITS_LIMITS_H
+
+#define IOV_MAX 1024
+
+// Niceness related
+#define NZERO 20
+
+// Maximum hostname length, posix defines it as 255
+#define HOST_NAME_MAX 255
+
+#define OPEN_MAX 256
+
+#endif //_ABIBITS_LIMITS_H
diff --git a/lib/mlibc/abis/ironclad/mode_t.h b/lib/mlibc/abis/ironclad/mode_t.h
new file mode 100644
index 0000000..77f75a9
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/mode_t.h
@@ -0,0 +1,6 @@
+#ifndef _ABIBITS_MODE_T_H
+#define _ABIBITS_MODE_T_H
+
+typedef int mode_t;
+
+#endif // _ABIBITS_MODE_T_H
diff --git a/lib/mlibc/abis/ironclad/mqueue.h b/lib/mlibc/abis/ironclad/mqueue.h
new file mode 100644
index 0000000..f18210c
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/mqueue.h
@@ -0,0 +1,20 @@
+#ifndef _ABIBITS_MQUEUE_H
+#define _ABIBITS_MQUEUE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct mq_attr {
+ long mq_flags;
+ long mq_maxmsg;
+ long mq_msgsize;
+ long mq_curmsgs;
+ long __pad[4];
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ABIBITS_MQUEUE_H */
diff --git a/lib/mlibc/abis/ironclad/msg.h b/lib/mlibc/abis/ironclad/msg.h
new file mode 100644
index 0000000..5e890c0
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/msg.h
@@ -0,0 +1,39 @@
+#ifndef _ABIBITS_MSG_H
+#define _ABIBITS_MSG_H
+
+#include <sys/ipc.h>
+#include <bits/ansi/time_t.h>
+#include <bits/types.h>
+#include <abi-bits/pid_t.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(__i386__)
+typedef __mlibc_uint64 msglen_t;
+typedef __mlibc_uint64 msgqnum_t;
+#else
+typedef unsigned long msglen_t;
+typedef unsigned long msgqnum_t;
+#endif
+
+struct msqid_ds {
+ struct ipc_perm msg_perm;
+ time_t msg_stime;
+ time_t msg_rtime;
+ time_t msg_ctime;
+ unsigned long msg_cbytes;
+ msgqnum_t msg_qnum;
+ msglen_t msg_qbytes;
+ pid_t msg_lspid;
+ pid_t msg_lrpid;
+ unsigned long __unused[2];
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ABIBITS_MSG_H */
+
diff --git a/lib/mlibc/abis/ironclad/nlink_t.h b/lib/mlibc/abis/ironclad/nlink_t.h
new file mode 100644
index 0000000..30e178c
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/nlink_t.h
@@ -0,0 +1,6 @@
+#ifndef _ABIBITS_NLINK_T_H
+#define _ABIBITS_NLINK_T_H
+
+typedef int nlink_t;
+
+#endif // _ABIBITS_NLINK_T_H
diff --git a/lib/mlibc/abis/ironclad/packet.h b/lib/mlibc/abis/ironclad/packet.h
new file mode 100644
index 0000000..ee1a424
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/packet.h
@@ -0,0 +1,6 @@
+#ifndef _ABIBITS_PACKET_H
+#define _ABIBITS_PACKET_H
+
+#define PACKET_HOST 0
+
+#endif // _ABIBITS_PACKET_H
diff --git a/lib/mlibc/abis/ironclad/pid_t.h b/lib/mlibc/abis/ironclad/pid_t.h
new file mode 100644
index 0000000..5ffbd06
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/pid_t.h
@@ -0,0 +1,6 @@
+#ifndef _ABIBITS_PID_T_H
+#define _ABIBITS_PID_T_H
+
+typedef int pid_t;
+
+#endif // _ABIBITS_PID_T_H
diff --git a/lib/mlibc/abis/ironclad/poll.h b/lib/mlibc/abis/ironclad/poll.h
new file mode 100644
index 0000000..e0fe1a5
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/poll.h
@@ -0,0 +1,16 @@
+#ifndef _ABIBITS_POLL_H
+#define _ABIBITS_POLL_H
+
+#define POLLIN 0x01
+#define POLLOUT 0x02
+#define POLLPRI 0x04
+#define POLLHUP 0x08
+#define POLLERR 0x10
+#define POLLRDHUP 0x20
+#define POLLNVAL 0x40
+#define POLLWRNORM 0x80
+#define POLLRDNORM 0x100
+#define POLLWRBAND 0x200
+#define POLLRDBAND 0x400
+
+#endif // _ABIBITS_POLL_H
diff --git a/lib/mlibc/abis/ironclad/ptrace.h b/lib/mlibc/abis/ironclad/ptrace.h
new file mode 100644
index 0000000..6f35eac
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/ptrace.h
@@ -0,0 +1,56 @@
+#ifndef _ABIBITS_PTRACE_H
+#define _ABIBITS_PTRACE_H
+
+#define PTRACE_PEEKTEXT 1
+#define PTRACE_PEEKDATA 2
+#define PTRACE_PEEKUSER 3
+#define PTRACE_POKETEXT 4
+#define PTRACE_POKEDATA 5
+#define PTRACE_CONT 7
+#define PTRACE_KILL 8
+#define PTRACE_SINGLESTEP 9
+#define PTRACE_GETREGS 14
+#define PTRACE_SETREGS 15
+#define PTRACE_ATTACH 16
+#define PTRACE_DETACH 17
+#define PTRACE_GETFPXREGS 18
+#define PTRACE_SETFPXREGS 19
+#define PTRACE_GETFPREGS 20
+#define PTRACE_SYSCALL 24
+#define PTRACE_SETOPTIONS 0x4200
+#define PTRACE_GETEVENTMSG 0x4201
+#define PTRACE_GETSIGINFO 0x4202
+#define PTRACE_SETSIGINFO 0x4203
+#define PTRACE_GETREGSET 0x4204
+#define PTRACE_SETREGSET 0x4205
+#define PTRACE_SEIZE 0x4206
+#define PTRACE_INTERRUPT 0x4207
+#define PTRACE_LISTEN 0x4208
+#define PTRACE_PEEKSIGINFO 0x4209
+#define PTRACE_GETSIGMASK 0x420A
+#define PTRACE_SETSIGMASK 0x420B
+#define PTRACE_SECCOMP_GET_FILTER 0x420C
+
+#define PTRACE_CE_O_TRACESYSGOOD 0x00000001
+#define PTRACE_O_TRACEFORK 0x00000002
+#define PTRACE_O_TRACEVFORK 0x00000004
+#define PTRACE_O_TRACECLONE 0x00000008
+#define PTRACE_O_TRACEEXEC 0x00000010
+#define PTRACE_O_TRACEVFORKDONE 0x00000020
+#define PTRACE_O_TRACEEXIT 0x00000040
+#define PTRACE_O_TRACESECCOMP 0x00000080
+#define PTRACE_O_EXITKILL 0x00100000
+#define PTRACE_O_SUSPEND_SECCOMP 0x00200000
+#define PTRACE_O_MASK 0x003000ff
+
+#define PTRACE_EVENT_FORK 1
+#define PTRACE_EVENT_VFORK 2
+#define PTRACE_EVENT_CLONE 3
+#define PTRACE_EVENT_EXEC 4
+#define PTRACE_EVENT_VFORK_DONE 5
+#define PTRACE_EVENT_EXIT 6
+#define PTRACE_EVENT_SECCOMP 7
+
+#define PTRACE_PEEKSIGINFO_SHARED 1
+
+#endif // _ABIBITS_PTRACE_H
diff --git a/lib/mlibc/abis/ironclad/reboot.h b/lib/mlibc/abis/ironclad/reboot.h
new file mode 100644
index 0000000..aadc18f
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/reboot.h
@@ -0,0 +1,12 @@
+#ifndef _ABIBITS_REBOOT_H
+#define _ABIBITS_REBOOT_H
+
+#define RB_AUTOBOOT 0x01234567
+#define RB_HALT_SYSTEM 0xcdef0123
+#define RB_ENABLE_CAD 0x89abcdef
+#define RB_DISABLE_CAD 0
+#define RB_POWER_OFF 0x4321fedc
+#define RB_SW_SUSPEND 0xd000fce2
+#define RB_KEXEC 0x45584543
+
+#endif // _ABIBITS_REBOOT_H
diff --git a/lib/mlibc/abis/ironclad/resource.h b/lib/mlibc/abis/ironclad/resource.h
new file mode 100644
index 0000000..927588b
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/resource.h
@@ -0,0 +1,53 @@
+#ifndef _ABIBITS_RESOURCE_H
+#define _ABIBITS_RESOURCE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <bits/posix/timeval.h>
+
+#define RUSAGE_SELF 1
+#define RUSAGE_CHILDREN 2
+
+#define RLIMIT_CORE 1
+#define RLIMIT_CPU 2
+#define RLIMIT_DATA 3
+#define RLIMIT_FSIZE 4
+#define RLIMIT_NOFILE 5
+#define RLIMIT_STACK 6
+#define RLIMIT_AS 7
+#define RLIMIT_MEMLOCK 8
+#define RLIMIT_RSS 9
+#define RLIMIT_NPROC 10
+#define RLIMIT_LOCKS 11
+#define RLIMIT_SIGPENDING 12
+#define RLIMIT_MSGQUEUE 13
+#define RLIMIT_NICE 14
+#define RLIMIT_RTPRIO 15
+#define RLIMIT_NLIMITS 16
+
+struct rusage {
+ struct timeval ru_utime;
+ struct timeval ru_stime;
+ long int ru_maxrss;
+ long int ru_ixrss;
+ long int ru_idrss;
+ long int ru_isrss;
+ long int ru_minflt;
+ long int ru_majflt;
+ long int ru_nswap;
+ long int ru_inblock;
+ long int ru_oublock;
+ long int ru_msgsnd;
+ long int ru_msgrcv;
+ long int ru_nsignals;
+ long int ru_nvcsw;
+ long int ru_nivcsw;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _ABIBITS_RESOURCE_H
diff --git a/lib/mlibc/abis/ironclad/seek-whence.h b/lib/mlibc/abis/ironclad/seek-whence.h
new file mode 100644
index 0000000..617b6f4
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/seek-whence.h
@@ -0,0 +1,8 @@
+#ifndef _ABIBITS_SEEK_WHENCE_H
+#define _ABIBITS_SEEK_WHENCE_H
+
+#define SEEK_SET 1
+#define SEEK_CUR 2
+#define SEEK_END 4
+
+#endif // _ABIBITS_SEEK_WHENCE_H
diff --git a/lib/mlibc/abis/ironclad/shm.h b/lib/mlibc/abis/ironclad/shm.h
new file mode 100644
index 0000000..93fb01b
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/shm.h
@@ -0,0 +1,21 @@
+#ifndef _ABIBITS_SHM_H
+#define _ABIBITS_SHM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct shm_info {
+ int used_ids;
+ unsigned long shm_tot;
+ unsigned long shm_rss;
+ unsigned long shm_swp;
+ unsigned long swap_attempts;
+ unsigned long swap_successes;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ABIBITS_SHM_H */
diff --git a/lib/mlibc/abis/ironclad/signal.h b/lib/mlibc/abis/ironclad/signal.h
new file mode 100644
index 0000000..2d20315
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/signal.h
@@ -0,0 +1,192 @@
+#ifndef _ABIBITS_SIGNAL_H
+#define _ABIBITS_SIGNAL_H
+
+#include <abi-bits/pid_t.h>
+#include <abi-bits/uid_t.h>
+#include <bits/size_t.h>
+
+union sigval {
+ int sival_int;
+ void *sival_ptr;
+};
+
+typedef struct {
+ int si_signo;
+ int si_code;
+ int si_errno;
+ pid_t si_pid;
+ uid_t si_uid;
+ void *si_addr;
+ int si_status;
+ union sigval si_value;
+} siginfo_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Argument for signal()
+typedef void (*__sighandler) (int);
+
+#define SIG_ERR ((__sighandler)(void *)(-1))
+#define SIG_DFL ((__sighandler)(void *)(-2))
+#define SIG_IGN ((__sighandler)(void *)(-3))
+
+#define SIGHUP 1
+#define SIGINT 2
+#define SIGQUIT 3
+#define SIGILL 4
+#define SIGTRAP 5
+#define SIGABRT 6
+#define SIGBUS 7
+#define SIGFPE 8
+#define SIGKILL 9
+#define SIGUSR1 10
+#define SIGSEGV 11
+#define SIGUSR2 12
+#define SIGPIPE 13
+#define SIGALRM 14
+#define SIGTERM 15
+#define SIGSTKFLT 16
+#define SIGCHLD 17
+#define SIGCONT 18
+#define SIGSTOP 19
+#define SIGTSTP 20
+#define SIGTTIN 21
+#define SIGTTOU 22
+#define SIGURG 23
+#define SIGXCPU 24
+#define SIGXFSZ 25
+#define SIGVTALRM 26
+#define SIGPROF 27
+#define SIGWINCH 28
+#define SIGIO 29
+#define SIGPOLL SIGIO
+#define SIGPWR 30
+#define SIGSYS 31
+#define SIGRTMIN 32
+#define SIGRTMAX 33
+#define SIGCANCEL SIGSYS
+
+// siginfo->si_info constants
+// SIGBUS
+#define BUS_ADRALN 1
+#define BUS_ADRERR 2
+#define BUS_OBJERR 3
+
+// SIGILL
+#define ILL_ILLOPC 1
+#define ILL_ILLOPN 2
+#define ILL_ILLADR 3
+#define ILL_ILLTRP 4
+#define ILL_PRVOPC 5
+#define ILL_PRVREG 6
+#define ILL_COPROC 7
+#define ILL_BADSTK 8
+#define ILL_BADIADDR 9
+
+// SIGSEGV
+#define SEGV_MAPERR 1
+#define SEGV_ACCERR 2
+
+// TODO: replace this by uint64_t
+typedef long sigset_t;
+
+#define SIGUNUSED SIGSYS
+
+// constants for sigprocmask()
+#define SIG_BLOCK 1
+#define SIG_UNBLOCK 2
+#define SIG_SETMASK 3
+
+#define SA_NOCLDSTOP (1 << 0)
+#define SA_ONSTACK (1 << 1)
+#define SA_RESETHAND (1 << 2)
+#define SA_RESTART (1 << 3)
+#define SA_SIGINFO (1 << 4)
+#define SA_NOCLDWAIT (1 << 5)
+#define SA_NODEFER (1 << 6)
+
+#define MINSIGSTKSZ 2048
+#define SIGSTKSZ 8192
+#define SS_ONSTACK 1
+#define SS_DISABLE 2
+
+typedef struct __stack {
+ void *ss_sp;
+ size_t ss_size;
+ int ss_flags;
+} stack_t;
+
+// constants for sigev_notify of struct sigevent
+#define SIGEV_NONE 1
+#define SIGEV_SIGNAL 2
+#define SIGEV_THREAD 3
+
+#define SI_ASYNCNL (-60)
+#define SI_TKILL (-6)
+#define SI_SIGIO (-5)
+#define SI_ASYNCIO (-4)
+#define SI_MESGQ (-3)
+#define SI_TIMER (-2)
+#define SI_QUEUE (-1)
+#define SI_USER 0
+#define SI_KERNEL 128
+
+#define NSIG 65
+#define _NSIG NSIG
+
+#define CLD_EXITED 1
+#define CLD_KILLED 2
+#define CLD_DUMPED 3
+#define CLD_TRAPPED 4
+#define CLD_STOPPED 5
+#define CLD_CONTINUED 6
+
+struct sigevent {
+ int sigev_notify;
+ int sigev_signo;
+ union sigval sigev_value;
+ void (*sigev_notify_function)(union sigval);
+ // MISSING: sigev_notify_attributes
+};
+
+struct sigaction {
+ union {
+ void (*sa_handler)(int);
+ void (*sa_sigaction)(int, siginfo_t *, void *);
+ };
+ sigset_t sa_mask;
+ int sa_flags;
+};
+
+#if defined(__x86_64__) || defined(__aarch64__)
+// TODO: This is wrong for AArch64.
+
+typedef struct {
+ unsigned long oldmask;
+ unsigned long gregs[16];
+ unsigned long pc, pr, sr;
+ unsigned long gbr, mach, macl;
+ unsigned long fpregs[16];
+ unsigned long xfpregs[16];
+ unsigned int fpscr, fpul, ownedfp;
+} mcontext_t;
+
+typedef struct __ucontext {
+ unsigned long uc_flags;
+ struct __ucontext *uc_link;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ sigset_t uc_sigmask;
+} ucontext_t;
+
+#else
+#error "Missing architecture specific code."
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _ABIBITS_SIGNAL_H
diff --git a/lib/mlibc/abis/ironclad/socket.h b/lib/mlibc/abis/ironclad/socket.h
new file mode 100644
index 0000000..48b8178
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/socket.h
@@ -0,0 +1,165 @@
+#ifndef _ABIBITS_SOCKET_H
+#define _ABIBITS_SOCKET_H
+
+#include <abi-bits/socklen_t.h>
+#include <bits/posix/iovec.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef unsigned int sa_family_t;
+
+struct msghdr {
+ void *msg_name;
+ socklen_t msg_namelen;
+ struct iovec *msg_iov;
+ int msg_iovlen;
+ void *msg_control;
+ socklen_t msg_controllen;
+ int msg_flags;
+};
+
+struct sockaddr_storage {
+ sa_family_t ss_family;
+ char __padding[128 - sizeof(sa_family_t)];
+};
+
+struct mmsghdr {
+ struct msghdr msg_hdr;
+ unsigned int msg_len;
+};
+
+struct cmsghdr {
+ socklen_t cmsg_len;
+ int cmsg_level;
+ int cmsg_type;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#define SCM_RIGHTS 1
+#define SCM_TIMESTAMP SO_TIMESTAMP
+#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
+
+//MISSING: CMSG_DATA, CMSG_NXTHDR, CMSG_FIRSTHDR
+
+#define SCM_CREDENTIALS 0x02
+
+#define SOCK_DGRAM 1
+#define SOCK_RAW 2
+#define SOCK_SEQPACKET 3
+#define SOCK_STREAM 4
+#define SOCK_DCCP 5
+#define SOCK_NONBLOCK 0x10000
+#define SOCK_CLOEXEC 0x20000
+#define SOCK_RDM 0x40000
+
+#define SOL_SOCKET 1
+#define SOL_IPV6 41
+#define SOL_PACKET 263
+#define SOL_NETLINK 270
+
+#define SO_ACCEPTCONN 1
+#define SO_BROADCAST 2
+#define SO_DEBUG 3
+#define SO_DONTROUTE 4
+#define SO_ERROR 5
+#define SO_KEEPALIVE 6
+#define SO_LINGER 7
+#define SO_OOBINLINE 8
+#define SO_RCVBUF 9
+#define SO_RCVLOWAT 10
+#define SO_RCVTIMEO 11
+#define SO_REUSEADDR 12
+#define SO_SNDBUF 13
+#define SO_SNDLOWAT 14
+#define SO_SNDTIMEO 15
+#define SO_TYPE 16
+#define SO_SNDBUFFORCE 17
+#define SO_PEERCRED 18
+#define SO_ATTACH_FILTER 19
+#define SO_PASSCRED 20
+#define SO_RCVBUFFORCE 21
+#define SO_DETACH_FILTER 22
+#define SO_PROTOCOL 23
+#define SO_REUSEPORT 24
+#define SO_TIMESTAMP 25
+#define SO_PEERSEC 26
+#define SO_BINDTODEVICE 27
+#define SO_DOMAIN 28
+#define SO_PASSSEC 29
+#define SO_TIMESTAMPNS 30
+#define SO_PRIORITY 31
+#define SO_MARK 32
+
+#define SOMAXCONN 1
+
+#define MSG_CTRUNC 0x1
+#define MSG_DONTROUTE 0x2
+#define MSG_EOR 0x4
+#define MSG_OOB 0x8
+#define MSG_NOSIGNAL 0x10
+#define MSG_PEEK 0x20
+#define MSG_TRUNC 0x40
+#define MSG_WAITALL 0x80
+#define MSG_FIN 0x200
+#define MSG_CONFIRM 0x800
+
+// Linux extensions.
+#define MSG_DONTWAIT 0x1000
+#define MSG_CMSG_CLOEXEC 0x2000
+#define MSG_MORE 0x4000
+#define MSG_FASTOPEN 0x20000000
+
+// GNU (?) extension: Protocol family constants.
+
+#define PF_INET 1
+#define PF_INET6 2
+#define PF_UNIX 3
+#define PF_LOCAL 3
+#define PF_UNSPEC 4
+#define PF_NETLINK 5
+#define PF_BRIDGE 6
+#define PF_APPLETALK 7
+#define PF_BLUETOOTH 8
+#define PF_DECnet 9
+#define PF_IPX 10
+#define PF_ISDN 11
+#define PF_SNA 12
+#define PF_PACKET 13
+#define PF_AX25 14
+#define PF_NETROM 15
+#define PF_ROSE 16
+#define PF_TIPC 30
+#define PF_ALG 38
+#define PF_MAX 46
+
+#define AF_INET PF_INET
+#define AF_INET6 PF_INET6
+#define AF_UNIX PF_UNIX
+#define AF_LOCAL PF_LOCAL
+#define AF_UNSPEC PF_UNSPEC
+#define AF_NETLINK PF_NETLINK
+#define AF_BRIDGE PF_BRIDGE
+#define AF_APPLETALK PF_APPLETALK
+#define AF_BLUETOOTH PF_BLUETOOTH
+#define AF_DECnet PF_DECnet
+#define AF_IPX PF_IPX
+#define AF_ISDN PF_ISDN
+#define AF_SNA PF_SNA
+#define AF_PACKET PF_PACKET
+#define AF_PACKET PF_PACKET
+#define AF_AX25 PF_AX25
+#define AF_NETROM PF_NETROM
+#define AF_ROSE PF_ROSE
+#define AF_TIPC PF_TIPC
+#define AF_ALG PF_ALG
+#define AF_MAX PF_MAX
+
+#define SHUT_RD 1
+#define SHUT_RDWR 2
+#define SHUT_WR 3
+#endif
diff --git a/lib/mlibc/abis/ironclad/socklen_t.h b/lib/mlibc/abis/ironclad/socklen_t.h
new file mode 100644
index 0000000..190e5f9
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/socklen_t.h
@@ -0,0 +1,6 @@
+#ifndef _ABIBITS_SOCKLEN_T_H
+#define _ABIBITS_SOCKLEN_T_H
+
+typedef unsigned socklen_t;
+
+#endif /* _ABIBITS_SOCKLEN_T_H */
diff --git a/lib/mlibc/abis/ironclad/stat.h b/lib/mlibc/abis/ironclad/stat.h
new file mode 100644
index 0000000..3f55970
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/stat.h
@@ -0,0 +1,69 @@
+#ifndef _ABIBITS_STAT_H
+#define _ABIBITS_STAT_H
+
+#include <abi-bits/uid_t.h>
+#include <abi-bits/gid_t.h>
+#include <bits/off_t.h>
+#include <abi-bits/mode_t.h>
+#include <abi-bits/dev_t.h>
+#include <abi-bits/ino_t.h>
+#include <abi-bits/blksize_t.h>
+#include <abi-bits/blkcnt_t.h>
+#include <abi-bits/nlink_t.h>
+#include <bits/ansi/time_t.h>
+#include <bits/ansi/timespec.h>
+
+#define S_IFMT 0x0F000
+#define S_IFBLK 0x06000
+#define S_IFCHR 0x02000
+#define S_IFIFO 0x01000
+#define S_IFREG 0x08000
+#define S_IFDIR 0x04000
+#define S_IFLNK 0x0A000
+#define S_IFSOCK 0x0C000
+
+#define S_IRWXU 0700
+#define S_IRUSR 0400
+#define S_IWUSR 0200
+#define S_IXUSR 0100
+#define S_IRWXG 070
+#define S_IRGRP 040
+#define S_IWGRP 020
+#define S_IXGRP 010
+#define S_IRWXO 07
+#define S_IROTH 04
+#define S_IWOTH 02
+#define S_IXOTH 01
+#define S_ISUID 04000
+#define S_ISGID 02000
+#define S_ISVTX 01000
+
+#define S_IREAD S_IRUSR
+#define S_IWRITE S_IWUSR
+#define S_IEXEC S_IXUSR
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct stat {
+ dev_t st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ nlink_t st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ dev_t st_rdev;
+ off_t st_size;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ blksize_t st_blksize;
+ blkcnt_t st_blocks;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _ABIBITS_STAT_H
diff --git a/lib/mlibc/abis/ironclad/statfs.h b/lib/mlibc/abis/ironclad/statfs.h
new file mode 100644
index 0000000..60c977f
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/statfs.h
@@ -0,0 +1,28 @@
+#ifndef _ABIBITS_STATFS_H
+#define _ABIBITS_STATFS_H
+
+#include <abi-bits/fsblkcnt_t.h>
+#include <abi-bits/fsfilcnt_t.h>
+
+typedef struct __mlibc_fsid {
+ int __val[2];
+} fsid_t;
+
+struct statfs {
+ unsigned long f_type;
+ unsigned long f_bsize;
+ fsblkcnt_t f_blocks;
+ fsblkcnt_t f_bfree;
+ fsblkcnt_t f_bavail;
+
+ fsfilcnt_t f_files;
+ fsfilcnt_t f_ffree;
+ fsid_t f_fsid;
+ unsigned long f_namelen;
+ unsigned long f_frsize;
+ unsigned long f_flags;
+ unsigned long __f_spare[4];
+};
+
+#endif /* _ABIBITS_STATFS_H */
+
diff --git a/lib/mlibc/abis/ironclad/statvfs.h b/lib/mlibc/abis/ironclad/statvfs.h
new file mode 100644
index 0000000..d4fc416
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/statvfs.h
@@ -0,0 +1,30 @@
+#ifndef _ABIBITS_STATVFS_H
+#define _ABIBITS_STATVFS_H
+
+#include <abi-bits/fsblkcnt_t.h>
+#include <abi-bits/fsfilcnt_t.h>
+
+#define ST_RDONLY 1
+#define ST_NOSUID 2
+#define ST_MANDLOCK 64
+
+// On Linux, this struct is not directly used by the kernel.
+struct statvfs {
+ unsigned long f_bsize;
+ unsigned long f_frsize;
+ fsblkcnt_t f_blocks;
+ fsblkcnt_t f_bfree;
+ fsblkcnt_t f_bavail;
+
+ fsfilcnt_t f_files;
+ fsfilcnt_t f_ffree;
+ fsfilcnt_t f_favail;
+
+ unsigned long f_fsid;
+ unsigned long f_flag;
+ unsigned long f_namemax;
+ char f_basetype[80];
+};
+
+#endif /* _ABIBITS_STATVFS_H */
+
diff --git a/lib/mlibc/abis/ironclad/suseconds_t.h b/lib/mlibc/abis/ironclad/suseconds_t.h
new file mode 100644
index 0000000..723ddfa
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/suseconds_t.h
@@ -0,0 +1,8 @@
+#ifndef _ABIBITS_SUSECONDS_T_H
+#define _ABIBITS_SUSECONDS_T_H
+
+#include <bits/types.h>
+
+typedef __mlibc_int64 suseconds_t;
+
+#endif /* _ABIBITS_SUSECONDS_T_H */
diff --git a/lib/mlibc/abis/ironclad/termios.h b/lib/mlibc/abis/ironclad/termios.h
new file mode 100644
index 0000000..4dd5987
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/termios.h
@@ -0,0 +1,116 @@
+#ifndef _ABIBITS_TERMIOS_H
+#define _ABIBITS_TERMIOS_H
+
+typedef unsigned int cc_t;
+typedef unsigned int speed_t;
+typedef unsigned int tcflag_t;
+
+// indices for the c_cc array in struct termios
+#define NCCS 11
+#define VEOF 0
+#define VEOL 1
+#define VERASE 2
+#define VINTR 3
+#define VKILL 4
+#define VMIN 5
+#define VQUIT 6
+#define VSTART 7
+#define VSTOP 8
+#define VSUSP 9
+#define VTIME 10
+
+// bitwise flags for c_iflag in struct termios
+#define BRKINT 0x0001
+#define ICRNL 0x0002
+#define IGNBRK 0x0004
+#define IGNCR 0x0008
+#define IGNPAR 0x0010
+#define INLCR 0x0020
+#define INPCK 0x0040
+#define ISTRIP 0x0080
+#define IXANY 0x0100
+#define IXOFF 0x0200
+#define IXON 0x0400
+#define PARMRK 0x0800
+#define ECHOCTL 0001000
+#define IMAXBEL 0020000
+#define ECHOKE 0004000
+
+// bitwise flags for c_oflag in struct termios
+#define OPOST 0x0001
+#define ONLCR 0x0002
+#define OCRNL 0x0004
+#define ONOCR 0x0008
+#define ONLRET 0x0010
+#define OFDEL 0x0020
+#define OFILL 0x0040
+
+#define NLDLY 0x0080
+#define NL0 0x0000
+#define NL1 0x0080
+
+#define CRDLY 0x0300
+#define CR0 0x0000
+#define CR1 0x0100
+#define CR2 0x0200
+#define CR3 0x0300
+
+#define TABDLY 0x0C00
+#define TAB0 0x0000
+#define TAB1 0x0400
+#define TAB2 0x0800
+#define TAB3 0x0C00
+
+#define BSDLY 0x1000
+#define BS0 0x0000
+#define BS1 0x1000
+
+#define VTDLY 0x2000
+#define VT0 0x0000
+#define VT1 0x2000
+
+#define FFDLY 0x4000
+#define FF0 0x0000
+#define FF1 0x4000
+
+// bitwise constants for c_cflag in struct termios
+#define CSIZE 0x0003
+#define CS5 0x0000
+#define CS6 0x0001
+#define CS7 0x0002
+#define CS8 0x0003
+
+#define CSTOPB 0x0004
+#define CREAD 0x0008
+#define PARENB 0x0010
+#define PARODD 0x0020
+#define HUPCL 0x0040
+#define CLOCAL 0x0080
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define CBAUD 0x100F
+#endif
+
+// bitwise constants for c_lflag in struct termios
+#define ECHO 0x0001
+#define ECHOE 0x0002
+#define ECHOK 0x0004
+#define ECHONL 0x0008
+#define ICANON 0x0010
+#define IEXTEN 0x0020
+#define ISIG 0x0040
+#define NOFLSH 0x0080
+#define TOSTOP 0x0100
+#define ECHOPRT 0x0200
+
+struct termios {
+ tcflag_t c_iflag;
+ tcflag_t c_oflag;
+ tcflag_t c_cflag;
+ tcflag_t c_lflag;
+ cc_t c_cc[NCCS];
+ speed_t ibaud;
+ speed_t obaud;
+};
+
+#endif
diff --git a/lib/mlibc/abis/ironclad/time.h b/lib/mlibc/abis/ironclad/time.h
new file mode 100644
index 0000000..3f49db3
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/time.h
@@ -0,0 +1,15 @@
+#ifndef _ABIBITS_TIME_H
+#define _ABIBITS_TIME_H
+
+#include <bits/posix/timeval.h>
+
+struct itimerval {
+ struct timeval it_interval; /* Interval for periodic timer */
+ struct timeval it_value; /* Time until next expiration */
+};
+
+#define ITIMER_REAL 0
+#define ITIMER_VIRTUAL 1
+#define ITIMER_PROF 2
+
+#endif // _ABIBITS_TIME_H
diff --git a/lib/mlibc/abis/ironclad/uid_t.h b/lib/mlibc/abis/ironclad/uid_t.h
new file mode 100644
index 0000000..1688d07
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/uid_t.h
@@ -0,0 +1,6 @@
+#ifndef _ABIBITS_UID_T_H
+#define _ABIBITS_UID_T_H
+
+typedef unsigned int uid_t;
+
+#endif // _ABIBITS_UID_T_H
diff --git a/lib/mlibc/abis/ironclad/utsname.h b/lib/mlibc/abis/ironclad/utsname.h
new file mode 100644
index 0000000..2cd2226
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/utsname.h
@@ -0,0 +1,12 @@
+#ifndef _ABIBITS_UTSNAME_T_H
+#define _ABIBITS_UTSNAME_T_H
+
+struct utsname {
+ char sysname[65];
+ char nodename[65];
+ char release[65];
+ char version[65];
+ char machine[65];
+};
+
+#endif // _ABIBITS_UTSNAME_T_H
diff --git a/lib/mlibc/abis/ironclad/vm-flags.h b/lib/mlibc/abis/ironclad/vm-flags.h
new file mode 100644
index 0000000..a686cd3
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/vm-flags.h
@@ -0,0 +1,46 @@
+#ifndef _ABIBITS_MMAP_FLAGS_H
+#define _ABIBITS_MMAP_FLAGS_H
+
+#define PROT_NONE 0x00
+#define PROT_READ 0x01
+#define PROT_WRITE 0x02
+#define PROT_EXEC 0x04
+
+#define MAP_FAILED ((void *)(-1))
+#define MAP_FILE 0x00
+#define MAP_PRIVATE 0x01
+#define MAP_SHARED 0x02
+#define MAP_FIXED 0x04
+#define MAP_ANON 0x08
+#define MAP_ANONYMOUS 0x08
+#define MAP_NORESERVE 0x10
+#define MAP_WC 0b10000
+
+#define MS_ASYNC 0x01
+#define MS_SYNC 0x02
+#define MS_INVALIDATE 0x04
+
+#define MCL_CURRENT 0x01
+#define MCL_FUTURE 0x02
+
+#define POSIX_MADV_NORMAL 1
+#define POSIX_MADV_SEQUENTIAL 2
+#define POSIX_MADV_RANDOM 3
+#define POSIX_MADV_DONTNEED 4
+#define POSIX_MADV_WILLNEED 5
+
+#define MADV_NORMAL 0
+#define MADV_RANDOM 1
+#define MADV_SEQUENTIAL 2
+#define MADV_WILLNEED 3
+#define MADV_DONTNEED 4
+#define MADV_FREE 8
+
+// Linux extensions:
+#define MREMAP_MAYMOVE 1
+#define MREMAP_FIXED 2
+
+#define MFD_CLOEXEC 1U
+#define MFD_ALLOW_SEALING 2U
+
+#endif // _ABIBITS_MMAP_FLAGS_H
diff --git a/lib/mlibc/abis/ironclad/wait.h b/lib/mlibc/abis/ironclad/wait.h
new file mode 100644
index 0000000..5aa6bb8
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/wait.h
@@ -0,0 +1,25 @@
+#ifndef _ABIBITS_WAIT_H
+#define _ABIBITS_WAIT_H
+
+#define WCONTINUED 1
+#define WNOHANG 2
+#define WUNTRACED 4
+#define WEXITED 8
+#define WNOWAIT 16
+#define WSTOPPED 32
+
+#define __WALL 0x40000000
+#define __WCLONE 0x80000000
+
+#define WCOREFLAG 0x80
+
+#define WEXITSTATUS(x) ((x) & 0x000000FF)
+#define WIFCONTINUED(x) ((x) & 0x00000100)
+#define WIFEXITED(x) ((x) & 0x00000200)
+#define WIFSIGNALED(x) ((x) & 0x00000400)
+#define WIFSTOPPED(x) ((x) & 0x00000800)
+#define WSTOPSIG(x) (((x) & 0x00FF0000) >> 16)
+#define WTERMSIG(x) (((x) & 0xFF000000) >> 24)
+#define WCOREDUMP(x) ((x) & WCOREFLAG)
+
+#endif //_ABIBITS_WAIT_H
diff --git a/lib/mlibc/abis/ironclad/xattr.h b/lib/mlibc/abis/ironclad/xattr.h
new file mode 100644
index 0000000..c0e7fbe
--- /dev/null
+++ b/lib/mlibc/abis/ironclad/xattr.h
@@ -0,0 +1,21 @@
+#ifndef MLIBC_ABIS_LINUX_XATTR_H
+#define MLIBC_ABIS_LINUX_XATTR_H
+
+/* __USE_KERNEL_XATTR_DEFS is exported when XATTR_* are emitted, and
+ * __UAPI_DEF_XATTR is used to determine the behaviour of the
+ * <linux/xattr.h> header (through <linux/libc-compat.h>), if it's set
+ * to 1, the header exports xattr defines and __USE_KERNEL_XATTR_DEFS.
+ * This applies for pretty much all other defines in libc-compat.h
+ * AFAICT.
+ */
+#ifndef __USE_KERNEL_XATTR_DEFS
+enum {
+ XATTR_CREATE = 1,
+#define XATTR_CREATE XATTR_CREATE
+ XATTR_REPLACE = 2,
+#define XATTR_REPLACE XATTR_REPLACE
+};
+# define __UAPI_DEF_XATTR 0
+#endif
+
+#endif /* MLIBC_ABIS_LINUX_XATTR_H */
diff --git a/lib/mlibc/abis/lemon/auxv.h b/lib/mlibc/abis/lemon/auxv.h
new file mode 100644
index 0000000..da7a438
--- /dev/null
+++ b/lib/mlibc/abis/lemon/auxv.h
@@ -0,0 +1,9 @@
+#ifndef _ABIBITS_AUXV_H
+#define _ABIBITS_AUXV_H
+
+#define AT_EXECPATH 15
+#define AT_SECURE 23
+#define AT_RANDOM 25
+#define AT_EXECFN 31
+
+#endif
diff --git a/lib/mlibc/abis/linux/access.h b/lib/mlibc/abis/linux/access.h
new file mode 100644
index 0000000..f76ca62
--- /dev/null
+++ b/lib/mlibc/abis/linux/access.h
@@ -0,0 +1,9 @@
+#ifndef _ABIBITS_ACCESS_H
+#define _ABIBITS_ACCESS_H
+
+#define F_OK 0
+#define X_OK 1
+#define W_OK 2
+#define R_OK 4
+
+#endif // _ABIBITS_ACCESS_H
diff --git a/lib/mlibc/abis/linux/auxv.h b/lib/mlibc/abis/linux/auxv.h
new file mode 100644
index 0000000..8eb8049
--- /dev/null
+++ b/lib/mlibc/abis/linux/auxv.h
@@ -0,0 +1,13 @@
+#ifndef _ABIBITS_AUXV_H
+#define _ABIBITS_AUXV_H
+
+#define AT_PLATFORM 15
+#define AT_HWCAP 16
+#define AT_CLKTCK 17
+#define AT_FPUCW 18
+#define AT_SECURE 23
+#define AT_RANDOM 25
+#define AT_EXECFN 31
+#define AT_SYSINFO_EHDR 33
+
+#endif // _ABIBITS_AUXV_H
diff --git a/lib/mlibc/abis/linux/blkcnt_t.h b/lib/mlibc/abis/linux/blkcnt_t.h
new file mode 100644
index 0000000..c4b4505
--- /dev/null
+++ b/lib/mlibc/abis/linux/blkcnt_t.h
@@ -0,0 +1,8 @@
+#ifndef _ABIBITS_BLKCNT_T_H
+#define _ABIBITS_BLKCNT_T_H
+
+#include <bits/types.h>
+
+typedef __mlibc_int64 blkcnt_t;
+
+#endif // _ABIBITS_BLKCNT_T_H
diff --git a/lib/mlibc/abis/linux/blksize_t.h b/lib/mlibc/abis/linux/blksize_t.h
new file mode 100644
index 0000000..afabadb
--- /dev/null
+++ b/lib/mlibc/abis/linux/blksize_t.h
@@ -0,0 +1,8 @@
+
+#ifndef _ABIBITS_BLKSIZE_T_H
+#define _ABIBITS_BLKSIZE_T_H
+
+typedef long blksize_t;
+
+#endif // _ABIBITS_BLKSIZE_T_H
+
diff --git a/lib/mlibc/abis/linux/clockid_t.h b/lib/mlibc/abis/linux/clockid_t.h
new file mode 100644
index 0000000..8d92826
--- /dev/null
+++ b/lib/mlibc/abis/linux/clockid_t.h
@@ -0,0 +1,7 @@
+#ifndef _ABIBITS_CLOCKID_T_H
+#define _ABIBITS_CLOCKID_T_H
+
+typedef int clockid_t;
+
+#endif /* _ABIBITS_CLOCKID_T_H */
+
diff --git a/lib/mlibc/abis/linux/dev_t.h b/lib/mlibc/abis/linux/dev_t.h
new file mode 100644
index 0000000..839a445
--- /dev/null
+++ b/lib/mlibc/abis/linux/dev_t.h
@@ -0,0 +1,10 @@
+
+#ifndef _ABIBITS_DEV_T_H
+#define _ABIBITS_DEV_T_H
+
+#include <bits/types.h>
+
+typedef __mlibc_uint64 dev_t;
+
+#endif // _ABIBITS_DEV_T_H
+
diff --git a/lib/mlibc/abis/linux/epoll.h b/lib/mlibc/abis/linux/epoll.h
new file mode 100644
index 0000000..0b984b6
--- /dev/null
+++ b/lib/mlibc/abis/linux/epoll.h
@@ -0,0 +1,6 @@
+#ifndef _ABIBITS_EPOLL_H
+#define _ABIBITS_EPOLL_H
+
+#define EPOLL_CLOEXEC 02000000 // Same as __MLIBC_O_CLOEXEC
+
+#endif // _ABIBITS_EPOLL_H
diff --git a/lib/mlibc/abis/linux/errno.h b/lib/mlibc/abis/linux/errno.h
new file mode 100644
index 0000000..b2680e3
--- /dev/null
+++ b/lib/mlibc/abis/linux/errno.h
@@ -0,0 +1,143 @@
+#ifndef _ABIBITS_ERRNO_H
+#define _ABIBITS_ERRNO_H
+
+#define EPERM 1
+#define ENOENT 2
+#define ESRCH 3
+#define EINTR 4
+#define EIO 5
+#define ENXIO 6
+#define E2BIG 7
+#define ENOEXEC 8
+#define EBADF 9
+#define ECHILD 10
+#define EAGAIN 11
+#define ENOMEM 12
+#define EACCES 13
+#define EFAULT 14
+#define ENOTBLK 15
+#define EBUSY 16
+#define EEXIST 17
+#define EXDEV 18
+#define ENODEV 19
+#define ENOTDIR 20
+#define EISDIR 21
+#define EINVAL 22
+#define ENFILE 23
+#define EMFILE 24
+#define ENOTTY 25
+#define ETXTBSY 26
+#define EFBIG 27
+#define ENOSPC 28
+#define ESPIPE 29
+#define EROFS 30
+#define EMLINK 31
+#define EPIPE 32
+#define EDOM 33
+#define ERANGE 34
+#define EDEADLK 35
+#define ENAMETOOLONG 36
+#define ENOLCK 37
+#define ENOSYS 38
+#define ENOTEMPTY 39
+#define ELOOP 40
+#define EWOULDBLOCK EAGAIN
+#define ENOMSG 42
+#define EIDRM 43
+#define ECHRNG 44
+#define EL2NSYNC 45
+#define EL3HLT 46
+#define EL3RST 47
+#define ELNRNG 48
+#define EUNATCH 49
+#define ENOCSI 50
+#define EL2HLT 51
+#define EBADE 52
+#define EBADR 53
+#define EXFULL 54
+#define ENOANO 55
+#define EBADRQC 56
+#define EBADSLT 57
+#define EDEADLOCK EDEADLK
+#define EBFONT 59
+#define ENOSTR 60
+#define ENODATA 61
+#define ETIME 62
+#define ENOSR 63
+#define ENONET 64
+#define ENOPKG 65
+#define EREMOTE 66
+#define ENOLINK 67
+#define EADV 68
+#define ESRMNT 69
+#define ECOMM 70
+#define EPROTO 71
+#define EMULTIHOP 72
+#define EDOTDOT 73
+#define EBADMSG 74
+#define EOVERFLOW 75
+#define ENOTUNIQ 76
+#define EBADFD 77
+#define EREMCHG 78
+#define ELIBACC 79
+#define ELIBBAD 80
+#define ELIBSCN 81
+#define ELIBMAX 82
+#define ELIBEXEC 83
+#define EILSEQ 84
+#define ERESTART 85
+#define ESTRPIPE 86
+#define EUSERS 87
+#define ENOTSOCK 88
+#define EDESTADDRREQ 89
+#define EMSGSIZE 90
+#define EPROTOTYPE 91
+#define ENOPROTOOPT 92
+#define EPROTONOSUPPORT 93
+#define ESOCKTNOSUPPORT 94
+#define EOPNOTSUPP 95
+#define ENOTSUP EOPNOTSUPP
+#define EPFNOSUPPORT 96
+#define EAFNOSUPPORT 97
+#define EADDRINUSE 98
+#define EADDRNOTAVAIL 99
+#define ENETDOWN 100
+#define ENETUNREACH 101
+#define ENETRESET 102
+#define ECONNABORTED 103
+#define ECONNRESET 104
+#define ENOBUFS 105
+#define EISCONN 106
+#define ENOTCONN 107
+#define ESHUTDOWN 108
+#define ETOOMANYREFS 109
+#define ETIMEDOUT 110
+#define ECONNREFUSED 111
+#define EHOSTDOWN 112
+#define EHOSTUNREACH 113
+#define EALREADY 114
+#define EINPROGRESS 115
+#define ESTALE 116
+#define EUCLEAN 117
+#define ENOTNAM 118
+#define ENAVAIL 119
+#define EISNAM 120
+#define EREMOTEIO 121
+#define EDQUOT 122
+#define ENOMEDIUM 123
+#define EMEDIUMTYPE 124
+#define ECANCELED 125
+#define ENOKEY 126
+#define EKEYEXPIRED 127
+#define EKEYREVOKED 128
+#define EKEYREJECTED 129
+#define EOWNERDEAD 130
+#define ENOTRECOVERABLE 131
+#define ERFKILL 132
+#define EHWPOISON 133
+
+
+// This is mlibc-specific.
+#define EIEIO 4095
+
+#endif // _ABIBITS_ERRNO_H
diff --git a/lib/mlibc/abis/linux/fcntl.h b/lib/mlibc/abis/linux/fcntl.h
new file mode 100644
index 0000000..35be979
--- /dev/null
+++ b/lib/mlibc/abis/linux/fcntl.h
@@ -0,0 +1,89 @@
+#ifndef _ABIBITS_FCNTL_H
+#define _ABIBITS_FCNTL_H
+
+#include <abi-bits/pid_t.h>
+
+#define O_PATH 010000000
+
+#define O_ACCMODE (03 | O_PATH)
+#define O_RDONLY 00
+#define O_WRONLY 01
+#define O_RDWR 02
+
+#define O_CREAT 0100
+#define O_EXCL 0200
+#define O_NOCTTY 0400
+#define O_TRUNC 01000
+#define O_APPEND 02000
+#define O_NONBLOCK 04000
+#define O_DSYNC 010000
+#define O_ASYNC 020000
+#define O_DIRECT 040000
+#define O_DIRECTORY 0200000
+#define O_NOFOLLOW 0400000
+#define O_CLOEXEC 02000000
+#define O_SYNC 04010000
+#define O_RSYNC 04010000
+#define O_LARGEFILE 0100000
+#define O_NOATIME 01000000
+#define O_TMPFILE 020000000
+
+#define O_EXEC O_PATH
+#define O_SEARCH O_PATH
+
+#define F_DUPFD 0
+#define F_GETFD 1
+#define F_SETFD 2
+#define F_GETFL 3
+#define F_SETFL 4
+
+#define F_SETOWN 8
+#define F_GETOWN 9
+#define F_SETSIG 10
+#define F_GETSIG 11
+
+#define F_GETLK 5
+#define F_SETLK 6
+#define F_SETLKW 7
+
+#define F_SETOWN_EX 15
+#define F_GETOWN_EX 16
+
+#define F_GETOWNER_UIDS 17
+
+#define F_DUPFD_CLOEXEC 1030
+#define F_ADD_SEALS 1033
+#define F_GET_SEALS 1034
+
+#define F_SEAL_SEAL 0x0001
+#define F_SEAL_SHRINK 0x0002
+#define F_SEAL_GROW 0x0004
+#define F_SEAL_WRITE 0x0008
+
+#define F_RDLCK 0
+#define F_WRLCK 1
+#define F_UNLCK 2
+
+#define FD_CLOEXEC 1
+
+#define AT_FDCWD -100
+#define AT_SYMLINK_NOFOLLOW 0x100
+#define AT_REMOVEDIR 0x200
+#define AT_SYMLINK_FOLLOW 0x400
+#define AT_EACCESS 0x200
+#define AT_EMPTY_PATH 0x1000
+
+
+struct f_owner_ex {
+ int type;
+ pid_t pid;
+};
+
+#define POSIX_FADV_NORMAL 0
+#define POSIX_FADV_RANDOM 1
+#define POSIX_FADV_SEQUENTIAL 2
+#define POSIX_FADV_WILLNEED 3
+#define POSIX_FADV_DONTNEED 4
+#define POSIX_FADV_NOREUSE 5
+
+#endif // _ABIBITS_FCNTL_H
diff --git a/lib/mlibc/abis/linux/fsblkcnt_t.h b/lib/mlibc/abis/linux/fsblkcnt_t.h
new file mode 100644
index 0000000..0d74456
--- /dev/null
+++ b/lib/mlibc/abis/linux/fsblkcnt_t.h
@@ -0,0 +1,8 @@
+#ifndef _ABIBITS_FSBLKCNT_T_H
+#define _ABIBITS_FSBLKCNT_T_H
+
+#include <bits/types.h>
+
+typedef __mlibc_uint64 fsblkcnt_t;
+
+#endif /* _ABIBITS_FSBLKCNT_T_H */
diff --git a/lib/mlibc/abis/linux/fsfilcnt_t.h b/lib/mlibc/abis/linux/fsfilcnt_t.h
new file mode 100644
index 0000000..1abda9a
--- /dev/null
+++ b/lib/mlibc/abis/linux/fsfilcnt_t.h
@@ -0,0 +1,8 @@
+#ifndef _ABIBITS_FSFILCNT_T_H
+#define _ABIBITS_FSFILCNT_T_H
+
+#include <bits/types.h>
+
+typedef __mlibc_uint64 fsfilcnt_t;
+
+#endif /* _ABIBITS_FSFILCNT_T_H */
diff --git a/lib/mlibc/abis/linux/gid_t.h b/lib/mlibc/abis/linux/gid_t.h
new file mode 100644
index 0000000..65afa40
--- /dev/null
+++ b/lib/mlibc/abis/linux/gid_t.h
@@ -0,0 +1,8 @@
+
+#ifndef _ABIBITS_GID_T_H
+#define _ABIBITS_GID_T_H
+
+typedef unsigned int gid_t;
+
+#endif // _ABIBITS_GID_T_H
+
diff --git a/lib/mlibc/abis/linux/in.h b/lib/mlibc/abis/linux/in.h
new file mode 100644
index 0000000..eb7be7b
--- /dev/null
+++ b/lib/mlibc/abis/linux/in.h
@@ -0,0 +1,217 @@
+#ifndef _ABIBITS_IN_H
+#define _ABIBITS_IN_H
+
+#include <bits/posix/in_addr_t.h>
+#include <bits/posix/in_port_t.h>
+#include <abi-bits/socket.h>
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct in_addr {
+ in_addr_t s_addr;
+};
+
+struct sockaddr_in {
+ sa_family_t sin_family;
+ in_port_t sin_port;
+ struct in_addr sin_addr;
+ uint8_t sin_zero[8];
+};
+
+struct in6_addr {
+ union {
+ uint8_t __s6_addr[16];
+ uint16_t __s6_addr16[8];
+ uint32_t __s6_addr32[4];
+ } __in6_union;
+};
+#define s6_addr __in6_union.__s6_addr
+#define s6_addr16 __in6_union.__s6_addr16
+#define s6_addr32 __in6_union.__s6_addr32
+
+struct sockaddr_in6 {
+ sa_family_t sin6_family;
+ in_port_t sin6_port;
+ uint32_t sin6_flowinfo;
+ struct in6_addr sin6_addr;
+ uint32_t sin6_scope_id;
+};
+
+#define MCAST_INCLUDE 1
+
+struct ip_mreq {
+ struct in_addr imr_multiaddr;
+ struct in_addr imr_interface;
+};
+
+struct ip_mreq_source {
+ struct in_addr imr_multiaddr;
+ struct in_addr imr_interface;
+ struct in_addr imr_sourceaddr;
+};
+
+struct ip_mreqn {
+ struct in_addr imr_multiaddr;
+ struct in_addr imr_address;
+ int imr_ifindex;
+};
+
+struct ipv6_mreq {
+ struct in6_addr ipv6mr_multiaddr;
+ unsigned ipv6mr_interface;
+};
+
+struct in_pktinfo {
+ unsigned int ipi_ifindex;
+ struct in_addr ipi_spec_dst;
+ struct in_addr ipi_addr;
+};
+
+struct in6_pktinfo {
+ struct in6_addr ipi6_addr;
+ uint32_t ipi6_ifindex;
+};
+
+struct group_req {
+ uint32_t gr_interface;
+ struct sockaddr_storage gr_group;
+};
+
+struct group_source_req {
+ uint32_t gsr_interface;
+ struct sockaddr_storage gsr_group;
+ struct sockaddr_storage gsr_source;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#define INADDR_ANY ((in_addr_t) 0x00000000)
+#define INADDR_BROADCAST ((in_addr_t) 0xffffffff)
+#define INADDR_NONE ((in_addr_t) 0xffffffff)
+#define INADDR_LOOPBACK ((in_addr_t) 0x7f000001)
+
+#define INADDR_UNSPEC_GROUP ((in_addr_t) 0xe0000000)
+#define INADDR_ALLHOSTS_GROUP ((in_addr_t) 0xe0000001)
+#define INADDR_ALLRTRS_GROUP ((in_addr_t) 0xe0000002)
+#define INADDR_ALLSNOOPERS_GROUP ((in_addr_t) 0xe000006a)
+#define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff)
+
+#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
+#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
+
+#define INET_ADDRSTRLEN 16
+#define INET6_ADDRSTRLEN 46
+
+#define IPPORT_RESERVED 1024
+
+#define IPPROTO_IP 0
+#define IPPROTO_HOPOPTS 0
+#define IPPROTO_ICMP 1
+#define IPPROTO_IGMP 2
+#define IPPROTO_IPIP 4
+#define IPPROTO_TCP 6
+#define IPPROTO_EGP 8
+#define IPPROTO_PUP 12
+#define IPPROTO_UDP 17
+#define IPPROTO_IDP 22
+#define IPPROTO_TP 29
+#define IPPROTO_DCCP 33
+#define IPPROTO_IPV6 41
+#define IPPROTO_ROUTING 43
+#define IPPROTO_FRAGMENT 44
+#define IPPROTO_RSVP 46
+#define IPPROTO_GRE 47
+#define IPPROTO_ESP 50
+#define IPPROTO_AH 51
+#define IPPROTO_ICMPV6 58
+#define IPPROTO_NONE 59
+#define IPPROTO_DSTOPTS 60
+#define IPPROTO_MTP 92
+#define IPPROTO_BEETPH 94
+#define IPPROTO_ENCAP 98
+#define IPPROTO_PIM 103
+#define IPPROTO_COMP 108
+#define IPPROTO_SCTP 132
+#define IPPROTO_MH 135
+#define IPPROTO_UDPLITE 136
+#define IPPROTO_MPLS 137
+#define IPPROTO_RAW 255
+#define IPPROTO_MAX 256
+
+#define IP_TOS 1
+#define IP_TTL 2
+#define IP_HDRINCL 3
+#define IP_OPTIONS 4
+#define IP_RECVOPTS 6
+#define IP_PKTINFO 8
+#define IP_PKTOPTIONS 9
+#define IP_MTU_DISCOVER 10
+#define IP_RECVERR 11
+#define IP_RECVTTL 12
+#define IP_MTU 14
+#define IP_MULTICAST_IF 32
+#define IP_MULTICAST_TTL 33
+#define IP_MULTICAST_LOOP 34
+#define IP_ADD_MEMBERSHIP 35
+#define IP_DROP_MEMBERSHIP 36
+#define IP_UNBLOCK_SOURCE 37
+#define IP_BLOCK_SOURCE 38
+#define IP_ADD_SOURCE_MEMBERSHIP 39
+#define IP_DROP_SOURCE_MEMBERSHIP 40
+#define IP_UNICAST_IF 50
+
+#define IPV6_2292PKTOPTIONS 6
+#define IPV6_UNICAST_HOPS 16
+#define IPV6_MULTICAST_IF 17
+#define IPV6_MULTICAST_HOPS 18
+#define IPV6_MULTICAST_LOOP 19
+#define IPV6_JOIN_GROUP 20
+#define IPV6_LEAVE_GROUP 21
+#define IPV6_MTU 24
+#define IPV6_RECVERR 25
+#define IPV6_V6ONLY 26
+#define IPV6_RECVPKTINFO 49
+#define IPV6_PKTINFO 50
+#define IPV6_RECVHOPLIMIT 51
+#define IPV6_HOPLIMIT 52
+
+#define IPV6_RECVTCLASS 66
+#define IPV6_TCLASS 67
+
+#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
+#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
+
+#define IP_PMTUDISC_DONT 0
+#define IP_PMTUDISC_WANT 1
+#define IP_PMTUDISC_DO 2
+#define IP_PMTUDISC_PROBE 3
+#define IP_PMTUDISC_INTERFACE 4
+#define IP_PMTUDISC_OMIT 5
+
+#define MCAST_BLOCK_SOURCE 43
+#define MCAST_UNBLOCK_SOURCE 44
+#define MCAST_JOIN_SOURCE_GROUP 46
+#define MCAST_LEAVE_SOURCE_GROUP 47
+
+/* These defines are needed for compatibility with Linux kernel headers. */
+#define __UAPI_DEF_IN_ADDR 0
+#define __UAPI_DEF_IN_IPPROTO 0
+#define __UAPI_DEF_IN_PKTINFO 0
+#define __UAPI_DEF_IP_MREQ 0
+#define __UAPI_DEF_SOCKADDR_IN 0
+#define __UAPI_DEF_IN_CLASS 0
+#define __UAPI_DEF_IN6_ADDR 0
+#define __UAPI_DEF_IN6_ADDR_ALT 0
+#define __UAPI_DEF_SOCKADDR_IN6 0
+#define __UAPI_DEF_IPV6_MREQ 0
+#define __UAPI_DEF_IPPROTO_V6 0
+#define __UAPI_DEF_IPV6_OPTIONS 0
+#define __UAPI_DEF_IN6_PKTINFO 0
+#define __UAPI_DEF_IP6_MTUINFO 0
+
+#endif // _ABITBITS_IN_H
diff --git a/lib/mlibc/abis/linux/ino_t.h b/lib/mlibc/abis/linux/ino_t.h
new file mode 100644
index 0000000..ba076f4
--- /dev/null
+++ b/lib/mlibc/abis/linux/ino_t.h
@@ -0,0 +1,10 @@
+
+#ifndef _ABIBITS_INO_T_H
+#define _ABIBITS_INO_T_H
+
+#include <bits/types.h>
+
+typedef __mlibc_uint64 ino_t;
+
+#endif // _ABIBITS_INO_T_H
+
diff --git a/lib/mlibc/abis/linux/inotify.h b/lib/mlibc/abis/linux/inotify.h
new file mode 100644
index 0000000..4a0bd4c
--- /dev/null
+++ b/lib/mlibc/abis/linux/inotify.h
@@ -0,0 +1,9 @@
+#ifndef _ABIBITS_INOTIFY_H
+#define _ABIBITS_INOTIFY_H
+
+#include <abi-bits/fcntl.h>
+
+#define IN_CLOEXEC O_CLOEXEC
+#define IN_NONBLOCK O_NONBLOCK
+
+#endif // _ABIBITS_INOTIFY_H
diff --git a/lib/mlibc/abis/linux/ioctls.h b/lib/mlibc/abis/linux/ioctls.h
new file mode 100644
index 0000000..3a957bf
--- /dev/null
+++ b/lib/mlibc/abis/linux/ioctls.h
@@ -0,0 +1,15 @@
+#ifndef _ABIBITS_IOCTLS_H
+#define _ABIBITS_IOCTLS_H
+
+#define SIOCPROTOPRIVATE 0x89E0
+#define SIOCGIFNAME 0x8910
+#define SIOCGIFCONF 0x8912
+#define SIOCGIFFLAGS 0x8913
+#define SIOCSIFFLAGS 0x8914
+#define SIOCGIFINDEX 0x8933
+#define SIOCATMARK 0x8905
+#define SIOCGIFHWADDR 0x8927
+#define SIOCGIFBRDADDR 0x8919
+#define SIOCGIFNETMASK 0x891B
+
+#endif /* _ABIBITS_IOCTLS_H */
diff --git a/lib/mlibc/abis/linux/limits.h b/lib/mlibc/abis/linux/limits.h
new file mode 100644
index 0000000..091b14b
--- /dev/null
+++ b/lib/mlibc/abis/linux/limits.h
@@ -0,0 +1,9 @@
+#ifndef _ABIBITS_LIMITS_H
+#define _ABIBITS_LIMITS_H
+
+#define IOV_MAX 1024
+#define LOGIN_NAME_MAX 256
+#define NAME_MAX 255
+#define OPEN_MAX 256
+
+#endif //_ABIBITS_LIMITS_H
diff --git a/lib/mlibc/abis/linux/mode_t.h b/lib/mlibc/abis/linux/mode_t.h
new file mode 100644
index 0000000..8374c12
--- /dev/null
+++ b/lib/mlibc/abis/linux/mode_t.h
@@ -0,0 +1,8 @@
+
+#ifndef _ABIBITS_MODE_T_H
+#define _ABIBITS_MODE_T_H
+
+typedef unsigned int mode_t;
+
+#endif // _ABIBITS_MODE_T_H
+
diff --git a/lib/mlibc/abis/linux/mqueue.h b/lib/mlibc/abis/linux/mqueue.h
new file mode 100644
index 0000000..1e2d3eb
--- /dev/null
+++ b/lib/mlibc/abis/linux/mqueue.h
@@ -0,0 +1,21 @@
+#ifndef _ABIBITS_MQUEUE_H
+#define _ABIBITS_MQUEUE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct mq_attr {
+ long mq_flags;
+ long mq_maxmsg;
+ long mq_msgsize;
+ long mq_curmsgs;
+ long __pad[4];
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ABIBITS_MQUEUE_H */
+
diff --git a/lib/mlibc/abis/linux/msg.h b/lib/mlibc/abis/linux/msg.h
new file mode 100644
index 0000000..5e890c0
--- /dev/null
+++ b/lib/mlibc/abis/linux/msg.h
@@ -0,0 +1,39 @@
+#ifndef _ABIBITS_MSG_H
+#define _ABIBITS_MSG_H
+
+#include <sys/ipc.h>
+#include <bits/ansi/time_t.h>
+#include <bits/types.h>
+#include <abi-bits/pid_t.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(__i386__)
+typedef __mlibc_uint64 msglen_t;
+typedef __mlibc_uint64 msgqnum_t;
+#else
+typedef unsigned long msglen_t;
+typedef unsigned long msgqnum_t;
+#endif
+
+struct msqid_ds {
+ struct ipc_perm msg_perm;
+ time_t msg_stime;
+ time_t msg_rtime;
+ time_t msg_ctime;
+ unsigned long msg_cbytes;
+ msgqnum_t msg_qnum;
+ msglen_t msg_qbytes;
+ pid_t msg_lspid;
+ pid_t msg_lrpid;
+ unsigned long __unused[2];
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ABIBITS_MSG_H */
+
diff --git a/lib/mlibc/abis/linux/nlink_t.h b/lib/mlibc/abis/linux/nlink_t.h
new file mode 100644
index 0000000..e0d9322
--- /dev/null
+++ b/lib/mlibc/abis/linux/nlink_t.h
@@ -0,0 +1,8 @@
+
+#ifndef _ABIBITS_NLINK_T_H
+#define _ABIBITS_NLINK_T_H
+
+typedef unsigned long nlink_t;
+
+#endif // _ABIBITS_NLINK_T_H
+
diff --git a/lib/mlibc/abis/linux/packet.h b/lib/mlibc/abis/linux/packet.h
new file mode 100644
index 0000000..ee1a424
--- /dev/null
+++ b/lib/mlibc/abis/linux/packet.h
@@ -0,0 +1,6 @@
+#ifndef _ABIBITS_PACKET_H
+#define _ABIBITS_PACKET_H
+
+#define PACKET_HOST 0
+
+#endif // _ABIBITS_PACKET_H
diff --git a/lib/mlibc/abis/linux/pid_t.h b/lib/mlibc/abis/linux/pid_t.h
new file mode 100644
index 0000000..323168e
--- /dev/null
+++ b/lib/mlibc/abis/linux/pid_t.h
@@ -0,0 +1,8 @@
+
+#ifndef _ABIBITS_PID_T_H
+#define _ABIBITS_PID_T_H
+
+typedef int pid_t;
+
+#endif // _ABIBITS_PID_T_H
+
diff --git a/lib/mlibc/abis/linux/poll.h b/lib/mlibc/abis/linux/poll.h
new file mode 100644
index 0000000..1585b46
--- /dev/null
+++ b/lib/mlibc/abis/linux/poll.h
@@ -0,0 +1,16 @@
+#ifndef _ABIBITS_POLL_H
+#define _ABIBITS_POLL_H
+
+#define POLLIN 0x0001
+#define POLLPRI 0x0002
+#define POLLOUT 0x0004
+#define POLLERR 0x0008
+#define POLLHUP 0x0010
+#define POLLNVAL 0x0020
+#define POLLRDNORM 0x0040
+#define POLLRDBAND 0x0080
+#define POLLWRNORM 0x0100
+#define POLLWRBAND 0x0200
+#define POLLRDHUP 0x2000
+
+#endif // _ABIBITS_POLL_H
diff --git a/lib/mlibc/abis/linux/ptrace.h b/lib/mlibc/abis/linux/ptrace.h
new file mode 100644
index 0000000..3d73aa1
--- /dev/null
+++ b/lib/mlibc/abis/linux/ptrace.h
@@ -0,0 +1,59 @@
+#ifndef _ABIBITS_PTRACE_H
+#define _ABIBITS_PTRACE_H
+
+#define PTRACE_PEEKTEXT 1
+#define PTRACE_PEEKDATA 2
+#define PTRACE_PEEKUSER 3
+#define PTRACE_POKETEXT 4
+#define PTRACE_POKEDATA 5
+#define PTRACE_POKEUSER 6
+#define PTRACE_CONT 7
+#define PTRACE_KILL 8
+#define PTRACE_SINGLESTEP 9
+#define PTRACE_GETREGS 12
+#define PTRACE_SETREGS 13
+#define PTRACE_GETFPREGS 14
+#define PTRACE_SETFPREGS 15
+#define PTRACE_ATTACH 16
+#define PTRACE_DETACH 17
+#define PTRACE_GETFPXREGS 18
+#define PTRACE_SETFPXREGS 19
+#define PTRACE_SYSCALL 24
+#define PTRACE_SETOPTIONS 0x4200
+#define PTRACE_GETEVENTMSG 0x4201
+#define PTRACE_GETSIGINFO 0x4202
+#define PTRACE_SETSIGINFO 0x4203
+#define PTRACE_GETREGSET 0x4204
+#define PTRACE_SETREGSET 0x4205
+#define PTRACE_SEIZE 0x4206
+#define PTRACE_INTERRUPT 0x4207
+#define PTRACE_LISTEN 0x4208
+#define PTRACE_PEEKSIGINFO 0x4209
+#define PTRACE_GETSIGMASK 0x420A
+#define PTRACE_SETSIGMASK 0x420B
+#define PTRACE_SECCOMP_GET_FILTER 0x420C
+
+#define PTRACE_O_TRACESYSGOOD 0x00000001
+#define PTRACE_O_TRACEFORK 0x00000002
+#define PTRACE_O_TRACEVFORK 0x00000004
+#define PTRACE_O_TRACECLONE 0x00000008
+#define PTRACE_O_TRACEEXEC 0x00000010
+#define PTRACE_O_TRACEVFORKDONE 0x00000020
+#define PTRACE_O_TRACEEXIT 0x00000040
+#define PTRACE_O_TRACESECCOMP 0x00000080
+#define PTRACE_O_EXITKILL 0x00100000
+#define PTRACE_O_SUSPEND_SECCOMP 0x00200000
+#define PTRACE_O_MASK 0x003000ff
+
+#define PTRACE_EVENT_FORK 1
+#define PTRACE_EVENT_VFORK 2
+#define PTRACE_EVENT_CLONE 3
+#define PTRACE_EVENT_EXEC 4
+#define PTRACE_EVENT_VFORK_DONE 5
+#define PTRACE_EVENT_EXIT 6
+#define PTRACE_EVENT_SECCOMP 7
+#define PTRACE_EVENT_STOP 128
+
+#define PTRACE_PEEKSIGINFO_SHARED 1
+
+#endif // _ABIBITS_PTRACE_H
diff --git a/lib/mlibc/abis/linux/reboot.h b/lib/mlibc/abis/linux/reboot.h
new file mode 100644
index 0000000..aadc18f
--- /dev/null
+++ b/lib/mlibc/abis/linux/reboot.h
@@ -0,0 +1,12 @@
+#ifndef _ABIBITS_REBOOT_H
+#define _ABIBITS_REBOOT_H
+
+#define RB_AUTOBOOT 0x01234567
+#define RB_HALT_SYSTEM 0xcdef0123
+#define RB_ENABLE_CAD 0x89abcdef
+#define RB_DISABLE_CAD 0
+#define RB_POWER_OFF 0x4321fedc
+#define RB_SW_SUSPEND 0xd000fce2
+#define RB_KEXEC 0x45584543
+
+#endif // _ABIBITS_REBOOT_H
diff --git a/lib/mlibc/abis/linux/resource.h b/lib/mlibc/abis/linux/resource.h
new file mode 100644
index 0000000..75e8120
--- /dev/null
+++ b/lib/mlibc/abis/linux/resource.h
@@ -0,0 +1,53 @@
+#ifndef _ABIBITS_RESOURCE_H
+#define _ABIBITS_RESOURCE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <bits/posix/timeval.h>
+
+#define RUSAGE_SELF 0
+#define RUSAGE_CHILDREN -1
+
+#define RLIMIT_CPU 0
+#define RLIMIT_FSIZE 1
+#define RLIMIT_DATA 2
+#define RLIMIT_STACK 3
+#define RLIMIT_CORE 4
+#define RLIMIT_RSS 5
+#define RLIMIT_NPROC 6
+#define RLIMIT_NOFILE 7
+#define RLIMIT_MEMLOCK 8
+#define RLIMIT_AS 9
+#define RLIMIT_LOCKS 10
+#define RLIMIT_SIGPENDING 11
+#define RLIMIT_MSGQUEUE 12
+#define RLIMIT_NICE 13
+#define RLIMIT_RTPRIO 14
+#define RLIMIT_NLIMITS 16
+
+struct rusage {
+ struct timeval ru_utime;
+ struct timeval ru_stime;
+ long ru_maxrss;
+ long ru_ixrss;
+ long ru_idrss;
+ long ru_isrss;
+ long ru_minflt;
+ long ru_majflt;
+ long ru_nswap;
+ long ru_inblock;
+ long ru_oublock;
+ long ru_msgsnd;
+ long ru_msgrcv;
+ long ru_nsignals;
+ long ru_nvcsw;
+ long ru_nivcsw;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _ABIBITS_RESOURCE_H
diff --git a/lib/mlibc/abis/linux/seek-whence.h b/lib/mlibc/abis/linux/seek-whence.h
new file mode 100644
index 0000000..47a5b0e
--- /dev/null
+++ b/lib/mlibc/abis/linux/seek-whence.h
@@ -0,0 +1,10 @@
+#ifndef _ABIBITS_SEEK_WHENCE_H
+#define _ABIBITS_SEEK_WHENCE_H
+
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#define SEEK_DATA 3
+#define SEEK_HOLE 4
+
+#endif // _ABIBITS_SEEK_WHENCE_H
diff --git a/lib/mlibc/abis/linux/shm.h b/lib/mlibc/abis/linux/shm.h
new file mode 100644
index 0000000..bf71c8c
--- /dev/null
+++ b/lib/mlibc/abis/linux/shm.h
@@ -0,0 +1,25 @@
+#ifndef _ABIBITS_SHM_H
+#define _ABIBITS_SHM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <unistd.h>
+
+struct shm_info {
+ int used_ids;
+ unsigned long shm_tot;
+ unsigned long shm_rss;
+ unsigned long shm_swp;
+ unsigned long swap_attempts;
+ unsigned long swap_successes;
+};
+
+#define SHMLBA (getpagesize())
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ABIBITS_SHM_H */
diff --git a/lib/mlibc/abis/linux/signal.h b/lib/mlibc/abis/linux/signal.h
new file mode 100644
index 0000000..d83b401
--- /dev/null
+++ b/lib/mlibc/abis/linux/signal.h
@@ -0,0 +1,496 @@
+#ifndef _ABIBITS_SIGNAL_H
+#define _ABIBITS_SIGNAL_H
+
+#include <stdint.h>
+#include <time.h>
+#include <abi-bits/pid_t.h>
+#include <abi-bits/uid_t.h>
+#include <bits/size_t.h>
+
+#define POLL_IN 1
+#define POLL_OUT 2
+#define POLL_MSG 3
+#define POLL_ERR 4
+#define POLL_PRI 5
+#define POLL_HUP 6
+
+union sigval {
+ int sival_int;
+ void *sival_ptr;
+};
+
+// struct taken from musl.
+
+typedef struct {
+ int si_signo, si_errno, si_code;
+ union {
+ char __pad[128 - 2*sizeof(int) - sizeof(long)];
+ struct {
+ union {
+ struct {
+ pid_t si_pid;
+ uid_t si_uid;
+ } __piduid;
+ struct {
+ int si_timerid;
+ int si_overrun;
+ } __timer;
+ } __first;
+ union {
+ union sigval si_value;
+ struct {
+ int si_status;
+ clock_t si_utime, si_stime;
+ } __sigchld;
+ } __second;
+ } __si_common;
+ struct {
+ void *si_addr;
+ short si_addr_lsb;
+ union {
+ struct {
+ void *si_lower;
+ void *si_upper;
+ } __addr_bnd;
+ unsigned si_pkey;
+ } __first;
+ } __sigfault;
+ struct {
+ long si_band;
+ int si_fd;
+ } __sigpoll;
+ struct {
+ void *si_call_addr;
+ int si_syscall;
+ unsigned si_arch;
+ } __sigsys;
+ } __si_fields;
+} siginfo_t;
+#define si_pid __si_fields.__si_common.__first.__piduid.si_pid
+#define si_uid __si_fields.__si_common.__first.__piduid.si_uid
+#define si_status __si_fields.__si_common.__second.__sigchld.si_status
+#define si_utime __si_fields.__si_common.__second.__sigchld.si_utime
+#define si_stime __si_fields.__si_common.__second.__sigchld.si_stime
+#define si_value __si_fields.__si_common.__second.si_value
+#define si_addr __si_fields.__sigfault.si_addr
+#define si_addr_lsb __si_fields.__sigfault.si_addr_lsb
+#define si_lower __si_fields.__sigfault.__first.__addr_bnd.si_lower
+#define si_upper __si_fields.__sigfault.__first.__addr_bnd.si_upper
+#define si_pkey __si_fields.__sigfault.__first.si_pkey
+#define si_band __si_fields.__sigpoll.si_band
+#define si_fd __si_fields.__sigpoll.si_fd
+#define si_timerid __si_fields.__si_common.__first.__timer.si_timerid
+#define si_overrun __si_fields.__si_common.__first.__timer.si_overrun
+#define si_ptr si_value.sival_ptr
+#define si_int si_value.sival_int
+#define si_call_addr __si_fields.__sigsys.si_call_addr
+#define si_syscall __si_fields.__sigsys.si_syscall
+#define si_arch __si_fields.__sigsys.si_arch
+
+// Required for sys_sigaction sysdep.
+#define SA_NOCLDSTOP 1
+#define SA_NOCLDWAIT 2
+#define SA_SIGINFO 4
+#define SA_ONSTACK 0x08000000
+#define SA_RESTART 0x10000000
+#define SA_NODEFER 0x40000000
+#define SA_RESETHAND 0x80000000
+#define SA_RESTORER 0x04000000
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Argument for signal()
+typedef void (*__sighandler) (int);
+
+#define SIG_ERR ((__sighandler)(void *)(-1))
+#define SIG_DFL ((__sighandler)(void *)(0))
+#define SIG_IGN ((__sighandler)(void *)(1))
+
+#define SIGABRT 6
+#define SIGFPE 8
+#define SIGILL 4
+#define SIGINT 2
+#define SIGSEGV 11
+#define SIGTERM 15
+#define SIGPROF 27
+#define SIGIO 29
+#define SIGPWR 30
+#define SIGRTMIN 35
+#define SIGRTMAX 64
+
+typedef uint64_t sigset_t;
+
+// constants for sigprocmask()
+#define SIG_BLOCK 0
+#define SIG_UNBLOCK 1
+#define SIG_SETMASK 2
+
+#define SIGHUP 1
+#define SIGQUIT 3
+#define SIGTRAP 5
+#define SIGIOT SIGABRT
+#define SIGBUS 7
+#define SIGKILL 9
+#define SIGUSR1 10
+#define SIGUSR2 12
+#define SIGPIPE 13
+#define SIGALRM 14
+#define SIGSTKFLT 16
+#define SIGCHLD 17
+#define SIGCONT 18
+#define SIGSTOP 19
+#define SIGTSTP 20
+#define SIGTTIN 21
+#define SIGTTOU 22
+#define SIGURG 23
+#define SIGXCPU 24
+#define SIGXFSZ 25
+#define SIGVTALRM 26
+#define SIGWINCH 28
+#define SIGPOLL 29
+#define SIGSYS 31
+#define SIGUNUSED SIGSYS
+#define SIGCANCEL 32
+
+#define MINSIGSTKSZ 2048
+#define SIGSTKSZ 8192
+#define SS_ONSTACK 1
+#define SS_DISABLE 2
+
+typedef struct __stack {
+ void *ss_sp;
+ int ss_flags;
+ size_t ss_size;
+} stack_t;
+
+// constants for sigev_notify of struct sigevent
+#define SIGEV_SIGNAL 0
+#define SIGEV_NONE 1
+#define SIGEV_THREAD 2
+#define SIGEV_THREAD_ID 4
+
+#define SEGV_MAPERR 1
+#define SEGV_ACCERR 2
+
+#define BUS_ADRALN 1
+#define BUS_ADRERR 2
+#define BUS_OBJERR 3
+#define BUS_MCEERR_AR 4
+#define BUS_MCEERR_AO 5
+
+#define ILL_ILLOPC 1
+#define ILL_ILLOPN 2
+#define ILL_ILLADR 3
+#define ILL_ILLTRP 4
+#define ILL_PRVOPC 5
+#define ILL_PRVREG 6
+#define ILL_COPROC 7
+#define ILL_BADSTK 8
+#define ILL_BADIADDR 9
+
+#define NSIG 65
+
+#define SI_ASYNCNL (-60)
+#define SI_TKILL (-6)
+#define SI_SIGIO (-5)
+#define SI_ASYNCIO (-4)
+#define SI_MESGQ (-3)
+#define SI_TIMER (-2)
+#define SI_QUEUE (-1)
+#define SI_USER 0
+#define SI_KERNEL 128
+
+#if defined(__i386__)
+#define REG_GS 0
+#define REG_FS 1
+#define REG_ES 2
+#define REG_DS 3
+#define REG_EDI 4
+#define REG_ESI 5
+#define REG_EBP 6
+#define REG_ESP 7
+#define REG_EBX 8
+#define REG_EDX 9
+#define REG_ECX 10
+#define REG_EAX 11
+#define REG_TRAPNO 12
+#define REG_ERR 13
+#define REG_EIP 14
+#define REG_CS 15
+#define REG_EFL 16
+#define REG_UESP 17
+#define REG_SS 18
+#define NGREG 19
+#elif defined(__x86_64__)
+#define REG_R8 0
+#define REG_R9 1
+#define REG_R10 2
+#define REG_R11 3
+#define REG_R12 4
+#define REG_R13 5
+#define REG_R14 6
+#define REG_R15 7
+#define REG_RDI 8
+#define REG_RSI 9
+#define REG_RBP 10
+#define REG_RBX 11
+#define REG_RDX 12
+#define REG_RAX 13
+#define REG_RCX 14
+#define REG_RSP 15
+#define REG_RIP 16
+#define REG_EFL 17
+#define REG_CSGSFS 18
+#define REG_ERR 19
+#define REG_TRAPNO 20
+#define REG_OLDMASK 21
+#define REG_CR2 22
+#define NGREG 23
+#endif
+
+#include <bits/threads.h>
+
+struct sigevent {
+ union sigval sigev_value;
+ int sigev_notify;
+ int sigev_signo;
+ void (*sigev_notify_function)(union sigval);
+ struct __mlibc_threadattr *sigev_notify_attributes;
+ pid_t sigev_notify_thread_id;
+};
+
+struct sigaction {
+ union {
+ void (*sa_handler)(int);
+ void (*sa_sigaction)(int, siginfo_t *, void *);
+ } __sa_handler;
+ sigset_t sa_mask;
+ int sa_flags;
+ void (*sa_restorer)(void);
+};
+#define sa_handler __sa_handler.sa_handler
+#define sa_sigaction __sa_handler.sa_sigaction
+
+// Taken from the linux kernel headers
+
+#if defined(__x86_64__) || defined(__i386__)
+
+struct _fpreg {
+ unsigned short significand[4];
+ unsigned short exponent;
+};
+
+struct _fpxreg {
+ unsigned short significand[4];
+ unsigned short exponent;
+ unsigned short padding[3];
+};
+
+struct _xmmreg {
+ uint32_t element[4];
+};
+
+struct _fpstate {
+#if defined(__x86_64__)
+ uint16_t cwd;
+ uint16_t swd;
+ uint16_t ftw;
+ uint16_t fop;
+ uint64_t rip;
+ uint64_t rdp;
+ uint32_t mxcsr;
+ uint32_t mxcr_mask;
+ struct _fpxreg _st[8];
+ struct _xmmreg _xmm[16];
+ uint32_t padding[24];
+#elif defined(__i386__)
+ uint32_t cw;
+ uint32_t sw;
+ uint32_t tag;
+ uint32_t ipoff;
+ uint32_t cssel;
+ uint32_t dataoff;
+ uint32_t datasel;
+ struct _fpreg _st[8];
+ uint16_t status;
+ uint16_t magic;
+
+ // FXSR FPU
+
+ uint32_t _fxsr_env[6];
+ uint32_t mxscr;
+ uint32_t reserved;
+ struct _fpxreg _fxsr_st[8];
+ struct _xmmreg _xmm[8];
+
+ uint32_t padding2[56];
+#endif
+};
+
+typedef struct {
+ unsigned long gregs[NGREG];
+ struct _fpstate *fpregs;
+ unsigned long __reserved1[8];
+} mcontext_t;
+
+typedef struct __ucontext {
+ unsigned long uc_flags;
+ struct __ucontext *uc_link;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ sigset_t uc_sigmask;
+} ucontext_t;
+
+#elif defined(__riscv) && __riscv_xlen == 64
+// Definitions from Linux kernel headers.
+
+#define NGREG 32
+
+enum {
+ REG_PC = 0,
+#define REG_PC REG_PC
+ REG_RA = 1,
+#define REG_RA REG_RA
+ REG_SP = 2,
+#define REG_SP REG_SP
+ REG_TP = 4,
+#define REG_TP REG_TP
+ REG_S0 = 8,
+#define REG_S0 REG_S0
+ REG_A0 = 10,
+#define REG_A0 REG_A0
+};
+
+struct __riscv_f_ext_state {
+ uint32_t f[32];
+ uint32_t fcsr;
+};
+
+struct __riscv_d_ext_state {
+ uint64_t f[32];
+ uint32_t fcsr;
+};
+
+struct __riscv_q_ext_state {
+ uint64_t f[64] __attribute__((__aligned__(16)));
+ uint32_t fcsr;
+ uint32_t reserved[3];
+};
+
+union __riscv_fp_state {
+ struct __riscv_f_ext_state f;
+ struct __riscv_d_ext_state d;
+ struct __riscv_q_ext_state q;
+};
+
+typedef unsigned long __riscv_mc_gp_state[NGREG];
+
+typedef struct sigcontext {
+ __riscv_mc_gp_state gregs;
+ union __riscv_fp_state fpregs;
+} mcontext_t;
+
+typedef struct __ucontext {
+ unsigned long uc_flags;
+ struct ucontext *uc_link;
+ stack_t uc_stack;
+ sigset_t uc_sigmask;
+ uint8_t __unused[1024 / 8 - sizeof(sigset_t)];
+ mcontext_t uc_mcontext;
+} ucontext_t;
+
+#elif defined (__aarch64__)
+
+#define NGREG 34
+
+typedef struct sigcontext {
+ uint64_t fault_address;
+ uint64_t regs[31];
+ uint64_t sp;
+ uint64_t pc;
+ uint64_t pstate;
+ uint8_t __reserved[4096];
+} mcontext_t;
+
+#define FPSIMD_MAGIC 0x46508001
+#define ESR_MAGIC 0x45535201
+#define EXTRA_MAGIC 0x45585401
+#define SVE_MAGIC 0x53564501
+struct _aarch64_ctx {
+ uint32_t magic;
+ uint32_t size;
+};
+struct fpsimd_context {
+ struct _aarch64_ctx head;
+ uint32_t fpsr;
+ uint32_t fpcr;
+ __uint128_t vregs[32];
+};
+struct esr_context {
+ struct _aarch64_ctx head;
+ uint64_t esr;
+};
+struct extra_context {
+ struct _aarch64_ctx head;
+ uint64_t datap;
+ uint32_t size;
+ uint32_t __reserved[3];
+};
+struct sve_context {
+ struct _aarch64_ctx head;
+ uint16_t vl;
+ uint16_t __reserved[3];
+};
+#define SVE_VQ_BYTES 16
+#define SVE_VQ_MIN 1
+#define SVE_VQ_MAX 512
+#define SVE_VL_MIN (SVE_VQ_MIN * SVE_VQ_BYTES)
+#define SVE_VL_MAX (SVE_VQ_MAX * SVE_VQ_BYTES)
+#define SVE_NUM_ZREGS 32
+#define SVE_NUM_PREGS 16
+#define sve_vl_valid(vl) \
+ ((vl) % SVE_VQ_BYTES == 0 && (vl) >= SVE_VL_MIN && (vl) <= SVE_VL_MAX)
+#define sve_vq_from_vl(vl) ((vl) / SVE_VQ_BYTES)
+#define sve_vl_from_vq(vq) ((vq) * SVE_VQ_BYTES)
+#define SVE_SIG_ZREG_SIZE(vq) ((unsigned)(vq) * SVE_VQ_BYTES)
+#define SVE_SIG_PREG_SIZE(vq) ((unsigned)(vq) * (SVE_VQ_BYTES / 8))
+#define SVE_SIG_FFR_SIZE(vq) SVE_SIG_PREG_SIZE(vq)
+#define SVE_SIG_REGS_OFFSET \
+ ((sizeof(struct sve_context) + (SVE_VQ_BYTES - 1)) \
+ / SVE_VQ_BYTES * SVE_VQ_BYTES)
+#define SVE_SIG_ZREGS_OFFSET SVE_SIG_REGS_OFFSET
+#define SVE_SIG_ZREG_OFFSET(vq, n) \
+ (SVE_SIG_ZREGS_OFFSET + SVE_SIG_ZREG_SIZE(vq) * (n))
+#define SVE_SIG_ZREGS_SIZE(vq) \
+ (SVE_SIG_ZREG_OFFSET(vq, SVE_NUM_ZREGS) - SVE_SIG_ZREGS_OFFSET)
+#define SVE_SIG_PREGS_OFFSET(vq) \
+ (SVE_SIG_ZREGS_OFFSET + SVE_SIG_ZREGS_SIZE(vq))
+#define SVE_SIG_PREG_OFFSET(vq, n) \
+ (SVE_SIG_PREGS_OFFSET(vq) + SVE_SIG_PREG_SIZE(vq) * (n))
+#define SVE_SIG_PREGS_SIZE(vq) \
+ (SVE_SIG_PREG_OFFSET(vq, SVE_NUM_PREGS) - SVE_SIG_PREGS_OFFSET(vq))
+#define SVE_SIG_FFR_OFFSET(vq) \
+ (SVE_SIG_PREGS_OFFSET(vq) + SVE_SIG_PREGS_SIZE(vq))
+#define SVE_SIG_REGS_SIZE(vq) \
+ (SVE_SIG_FFR_OFFSET(vq) + SVE_SIG_FFR_SIZE(vq) - SVE_SIG_REGS_OFFSET)
+#define SVE_SIG_CONTEXT_SIZE(vq) (SVE_SIG_REGS_OFFSET + SVE_SIG_REGS_SIZE(vq))
+
+typedef struct __ucontext {
+ unsigned long uc_flags;
+ struct __ucontext *uc_link;
+ stack_t uc_stack;
+ sigset_t uc_sigmask;
+ mcontext_t uc_mcontext;
+} ucontext_t;
+
+#else
+#error "Missing architecture specific code."
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _ABIBITS_SIGNAL_H
diff --git a/lib/mlibc/abis/linux/socket.h b/lib/mlibc/abis/linux/socket.h
new file mode 100644
index 0000000..713d532
--- /dev/null
+++ b/lib/mlibc/abis/linux/socket.h
@@ -0,0 +1,299 @@
+#ifndef _ABIBITS_SOCKET_H
+#define _ABIBITS_SOCKET_H
+
+#include <stddef.h>
+#include <abi-bits/socklen_t.h>
+#include <bits/posix/iovec.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef unsigned short sa_family_t;
+
+struct msghdr {
+ void *msg_name;
+ socklen_t msg_namelen;
+ struct iovec *msg_iov;
+ size_t msg_iovlen; /* int in POSIX */
+ void *msg_control;
+ size_t msg_controllen; /* socklen_t in POSIX */
+ int msg_flags;
+};
+
+struct sockaddr_storage {
+ sa_family_t ss_family;
+ char __padding[128 - sizeof(sa_family_t)];
+};
+
+struct mmsghdr {
+ struct msghdr msg_hdr;
+ unsigned int msg_len;
+};
+
+struct cmsghdr {
+ size_t cmsg_len; /* socklen_t in POSIX */
+ int cmsg_level;
+ int cmsg_type;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#define SCM_RIGHTS 1
+#define SCM_CREDENTIALS 2
+
+#define SHUT_RD 0
+#define SHUT_WR 1
+#define SHUT_RDWR 2
+
+#ifndef SOCK_STREAM
+#define SOCK_STREAM 1
+#define SOCK_DGRAM 2
+#endif
+
+#define SOCK_RAW 3
+#define SOCK_RDM 4
+#define SOCK_SEQPACKET 5
+#define SOCK_DCCP 6
+#define SOCK_PACKET 10
+
+#ifndef SOCK_CLOEXEC
+#define SOCK_CLOEXEC 02000000
+#define SOCK_NONBLOCK 04000
+#endif
+
+#define PF_UNSPEC 0
+#define PF_LOCAL 1
+#define PF_UNIX PF_LOCAL
+#define PF_FILE PF_LOCAL
+#define PF_INET 2
+#define PF_AX25 3
+#define PF_IPX 4
+#define PF_APPLETALK 5
+#define PF_NETROM 6
+#define PF_BRIDGE 7
+#define PF_ATMPVC 8
+#define PF_X25 9
+#define PF_INET6 10
+#define PF_ROSE 11
+#define PF_DECnet 12
+#define PF_NETBEUI 13
+#define PF_SECURITY 14
+#define PF_KEY 15
+#define PF_NETLINK 16
+#define PF_ROUTE PF_NETLINK
+#define PF_PACKET 17
+#define PF_ASH 18
+#define PF_ECONET 19
+#define PF_ATMSVC 20
+#define PF_RDS 21
+#define PF_SNA 22
+#define PF_IRDA 23
+#define PF_PPPOX 24
+#define PF_WANPIPE 25
+#define PF_LLC 26
+#define PF_IB 27
+#define PF_MPLS 28
+#define PF_CAN 29
+#define PF_TIPC 30
+#define PF_BLUETOOTH 31
+#define PF_IUCV 32
+#define PF_RXRPC 33
+#define PF_ISDN 34
+#define PF_PHONET 35
+#define PF_IEEE802154 36
+#define PF_CAIF 37
+#define PF_ALG 38
+#define PF_NFC 39
+#define PF_VSOCK 40
+#define PF_KCM 41
+#define PF_QIPCRTR 42
+#define PF_SMC 43
+#define PF_XDP 44
+#define PF_MAX 45
+
+#define AF_UNSPEC PF_UNSPEC
+#define AF_LOCAL PF_LOCAL
+#define AF_UNIX AF_LOCAL
+#define AF_FILE AF_LOCAL
+#define AF_INET PF_INET
+#define AF_AX25 PF_AX25
+#define AF_IPX PF_IPX
+#define AF_APPLETALK PF_APPLETALK
+#define AF_NETROM PF_NETROM
+#define AF_BRIDGE PF_BRIDGE
+#define AF_ATMPVC PF_ATMPVC
+#define AF_X25 PF_X25
+#define AF_INET6 PF_INET6
+#define AF_ROSE PF_ROSE
+#define AF_DECnet PF_DECnet
+#define AF_NETBEUI PF_NETBEUI
+#define AF_SECURITY PF_SECURITY
+#define AF_KEY PF_KEY
+#define AF_NETLINK PF_NETLINK
+#define AF_ROUTE PF_ROUTE
+#define AF_PACKET PF_PACKET
+#define AF_ASH PF_ASH
+#define AF_ECONET PF_ECONET
+#define AF_ATMSVC PF_ATMSVC
+#define AF_RDS PF_RDS
+#define AF_SNA PF_SNA
+#define AF_IRDA PF_IRDA
+#define AF_PPPOX PF_PPPOX
+#define AF_WANPIPE PF_WANPIPE
+#define AF_LLC PF_LLC
+#define AF_IB PF_IB
+#define AF_MPLS PF_MPLS
+#define AF_CAN PF_CAN
+#define AF_TIPC PF_TIPC
+#define AF_BLUETOOTH PF_BLUETOOTH
+#define AF_IUCV PF_IUCV
+#define AF_RXRPC PF_RXRPC
+#define AF_ISDN PF_ISDN
+#define AF_PHONET PF_PHONET
+#define AF_IEEE802154 PF_IEEE802154
+#define AF_CAIF PF_CAIF
+#define AF_ALG PF_ALG
+#define AF_NFC PF_NFC
+#define AF_VSOCK PF_VSOCK
+#define AF_KCM PF_KCM
+#define AF_QIPCRTR PF_QIPCRTR
+#define AF_SMC PF_SMC
+#define AF_XDP PF_XDP
+#define AF_MAX PF_MAX
+
+#define SO_DEBUG 1
+#define SO_REUSEADDR 2
+#define SO_TYPE 3
+#define SO_ERROR 4
+#define SO_DONTROUTE 5
+#define SO_BROADCAST 6
+#define SO_SNDBUF 7
+#define SO_RCVBUF 8
+#define SO_KEEPALIVE 9
+#define SO_OOBINLINE 10
+#define SO_NO_CHECK 11
+#define SO_PRIORITY 12
+#define SO_LINGER 13
+#define SO_BSDCOMPAT 14
+#define SO_REUSEPORT 15
+#define SO_PASSCRED 16
+#define SO_PEERCRED 17
+#define SO_RCVLOWAT 18
+#define SO_SNDLOWAT 19
+#define SO_ACCEPTCONN 30
+#define SO_PEERSEC 31
+#define SO_SNDBUFFORCE 32
+#define SO_RCVBUFFORCE 33
+#define SO_PROTOCOL 38
+#define SO_DOMAIN 39
+
+#define SO_RCVTIMEO 20
+#define SO_SNDTIMEO 21
+
+#define SO_TIMESTAMP 29
+#define SO_TIMESTAMPNS 35
+#define SO_TIMESTAMPING 37
+
+#define SO_SECURITY_AUTHENTICATION 22
+#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
+#define SO_SECURITY_ENCRYPTION_NETWORK 24
+
+#define SO_BINDTODEVICE 25
+
+#define SO_ATTACH_FILTER 26
+#define SO_DETACH_FILTER 27
+#define SO_GET_FILTER SO_ATTACH_FILTER
+
+#define SO_PEERNAME 28
+#define SCM_TIMESTAMP SO_TIMESTAMP
+#define SO_PASSSEC 34
+#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
+#define SO_MARK 36
+#define SCM_TIMESTAMPING SO_TIMESTAMPING
+#define SO_RXQ_OVFL 40
+#define SO_WIFI_STATUS 41
+#define SCM_WIFI_STATUS SO_WIFI_STATUS
+#define SO_PEEK_OFF 42
+#define SO_NOFCS 43
+#define SO_LOCK_FILTER 44
+#define SO_SELECT_ERR_QUEUE 45
+#define SO_BUSY_POLL 46
+#define SO_MAX_PACING_RATE 47
+#define SO_BPF_EXTENSIONS 48
+#define SO_INCOMING_CPU 49
+#define SO_ATTACH_BPF 50
+#define SO_DETACH_BPF SO_DETACH_FILTER
+#define SO_ATTACH_REUSEPORT_CBPF 51
+#define SO_ATTACH_REUSEPORT_EBPF 52
+#define SO_CNX_ADVICE 53
+#define SCM_TIMESTAMPING_OPT_STATS 54
+#define SO_MEMINFO 55
+#define SO_INCOMING_NAPI_ID 56
+#define SO_COOKIE 57
+#define SCM_TIMESTAMPING_PKTINFO 58
+#define SO_PEERGROUPS 59
+#define SO_ZEROCOPY 60
+#define SO_TXTIME 61
+#define SCM_TXTIME SO_TXTIME
+#define SO_BINDTOIFINDEX 62
+#define SO_DETACH_REUSEPORT_BPF 68
+
+#define SOL_SOCKET 1
+
+#define SOL_IP 0
+#define SOL_IPV6 41
+#define SOL_ICMPV6 58
+
+#define SOL_RAW 255
+#define SOL_DECNET 261
+#define SOL_X25 262
+#define SOL_PACKET 263
+#define SOL_ATM 264
+#define SOL_AAL 265
+#define SOL_IRDA 266
+#define SOL_NETBEUI 267
+#define SOL_LLC 268
+#define SOL_DCCP 269
+#define SOL_NETLINK 270
+#define SOL_TIPC 271
+#define SOL_RXRPC 272
+#define SOL_PPPOL2TP 273
+#define SOL_BLUETOOTH 274
+#define SOL_PNPIPE 275
+#define SOL_RDS 276
+#define SOL_IUCV 277
+#define SOL_CAIF 278
+#define SOL_ALG 279
+#define SOL_NFC 280
+#define SOL_KCM 281
+#define SOL_TLS 282
+#define SOL_XDP 283
+
+#define SOMAXCONN 128
+
+#define MSG_OOB 0x0001
+#define MSG_PEEK 0x0002
+#define MSG_DONTROUTE 0x0004
+#define MSG_CTRUNC 0x0008
+#define MSG_PROXY 0x0010
+#define MSG_TRUNC 0x0020
+#define MSG_DONTWAIT 0x0040
+#define MSG_EOR 0x0080
+#define MSG_WAITALL 0x0100
+#define MSG_FIN 0x0200
+#define MSG_SYN 0x0400
+#define MSG_CONFIRM 0x0800
+#define MSG_RST 0x1000
+#define MSG_ERRQUEUE 0x2000
+#define MSG_NOSIGNAL 0x4000
+#define MSG_MORE 0x8000
+#define MSG_WAITFORONE 0x10000
+#define MSG_BATCH 0x40000
+#define MSG_ZEROCOPY 0x4000000
+#define MSG_FASTOPEN 0x20000000
+#define MSG_CMSG_CLOEXEC 0x40000000
+
+#endif
diff --git a/lib/mlibc/abis/linux/socklen_t.h b/lib/mlibc/abis/linux/socklen_t.h
new file mode 100644
index 0000000..190e5f9
--- /dev/null
+++ b/lib/mlibc/abis/linux/socklen_t.h
@@ -0,0 +1,6 @@
+#ifndef _ABIBITS_SOCKLEN_T_H
+#define _ABIBITS_SOCKLEN_T_H
+
+typedef unsigned socklen_t;
+
+#endif /* _ABIBITS_SOCKLEN_T_H */
diff --git a/lib/mlibc/abis/linux/stat.h b/lib/mlibc/abis/linux/stat.h
new file mode 100644
index 0000000..5c55ba8
--- /dev/null
+++ b/lib/mlibc/abis/linux/stat.h
@@ -0,0 +1,123 @@
+#ifndef _ABIBITS_STAT_H
+#define _ABIBITS_STAT_H
+
+#include <abi-bits/uid_t.h>
+#include <abi-bits/gid_t.h>
+#include <bits/off_t.h>
+#include <abi-bits/mode_t.h>
+#include <abi-bits/dev_t.h>
+#include <abi-bits/ino_t.h>
+#include <abi-bits/blksize_t.h>
+#include <abi-bits/blkcnt_t.h>
+#include <abi-bits/nlink_t.h>
+#include <bits/ansi/time_t.h>
+#include <bits/ansi/timespec.h>
+
+#define S_IFMT 0x0F000
+#define S_IFBLK 0x06000
+#define S_IFCHR 0x02000
+#define S_IFIFO 0x01000
+#define S_IFREG 0x08000
+#define S_IFDIR 0x04000
+#define S_IFLNK 0x0A000
+#define S_IFSOCK 0x0C000
+
+#define S_IRWXU 0700
+#define S_IRUSR 0400
+#define S_IWUSR 0200
+#define S_IXUSR 0100
+#define S_IEXEC S_IXUSR
+#define S_IRWXG 070
+#define S_IRGRP 040
+#define S_IWGRP 020
+#define S_IXGRP 010
+#define S_IRWXO 07
+#define S_IROTH 04
+#define S_IWOTH 02
+#define S_IXOTH 01
+#define S_ISUID 04000
+#define S_ISGID 02000
+#define S_ISVTX 01000
+
+#define S_IREAD S_IRUSR
+#define S_IWRITE S_IWUSR
+#define S_IEXEC S_IXUSR
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(__x86_64__)
+
+struct stat {
+ dev_t st_dev;
+ ino_t st_ino;
+ nlink_t st_nlink;
+ mode_t st_mode;
+ uid_t st_uid;
+ gid_t st_gid;
+ unsigned int __pad0;
+ dev_t st_rdev;
+ off_t st_size;
+ blksize_t st_blksize;
+ blkcnt_t st_blocks;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ long __unused[3];
+};
+
+#elif (defined(__riscv) && __riscv_xlen == 64) || defined (__aarch64__)
+
+struct stat {
+ dev_t st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ nlink_t st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ dev_t st_rdev;
+ unsigned long __pad1;
+ off_t st_size;
+ blksize_t st_blksize;
+ int __pad2;
+ blkcnt_t st_blocks;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ unsigned int __unused4;
+ unsigned int __unused5;
+};
+
+#elif defined(__i386__)
+
+struct stat {
+ dev_t st_dev;
+ int __st_dev_padding;
+ long __st_ino_truncated;
+ mode_t st_mode;
+ nlink_t st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ dev_t st_rdev;
+ int __st_rdev_padding;
+ off_t st_size;
+ blksize_t st_blksize;
+ blkcnt_t st_blocks;
+ struct {
+ long tv_sec;
+ long tv_nsec;
+ } __st_atim32, __st_mtim32, __st_ctim32;
+ ino_t st_ino;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+};
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _ABIBITS_STAT_H
diff --git a/lib/mlibc/abis/linux/statfs.h b/lib/mlibc/abis/linux/statfs.h
new file mode 100644
index 0000000..60c977f
--- /dev/null
+++ b/lib/mlibc/abis/linux/statfs.h
@@ -0,0 +1,28 @@
+#ifndef _ABIBITS_STATFS_H
+#define _ABIBITS_STATFS_H
+
+#include <abi-bits/fsblkcnt_t.h>
+#include <abi-bits/fsfilcnt_t.h>
+
+typedef struct __mlibc_fsid {
+ int __val[2];
+} fsid_t;
+
+struct statfs {
+ unsigned long f_type;
+ unsigned long f_bsize;
+ fsblkcnt_t f_blocks;
+ fsblkcnt_t f_bfree;
+ fsblkcnt_t f_bavail;
+
+ fsfilcnt_t f_files;
+ fsfilcnt_t f_ffree;
+ fsid_t f_fsid;
+ unsigned long f_namelen;
+ unsigned long f_frsize;
+ unsigned long f_flags;
+ unsigned long __f_spare[4];
+};
+
+#endif /* _ABIBITS_STATFS_H */
+
diff --git a/lib/mlibc/abis/linux/statvfs.h b/lib/mlibc/abis/linux/statvfs.h
new file mode 100644
index 0000000..7a75d3a
--- /dev/null
+++ b/lib/mlibc/abis/linux/statvfs.h
@@ -0,0 +1,29 @@
+#ifndef _ABIBITS_STATVFS_H
+#define _ABIBITS_STATVFS_H
+
+#include <abi-bits/fsblkcnt_t.h>
+#include <abi-bits/fsfilcnt_t.h>
+
+#define ST_RDONLY 1
+#define ST_NOSUID 2
+#define ST_MANDLOCK 64
+
+// On Linux, this struct is not directly used by the kernel.
+struct statvfs {
+ unsigned long f_bsize;
+ unsigned long f_frsize;
+ fsblkcnt_t f_blocks;
+ fsblkcnt_t f_bfree;
+ fsblkcnt_t f_bavail;
+
+ fsfilcnt_t f_files;
+ fsfilcnt_t f_ffree;
+ fsfilcnt_t f_favail;
+
+ unsigned long f_fsid;
+ unsigned long f_flag;
+ unsigned long f_namemax;
+};
+
+#endif /* _ABIBITS_STATVFS_H */
+
diff --git a/lib/mlibc/abis/linux/suseconds_t.h b/lib/mlibc/abis/linux/suseconds_t.h
new file mode 100644
index 0000000..1de1a7c
--- /dev/null
+++ b/lib/mlibc/abis/linux/suseconds_t.h
@@ -0,0 +1,8 @@
+#ifndef _ABIBITS_SUSECONDS_T_H
+#define _ABIBITS_SUSECONDS_T_H
+
+#include <bits/types.h>
+
+typedef long suseconds_t;
+
+#endif /* _ABIBITS_SUSECONDS_T_H */
diff --git a/lib/mlibc/abis/linux/termios.h b/lib/mlibc/abis/linux/termios.h
new file mode 100644
index 0000000..3ee43d0
--- /dev/null
+++ b/lib/mlibc/abis/linux/termios.h
@@ -0,0 +1,155 @@
+#ifndef _ABIBITS_TERMIOS_H
+#define _ABIBITS_TERMIOS_H
+
+typedef unsigned char cc_t;
+typedef unsigned int speed_t;
+typedef unsigned int tcflag_t;
+
+// indices for the c_cc array in struct termios
+#define NCCS 32
+#define VINTR 0
+#define VQUIT 1
+#define VERASE 2
+#define VKILL 3
+#define VEOF 4
+#define VTIME 5
+#define VMIN 6
+#define VSWTC 7
+#define VSTART 8
+#define VSTOP 9
+#define VSUSP 10
+#define VEOL 11
+#define VREPRINT 12
+#define VDISCARD 13
+#define VWERASE 14
+#define VLNEXT 15
+#define VEOL2 16
+
+// bitwise flags for c_iflag in struct termios
+#define IGNBRK 0000001
+#define BRKINT 0000002
+#define IGNPAR 0000004
+#define PARMRK 0000010
+#define INPCK 0000020
+#define ISTRIP 0000040
+#define INLCR 0000100
+#define IGNCR 0000200
+#define ICRNL 0000400
+#define IUCLC 0001000
+#define IXON 0002000
+#define IXANY 0004000
+#define IXOFF 0010000
+#define IMAXBEL 0020000
+#define IUTF8 0040000
+
+// bitwise flags for c_oflag in struct termios
+#define OPOST 0000001
+#define OLCUC 0000002
+#define ONLCR 0000004
+#define OCRNL 0000010
+#define ONOCR 0000020
+#define ONLRET 0000040
+#define OFILL 0000100
+#define OFDEL 0000200
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_XOPEN_SOURCE)
+
+#define NLDLY 0000400
+#define NL0 0000000
+#define NL1 0000400
+
+#define CRDLY 0003000
+#define CR0 0000000
+#define CR1 0001000
+#define CR2 0002000
+#define CR3 0003000
+
+#define TABDLY 0014000
+#define TAB0 0000000
+#define TAB1 0004000
+#define TAB2 0010000
+#define TAB3 0014000
+
+#define BSDLY 0020000
+#define BS0 0000000
+#define BS1 0020000
+
+#define FFDLY 0100000
+#define FF0 0000000
+#define FF1 0100000
+
+#endif
+
+#define VTDLY 0040000
+#define VT0 0000000
+#define VT1 0040000
+
+// bitwise constants for c_cflag in struct termios
+#define CSIZE 0000060
+#define CS5 0000000
+#define CS6 0000020
+#define CS7 0000040
+#define CS8 0000060
+
+#define CSTOPB 0000100
+#define CREAD 0000200
+#define PARENB 0000400
+#define PARODD 0001000
+#define HUPCL 0002000
+#define CLOCAL 0004000
+
+// bitwise constants for c_lflag in struct termios
+#define ISIG 0000001
+#define ICANON 0000002
+#define ECHO 0000010
+#define ECHOE 0000020
+#define ECHOK 0000040
+#define ECHONL 0000100
+#define NOFLSH 0000200
+#define TOSTOP 0000400
+#define IEXTEN 0100000
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+
+#define EXTA 0000016
+#define EXTB 0000017
+#define CBAUD 0010017
+#define CBAUDEX 0010000
+#define CIBAUD 002003600000
+#define CMSPAR 010000000000
+#define CRTSCTS 020000000000
+
+#define XCASE 0000004
+#define ECHOCTL 0001000
+#define ECHOPRT 0002000
+#define ECHOKE 0004000
+#define FLUSHO 0010000
+#define PENDIN 0040000
+#define EXTPROC 0200000
+
+#define XTABS 0014000
+
+#endif
+
+struct termios {
+ tcflag_t c_iflag;
+ tcflag_t c_oflag;
+ tcflag_t c_cflag;
+ tcflag_t c_lflag;
+ cc_t c_line;
+ cc_t c_cc[NCCS];
+ speed_t ibaud;
+ speed_t obaud;
+};
+
+#define NCC 8
+struct termio {
+ unsigned short c_iflag;
+ unsigned short c_oflag;
+ unsigned short c_cflag;
+ unsigned short c_lflag;
+ unsigned char c_line;
+ unsigned char c_cc[NCC];
+};
+
+#endif
diff --git a/lib/mlibc/abis/linux/time.h b/lib/mlibc/abis/linux/time.h
new file mode 100644
index 0000000..3f49db3
--- /dev/null
+++ b/lib/mlibc/abis/linux/time.h
@@ -0,0 +1,15 @@
+#ifndef _ABIBITS_TIME_H
+#define _ABIBITS_TIME_H
+
+#include <bits/posix/timeval.h>
+
+struct itimerval {
+ struct timeval it_interval; /* Interval for periodic timer */
+ struct timeval it_value; /* Time until next expiration */
+};
+
+#define ITIMER_REAL 0
+#define ITIMER_VIRTUAL 1
+#define ITIMER_PROF 2
+
+#endif // _ABIBITS_TIME_H
diff --git a/lib/mlibc/abis/linux/uid_t.h b/lib/mlibc/abis/linux/uid_t.h
new file mode 100644
index 0000000..5b53ca3
--- /dev/null
+++ b/lib/mlibc/abis/linux/uid_t.h
@@ -0,0 +1,8 @@
+
+#ifndef _ABIBITS_UID_T_H
+#define _ABIBITS_UID_T_H
+
+typedef unsigned int uid_t;
+
+#endif // _ABIBITS_UID_T_H
+
diff --git a/lib/mlibc/abis/linux/utsname.h b/lib/mlibc/abis/linux/utsname.h
new file mode 100644
index 0000000..9875a46
--- /dev/null
+++ b/lib/mlibc/abis/linux/utsname.h
@@ -0,0 +1,13 @@
+#ifndef _ABIBITS_UTSNAME_T_H
+#define _ABIBITS_UTSNAME_T_H
+
+struct utsname {
+ char sysname[65];
+ char nodename[65];
+ char release[65];
+ char version[65];
+ char machine[65];
+ char domainname[65];
+};
+
+#endif // _ABIBITS_UTSNAME_T_H
diff --git a/lib/mlibc/abis/linux/vm-flags.h b/lib/mlibc/abis/linux/vm-flags.h
new file mode 100644
index 0000000..3f8137c
--- /dev/null
+++ b/lib/mlibc/abis/linux/vm-flags.h
@@ -0,0 +1,70 @@
+#ifndef _ABIBITS_VM_FLAGS_H
+#define _ABIBITS_VM_FLAGS_H
+
+#define PROT_NONE 0x00
+#define PROT_READ 0x01
+#define PROT_WRITE 0x02
+#define PROT_EXEC 0x04
+
+#define MAP_FAILED ((void *)(-1))
+#define MAP_FILE 0x00
+#define MAP_SHARED 0x01
+#define MAP_PRIVATE 0x02
+#define MAP_FIXED 0x10
+#define MAP_ANON 0x20
+#define MAP_ANONYMOUS 0x20
+#define MAP_GROWSDOWN 0x100
+#define MAP_DENYWRITE 0x800
+#define MAP_EXECUTABLE 0x1000
+#define MAP_LOCKED 0x2000
+#define MAP_NORESERVE 0x4000
+#define MAP_POPULATE 0x8000
+#define MAP_NONBLOCK 0x10000
+#define MAP_STACK 0x20000
+#define MAP_HUGETLB 0x40000
+#define MAP_SYNC 0x80000
+#define MAP_FIXED_NOREPLACE 0x100000
+
+#define MS_ASYNC 0x01
+#define MS_INVALIDATE 0x02
+#define MS_SYNC 0x04
+
+#define MCL_CURRENT 0x01
+#define MCL_FUTURE 0x02
+
+#define POSIX_MADV_NORMAL 0
+#define POSIX_MADV_RANDOM 1
+#define POSIX_MADV_SEQUENTIAL 2
+#define POSIX_MADV_WILLNEED 3
+#define POSIX_MADV_DONTNEED 4
+
+#define MADV_NORMAL 0
+#define MADV_RANDOM 1
+#define MADV_SEQUENTIAL 2
+#define MADV_WILLNEED 3
+#define MADV_DONTNEED 4
+#define MADV_FREE 8
+#define MADV_REMOVE 9
+#define MADV_DONTFORK 10
+#define MADV_DOFORK 11
+#define MADV_MERGEABLE 12
+#define MADV_UNMERGEABLE 13
+#define MADV_HUGEPAGE 14
+#define MADV_NOHUGEPAGE 15
+#define MADV_DONTDUMP 16
+#define MADV_DODUMP 17
+#define MADV_WIPEONFORK 18
+#define MADV_KEEPONFORK 19
+#define MADV_COLD 20
+#define MADV_PAGEOUT 21
+#define MADV_HWPOISON 100
+#define MADV_SOFT_OFFLINE 101
+
+#define MREMAP_MAYMOVE 1
+#define MREMAP_FIXED 2
+
+#define MFD_CLOEXEC 1U
+#define MFD_ALLOW_SEALING 2U
+#define MFD_HUGETLB 4U
+
+#endif // _ABIBITS_VM_FLAGS_H
diff --git a/lib/mlibc/abis/linux/vt.h b/lib/mlibc/abis/linux/vt.h
new file mode 100644
index 0000000..811933b
--- /dev/null
+++ b/lib/mlibc/abis/linux/vt.h
@@ -0,0 +1,76 @@
+#ifndef _ABIBITS_VT_H
+#define _ABIBITS_VT_H
+
+#define MIN_NR_CONSOLES 1
+#define MAX_NR_CONSOLES 63
+
+#define VT_OPENQRY 0x5600
+#define VT_GETMODE 0x5601
+#define VT_SETMODE 0x5602
+#define VT_GETSTATE 0x5603
+#define VT_SENDSIG 0x5604
+#define VT_RELDISP 0x5605
+#define VT_ACTIVATE 0x5606
+#define VT_WAITACTIVE 0x5607
+#define VT_DISALLOCATE 0x5608
+#define VT_RESIZE 0x5609
+#define VT_RESIZEX 0x560A
+#define VT_LOCKSWITCH 0x560B
+#define VT_UNLOCKSWITCH 0x560C
+#define VT_GETHIFONTMASK 0x560D
+#define VT_WAITEVENT 0x560E
+#define VT_SETACTIVATE 0x560F
+
+struct vt_mode {
+ char mode;
+ char waitv;
+ short relsig;
+ short acqsig;
+ short frsig;
+};
+
+#define VT_AUTO 0x00
+#define VT_PROCESS 0x01
+#define VT_ACKACQ 0x02
+
+struct vt_stat {
+ unsigned short v_active;
+ unsigned short v_signal;
+ unsigned short v_state;
+};
+
+struct vt_sizes {
+ unsigned short v_rows;
+ unsigned short v_cols;
+ unsigned short v_scrollsize;
+};
+
+struct vt_consize {
+ unsigned short v_rows;
+ unsigned short v_cols;
+ unsigned short v_vlin;
+ unsigned short v_clin;
+ unsigned short v_vcol;
+ unsigned short v_ccol;
+};
+
+#define VT_EVENT_SWITCH 0x0001
+#define VT_EVENT_BLANK 0x0002
+#define VT_EVENT_UNBLANK 0x0004
+#define VT_EVENT_RESIZE 0x0008
+#define VT_MAX_EVENT 0x000F
+
+struct vt_event {
+ unsigned int event;
+
+ unsigned int oldev;
+ unsigned int newev;
+ unsigned int pad[4];
+};
+
+struct vt_setactivate {
+ unsigned int console;
+ struct vt_mode mode;
+};
+
+#endif // _ABIBITS_VT_H
diff --git a/lib/mlibc/abis/linux/wait.h b/lib/mlibc/abis/linux/wait.h
new file mode 100644
index 0000000..58d1462
--- /dev/null
+++ b/lib/mlibc/abis/linux/wait.h
@@ -0,0 +1,28 @@
+#ifndef _ABIBITS_WAIT_H
+#define _ABIBITS_WAIT_H
+
+#define WNOHANG 1
+#define WUNTRACED 2
+#define WSTOPPED 2
+#define WEXITED 4
+#define WCONTINUED 8
+#define WNOWAIT 0x01000000
+
+#define __WALL 0x40000000
+#define __WCLONE 0x80000000
+
+#define WCOREFLAG 0x80
+
+#define WEXITSTATUS(x) (((x) & 0xff00) >> 8)
+#define WTERMSIG(x) ((x) & 0x7f)
+#define WSTOPSIG(x) WEXITSTATUS(x)
+#define WIFEXITED(x) (WTERMSIG(x) == 0)
+#define WIFSIGNALED(x) (((signed char) (((x) & 0x7f) + 1) >> 1) > 0)
+#define WIFSTOPPED(x) (((x) & 0xff) == 0x7f)
+#define WIFCONTINUED(x) ((x) == 0xffff)
+#define WCOREDUMP(x) ((x) & WCOREFLAG)
+
+/* glibc extension, but also useful for kernels */
+#define W_EXITCODE(ret, sig) (((ret) << 8) | (sig))
+
+#endif //_ABIBITS_WAIT_H
diff --git a/lib/mlibc/abis/linux/xattr.h b/lib/mlibc/abis/linux/xattr.h
new file mode 100644
index 0000000..c0e7fbe
--- /dev/null
+++ b/lib/mlibc/abis/linux/xattr.h
@@ -0,0 +1,21 @@
+#ifndef MLIBC_ABIS_LINUX_XATTR_H
+#define MLIBC_ABIS_LINUX_XATTR_H
+
+/* __USE_KERNEL_XATTR_DEFS is exported when XATTR_* are emitted, and
+ * __UAPI_DEF_XATTR is used to determine the behaviour of the
+ * <linux/xattr.h> header (through <linux/libc-compat.h>), if it's set
+ * to 1, the header exports xattr defines and __USE_KERNEL_XATTR_DEFS.
+ * This applies for pretty much all other defines in libc-compat.h
+ * AFAICT.
+ */
+#ifndef __USE_KERNEL_XATTR_DEFS
+enum {
+ XATTR_CREATE = 1,
+#define XATTR_CREATE XATTR_CREATE
+ XATTR_REPLACE = 2,
+#define XATTR_REPLACE XATTR_REPLACE
+};
+# define __UAPI_DEF_XATTR 0
+#endif
+
+#endif /* MLIBC_ABIS_LINUX_XATTR_H */
diff --git a/lib/mlibc/abis/lyre/statvfs.h b/lib/mlibc/abis/lyre/statvfs.h
new file mode 100644
index 0000000..7f53fc0
--- /dev/null
+++ b/lib/mlibc/abis/lyre/statvfs.h
@@ -0,0 +1,35 @@
+#ifndef _ABIBITS_STATVFS_H
+#define _ABIBITS_STATVFS_H
+
+#include <abi-bits/fsblkcnt_t.h>
+#include <abi-bits/fsfilcnt_t.h>
+
+#define ST_RDONLY 1
+#define ST_NOSUID 2
+#define ST_MANDLOCK 64
+
+#define FSTYPSZ 16
+
+// On Linux, this struct is not directly used by the kernel.
+struct statvfs {
+ unsigned long f_bsize;
+ unsigned long f_frsize;
+ fsblkcnt_t f_blocks;
+ fsblkcnt_t f_bfree;
+ fsblkcnt_t f_bavail;
+
+ fsfilcnt_t f_files;
+ fsfilcnt_t f_ffree;
+ fsfilcnt_t f_favail;
+
+ unsigned long f_fsid;
+ char f_basetype[FSTYPSZ];
+
+ unsigned long f_flag;
+ unsigned long f_namemax;
+ char f_fstr[32];
+ unsigned long f_filler[16];
+};
+
+#endif /* _ABIBITS_STATVFS_H */
+
diff --git a/lib/mlibc/abis/managarm/auxv.h b/lib/mlibc/abis/managarm/auxv.h
new file mode 100644
index 0000000..5db7f03
--- /dev/null
+++ b/lib/mlibc/abis/managarm/auxv.h
@@ -0,0 +1,16 @@
+#ifndef _ABIBITS_AUXV_H
+#define _ABIBITS_AUXV_H
+
+#define AT_SECURE 23
+#define AT_RANDOM 25
+#define AT_EXECFN 31
+#define AT_SYSINFO_EHDR 33
+
+// managarm specific auxvector entries.
+
+#define AT_XPIPE 0x1000
+#define AT_OPENFILES 0x1001
+#define AT_FS_SERVER 0x1102
+#define AT_MBUS_SERVER 0x1103
+
+#endif // _ABIBITS_AUXV_H
diff --git a/lib/mlibc/abis/mlibc/access.h b/lib/mlibc/abis/mlibc/access.h
new file mode 100644
index 0000000..bc19728
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/access.h
@@ -0,0 +1,9 @@
+#ifndef _ABIBITS_ACCESS_H
+#define _ABIBITS_ACCESS_H
+
+#define F_OK 1
+#define R_OK 2
+#define W_OK 4
+#define X_OK 8
+
+#endif // _ABIBITS_ACCESS_H
diff --git a/lib/mlibc/abis/mlibc/blkcnt_t.h b/lib/mlibc/abis/mlibc/blkcnt_t.h
new file mode 100644
index 0000000..51c1519
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/blkcnt_t.h
@@ -0,0 +1,7 @@
+#ifndef _ABIBITS_BLKCNT_T_H
+#define _ABIBITS_BLKCNT_T_H
+
+// TODO: use int64_t?
+typedef long blkcnt_t;
+
+#endif // _ABIBITS_BLKCNT_T_H
diff --git a/lib/mlibc/abis/mlibc/blksize_t.h b/lib/mlibc/abis/mlibc/blksize_t.h
new file mode 100644
index 0000000..9363a50
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/blksize_t.h
@@ -0,0 +1,9 @@
+
+#ifndef _ABIBITS_BLKSIZE_T_H
+#define _ABIBITS_BLKSIZE_T_H
+
+// TODO: use int64_t?
+typedef long blksize_t;
+
+#endif // _ABIBITS_BLKSIZE_T_H
+
diff --git a/lib/mlibc/abis/mlibc/clockid_t.h b/lib/mlibc/abis/mlibc/clockid_t.h
new file mode 100644
index 0000000..c3932ef
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/clockid_t.h
@@ -0,0 +1,7 @@
+#ifndef _ABIBITS_CLOCKID_T_H
+#define _ABIBITS_CLOCKID_T_H
+
+typedef long clockid_t;
+
+#endif /* _ABIBITS_CLOCKID_T_H */
+
diff --git a/lib/mlibc/abis/mlibc/dev_t.h b/lib/mlibc/abis/mlibc/dev_t.h
new file mode 100644
index 0000000..2481af3
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/dev_t.h
@@ -0,0 +1,8 @@
+
+#ifndef _ABIBITS_DEV_T_H
+#define _ABIBITS_DEV_T_H
+
+typedef unsigned long dev_t;
+
+#endif // _ABIBITS_DEV_T_H
+
diff --git a/lib/mlibc/abis/mlibc/epoll.h b/lib/mlibc/abis/mlibc/epoll.h
new file mode 100644
index 0000000..49969d5
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/epoll.h
@@ -0,0 +1,6 @@
+#ifndef _ABIBITS_EPOLL_H
+#define _ABIBITS_EPOLL_H
+
+#define EPOLL_CLOEXEC 1
+
+#endif // _ABIBITS_EPOLL_H
diff --git a/lib/mlibc/abis/mlibc/errno.h b/lib/mlibc/abis/mlibc/errno.h
new file mode 100644
index 0000000..f8c7203
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/errno.h
@@ -0,0 +1,126 @@
+#ifndef _ABIBITS_ERRNO_H
+#define _ABIBITS_ERRNO_H
+
+#define EDOM 1
+#define EILSEQ 2
+#define ERANGE 3
+
+#define E2BIG 1001
+#define EACCES 1002
+#define EADDRINUSE 1003
+#define EADDRNOTAVAIL 1004
+#define EAFNOSUPPORT 1005
+#define EAGAIN 1006
+#define EALREADY 1007
+#define EBADF 1008
+#define EBADMSG 1009
+#define EBUSY 1010
+#define ECANCELED 1011
+#define ECHILD 1012
+#define ECONNABORTED 1013
+#define ECONNREFUSED 1014
+#define ECONNRESET 1015
+#define EDEADLK 1016
+#define EDESTADDRREQ 1017
+#define EDQUOT 1018
+#define EEXIST 1019
+#define EFAULT 1020
+#define EFBIG 1021
+#define EHOSTUNREACH 1022
+#define EIDRM 1023
+#define EINPROGRESS 1024
+#define EINTR 1025
+#define EINVAL 1026
+#define EIO 1027
+#define EISCONN 1028
+#define EISDIR 1029
+#define ELOOP 1030
+#define EMFILE 1031
+#define EMLINK 1032
+#define EMSGSIZE 1034
+#define EMULTIHOP 1035
+#define ENAMETOOLONG 1036
+#define ENETDOWN 1037
+#define ENETRESET 1038
+#define ENETUNREACH 1039
+#define ENFILE 1040
+#define ENOBUFS 1041
+#define ENODEV 1042
+#define ENOENT 1043
+#define ENOEXEC 1044
+#define ENOLCK 1045
+#define ENOLINK 1046
+#define ENOMEM 1047
+#define ENOMSG 1048
+#define ENOPROTOOPT 1049
+#define ENOSPC 1050
+#define ENOSYS 1051
+#define ENOTCONN 1052
+#define ENOTDIR 1053
+#define ENOTEMPTY 1054
+#define ENOTRECOVERABLE 1055
+#define ENOTSOCK 1056
+#define ENOTSUP 1057
+#define ENOTTY 1058
+#define ENXIO 1059
+#define EOPNOTSUPP 1060
+#define EOVERFLOW 1061
+#define EOWNERDEAD 1062
+#define EPERM 1063
+#define EPIPE 1064
+#define EPROTO 1065
+#define EPROTONOSUPPORT 1066
+#define EPROTOTYPE 1067
+#define EROFS 1068
+#define ESPIPE 1069
+#define ESRCH 1070
+#define ESTALE 1071
+#define ETIMEDOUT 1072
+#define ETXTBSY 1073
+#define EWOULDBLOCK EAGAIN
+#define EXDEV 1075
+#define ENODATA 1076
+#define ETIME 1077
+#define ENOKEY 1078
+#define ESHUTDOWN 1079
+#define EHOSTDOWN 1080
+#define EBADFD 1081
+#define ENOMEDIUM 1082
+#define ENOTBLK 1083
+#define ENONET 1084
+#define EPFNOSUPPORT 1085
+#define ESOCKTNOSUPPORT 1086
+#define ESTRPIPE 1087
+#define EREMOTEIO 1088
+#define ERFKILL 1089
+#define EBADR 1090
+#define EUNATCH 1091
+#define EMEDIUMTYPE 1092
+#define EREMOTE 1093
+#define EKEYREJECTED 1094
+#define EUCLEAN 1095
+#define EBADSLT 1096
+#define ENOANO 1097
+#define ENOCSI 1098
+#define ENOSTR 1099
+#define ETOOMANYREFS 1100
+#define ENOPKG 1101
+#define EKEYREVOKED 1102
+#define EXFULL 1103
+#define ELNRNG 1104
+#define ENOTUNIQ 1105
+#define ERESTART 1106
+#define EUSERS 1107
+#define ECHRNG 1108
+#define ELIBBAD 1109
+#define EL2HLT 1110
+#define EL3HLT 1111
+#define EKEYEXPIRED 1112
+#define ECOMM 1113
+#define EBADE 1114
+#define EHWPOISON 1115
+#define EBADRQC 1116
+
+#define EIEIO 1524152434
+
+#endif // _ABIBITS_ERRNO_H
diff --git a/lib/mlibc/abis/mlibc/fcntl.h b/lib/mlibc/abis/mlibc/fcntl.h
new file mode 100644
index 0000000..8f773aa
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/fcntl.h
@@ -0,0 +1,76 @@
+#ifndef _ABIBITS_FCNTL_H
+#define _ABIBITS_FCNTL_H
+
+// reserve 3 bits for the access mode
+#define O_ACCMODE 0x0007
+#define O_EXEC 1
+#define O_RDONLY 2
+#define O_RDWR 3
+#define O_SEARCH 4
+#define O_WRONLY 5
+
+// these flags get their own bit
+#define O_APPEND 0x000008
+#define O_CREAT 0x000010
+#define O_DIRECTORY 0x000020
+#define O_EXCL 0x000040
+#define O_NOCTTY 0x000080
+#define O_NOFOLLOW 0x000100
+#define O_TRUNC 0x000200
+#define O_NONBLOCK 0x000400
+#define O_DSYNC 0x000800
+#define O_RSYNC 0x001000
+#define O_SYNC 0x002000
+#define O_CLOEXEC 0x004000
+#define O_PATH 0x008000
+#define O_LARGEFILE 0x010000
+#define O_NOATIME 0x020000
+#define O_ASYNC 0x040000
+#define O_TMPFILE 0x080000
+#define O_DIRECT 0x100000
+
+// constants for fcntl()'s command argument
+#define F_DUPFD 1
+#define F_DUPFD_CLOEXEC 2
+#define F_GETFD 3
+#define F_SETFD 4
+#define F_GETFL 5
+#define F_SETFL 6
+#define F_GETLK 7
+#define F_SETLK 8
+#define F_SETLKW 9
+#define F_GETOWN 10
+#define F_SETOWN 11
+
+// constants for struct flock's l_type member
+#define F_RDLCK 1
+#define F_UNLCK 2
+#define F_WRLCK 3
+
+// constants for fcntl()'s additional argument of F_GETFD and F_SETFD
+#define FD_CLOEXEC 1
+
+// Used by mmap
+#define F_SEAL_SHRINK 0x0002
+#define F_SEAL_GROW 0x0004
+#define F_SEAL_WRITE 0x0008
+#define F_SEAL_SEAL 0x0010
+#define F_ADD_SEALS 1033
+#define F_GET_SEALS 1034
+
+#define AT_EMPTY_PATH 1
+#define AT_SYMLINK_FOLLOW 2
+#define AT_SYMLINK_NOFOLLOW 4
+#define AT_REMOVEDIR 8
+#define AT_EACCESS 512
+
+#define AT_FDCWD -100
+
+#define POSIX_FADV_NORMAL 1
+#define POSIX_FADV_SEQUENTIAL 2
+#define POSIX_FADV_NOREUSE 3
+#define POSIX_FADV_DONTNEED 4
+#define POSIX_FADV_WILLNEED 5
+#define POSIX_FADV_RANDOM 6
+
+#endif // _ABITBITS_FCNTL_H
diff --git a/lib/mlibc/abis/mlibc/gid_t.h b/lib/mlibc/abis/mlibc/gid_t.h
new file mode 100644
index 0000000..65afa40
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/gid_t.h
@@ -0,0 +1,8 @@
+
+#ifndef _ABIBITS_GID_T_H
+#define _ABIBITS_GID_T_H
+
+typedef unsigned int gid_t;
+
+#endif // _ABIBITS_GID_T_H
+
diff --git a/lib/mlibc/abis/mlibc/in.h b/lib/mlibc/abis/mlibc/in.h
new file mode 100644
index 0000000..3c736e3
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/in.h
@@ -0,0 +1,168 @@
+#ifndef _ABIBITS_IN_H
+#define _ABIBITS_IN_H
+
+#include <bits/posix/in_addr_t.h>
+#include <bits/posix/in_port_t.h>
+#include <abi-bits/socket.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct in_addr {
+ in_addr_t s_addr;
+};
+
+struct sockaddr_in {
+ sa_family_t sin_family;
+ in_port_t sin_port;
+ struct in_addr sin_addr;
+ uint8_t pad[8];
+};
+#define sin_zero pad /* for BSD Unix compatibility */
+
+struct in6_addr {
+ union {
+ uint8_t __s6_addr[16];
+ uint16_t __s6_addr16[8];
+ uint32_t __s6_addr32[4];
+ } __in6_union;
+};
+#define s6_addr __in6_union.__s6_addr
+#define s6_addr16 __in6_union.__s6_addr16
+#define s6_addr32 __in6_union.__s6_addr32
+
+struct in6_pktinfo {
+ struct in6_addr ipi6_addr;
+ uint32_t ipi6_ifindex;
+};
+
+struct sockaddr_in6 {
+ sa_family_t sin6_family;
+ in_port_t sin6_port;
+ uint32_t sin6_flowinfo;
+ struct in6_addr sin6_addr;
+ uint32_t sin6_scope_id;
+};
+
+struct ipv6_mreq {
+ struct in6_addr ipv6mr_multiaddr;
+ unsigned ipv6mr_interface;
+};
+
+struct ip_mreq {
+ struct in_addr imr_multiaddr;
+ struct in_addr imr_interface;
+};
+
+struct ip_mreq_source {
+ struct in_addr imr_multiaddr;
+ struct in_addr imr_interface;
+ struct in_addr imr_sourceaddr;
+};
+
+struct ip_mreqn {
+ struct in_addr imr_multiaddr;
+ struct in_addr imr_address;
+ int imr_ifindex;
+};
+
+struct in_pktinfo {
+ unsigned int ipi_ifindex;
+ struct in_addr ipi_spec_dst;
+ struct in_addr ipi_addr;
+};
+
+struct group_source_req {
+ uint32_t gsr_interface;
+ struct sockaddr_storage gsr_group;
+ struct sockaddr_storage gsr_source;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
+#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
+
+#define IPPROTO_IP 1
+#define IPPROTO_IPV6 2
+#define IPPROTO_ICMP 3
+#define IPPROTO_RAW 4
+#define IPPROTO_TCP 5
+#define IPPROTO_UDP 6
+#define IPPROTO_IGMP 7
+#define IPPROTO_IPIP 8
+#define IPPROTO_DCCP 33
+#define IPPROTO_ROUTING 43
+#define IPPROTO_GRE 47
+#define IPPROTO_ESP 50
+#define IPPROTO_AH 51
+#define IPPROTO_ICMPV6 58
+#define IPPROTO_DSTOPTS 60
+#define IPPROTO_COMP 108
+#define IPPROTO_SCTP 132
+#define IPPROTO_UDPLITE 136
+#define IPPROTO_MAX 256
+
+#define INADDR_ANY ((in_addr_t)0x00000000)
+#define INADDR_BROADCAST ((in_addr_t)0xffffffff)
+#define INADDR_LOOPBACK ((in_addr_t)0x7f000001)
+#define INADDR_NONE ((in_addr_t)0xffffffff)
+
+#define INET_ADDRSTRLEN 16
+
+#define INET6_ADDRSTRLEN 46
+
+#define IPV6_JOIN_GROUP 1
+#define IPV6_LEAVE_GROUP 2
+#define IPV6_MULTICAST_HOPS 3
+#define IPV6_MULTICAST_IF 4
+#define IPV6_MULTICAST_LOOP 5
+#define IPV6_UNICAST_HOPS 6
+#define IPV6_V6ONLY 7
+#define IPV6_PMTUDISC_DONT 8
+#define IPV6_PMTUDISC_DO 9
+#define IPV6_MTU 10
+#define IPV6_2292PKTOPTIONS 11
+#define IPV6_MTU_DISCOVER 23
+#define IPV6_RECVERR 25
+#define IPV6_RECVPKTINFO 49
+#define IPV6_PKTINFO 50
+#define IPV6_RECVHOPLIMIT 51
+#define IPV6_HOPLIMIT 52
+#define IPV6_TCLASS 67
+
+#define IP_TOS 1
+#define IP_TTL 2
+#define IP_OPTIONS 4
+#define IP_PMTUDISC_OMIT 5
+#define IP_PKTINFO 8
+#define IP_PKTOPTIONS 9
+#define IP_MTU_DISCOVER 10
+#define IP_RECVERR 11
+#define IP_RECVTTL 12
+#define IP_UNICAST_IF 13
+#define IP_MTU 14
+
+#define IP_DEFAULT_MULTICAST_TTL 1
+#define IP_MULTICAST_IF 32
+#define IP_MULTICAST_TTL 33
+#define IP_MULTICAST_LOOP 34
+#define IP_ADD_MEMBERSHIP 35
+#define IP_DROP_MEMBERSHIP 36
+#define IP_UNBLOCK_SOURCE 37
+#define IP_BLOCK_SOURCE 38
+#define IP_ADD_SOURCE_MEMBERSHIP 39
+#define IP_DROP_SOURCE_MEMBERSHIP 40
+#define MCAST_JOIN_SOURCE_GROUP 46
+#define MCAST_LEAVE_SOURCE_GROUP 47
+
+#define IP_PMTUDISC_DONT 0
+#define IP_PMTUDISC_DO 2
+
+#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
+#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
+
+#endif // _ABIBITS_IN_H
diff --git a/lib/mlibc/abis/mlibc/ino_t.h b/lib/mlibc/abis/mlibc/ino_t.h
new file mode 100644
index 0000000..a80249f
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/ino_t.h
@@ -0,0 +1,9 @@
+
+#ifndef _ABIBITS_INO_T_H
+#define _ABIBITS_INO_T_H
+
+// TODO: use (u)int64_t?
+typedef long ino_t;
+
+#endif // _ABIBITS_INO_T_H
+
diff --git a/lib/mlibc/abis/mlibc/inotify.h b/lib/mlibc/abis/mlibc/inotify.h
new file mode 100644
index 0000000..38c9c77
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/inotify.h
@@ -0,0 +1,7 @@
+#ifndef _ABIBITS_INOTIFY_H
+#define _ABIBITS_INOTIFY_H
+
+#define IN_CLOEXEC 1
+#define IN_NONBLOCK 2
+
+#endif // _ABIBITS_INOTIFY_H
diff --git a/lib/mlibc/abis/mlibc/limits.h b/lib/mlibc/abis/mlibc/limits.h
new file mode 100644
index 0000000..6aac622
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/limits.h
@@ -0,0 +1,14 @@
+#ifndef _ABIBITS_LIMITS_H
+#define _ABIBITS_LIMITS_H
+
+#define IOV_MAX 1024
+
+// Niceness related
+#define NZERO 20
+
+// Maximum hostname length, posix defines it as 255
+#define HOST_NAME_MAX 255
+
+#define OPEN_MAX 256
+
+#endif //_ABIBITS_LIMITS_H
diff --git a/lib/mlibc/abis/mlibc/mode_t.h b/lib/mlibc/abis/mlibc/mode_t.h
new file mode 100644
index 0000000..c833299
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/mode_t.h
@@ -0,0 +1,8 @@
+
+#ifndef _ABIBITS_MODE_T_H
+#define _ABIBITS_MODE_T_H
+
+typedef int mode_t;
+
+#endif // _ABIBITS_MODE_T_H
+
diff --git a/lib/mlibc/abis/mlibc/nlink_t.h b/lib/mlibc/abis/mlibc/nlink_t.h
new file mode 100644
index 0000000..cb1e76b
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/nlink_t.h
@@ -0,0 +1,8 @@
+
+#ifndef _ABIBITS_NLINK_T_H
+#define _ABIBITS_NLINK_T_H
+
+typedef int nlink_t;
+
+#endif // _ABIBITS_NLINK_T_H
+
diff --git a/lib/mlibc/abis/mlibc/packet.h b/lib/mlibc/abis/mlibc/packet.h
new file mode 100644
index 0000000..ee1a424
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/packet.h
@@ -0,0 +1,6 @@
+#ifndef _ABIBITS_PACKET_H
+#define _ABIBITS_PACKET_H
+
+#define PACKET_HOST 0
+
+#endif // _ABIBITS_PACKET_H
diff --git a/lib/mlibc/abis/mlibc/pid_t.h b/lib/mlibc/abis/mlibc/pid_t.h
new file mode 100644
index 0000000..323168e
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/pid_t.h
@@ -0,0 +1,8 @@
+
+#ifndef _ABIBITS_PID_T_H
+#define _ABIBITS_PID_T_H
+
+typedef int pid_t;
+
+#endif // _ABIBITS_PID_T_H
+
diff --git a/lib/mlibc/abis/mlibc/poll.h b/lib/mlibc/abis/mlibc/poll.h
new file mode 100644
index 0000000..e0fe1a5
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/poll.h
@@ -0,0 +1,16 @@
+#ifndef _ABIBITS_POLL_H
+#define _ABIBITS_POLL_H
+
+#define POLLIN 0x01
+#define POLLOUT 0x02
+#define POLLPRI 0x04
+#define POLLHUP 0x08
+#define POLLERR 0x10
+#define POLLRDHUP 0x20
+#define POLLNVAL 0x40
+#define POLLWRNORM 0x80
+#define POLLRDNORM 0x100
+#define POLLWRBAND 0x200
+#define POLLRDBAND 0x400
+
+#endif // _ABIBITS_POLL_H
diff --git a/lib/mlibc/abis/mlibc/ptrace.h b/lib/mlibc/abis/mlibc/ptrace.h
new file mode 100644
index 0000000..6f35eac
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/ptrace.h
@@ -0,0 +1,56 @@
+#ifndef _ABIBITS_PTRACE_H
+#define _ABIBITS_PTRACE_H
+
+#define PTRACE_PEEKTEXT 1
+#define PTRACE_PEEKDATA 2
+#define PTRACE_PEEKUSER 3
+#define PTRACE_POKETEXT 4
+#define PTRACE_POKEDATA 5
+#define PTRACE_CONT 7
+#define PTRACE_KILL 8
+#define PTRACE_SINGLESTEP 9
+#define PTRACE_GETREGS 14
+#define PTRACE_SETREGS 15
+#define PTRACE_ATTACH 16
+#define PTRACE_DETACH 17
+#define PTRACE_GETFPXREGS 18
+#define PTRACE_SETFPXREGS 19
+#define PTRACE_GETFPREGS 20
+#define PTRACE_SYSCALL 24
+#define PTRACE_SETOPTIONS 0x4200
+#define PTRACE_GETEVENTMSG 0x4201
+#define PTRACE_GETSIGINFO 0x4202
+#define PTRACE_SETSIGINFO 0x4203
+#define PTRACE_GETREGSET 0x4204
+#define PTRACE_SETREGSET 0x4205
+#define PTRACE_SEIZE 0x4206
+#define PTRACE_INTERRUPT 0x4207
+#define PTRACE_LISTEN 0x4208
+#define PTRACE_PEEKSIGINFO 0x4209
+#define PTRACE_GETSIGMASK 0x420A
+#define PTRACE_SETSIGMASK 0x420B
+#define PTRACE_SECCOMP_GET_FILTER 0x420C
+
+#define PTRACE_CE_O_TRACESYSGOOD 0x00000001
+#define PTRACE_O_TRACEFORK 0x00000002
+#define PTRACE_O_TRACEVFORK 0x00000004
+#define PTRACE_O_TRACECLONE 0x00000008
+#define PTRACE_O_TRACEEXEC 0x00000010
+#define PTRACE_O_TRACEVFORKDONE 0x00000020
+#define PTRACE_O_TRACEEXIT 0x00000040
+#define PTRACE_O_TRACESECCOMP 0x00000080
+#define PTRACE_O_EXITKILL 0x00100000
+#define PTRACE_O_SUSPEND_SECCOMP 0x00200000
+#define PTRACE_O_MASK 0x003000ff
+
+#define PTRACE_EVENT_FORK 1
+#define PTRACE_EVENT_VFORK 2
+#define PTRACE_EVENT_CLONE 3
+#define PTRACE_EVENT_EXEC 4
+#define PTRACE_EVENT_VFORK_DONE 5
+#define PTRACE_EVENT_EXIT 6
+#define PTRACE_EVENT_SECCOMP 7
+
+#define PTRACE_PEEKSIGINFO_SHARED 1
+
+#endif // _ABIBITS_PTRACE_H
diff --git a/lib/mlibc/abis/mlibc/resource.h b/lib/mlibc/abis/mlibc/resource.h
new file mode 100644
index 0000000..927588b
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/resource.h
@@ -0,0 +1,53 @@
+#ifndef _ABIBITS_RESOURCE_H
+#define _ABIBITS_RESOURCE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <bits/posix/timeval.h>
+
+#define RUSAGE_SELF 1
+#define RUSAGE_CHILDREN 2
+
+#define RLIMIT_CORE 1
+#define RLIMIT_CPU 2
+#define RLIMIT_DATA 3
+#define RLIMIT_FSIZE 4
+#define RLIMIT_NOFILE 5
+#define RLIMIT_STACK 6
+#define RLIMIT_AS 7
+#define RLIMIT_MEMLOCK 8
+#define RLIMIT_RSS 9
+#define RLIMIT_NPROC 10
+#define RLIMIT_LOCKS 11
+#define RLIMIT_SIGPENDING 12
+#define RLIMIT_MSGQUEUE 13
+#define RLIMIT_NICE 14
+#define RLIMIT_RTPRIO 15
+#define RLIMIT_NLIMITS 16
+
+struct rusage {
+ struct timeval ru_utime;
+ struct timeval ru_stime;
+ long int ru_maxrss;
+ long int ru_ixrss;
+ long int ru_idrss;
+ long int ru_isrss;
+ long int ru_minflt;
+ long int ru_majflt;
+ long int ru_nswap;
+ long int ru_inblock;
+ long int ru_oublock;
+ long int ru_msgsnd;
+ long int ru_msgrcv;
+ long int ru_nsignals;
+ long int ru_nvcsw;
+ long int ru_nivcsw;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _ABIBITS_RESOURCE_H
diff --git a/lib/mlibc/abis/mlibc/seek-whence.h b/lib/mlibc/abis/mlibc/seek-whence.h
new file mode 100644
index 0000000..5af138b
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/seek-whence.h
@@ -0,0 +1,10 @@
+#ifndef _ABIBITS_SEEK_WHENCE_H
+#define _ABIBITS_SEEK_WHENCE_H
+
+#define SEEK_CUR 1
+#define SEEK_END 2
+#define SEEK_SET 3
+#define SEEK_DATA 4
+#define SEEK_HOLE 5
+
+#endif // _ABIBITS_SEEK_WHENCE_H
diff --git a/lib/mlibc/abis/mlibc/signal.h b/lib/mlibc/abis/mlibc/signal.h
new file mode 100644
index 0000000..320bea7
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/signal.h
@@ -0,0 +1,195 @@
+#ifndef _ABIBITS_SIGNAL_H
+#define _ABIBITS_SIGNAL_H
+
+#if __MLIBC_BUILDING_MLIBC
+#warning abis/mlibc/signal.h is deprecated. We suggest to use abis/linux/signal.h instead. \
+ Note that this will potentially require kernel changes.
+#endif
+
+#include <abi-bits/pid_t.h>
+#include <abi-bits/uid_t.h>
+#include <bits/types.h>
+#include <bits/size_t.h>
+
+union sigval {
+ int sival_int;
+ void *sival_ptr;
+};
+
+typedef struct {
+ int si_signo;
+ int si_code;
+ int si_errno;
+ pid_t si_pid;
+ uid_t si_uid;
+ void *si_addr;
+ int si_status;
+ union sigval si_value;
+} siginfo_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Argument for signal()
+typedef void (*__sighandler) (int);
+
+#define SIG_ERR ((__sighandler)(void *)(-1))
+#define SIG_DFL ((__sighandler)(void *)(-2))
+#define SIG_IGN ((__sighandler)(void *)(-3))
+
+#define SIGHUP 1
+#define SIGINT 2
+#define SIGQUIT 3
+#define SIGILL 4
+#define SIGTRAP 5
+#define SIGABRT 6
+#define SIGBUS 7
+#define SIGFPE 8
+#define SIGKILL 9
+#define SIGUSR1 10
+#define SIGSEGV 11
+#define SIGUSR2 12
+#define SIGPIPE 13
+#define SIGALRM 14
+#define SIGTERM 15
+#define SIGSTKFLT 16
+#define SIGCHLD 17
+#define SIGCONT 18
+#define SIGSTOP 19
+#define SIGTSTP 20
+#define SIGTTIN 21
+#define SIGTTOU 22
+#define SIGURG 23
+#define SIGXCPU 24
+#define SIGXFSZ 25
+#define SIGVTALRM 26
+#define SIGPROF 27
+#define SIGWINCH 28
+#define SIGIO 29
+#define SIGPOLL SIGIO
+#define SIGPWR 30
+#define SIGSYS 31
+#define SIGRTMIN 32
+#define SIGRTMAX 33
+#define SIGCANCEL 34
+
+// siginfo->si_info constants
+// SIGBUS
+#define BUS_ADRALN 1
+#define BUS_ADRERR 2
+#define BUS_OBJERR 3
+
+// SIGILL
+#define ILL_ILLOPC 1
+#define ILL_ILLOPN 2
+#define ILL_ILLADR 3
+#define ILL_ILLTRP 4
+#define ILL_PRVOPC 5
+#define ILL_PRVREG 6
+#define ILL_COPROC 7
+#define ILL_BADSTK 8
+#define ILL_BADIADDR 9
+
+// SIGSEGV
+#define SEGV_MAPERR 1
+#define SEGV_ACCERR 2
+
+typedef __mlibc_uint64 sigset_t;
+
+#define SIGUNUSED SIGSYS
+
+// constants for sigprocmask()
+#define SIG_BLOCK 1
+#define SIG_UNBLOCK 2
+#define SIG_SETMASK 3
+
+#define SA_NOCLDSTOP (1 << 0)
+#define SA_ONSTACK (1 << 1)
+#define SA_RESETHAND (1 << 2)
+#define SA_RESTART (1 << 3)
+#define SA_SIGINFO (1 << 4)
+#define SA_NOCLDWAIT (1 << 5)
+#define SA_NODEFER (1 << 6)
+
+#define MINSIGSTKSZ 2048
+#define SIGSTKSZ 8192
+#define SS_ONSTACK 1
+#define SS_DISABLE 2
+
+typedef struct __stack {
+ void *ss_sp;
+ size_t ss_size;
+ int ss_flags;
+} stack_t;
+
+// constants for sigev_notify of struct sigevent
+#define SIGEV_NONE 1
+#define SIGEV_SIGNAL 2
+#define SIGEV_THREAD 3
+
+#define SI_ASYNCNL (-60)
+#define SI_TKILL (-6)
+#define SI_SIGIO (-5)
+#define SI_ASYNCIO (-4)
+#define SI_MESGQ (-3)
+#define SI_TIMER (-2)
+#define SI_QUEUE (-1)
+#define SI_USER 0
+#define SI_KERNEL 128
+
+#define NSIG 65
+#define _NSIG NSIG
+
+#define CLD_EXITED 1
+#define CLD_KILLED 2
+#define CLD_DUMPED 3
+#define CLD_TRAPPED 4
+#define CLD_STOPPED 5
+#define CLD_CONTINUED 6
+
+struct sigevent {
+ int sigev_notify;
+ int sigev_signo;
+ union sigval sigev_value;
+ void (*sigev_notify_function)(union sigval);
+ // MISSING: sigev_notify_attributes
+};
+
+struct sigaction {
+ void (*sa_handler)(int);
+ sigset_t sa_mask;
+ int sa_flags;
+ void (*sa_sigaction)(int, siginfo_t *, void *);
+};
+
+#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__)
+// TODO: This is wrong for AArch64.
+
+typedef struct {
+ unsigned long oldmask;
+ unsigned long gregs[16];
+ unsigned long pc, pr, sr;
+ unsigned long gbr, mach, macl;
+ unsigned long fpregs[16];
+ unsigned long xfpregs[16];
+ unsigned int fpscr, fpul, ownedfp;
+} mcontext_t;
+
+typedef struct __ucontext {
+ unsigned long uc_flags;
+ struct __ucontext *uc_link;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ sigset_t uc_sigmask;
+} ucontext_t;
+
+#else
+#error "Missing architecture specific code."
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _ABIBITS_SIGNAL_H
diff --git a/lib/mlibc/abis/mlibc/socket.h b/lib/mlibc/abis/mlibc/socket.h
new file mode 100644
index 0000000..48b8178
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/socket.h
@@ -0,0 +1,165 @@
+#ifndef _ABIBITS_SOCKET_H
+#define _ABIBITS_SOCKET_H
+
+#include <abi-bits/socklen_t.h>
+#include <bits/posix/iovec.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef unsigned int sa_family_t;
+
+struct msghdr {
+ void *msg_name;
+ socklen_t msg_namelen;
+ struct iovec *msg_iov;
+ int msg_iovlen;
+ void *msg_control;
+ socklen_t msg_controllen;
+ int msg_flags;
+};
+
+struct sockaddr_storage {
+ sa_family_t ss_family;
+ char __padding[128 - sizeof(sa_family_t)];
+};
+
+struct mmsghdr {
+ struct msghdr msg_hdr;
+ unsigned int msg_len;
+};
+
+struct cmsghdr {
+ socklen_t cmsg_len;
+ int cmsg_level;
+ int cmsg_type;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#define SCM_RIGHTS 1
+#define SCM_TIMESTAMP SO_TIMESTAMP
+#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
+
+//MISSING: CMSG_DATA, CMSG_NXTHDR, CMSG_FIRSTHDR
+
+#define SCM_CREDENTIALS 0x02
+
+#define SOCK_DGRAM 1
+#define SOCK_RAW 2
+#define SOCK_SEQPACKET 3
+#define SOCK_STREAM 4
+#define SOCK_DCCP 5
+#define SOCK_NONBLOCK 0x10000
+#define SOCK_CLOEXEC 0x20000
+#define SOCK_RDM 0x40000
+
+#define SOL_SOCKET 1
+#define SOL_IPV6 41
+#define SOL_PACKET 263
+#define SOL_NETLINK 270
+
+#define SO_ACCEPTCONN 1
+#define SO_BROADCAST 2
+#define SO_DEBUG 3
+#define SO_DONTROUTE 4
+#define SO_ERROR 5
+#define SO_KEEPALIVE 6
+#define SO_LINGER 7
+#define SO_OOBINLINE 8
+#define SO_RCVBUF 9
+#define SO_RCVLOWAT 10
+#define SO_RCVTIMEO 11
+#define SO_REUSEADDR 12
+#define SO_SNDBUF 13
+#define SO_SNDLOWAT 14
+#define SO_SNDTIMEO 15
+#define SO_TYPE 16
+#define SO_SNDBUFFORCE 17
+#define SO_PEERCRED 18
+#define SO_ATTACH_FILTER 19
+#define SO_PASSCRED 20
+#define SO_RCVBUFFORCE 21
+#define SO_DETACH_FILTER 22
+#define SO_PROTOCOL 23
+#define SO_REUSEPORT 24
+#define SO_TIMESTAMP 25
+#define SO_PEERSEC 26
+#define SO_BINDTODEVICE 27
+#define SO_DOMAIN 28
+#define SO_PASSSEC 29
+#define SO_TIMESTAMPNS 30
+#define SO_PRIORITY 31
+#define SO_MARK 32
+
+#define SOMAXCONN 1
+
+#define MSG_CTRUNC 0x1
+#define MSG_DONTROUTE 0x2
+#define MSG_EOR 0x4
+#define MSG_OOB 0x8
+#define MSG_NOSIGNAL 0x10
+#define MSG_PEEK 0x20
+#define MSG_TRUNC 0x40
+#define MSG_WAITALL 0x80
+#define MSG_FIN 0x200
+#define MSG_CONFIRM 0x800
+
+// Linux extensions.
+#define MSG_DONTWAIT 0x1000
+#define MSG_CMSG_CLOEXEC 0x2000
+#define MSG_MORE 0x4000
+#define MSG_FASTOPEN 0x20000000
+
+// GNU (?) extension: Protocol family constants.
+
+#define PF_INET 1
+#define PF_INET6 2
+#define PF_UNIX 3
+#define PF_LOCAL 3
+#define PF_UNSPEC 4
+#define PF_NETLINK 5
+#define PF_BRIDGE 6
+#define PF_APPLETALK 7
+#define PF_BLUETOOTH 8
+#define PF_DECnet 9
+#define PF_IPX 10
+#define PF_ISDN 11
+#define PF_SNA 12
+#define PF_PACKET 13
+#define PF_AX25 14
+#define PF_NETROM 15
+#define PF_ROSE 16
+#define PF_TIPC 30
+#define PF_ALG 38
+#define PF_MAX 46
+
+#define AF_INET PF_INET
+#define AF_INET6 PF_INET6
+#define AF_UNIX PF_UNIX
+#define AF_LOCAL PF_LOCAL
+#define AF_UNSPEC PF_UNSPEC
+#define AF_NETLINK PF_NETLINK
+#define AF_BRIDGE PF_BRIDGE
+#define AF_APPLETALK PF_APPLETALK
+#define AF_BLUETOOTH PF_BLUETOOTH
+#define AF_DECnet PF_DECnet
+#define AF_IPX PF_IPX
+#define AF_ISDN PF_ISDN
+#define AF_SNA PF_SNA
+#define AF_PACKET PF_PACKET
+#define AF_PACKET PF_PACKET
+#define AF_AX25 PF_AX25
+#define AF_NETROM PF_NETROM
+#define AF_ROSE PF_ROSE
+#define AF_TIPC PF_TIPC
+#define AF_ALG PF_ALG
+#define AF_MAX PF_MAX
+
+#define SHUT_RD 1
+#define SHUT_RDWR 2
+#define SHUT_WR 3
+#endif
diff --git a/lib/mlibc/abis/mlibc/stat.h b/lib/mlibc/abis/mlibc/stat.h
new file mode 100644
index 0000000..3f55970
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/stat.h
@@ -0,0 +1,69 @@
+#ifndef _ABIBITS_STAT_H
+#define _ABIBITS_STAT_H
+
+#include <abi-bits/uid_t.h>
+#include <abi-bits/gid_t.h>
+#include <bits/off_t.h>
+#include <abi-bits/mode_t.h>
+#include <abi-bits/dev_t.h>
+#include <abi-bits/ino_t.h>
+#include <abi-bits/blksize_t.h>
+#include <abi-bits/blkcnt_t.h>
+#include <abi-bits/nlink_t.h>
+#include <bits/ansi/time_t.h>
+#include <bits/ansi/timespec.h>
+
+#define S_IFMT 0x0F000
+#define S_IFBLK 0x06000
+#define S_IFCHR 0x02000
+#define S_IFIFO 0x01000
+#define S_IFREG 0x08000
+#define S_IFDIR 0x04000
+#define S_IFLNK 0x0A000
+#define S_IFSOCK 0x0C000
+
+#define S_IRWXU 0700
+#define S_IRUSR 0400
+#define S_IWUSR 0200
+#define S_IXUSR 0100
+#define S_IRWXG 070
+#define S_IRGRP 040
+#define S_IWGRP 020
+#define S_IXGRP 010
+#define S_IRWXO 07
+#define S_IROTH 04
+#define S_IWOTH 02
+#define S_IXOTH 01
+#define S_ISUID 04000
+#define S_ISGID 02000
+#define S_ISVTX 01000
+
+#define S_IREAD S_IRUSR
+#define S_IWRITE S_IWUSR
+#define S_IEXEC S_IXUSR
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct stat {
+ dev_t st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ nlink_t st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ dev_t st_rdev;
+ off_t st_size;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ blksize_t st_blksize;
+ blkcnt_t st_blocks;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _ABIBITS_STAT_H
diff --git a/lib/mlibc/abis/mlibc/termios.h b/lib/mlibc/abis/mlibc/termios.h
new file mode 100644
index 0000000..49af908
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/termios.h
@@ -0,0 +1,118 @@
+#ifndef _ABIBITS_TERMIOS_H
+#define _ABIBITS_TERMIOS_H
+
+#if __MLIBC_BUILDING_MLIBC
+#warning abis/mlibc/termios.h is deprecated. We suggest to use abis/linux/termios.h instead. \
+ Note that this will potentially require kernel changes.
+#endif
+
+typedef unsigned int cc_t;
+typedef unsigned int speed_t;
+typedef unsigned int tcflag_t;
+
+// indices for the c_cc array in struct termios
+#define NCCS 11
+#define VEOF 0
+#define VEOL 1
+#define VERASE 2
+#define VINTR 3
+#define VKILL 4
+#define VMIN 5
+#define VQUIT 6
+#define VSTART 7
+#define VSTOP 8
+#define VSUSP 9
+#define VTIME 10
+
+// bitwise flags for c_iflag in struct termios
+#define BRKINT 0x0001
+#define ICRNL 0x0002
+#define IGNBRK 0x0004
+#define IGNCR 0x0008
+#define IGNPAR 0x0010
+#define INLCR 0x0020
+#define INPCK 0x0040
+#define ISTRIP 0x0080
+#define IXANY 0x0100
+#define IXOFF 0x0200
+#define IXON 0x0400
+#define PARMRK 0x0800
+
+// bitwise flags for c_oflag in struct termios
+#define OPOST 0x0001
+#define ONLCR 0x0002
+#define OCRNL 0x0004
+#define ONOCR 0x0008
+#define ONLRET 0x0010
+#define OFDEL 0x0020
+#define OFILL 0x0040
+
+#define NLDLY 0x0080
+#define NL0 0x0000
+#define NL1 0x0080
+
+#define CRDLY 0x0300
+#define CR0 0x0000
+#define CR1 0x0100
+#define CR2 0x0200
+#define CR3 0x0300
+
+#define TABDLY 0x0C00
+#define TAB0 0x0000
+#define TAB1 0x0400
+#define TAB2 0x0800
+#define TAB3 0x0C00
+
+#define BSDLY 0x1000
+#define BS0 0x0000
+#define BS1 0x1000
+
+#define VTDLY 0x2000
+#define VT0 0x0000
+#define VT1 0x2000
+
+#define FFDLY 0x4000
+#define FF0 0x0000
+#define FF1 0x4000
+
+// bitwise constants for c_cflag in struct termios
+#define CSIZE 0x0003
+#define CS5 0x0000
+#define CS6 0x0001
+#define CS7 0x0002
+#define CS8 0x0003
+
+#define CSTOPB 0x0004
+#define CREAD 0x0008
+#define PARENB 0x0010
+#define PARODD 0x0020
+#define HUPCL 0x0040
+#define CLOCAL 0x0080
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define CBAUD 0x100F
+#endif
+
+// bitwise constants for c_lflag in struct termios
+#define ECHO 0x0001
+#define ECHOE 0x0002
+#define ECHOK 0x0004
+#define ECHONL 0x0008
+#define ICANON 0x0010
+#define IEXTEN 0x0020
+#define ISIG 0x0040
+#define NOFLSH 0x0080
+#define TOSTOP 0x0100
+#define ECHOPRT 0x0200
+
+struct termios {
+ tcflag_t c_iflag;
+ tcflag_t c_oflag;
+ tcflag_t c_cflag;
+ tcflag_t c_lflag;
+ cc_t c_cc[NCCS];
+ speed_t ibaud;
+ speed_t obaud;
+};
+
+#endif
diff --git a/lib/mlibc/abis/mlibc/time.h b/lib/mlibc/abis/mlibc/time.h
new file mode 100644
index 0000000..3f49db3
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/time.h
@@ -0,0 +1,15 @@
+#ifndef _ABIBITS_TIME_H
+#define _ABIBITS_TIME_H
+
+#include <bits/posix/timeval.h>
+
+struct itimerval {
+ struct timeval it_interval; /* Interval for periodic timer */
+ struct timeval it_value; /* Time until next expiration */
+};
+
+#define ITIMER_REAL 0
+#define ITIMER_VIRTUAL 1
+#define ITIMER_PROF 2
+
+#endif // _ABIBITS_TIME_H
diff --git a/lib/mlibc/abis/mlibc/uid_t.h b/lib/mlibc/abis/mlibc/uid_t.h
new file mode 100644
index 0000000..5b53ca3
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/uid_t.h
@@ -0,0 +1,8 @@
+
+#ifndef _ABIBITS_UID_T_H
+#define _ABIBITS_UID_T_H
+
+typedef unsigned int uid_t;
+
+#endif // _ABIBITS_UID_T_H
+
diff --git a/lib/mlibc/abis/mlibc/utsname.h b/lib/mlibc/abis/mlibc/utsname.h
new file mode 100644
index 0000000..4e212b3
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/utsname.h
@@ -0,0 +1,17 @@
+#ifndef _ABIBITS_UTSNAME_T_H
+#define _ABIBITS_UTSNAME_T_H
+
+#if __MLIBC_BUILDING_MLIBC
+#warning abis/mlibc/utsname.h is deprecated. We suggest to use abis/linux/utsname.h instead. \
+ Note that this will potentially require kernel changes.
+#endif
+
+struct utsname {
+ char sysname[65];
+ char nodename[65];
+ char release[65];
+ char version[65];
+ char machine[65];
+};
+
+#endif // _ABIBITS_UTSNAME_T_H
diff --git a/lib/mlibc/abis/mlibc/vm-flags.h b/lib/mlibc/abis/mlibc/vm-flags.h
new file mode 100644
index 0000000..700d745
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/vm-flags.h
@@ -0,0 +1,46 @@
+#ifndef _ABIBITS_MMAP_FLAGS_H
+#define _ABIBITS_MMAP_FLAGS_H
+
+#define PROT_NONE 0x00
+#define PROT_READ 0x01
+#define PROT_WRITE 0x02
+#define PROT_EXEC 0x04
+
+#define MAP_FAILED ((void *)(-1))
+#define MAP_FILE 0x00
+#define MAP_PRIVATE 0x01
+#define MAP_SHARED 0x02
+#define MAP_FIXED 0x04
+#define MAP_ANON 0x08
+#define MAP_ANONYMOUS 0x08
+#define MAP_NORESERVE 0x10
+#define MAP_FIXED_NOREPLACE 0x20
+
+#define MS_ASYNC 0x01
+#define MS_SYNC 0x02
+#define MS_INVALIDATE 0x04
+
+#define MCL_CURRENT 0x01
+#define MCL_FUTURE 0x02
+
+#define POSIX_MADV_NORMAL 1
+#define POSIX_MADV_SEQUENTIAL 2
+#define POSIX_MADV_RANDOM 3
+#define POSIX_MADV_DONTNEED 4
+#define POSIX_MADV_WILLNEED 5
+
+#define MADV_NORMAL 0
+#define MADV_RANDOM 1
+#define MADV_SEQUENTIAL 2
+#define MADV_WILLNEED 3
+#define MADV_DONTNEED 4
+#define MADV_FREE 8
+
+// Linux extensions:
+#define MREMAP_MAYMOVE 1
+#define MREMAP_FIXED 2
+
+#define MFD_CLOEXEC 1U
+#define MFD_ALLOW_SEALING 2U
+
+#endif // _ABIBITS_MMAP_FLAGS_H
diff --git a/lib/mlibc/abis/mlibc/wait.h b/lib/mlibc/abis/mlibc/wait.h
new file mode 100644
index 0000000..ebc7ee6
--- /dev/null
+++ b/lib/mlibc/abis/mlibc/wait.h
@@ -0,0 +1,30 @@
+#ifndef _ABIBITS_WAIT_H
+#define _ABIBITS_WAIT_H
+
+#if __MLIBC_BUILDING_MLIBC
+#warning abis/mlibc/wait.h is deprecated. We suggest to use abis/linux/wait.h instead. \
+ Note that this will potentially require kernel changes.
+#endif
+
+#define WCONTINUED 1
+#define WNOHANG 2
+#define WUNTRACED 4
+#define WEXITED 8
+#define WNOWAIT 16
+#define WSTOPPED 32
+
+#define __WALL 0x40000000
+#define __WCLONE 0x80000000
+
+#define WCOREFLAG 0x80
+
+#define WEXITSTATUS(x) ((x) & 0x000000FF)
+#define WIFCONTINUED(x) ((x) & 0x00000100)
+#define WIFEXITED(x) ((x) & 0x00000200)
+#define WIFSIGNALED(x) ((x) & 0x00000400)
+#define WIFSTOPPED(x) ((x) & 0x00000800)
+#define WSTOPSIG(x) (((x) & 0x00FF0000) >> 16)
+#define WTERMSIG(x) (((x) & 0xFF000000) >> 24)
+#define WCOREDUMP(x) ((x) & WCOREFLAG)
+
+#endif //_ABIBITS_WAIT_H