summaryrefslogtreecommitdiff
path: root/lib/mlibc/options/posix/include/sys
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mlibc/options/posix/include/sys')
-rw-r--r--lib/mlibc/options/posix/include/sys/file.h25
-rw-r--r--lib/mlibc/options/posix/include/sys/ipc.h53
-rw-r--r--lib/mlibc/options/posix/include/sys/mman.h47
-rw-r--r--lib/mlibc/options/posix/include/sys/msg.h27
-rw-r--r--lib/mlibc/options/posix/include/sys/param.h36
-rw-r--r--lib/mlibc/options/posix/include/sys/poll.h37
-rw-r--r--lib/mlibc/options/posix/include/sys/resource.h52
-rw-r--r--lib/mlibc/options/posix/include/sys/select.h49
-rw-r--r--lib/mlibc/options/posix/include/sys/sem.h44
-rw-r--r--lib/mlibc/options/posix/include/sys/shm.h83
-rw-r--r--lib/mlibc/options/posix/include/sys/socket.h105
-rw-r--r--lib/mlibc/options/posix/include/sys/stat.h37
-rw-r--r--lib/mlibc/options/posix/include/sys/statvfs.h22
-rw-r--r--lib/mlibc/options/posix/include/sys/syslog.h1
-rw-r--r--lib/mlibc/options/posix/include/sys/termios.h6
-rw-r--r--lib/mlibc/options/posix/include/sys/time.h68
-rw-r--r--lib/mlibc/options/posix/include/sys/times.h28
-rw-r--r--lib/mlibc/options/posix/include/sys/ttydefaults.h39
-rw-r--r--lib/mlibc/options/posix/include/sys/types.h53
-rw-r--r--lib/mlibc/options/posix/include/sys/uio.h31
-rw-r--r--lib/mlibc/options/posix/include/sys/un.h24
-rw-r--r--lib/mlibc/options/posix/include/sys/utsname.h22
-rw-r--r--lib/mlibc/options/posix/include/sys/wait.h40
23 files changed, 929 insertions, 0 deletions
diff --git a/lib/mlibc/options/posix/include/sys/file.h b/lib/mlibc/options/posix/include/sys/file.h
new file mode 100644
index 0000000..add43d3
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/file.h
@@ -0,0 +1,25 @@
+
+#ifndef _SYS_FILE_H
+#define _SYS_FILE_H
+
+#define LOCK_SH 1
+#define LOCK_EX 2
+#define LOCK_NB 4
+#define LOCK_UN 8
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __MLIBC_ABI_ONLY
+
+int flock(int, int);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_FILE_H
+
diff --git a/lib/mlibc/options/posix/include/sys/ipc.h b/lib/mlibc/options/posix/include/sys/ipc.h
new file mode 100644
index 0000000..8318dde
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/ipc.h
@@ -0,0 +1,53 @@
+#ifndef _SYS_IPC_H
+#define _SYS_IPC_H
+
+#include <abi-bits/uid_t.h>
+#include <abi-bits/gid_t.h>
+#include <abi-bits/mode_t.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define IPC_CREAT 01000
+#define IPC_EXCL 02000
+#define IPC_NOWAIT 04000
+
+#define IPC_RMID 0
+#define IPC_SET 1
+#define IPC_STAT 2
+#define IPC_INFO 3
+
+#define IPC_PRIVATE ((key_t) 0)
+
+#if defined(__aarch64__) || defined(__i386__)
+#define IPC_64 0x100
+#elif defined(__x86_64__) || (defined(__riscv) && __riscv_xlen == 64)
+#define IPC_64 0
+#else
+#error "Unsupported arch!"
+#endif
+
+typedef int key_t;
+
+struct ipc_perm {
+ key_t __ipc_perm_key;
+ uid_t uid;
+ gid_t gid;
+ uid_t cuid;
+ gid_t cgid;
+ mode_t mode;
+ int __ipc_perm_seq;
+};
+
+#ifndef __MLIBC_ABI_ONLY
+
+key_t ftok(const char *, int);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/mlibc/options/posix/include/sys/mman.h b/lib/mlibc/options/posix/include/sys/mman.h
new file mode 100644
index 0000000..784878e
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/mman.h
@@ -0,0 +1,47 @@
+#ifndef _SYS_MMAN_H
+#define _SYS_MMAN_H
+
+#include <mlibc-config.h>
+#include <abi-bits/mode_t.h>
+#include <abi-bits/vm-flags.h>
+#include <bits/off_t.h>
+#include <bits/size_t.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __MLIBC_ABI_ONLY
+
+void *mmap(void *, size_t, int, int, int, off_t);
+int mprotect(void *, size_t, int);
+int munmap(void *, size_t);
+
+int mlock(const void *, size_t);
+int mlockall(int);
+int munlock(const void *, size_t);
+int munlockall(void);
+
+int posix_madvise(void *, size_t, int);
+int msync(void *, size_t, int);
+
+int shm_open(const char *, int, mode_t);
+int shm_unlink(const char *);
+
+// Linux extension:
+void *mremap(void *, size_t, size_t, int, ...);
+int remap_file_pages(void *, size_t, int, size_t, int);
+
+#if __MLIBC_LINUX_OPTION
+int memfd_create(const char *, unsigned int);
+int madvise(void *, size_t, int);
+int mincore(void *, size_t, unsigned char *);
+#endif /* __MLIBC_LINUX_OPTION */
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_MMAN_H
diff --git a/lib/mlibc/options/posix/include/sys/msg.h b/lib/mlibc/options/posix/include/sys/msg.h
new file mode 100644
index 0000000..d602f76
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/msg.h
@@ -0,0 +1,27 @@
+#ifndef _SYS_MSG_H
+#define _SYS_MSG_H
+
+#include <abi-bits/msg.h>
+#include <bits/size_t.h>
+#include <bits/ssize_t.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __MLIBC_ABI_ONLY
+
+int msgget(key_t, int);
+
+int msgctl(int msqid, int cmd, struct msqid_ds *buf);
+
+ssize_t msgrcv(int, void *, size_t, long, int);
+int msgsnd(int, const void *, size_t, int);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_MSG_H
diff --git a/lib/mlibc/options/posix/include/sys/param.h b/lib/mlibc/options/posix/include/sys/param.h
new file mode 100644
index 0000000..9bb4552
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/param.h
@@ -0,0 +1,36 @@
+
+#ifndef _SYS_PARAM_H
+#define _SYS_PARAM_H
+
+#include <endian.h>
+#include <limits.h>
+
+#define NBBY CHAR_BIT
+#define NGROUPS NGROUPS_MAX
+
+// Report the same value as Linux here.
+#define MAXNAMLEN 255
+#define MAXPATHLEN 4096
+#define HOST_NAME_MAX 64
+#define MAXSYMLINKS 20
+#define MAXHOSTNAMELEN HOST_NAME_MAX
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#undef MIN
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#undef MAX
+#define MAX(a,b) (((a) > (b)) ? (a) : (b))
+
+#define howmany(x, y) (((x) + ((y) - 1)) / (y))
+
+#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_PARAM_H
+
diff --git a/lib/mlibc/options/posix/include/sys/poll.h b/lib/mlibc/options/posix/include/sys/poll.h
new file mode 100644
index 0000000..3edecab
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/poll.h
@@ -0,0 +1,37 @@
+#ifndef _SYS_POLL_H
+#define _SYS_POLL_H
+
+#include <bits/types.h>
+#include <bits/sigset_t.h>
+#include <bits/ansi/timespec.h>
+#include <abi-bits/poll.h>
+#include <abi-bits/signal.h>
+#include <mlibc-config.h>
+
+typedef __mlibc_size nfds_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct pollfd {
+ int fd;
+ short events;
+ short revents;
+};
+
+#ifndef __MLIBC_ABI_ONLY
+
+int poll(struct pollfd *, nfds_t, int);
+
+#if __MLIBC_LINUX_OPTION
+int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts, const sigset_t *sigmask);
+#endif // __MLIBC_LINUX_OPTION
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_POLL_H
diff --git a/lib/mlibc/options/posix/include/sys/resource.h b/lib/mlibc/options/posix/include/sys/resource.h
new file mode 100644
index 0000000..c5453e2
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/resource.h
@@ -0,0 +1,52 @@
+#ifndef _SYS_RESOURCE_H
+#define _SYS_RESOURCE_H
+
+#include <abi-bits/pid_t.h>
+#include <abi-bits/resource.h>
+#include <bits/posix/id_t.h>
+#include <abi-bits/suseconds_t.h>
+#include <bits/ansi/time_t.h>
+#include <bits/posix/timeval.h>
+
+#define PRIO_PROCESS 1
+#define PRIO_PGRP 2
+#define PRIO_USER 3
+
+#define PRIO_MIN (-20)
+#define PRIO_MAX 20
+
+#define RLIM_INFINITY ((rlim_t)-1)
+#define RLIM_SAVED_MAX ((rlim_t)-1)
+#define RLIM_SAVED_CUR ((rlim_t)-1)
+
+#define RLIM_NLIMITS RLIMIT_NLIMITS
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef unsigned long rlim_t;
+
+struct rlimit {
+ rlim_t rlim_cur;
+ rlim_t rlim_max;
+};
+
+#ifndef __MLIBC_ABI_ONLY
+
+int getpriority(int, id_t);
+int setpriority(int, id_t, int);
+
+int getrusage(int, struct rusage *);
+int getrlimit(int, struct rlimit *);
+int setrlimit(int, const struct rlimit *);
+
+int prlimit(pid_t pid, int resource, const struct rlimit *new_limits, struct rlimit *old_limits);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_RESOURCE_H
diff --git a/lib/mlibc/options/posix/include/sys/select.h b/lib/mlibc/options/posix/include/sys/select.h
new file mode 100644
index 0000000..85a15b0
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/select.h
@@ -0,0 +1,49 @@
+
+#ifndef _SYS_SELECT_H
+#define _SYS_SELECT_H
+
+#include <abi-bits/signal.h>
+
+#include <bits/ansi/time_t.h>
+#include <bits/ansi/timespec.h>
+#include <abi-bits/suseconds_t.h>
+#include <bits/posix/timeval.h>
+#include <bits/posix/fd_set.h>
+
+#define FD_SETSIZE 1024
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef long int __fd_mask;
+#define __NFDBITS (8 * (int) sizeof (__fd_mask))
+
+typedef __fd_mask fd_mask;
+#define NFDBITS __NFDBITS
+
+#ifndef __MLIBC_ABI_ONLY
+
+void __FD_CLR(int fd, fd_set *);
+int __FD_ISSET(int fd, fd_set *);
+void __FD_SET(int fd, fd_set *);
+void __FD_ZERO(fd_set *);
+
+#define FD_CLR(fd, set) __FD_CLR(fd, set)
+#define FD_ISSET(fd, set) __FD_ISSET(fd, set)
+#define FD_SET(fd, set) __FD_SET(fd, set)
+#define FD_ZERO(set) __FD_ZERO(set)
+
+int select(int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict,
+ struct timeval *__restrict);
+int pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *,
+ const sigset_t *);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_SELECT_H
+
diff --git a/lib/mlibc/options/posix/include/sys/sem.h b/lib/mlibc/options/posix/include/sys/sem.h
new file mode 100644
index 0000000..cb3516a
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/sem.h
@@ -0,0 +1,44 @@
+#ifndef _SYS_SEM_H
+#define _SYS_SEM_H
+
+#include <bits/ansi/time_t.h>
+#include <sys/ipc.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define GETALL 13
+#define SETVAL 16
+#define SETALL 17
+
+#define SEM_UNDO 0x1000
+
+struct sembuf {
+ unsigned short int sem_num;
+ short int sem_op;
+ short int sem_flg;
+};
+
+struct semid_ds {
+ struct ipc_perm sem_perm;
+ time_t sem_otime;
+ time_t sem_ctime;
+
+ unsigned long sem_nsems;
+};
+
+#ifndef __MLIBC_ABI_ONLY
+
+int semget(key_t, int, int);
+int semop(int, struct sembuf *, size_t);
+int semctl(int, int, int, ...);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_SEM_H
diff --git a/lib/mlibc/options/posix/include/sys/shm.h b/lib/mlibc/options/posix/include/sys/shm.h
new file mode 100644
index 0000000..3767ced
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/shm.h
@@ -0,0 +1,83 @@
+#ifndef _SYS_SHM_H
+#define _SYS_SHM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <abi-bits/pid_t.h>
+#include <abi-bits/shm.h>
+#include <bits/size_t.h>
+#include <time.h>
+
+#include <sys/ipc.h>
+
+#define SHM_R 0400
+#define SHM_W 0200
+
+#define SHM_RDONLY 010000
+#define SHM_RND 020000
+#define SHM_REMAP 040000
+#define SHM_EXEC 0100000
+
+#define SHM_LOCK 11
+#define SHM_UNLOCK 12
+#define SHM_STAT 13
+#define SHM_INFO 14
+#define SHM_STAT_ANY 15
+#define SHM_DEST 01000
+#define SHM_LOCKED 02000
+#define SHM_HUGETLB 04000
+#define SHM_NORESERVE 010000
+
+#define SHM_HUGE_SHIFT 26
+#define SHM_HUGE_MASK 0x3f
+#define SHM_HUGE_64KB (16 << 26)
+#define SHM_HUGE_512KB (19 << 26)
+#define SHM_HUGE_1MB (20 << 26)
+#define SHM_HUGE_2MB (21 << 26)
+#define SHM_HUGE_8MB (23 << 26)
+#define SHM_HUGE_16MB (24 << 26)
+#define SHM_HUGE_32MB (25 << 26)
+#define SHM_HUGE_256MB (28 << 26)
+#define SHM_HUGE_512MB (29 << 26)
+#define SHM_HUGE_1GB (30 << 26)
+#define SHM_HUGE_2GB (31 << 26)
+#define SHM_HUGE_16GB (34U << 26)
+
+typedef unsigned long shmatt_t;
+
+struct shmid_ds {
+ struct ipc_perm shm_perm;
+ size_t shm_segsz;
+ time_t shm_atime;
+ time_t shm_dtime;
+ time_t shm_ctime;
+ pid_t shm_cpid;
+ pid_t shm_lpid;
+ unsigned long shm_nattch;
+};
+
+struct shminfo {
+ unsigned long shmmax;
+ unsigned long shmmin;
+ unsigned long shmmni;
+ unsigned long shmseg;
+ unsigned long shmall;
+ unsigned long __unused[4];
+};
+
+#ifndef __MLIBC_ABI_ONLY
+
+void *shmat(int, const void *, int);
+int shmctl(int, int, struct shmid_ds *);
+int shmdt(const void *);
+int shmget(key_t, size_t, int);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_SHM_H
diff --git a/lib/mlibc/options/posix/include/sys/socket.h b/lib/mlibc/options/posix/include/sys/socket.h
new file mode 100644
index 0000000..9552f93
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/socket.h
@@ -0,0 +1,105 @@
+
+#ifndef _SOCKET_H
+#define _SOCKET_H
+
+#include <abi-bits/gid_t.h>
+#include <abi-bits/pid_t.h>
+#include <bits/size_t.h>
+#include <abi-bits/socklen_t.h>
+#include <bits/ssize_t.h>
+#include <abi-bits/uid_t.h>
+#include <bits/posix/iovec.h>
+#include <abi-bits/socket.h>
+#include <bits/ansi/time_t.h>
+#include <bits/ansi/timespec.h>
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct sockaddr {
+ sa_family_t sa_family;
+ char sa_data[14];
+};
+
+// Control message format:
+// The offsets marked with ^ are aligned to alignof(size_t).
+//
+// |---HEADER---|---DATA---|---PADDING---|---HEADER---|...
+// ^ ^ ^
+// |---------CMSG_LEN------|
+// |---------------CMSG_SPACE------------|
+
+// Auxiliary macro. While there is basically no reason for applications
+// to use this, it is exported by glibc.
+#define CMSG_ALIGN(s) (((s) + __alignof__(size_t) - 1) & \
+ ~(__alignof__(size_t) - 1))
+
+// Basic macros to return content and padding size of a control message.
+#define CMSG_LEN(s) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (s))
+#define CMSG_SPACE(s) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(s))
+
+// Provides access to the data of a control message.
+#define CMSG_DATA(c) ((char *)(c) + CMSG_ALIGN(sizeof(struct cmsghdr)))
+
+#define __MLIBC_CMSG_NEXT(c) ((char *)(c) + CMSG_ALIGN((c)->cmsg_len))
+#define __MLIBC_MHDR_LIMIT(m) ((char *)(m)->msg_control + (m)->msg_controllen)
+
+// For parsing control messages only.
+// Returns a pointer to the first header or nullptr if there is none.
+#define CMSG_FIRSTHDR(m) ((size_t)(m)->msg_controllen <= sizeof(struct cmsghdr) \
+ ? (struct cmsghdr *)0 : (struct cmsghdr *) (m)->msg_control)
+
+// For parsing control messages only.
+// Returns a pointer to the next header or nullptr if there is none.
+#define CMSG_NXTHDR(m, c) \
+ ((c)->cmsg_len < sizeof(struct cmsghdr) || \
+ (ptrdiff_t)(sizeof(struct cmsghdr) + CMSG_ALIGN((c)->cmsg_len)) \
+ >= __MLIBC_MHDR_LIMIT(m) - (char *)(c) \
+ ? (struct cmsghdr *)0 : (struct cmsghdr *)__MLIBC_CMSG_NEXT(c))
+
+struct linger{
+ int l_onoff;
+ int l_linger;
+};
+
+struct ucred {
+ pid_t pid;
+ uid_t uid;
+ gid_t gid;
+};
+
+#ifndef __MLIBC_ABI_ONLY
+
+int accept(int, struct sockaddr *__restrict, socklen_t *__restrict);
+int accept4(int, struct sockaddr *__restrict, socklen_t *__restrict, int);
+int bind(int, const struct sockaddr *, socklen_t);
+int connect(int, const struct sockaddr *, socklen_t);
+int getpeername(int, struct sockaddr *__restrict, socklen_t *__restrict);
+int getsockname(int, struct sockaddr *__restrict, socklen_t *__restrict);
+int getsockopt(int, int, int, void *__restrict, socklen_t *__restrict);
+int listen(int, int);
+ssize_t recv(int, void *, size_t, int);
+ssize_t recvfrom(int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict);
+ssize_t recvmsg(int, struct msghdr *, int);
+ssize_t send(int, const void *, size_t, int);
+ssize_t sendmsg(int, const struct msghdr *, int);
+ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t);
+int recvmmsg(int sockfd, struct mmsghdr *msgvec, unsigned int vlen, int flags, struct timespec *timeout);
+int sendmmsg(int sockfd, struct mmsghdr *msgvec, unsigned int vlen, int flags);
+int setsockopt(int, int, int, const void *, socklen_t);
+int shutdown(int, int);
+int sockatmark(int);
+int socket(int, int, int);
+int socketpair(int, int, int, int [2]);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _UNISTD_H
+
diff --git a/lib/mlibc/options/posix/include/sys/stat.h b/lib/mlibc/options/posix/include/sys/stat.h
new file mode 100644
index 0000000..7159a77
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/stat.h
@@ -0,0 +1,37 @@
+
+#ifndef _SYS_STAT_H
+#define _SYS_STAT_H
+
+#include <bits/posix/stat.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __MLIBC_ABI_ONLY
+
+int chmod(const char *, mode_t);
+int fchmod(int, mode_t);
+int fchmodat(int, const char *, mode_t, int);
+int fstat(int fd, struct stat *result);
+int fstatat(int, const char *__restrict, struct stat *__restrict, int);
+int futimens(int fd, const struct timespec times[2]);
+int lstat(const char *__restrict, struct stat *__restrict);
+int mkdir(const char *, mode_t);
+int mkdirat(int, const char *, mode_t);
+int mkfifo(const char *, mode_t);
+int mkfifoat(int, const char *, mode_t);
+int mknod(const char *, mode_t, dev_t);
+int mknodat(int, const char *, mode_t, dev_t);
+int stat(const char *__restrict, struct stat *__restrict);
+mode_t umask(mode_t);
+int utimensat(int, const char *, const struct timespec times[2], int);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_STAT_H
+
diff --git a/lib/mlibc/options/posix/include/sys/statvfs.h b/lib/mlibc/options/posix/include/sys/statvfs.h
new file mode 100644
index 0000000..0e4c308
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/statvfs.h
@@ -0,0 +1,22 @@
+#ifndef _SYS_STATVFS_H
+#define _SYS_STATVFS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <abi-bits/statvfs.h>
+
+#ifndef __MLIBC_ABI_ONLY
+
+int statvfs(const char *__restrict, struct statvfs *__restrict);
+int fstatvfs(int, struct statvfs *);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_STATVFS_H
+
diff --git a/lib/mlibc/options/posix/include/sys/syslog.h b/lib/mlibc/options/posix/include/sys/syslog.h
new file mode 100644
index 0000000..7761ece
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/syslog.h
@@ -0,0 +1 @@
+#include <syslog.h>
diff --git a/lib/mlibc/options/posix/include/sys/termios.h b/lib/mlibc/options/posix/include/sys/termios.h
new file mode 100644
index 0000000..b23f171
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/termios.h
@@ -0,0 +1,6 @@
+
+#ifndef _SYS_TERMIOS_H
+#define _SYS_TERMIOS_H
+#include <termios.h>
+#endif // _SYS_TERMIOS_H
+
diff --git a/lib/mlibc/options/posix/include/sys/time.h b/lib/mlibc/options/posix/include/sys/time.h
new file mode 100644
index 0000000..838d7cc
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/time.h
@@ -0,0 +1,68 @@
+#ifndef _SYS_TIME_H
+#define _SYS_TIME_H
+
+#include <abi-bits/time.h>
+#include <abi-bits/signal.h>
+#include <abi-bits/clockid_t.h>
+#include <bits/ansi/time_t.h>
+#include <abi-bits/suseconds_t.h>
+#include <bits/posix/timer_t.h>
+#include <bits/posix/timeval.h>
+
+#include <sys/select.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct timezone {
+ int tz_minuteswest;
+ int tz_dsttime;
+};
+
+#ifndef __MLIBC_ABI_ONLY
+
+// TODO: this function is [OB]. disable it by default and add a macro to enable it
+int gettimeofday(struct timeval *__restrict result, void *__restrict unused);
+int settimeofday(const struct timeval *result, const struct timezone *zone);
+
+void timeradd(const struct timeval *a, const struct timeval *b, struct timeval *res);
+void timersub(const struct timeval *a, const struct timeval *b, struct timeval *res);
+void timerclear(struct timeval *tvp);
+int timerisset(struct timeval *tvp);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+// timercmp taken from musl
+#define timercmp(s,t,op) ((s)->tv_sec == (t)->tv_sec ? \
+ (s)->tv_usec op (t)->tv_usec : (s)->tv_sec op (t)->tv_sec)
+
+#ifndef __MLIBC_ABI_ONLY
+
+int getitimer(int which, struct itimerval *curr_value);
+int setitimer(int which, const struct itimerval *new_value,
+ struct itimerval *old_value);
+
+int timer_create(clockid_t clockid, struct sigevent *__restrict sevp, timer_t *__restrict timerid);
+int timer_settime(timer_t timerid, int flags, const struct itimerspec *__restrict new_value,
+ struct itimerspec *__restrict old_value);
+int timer_gettime(timer_t timerid, struct itimerspec *curr_value);
+int timer_delete(timer_t timerid);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+// The following 2 macros are taken from musl
+#define TIMEVAL_TO_TIMESPEC(tv, ts) ( \
+ (ts)->tv_sec = (tv)->tv_sec, \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000, \
+ (void)0 )
+#define TIMESPEC_TO_TIMEVAL(tv, ts) ( \
+ (tv)->tv_sec = (ts)->tv_sec, \
+ (tv)->tv_usec = (ts)->tv_nsec / 1000, \
+ (void)0 )
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_TIME_H
diff --git a/lib/mlibc/options/posix/include/sys/times.h b/lib/mlibc/options/posix/include/sys/times.h
new file mode 100644
index 0000000..2dd2889
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/times.h
@@ -0,0 +1,28 @@
+#ifndef _SYS_TIMES_H
+#define _SYS_TIMES_H
+
+// TODO: Only define the clock_t type.
+#include <time.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct tms {
+ clock_t tms_utime;
+ clock_t tms_stime;
+ clock_t tms_cutime;
+ clock_t tms_cstime;
+};
+
+#ifndef __MLIBC_ABI_ONLY
+
+clock_t times(struct tms *);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_TIMES_H
diff --git a/lib/mlibc/options/posix/include/sys/ttydefaults.h b/lib/mlibc/options/posix/include/sys/ttydefaults.h
new file mode 100644
index 0000000..c6d04f6
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/ttydefaults.h
@@ -0,0 +1,39 @@
+
+#ifndef _SYS_TTYDEFAULTS_H
+#define _SYS_TTYDEFAULTS_H
+
+// Values taken from musl
+
+#define TTYDEF_IFLAG (BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)
+#define TTYDEF_OFLAG (OPOST | ONLCR | XTABS)
+#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)
+#define TTYDEF_CFLAG (CREAD | CS7 | PARENB | HUPCL)
+#define TTYDEF_SPEED (B9600)
+
+#define CTRL(x) ((x) & 037)
+#define CEOF CTRL('d')
+
+#define CEOL '\0'
+#define CEOL2 '\0'
+#define CSTATUS '\0'
+
+#define CERASE 0177
+#define CINTR CTRL('c')
+#define CKILL CTRL('u')
+#define CMIN 1
+#define CQUIT 034
+#define CSUSP CTRL('z')
+#define CTIME 0
+#define CDSUSP CTRL('y')
+#define CSTART CTRL('q')
+#define CSTOP CTRL('s')
+#define CLNEXT CTRL('v')
+#define CDISCARD CTRL('o')
+#define CWERASE CTRL('w')
+#define CREPRINT CTRL('r')
+#define CEOT CEOF
+#define CBRK CEOL
+#define CRPRNT CREPRINT
+#define CFLUSH CDISCARD
+
+#endif // _SYS_TTYDEFAULTS_H
diff --git a/lib/mlibc/options/posix/include/sys/types.h b/lib/mlibc/options/posix/include/sys/types.h
new file mode 100644
index 0000000..ad837fc
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/types.h
@@ -0,0 +1,53 @@
+
+#ifndef _SYS_TYPES_H
+#define _SYS_TYPES_H
+
+#include <bits/size_t.h>
+#include <bits/ssize_t.h>
+#include <bits/off_t.h>
+
+#include <bits/posix/id_t.h>
+#include <abi-bits/uid_t.h>
+#include <abi-bits/gid_t.h>
+#include <abi-bits/pid_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 <abi-bits/suseconds_t.h>
+
+#include <abi-bits/fsblkcnt_t.h>
+#include <abi-bits/fsfilcnt_t.h>
+#include <bits/posix/fd_set.h>
+
+#include <stdint.h>
+
+#include <sys/select.h>
+
+typedef unsigned int u_int;
+typedef unsigned char u_char;
+typedef unsigned short u_short;
+typedef unsigned long int u_long;
+typedef char *caddr_t;
+typedef off64_t loff_t;
+
+typedef unsigned long int ulong;
+typedef unsigned short int ushort;
+typedef unsigned int uint;
+
+typedef uint8_t u_int8_t;
+typedef uint16_t u_int16_t;
+typedef uint32_t u_int32_t;
+typedef uint64_t u_int64_t;
+
+// BSD extensions
+typedef int64_t quad_t;
+typedef uint64_t u_quad_t;
+
+#endif // _SYS_TYPES_H
+
diff --git a/lib/mlibc/options/posix/include/sys/uio.h b/lib/mlibc/options/posix/include/sys/uio.h
new file mode 100644
index 0000000..04679a6
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/uio.h
@@ -0,0 +1,31 @@
+#ifndef _SYS_UIO_H
+#define _SYS_UIO_H
+
+#include <bits/posix/iovec.h>
+#include <bits/ssize_t.h>
+#include <bits/off_t.h>
+#include <bits/size_t.h>
+#include <limits.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define UIO_MAXIOV IOV_MAX
+
+#ifndef __MLIBC_ABI_ONLY
+
+ssize_t readv(int fd, const struct iovec *iov, int iovcnt);
+ssize_t writev(int fd, const struct iovec *iov, int iovcnt);
+
+// Non standard extensions, also found on modern BSD's
+ssize_t preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset);
+ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_UIO_H
diff --git a/lib/mlibc/options/posix/include/sys/un.h b/lib/mlibc/options/posix/include/sys/un.h
new file mode 100644
index 0000000..bb9b5ad
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/un.h
@@ -0,0 +1,24 @@
+
+#ifndef _SYS_UN_H
+#define _SYS_UN_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <abi-bits/socket.h>
+
+struct sockaddr_un {
+ sa_family_t sun_family;
+ char sun_path[108];
+};
+
+// Evaluate to actual length of the `sockaddr_un' structure.
+#define SUN_LEN(ptr) ((size_t) offsetof(struct sockaddr_un, sun_path) + strlen((ptr)->sun_path))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_UN_H
+
diff --git a/lib/mlibc/options/posix/include/sys/utsname.h b/lib/mlibc/options/posix/include/sys/utsname.h
new file mode 100644
index 0000000..bd7b174
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/utsname.h
@@ -0,0 +1,22 @@
+
+#ifndef _SYS_UTSNAME_H
+#define _SYS_UTSNAME_H
+
+#include <abi-bits/utsname.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __MLIBC_ABI_ONLY
+
+int uname(struct utsname *);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_UTSNAME_H
+
diff --git a/lib/mlibc/options/posix/include/sys/wait.h b/lib/mlibc/options/posix/include/sys/wait.h
new file mode 100644
index 0000000..5081041
--- /dev/null
+++ b/lib/mlibc/options/posix/include/sys/wait.h
@@ -0,0 +1,40 @@
+
+#ifndef _SYS_WAIT_H
+#define _SYS_WAIT_H
+
+#include <bits/posix/id_t.h>
+#include <abi-bits/pid_t.h>
+// for siginfo_t
+#include <abi-bits/signal.h>
+#include <abi-bits/wait.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// According to POSIX, <sys/wait.h> does not make rusage available.
+struct rusage;
+
+// TODO: move to own file and include in sys/types.h
+typedef enum {
+ P_ALL, P_PID, P_PGID
+} idtype_t;
+
+#ifndef __MLIBC_ABI_ONLY
+
+pid_t wait(int *status);
+int waitid(idtype_t idtype, id_t id, siginfo_t *siginfo, int flags);
+pid_t waitpid(pid_t pid, int *status, int flags);
+
+// GNU extensions.
+pid_t wait3(int *, int, struct rusage *);
+pid_t wait4(pid_t pid, int *status, int options, struct rusage *ru);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _SYS_WAIT_H
+