From bd5969fc876a10b18613302db7087ef3c40f18e1 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 7 Mar 2024 17:28:00 -0500 Subject: lib: Add mlibc Signed-off-by: Ian Moffett --- lib/mlibc/options/linux/include/sys/epoll.h | 66 ++++++++++++ lib/mlibc/options/linux/include/sys/eventfd.h | 29 ++++++ lib/mlibc/options/linux/include/sys/fsuid.h | 22 ++++ lib/mlibc/options/linux/include/sys/inotify.h | 63 ++++++++++++ lib/mlibc/options/linux/include/sys/klog.h | 18 ++++ lib/mlibc/options/linux/include/sys/mount.h | 90 +++++++++++++++++ lib/mlibc/options/linux/include/sys/prctl.h | 128 ++++++++++++++++++++++++ lib/mlibc/options/linux/include/sys/ptrace.h | 55 ++++++++++ lib/mlibc/options/linux/include/sys/quota.h | 24 +++++ lib/mlibc/options/linux/include/sys/random.h | 26 +++++ lib/mlibc/options/linux/include/sys/reboot.h | 20 ++++ lib/mlibc/options/linux/include/sys/sendfile.h | 22 ++++ lib/mlibc/options/linux/include/sys/signalfd.h | 48 +++++++++ lib/mlibc/options/linux/include/sys/statfs.h | 22 ++++ lib/mlibc/options/linux/include/sys/swap.h | 24 +++++ lib/mlibc/options/linux/include/sys/sysinfo.h | 34 +++++++ lib/mlibc/options/linux/include/sys/sysmacros.h | 35 +++++++ lib/mlibc/options/linux/include/sys/timerfd.h | 32 ++++++ lib/mlibc/options/linux/include/sys/vfs.h | 16 +++ lib/mlibc/options/linux/include/sys/vt.h | 6 ++ lib/mlibc/options/linux/include/sys/xattr.h | 38 +++++++ 21 files changed, 818 insertions(+) create mode 100644 lib/mlibc/options/linux/include/sys/epoll.h create mode 100644 lib/mlibc/options/linux/include/sys/eventfd.h create mode 100644 lib/mlibc/options/linux/include/sys/fsuid.h create mode 100644 lib/mlibc/options/linux/include/sys/inotify.h create mode 100644 lib/mlibc/options/linux/include/sys/klog.h create mode 100644 lib/mlibc/options/linux/include/sys/mount.h create mode 100644 lib/mlibc/options/linux/include/sys/prctl.h create mode 100644 lib/mlibc/options/linux/include/sys/ptrace.h create mode 100644 lib/mlibc/options/linux/include/sys/quota.h create mode 100644 lib/mlibc/options/linux/include/sys/random.h create mode 100644 lib/mlibc/options/linux/include/sys/reboot.h create mode 100644 lib/mlibc/options/linux/include/sys/sendfile.h create mode 100644 lib/mlibc/options/linux/include/sys/signalfd.h create mode 100644 lib/mlibc/options/linux/include/sys/statfs.h create mode 100644 lib/mlibc/options/linux/include/sys/swap.h create mode 100644 lib/mlibc/options/linux/include/sys/sysinfo.h create mode 100644 lib/mlibc/options/linux/include/sys/sysmacros.h create mode 100644 lib/mlibc/options/linux/include/sys/timerfd.h create mode 100644 lib/mlibc/options/linux/include/sys/vfs.h create mode 100644 lib/mlibc/options/linux/include/sys/vt.h create mode 100644 lib/mlibc/options/linux/include/sys/xattr.h (limited to 'lib/mlibc/options/linux/include/sys') diff --git a/lib/mlibc/options/linux/include/sys/epoll.h b/lib/mlibc/options/linux/include/sys/epoll.h new file mode 100644 index 0000000..f84da7a --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/epoll.h @@ -0,0 +1,66 @@ +#ifndef _SYS_EPOLL_H +#define _SYS_EPOLL_H + +#include +#include +#include +#include + +#define EPOLL_NONBLOCK O_NONBLOCK + +// These constants match the Linux definitions. +#define EPOLLIN 0x001 +#define EPOLLPRI 0x002 +#define EPOLLOUT 0x004 +#define EPOLLRDNORM 0x040 +#define EPOLLRDBAND 0x080 +#define EPOLLWRNORM 0x100 +#define EPOLLWRBAND 0x200 +#define EPOLLMSG 0x400 +#define EPOLLERR 0x008 +#define EPOLLHUP 0x010 +#define EPOLLRDHUP 0x2000 +#define EPOLLEXCLUSIVE (1U << 28) +#define EPOLLWAKEUP (1U << 29) +#define EPOLLONESHOT (1U << 30) +#define EPOLLET (1U << 31) + +#define EPOLL_CTL_ADD 1 +#define EPOLL_CTL_DEL 2 +#define EPOLL_CTL_MOD 3 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef union epoll_data { + void *ptr; + int fd; + uint32_t u32; + uint64_t u64; +} epoll_data_t; + +struct epoll_event { + uint32_t events; + epoll_data_t data; +} +#ifdef __x86_64__ +__attribute__((__packed__)) +#endif +; + +#ifndef __MLIBC_ABI_ONLY + +int epoll_create(int); +int epoll_create1(int); +int epoll_ctl(int, int, int, struct epoll_event *); +int epoll_wait(int, struct epoll_event *, int, int); +int epoll_pwait(int, struct epoll_event *, int, int, const sigset_t *); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif // _SYS_EPOLL_H diff --git a/lib/mlibc/options/linux/include/sys/eventfd.h b/lib/mlibc/options/linux/include/sys/eventfd.h new file mode 100644 index 0000000..454a8c1 --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/eventfd.h @@ -0,0 +1,29 @@ +#ifndef _SYS_EVENTFD_H +#define _SYS_EVENTFD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +typedef uint64_t eventfd_t; + +#define EFD_SEMAPHORE 1 +#define EFD_CLOEXEC O_CLOEXEC +#define EFD_NONBLOCK O_NONBLOCK + +#ifndef __MLIBC_ABI_ONLY + +int eventfd(unsigned int, int); +int eventfd_read(int, eventfd_t *); +int eventfd_write(int, eventfd_t); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif // _SYS_EVENTFD_H diff --git a/lib/mlibc/options/linux/include/sys/fsuid.h b/lib/mlibc/options/linux/include/sys/fsuid.h new file mode 100644 index 0000000..9df9efc --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/fsuid.h @@ -0,0 +1,22 @@ +#ifndef _SYS_FSUID_H +#define _SYS_FSUID_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __MLIBC_ABI_ONLY + +int setfsuid(uid_t uid); +int setfsgid(gid_t gid); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif // _SYS_FSUID_H diff --git a/lib/mlibc/options/linux/include/sys/inotify.h b/lib/mlibc/options/linux/include/sys/inotify.h new file mode 100644 index 0000000..3c48403 --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/inotify.h @@ -0,0 +1,63 @@ +#ifndef _SYS_INOTIFY_H +#define _SYS_INOTIFY_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define IN_ACCESS 0x1 +#define IN_ATTRIB 0x4 +#define IN_CLOSE_WRITE 0x8 +#define IN_CLOSE_NOWRITE 0x10 +#define IN_CREATE 0x100 +#define IN_DELETE 0x200 +#define IN_DELETE_SELF 0x400 +#define IN_MODIFY 0x2 +#define IN_MOVE_SELF 0x800 +#define IN_MOVED_FROM 0x40 +#define IN_MOVED_TO 0x80 +#define IN_OPEN 0x20 +#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) +#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) +#define IN_DONT_FOLLOW 0x2000000 +#define IN_EXCL_UNLINK 0x4000000 +#define IN_MASK_ADD 0x20000000 +#define IN_ONESHOT 0x80000000 +#define IN_ONLYDIR 0x1000000 +#define IN_IGNORED 0x8000 +#define IN_ISDIR 0x40000000 +#define IN_Q_OVERFLOW 0x4000 +#define IN_UNMOUNT 0x2000 + +#define IN_ALL_EVENTS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \ + IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \ + IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \ + IN_MOVE_SELF) + +struct inotify_event { + int wd; + unsigned int mask; + unsigned int cookie; + unsigned int len; + char name[]; +}; + +#ifndef __MLIBC_ABI_ONLY + +int inotify_init(void); +int inotify_init1(int); +int inotify_add_watch(int, const char *, uint32_t); +int inotify_rm_watch(int, int); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif //_SYS_INOTIFY_H + diff --git a/lib/mlibc/options/linux/include/sys/klog.h b/lib/mlibc/options/linux/include/sys/klog.h new file mode 100644 index 0000000..520bdd1 --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/klog.h @@ -0,0 +1,18 @@ +#ifndef _SYS_KLOG_H +#define _SYS_KLOG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __MLIBC_ABI_ONLY + +int klogctl(int type, char *bufp, int len); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KLOG_H */ diff --git a/lib/mlibc/options/linux/include/sys/mount.h b/lib/mlibc/options/linux/include/sys/mount.h new file mode 100644 index 0000000..2486128 --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/mount.h @@ -0,0 +1,90 @@ +#ifndef _SYS_MOUNT_H +#define _SYS_MOUNT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MS_RDONLY 1 +#define MS_NOSUID 2 +#define MS_NODEV 4 +#define MS_NOEXEC 8 +#define MS_SYNCHRONOUS 16 +#define MS_REMOUNT 32 +#define MS_MANDLOCK 64 +#define MS_DIRSYNC 128 +#define MS_NOSYMFOLLOW 256 +#define MS_NOATIME 1024 +#define MS_NODIRATIME 2048 +#define MS_BIND 4096 +#define MS_MOVE 8192 +#define MS_REC 16384 +#define MS_SILENT 32768 +#define MS_POSIXACL (1 << 16) +#define MS_UNBINDABLE (1 << 17) +#define MS_PRIVATE (1 << 18) +#define MS_SLAVE (1 << 19) +#define MS_SHARED (1 << 20) +#define MS_RELATIME (1 << 21) +#define MS_KERNMOUNT (1 << 22) +#define MS_I_VERSION (1 << 23) +#define MS_STRICTATIME (1 << 24) +#define MS_LAZYTIME (1 << 25) +#define MS_NOREMOTELOCK (1 << 27) +#define MS_NOSEC (1 << 28) +#define MS_BORN (1 << 29) +#define MS_ACTIVE (1 << 30) +#define MS_NOUSER (1 << 31) + +#define MNT_FORCE 1 +#define MNT_DETACH 2 +#define MNT_EXPIRE 4 +#define UMOUNT_NOFOLLOW 8 + +#undef BLKROSET +#define BLKROSET _IO(0x12, 93) +#undef BLKROGET +#define BLKROGET _IO(0x12, 94) +#undef BLKRRPART +#define BLKRRPART _IO(0x12, 95) +#undef BLKGETSIZE +#define BLKGETSIZE _IO(0x12, 96) +#undef BLKFLSBUF +#define BLKFLSBUF _IO(0x12, 97) +#undef BLKRASET +#define BLKRASET _IO(0x12, 98) +#undef BLKRAGET +#define BLKRAGET _IO(0x12, 99) +#undef BLKFRASET +#define BLKFRASET _IO(0x12, 100) +#undef BLKFRAGET +#define BLKFRAGET _IO(0x12, 101) +#undef BLKSECTSET +#define BLKSECTSET _IO(0x12, 102) +#undef BLKSECTGET +#define BLKSECTGET _IO(0x12, 103) +#undef BLKSSZGET +#define BLKSSZGET _IO(0x12, 104) +#undef BLKBSZGET +#define BLKBSZGET _IOR(0x12, 112, size_t) +#undef BLKBSZSET +#define BLKBSZSET _IOW(0x12, 113, size_t) +#undef BLKGETSIZE64 +#define BLKGETSIZE64 _IOR(0x12, 114, size_t) + +#ifndef __MLIBC_ABI_ONLY + +int mount(const char *source, const char *target, + const char *fstype, unsigned long flags, const void *data); +int umount(const char *target); +int umount2(const char *target, int flags); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif // _SYS_MOUNT_H diff --git a/lib/mlibc/options/linux/include/sys/prctl.h b/lib/mlibc/options/linux/include/sys/prctl.h new file mode 100644 index 0000000..de987c1 --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/prctl.h @@ -0,0 +1,128 @@ + +#ifndef _SYS_PRCTL_H +#define _SYS_PRCTL_H + +#include + +#define PR_SET_PDEATHSIG 1 +#define PR_GET_PDEATHSIG 2 +#define PR_GET_DUMPABLE 3 +#define PR_SET_DUMPABLE 4 +#define PR_GET_UNALIGN 5 +#define PR_SET_UNALIGN 6 +#define PR_UNALIGN_NOPRINT 1 +#define PR_UNALIGN_SIGBUS 2 +#define PR_GET_KEEPCAPS 7 +#define PR_SET_KEEPCAPS 8 +#define PR_GET_FPEMU 9 +#define PR_SET_FPEMU 10 +#define PR_FPEMU_NOPRINT 1 +#define PR_FPEMU_SIGFPE 2 +#define PR_GET_FPEXC 11 +#define PR_SET_FPEXC 12 +#define PR_FP_EXC_SW_ENABLE 0x80 +#define PR_FP_EXC_DIV 0x010000 +#define PR_FP_EXC_OVF 0x020000 +#define PR_FP_EXC_UND 0x040000 +#define PR_FP_EXC_RES 0x080000 +#define PR_FP_EXC_INV 0x100000 +#define PR_FP_EXC_DISABLED 0 +#define PR_FP_EXC_NONRECOV 1 +#define PR_FP_EXC_ASYNC 2 +#define PR_FP_EXC_PRECISE 3 +#define PR_GET_TIMING 13 +#define PR_SET_TIMING 14 +#define PR_TIMING_STATISTICAL 0 +#define PR_TIMING_TIMESTAMP 1 +#define PR_SET_NAME 15 +#define PR_GET_NAME 16 +#define PR_GET_ENDIAN 19 +#define PR_SET_ENDIAN 20 +#define PR_ENDIAN_BIG 0 +#define PR_ENDIAN_LITTLE 1 +#define PR_ENDIAN_PPC_LITTLE 2 +#define PR_GET_SECCOMP 21 +#define PR_SET_SECCOMP 22 +#define PR_CAPBSET_READ 23 +#define PR_CAPBSET_DROP 24 +#define PR_GET_TSC 25 +#define PR_SET_TSC 26 +#define PR_TSC_ENABLE 1 +#define PR_TSC_SIGSEGV 2 +#define PR_GET_SECUREBITS 27 +#define PR_SET_SECUREBITS 28 +#define PR_SET_TIMERSLACK 29 +#define PR_GET_TIMERSLACK 30 + +#define PR_TASK_PERF_EVENTS_DISABLE 31 +#define PR_TASK_PERF_EVENTS_ENABLE 32 + +#define PR_MCE_KILL 33 +#define PR_MCE_KILL_CLEAR 0 +#define PR_MCE_KILL_SET 1 +#define PR_MCE_KILL_LATE 0 +#define PR_MCE_KILL_EARLY 1 +#define PR_MCE_KILL_DEFAULT 2 +#define PR_MCE_KILL_GET 34 + +#define PR_SET_MM 35 +#define PR_SET_MM_START_CODE 1 +#define PR_SET_MM_END_CODE 2 +#define PR_SET_MM_START_DATA 3 +#define PR_SET_MM_END_DATA 4 +#define PR_SET_MM_START_STACK 5 +#define PR_SET_MM_START_BRK 6 +#define PR_SET_MM_BRK 7 +#define PR_SET_MM_ARG_START 8 +#define PR_SET_MM_ARG_END 9 +#define PR_SET_MM_ENV_START 10 +#define PR_SET_MM_ENV_END 11 +#define PR_SET_MM_AUXV 12 +#define PR_SET_MM_EXE_FILE 13 +#define PR_SET_MM_MAP 14 +#define PR_SET_MM_MAP_SIZE 15 + +#define PR_SET_PTRACER 0x59616d61 +#define PR_SET_PTRACER_ANY (-1UL) + +#define PR_SET_CHILD_SUBREAPER 36 +#define PR_GET_CHILD_SUBREAPER 37 + +#define PR_SET_NO_NEW_PRIVS 38 +#define PR_GET_NO_NEW_PRIVS 39 + +#define PR_GET_TID_ADDRESS 40 + +#define PR_SET_THP_DISABLE 41 +#define PR_GET_THP_DISABLE 42 + +#define PR_MPX_ENABLE_MANAGEMENT 43 +#define PR_MPX_DISABLE_MANAGEMENT 44 + +#define PR_SET_FP_MODE 45 +#define PR_GET_FP_MODE 46 +#define PR_FP_MODE_FR (1 << 0) +#define PR_FP_MODE_FRE (1 << 1) + +#define PR_CAP_AMBIENT 47 +#define PR_CAP_AMBIENT_IS_SET 1 +#define PR_CAP_AMBIENT_RAISE 2 +#define PR_CAP_AMBIENT_LOWER 3 +#define PR_CAP_AMBIENT_CLEAR_ALL 4 + +#ifndef __MLIBC_ABI_ONLY + +#ifdef __cplusplus +extern "C" { +#endif + +int prctl (int, ...); + +#ifdef __cplusplus +} +#endif + +#endif /* !__MLIBC_ABI_ONLY */ + +#endif // _SYS_PRCTL_H + diff --git a/lib/mlibc/options/linux/include/sys/ptrace.h b/lib/mlibc/options/linux/include/sys/ptrace.h new file mode 100644 index 0000000..e98d38a --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/ptrace.h @@ -0,0 +1,55 @@ + +#ifndef _SYS_PTRACE_H +#define _SYS_PTRACE_H + +#include +#include + +#define PTRACE_TRACEME 0 +#define PT_TRACE_ME PTRACE_TRACEME + +#define PT_READ_I PTRACE_PEEKTEXT +#define PT_READ_D PTRACE_PEEKDATA +#define PT_READ_U PTRACE_PEEKUSER +#define PT_WRITE_I PTRACE_POKETEXT +#define PT_WRITE_D PTRACE_POKEDATA +#define PT_WRITE_U PTRACE_POKEUSER +#define PT_CONTINUE PTRACE_CONT +#define PT_KILL PTRACE_KILL +#define PT_STEP PTRACE_SINGLESTEP +#define PT_GETREGS PTRACE_GETREGS +#define PT_SETREGS PTRACE_SETREGS +#define PT_GETFPREGS PTRACE_GETFPREGS +#define PT_SETFPREGS PTRACE_SETFPREGS +#define PT_ATTACH PTRACE_ATTACH +#define PT_DETACH PTRACE_DETACH +#define PT_GETFPXREGS PTRACE_GETFPXREGS +#define PT_SETFPXREGS PTRACE_SETFPXREGS +#define PT_SYSCALL PTRACE_SYSCALL +#define PT_SETOPTIONS PTRACE_SETOPTIONS +#define PT_GETEVENTMSG PTRACE_GETEVENTMSG +#define PT_GETSIGINFO PTRACE_GETSIGINFO +#define PT_SETSIGINFO PTRACE_SETSIGINFO + +#ifdef __cplusplus +extern "C" { +#endif + +struct ptrace_peeksiginfo_args { + uint64_t offset; + uint32_t flags; + int32_t nr; +}; + +#ifndef __MLIBC_ABI_ONLY + +long ptrace(int, ...); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif // _SYS_PTRACE_H + diff --git a/lib/mlibc/options/linux/include/sys/quota.h b/lib/mlibc/options/linux/include/sys/quota.h new file mode 100644 index 0000000..f668d9b --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/quota.h @@ -0,0 +1,24 @@ +#ifndef _SYS_QUOTA_H +#define _SYS_QUOTA_H + +#include + +#define SUBCMDMASK 0x00ff +#define SUBCMDSHIFT 8 +#define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK)) + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __MLIBC_ABI_ONLY + +int quotactl(int cmd, const char *special, int id, caddr_t addr); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif // _SYS_QUOTA_H diff --git a/lib/mlibc/options/linux/include/sys/random.h b/lib/mlibc/options/linux/include/sys/random.h new file mode 100644 index 0000000..0b24b74 --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/random.h @@ -0,0 +1,26 @@ + +#ifndef _SYS_RANDOM_H +#define _SYS_RANDOM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define GRND_RANDOM 1 +#define GRND_NONBLOCK 2 + +#include +#include + +#ifndef __MLIBC_ABI_ONLY + +ssize_t getrandom(void *, size_t, unsigned int); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif //_SYS_RANDOM_H + diff --git a/lib/mlibc/options/linux/include/sys/reboot.h b/lib/mlibc/options/linux/include/sys/reboot.h new file mode 100644 index 0000000..6c4e495 --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/reboot.h @@ -0,0 +1,20 @@ +#ifndef MLIBC_SYS_REBOOT_H +#define MLIBC_SYS_REBOOT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __MLIBC_ABI_ONLY + +int reboot(int arg); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif // MLIBC_SYS_REBOOT_H diff --git a/lib/mlibc/options/linux/include/sys/sendfile.h b/lib/mlibc/options/linux/include/sys/sendfile.h new file mode 100644 index 0000000..32b17ce --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/sendfile.h @@ -0,0 +1,22 @@ + +#ifndef _SYS_SENDFILE_H_ +#define _SYS_SENDFILE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifndef __MLIBC_ABI_ONLY + +ssize_t sendfile(int, int, off_t *, size_t); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif // _SYS_SENDFILE_H_ + diff --git a/lib/mlibc/options/linux/include/sys/signalfd.h b/lib/mlibc/options/linux/include/sys/signalfd.h new file mode 100644 index 0000000..adf7c1b --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/signalfd.h @@ -0,0 +1,48 @@ +#ifndef _SYS_SIGNALFD_H +#define _SYS_SIGNALFD_H + +// TODO: Define sigset separately and remove this include. +#include +// musl includes those. Restructure this so we do not need them? +#include +#include + +#define SFD_CLOEXEC O_CLOEXEC +#define SFD_NONBLOCK O_NONBLOCK + +#ifdef __cplusplus +extern "C" { +#endif + +struct signalfd_siginfo { + uint32_t ssi_signo; + int32_t ssi_errno; + int32_t ssi_code; + uint32_t ssi_pid; + uint32_t ssi_uid; + int32_t ssi_fd; + uint32_t ssi_tid; + uint32_t ssi_band; + uint32_t ssi_overrun; + uint32_t ssi_trapno; + int32_t ssi_status; + int32_t ssi_int; + uint64_t ssi_ptr; + uint64_t ssi_utime; + uint64_t ssi_stime; + uint64_t ssi_addr; + uint16_t ssi_addr_lsb; + uint8_t pad[128-12*4-4*8-2]; +}; + +#ifndef __MLIBC_ABI_ONLY + +int signalfd(int, const sigset_t *, int); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif // _SYS_SIGNALFD_H diff --git a/lib/mlibc/options/linux/include/sys/statfs.h b/lib/mlibc/options/linux/include/sys/statfs.h new file mode 100644 index 0000000..07ae693 --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/statfs.h @@ -0,0 +1,22 @@ +#ifndef _SYS_STATFS_H +#define _SYS_STATFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifndef __MLIBC_ABI_ONLY + +int statfs(const char *, struct statfs *); +int fstatfs(int, struct statfs *); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif // _SYS_STATFS_H + diff --git a/lib/mlibc/options/linux/include/sys/swap.h b/lib/mlibc/options/linux/include/sys/swap.h new file mode 100644 index 0000000..79e89c6 --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/swap.h @@ -0,0 +1,24 @@ +#ifndef _SYS_SWAP_H +#define _SYS_SWAP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define SWAP_FLAG_PREFER 0x8000 +#define SWAP_FLAG_PRIO_MASK 0x7fff +#define SWAP_FLAG_PRIO_SHIFT 0 +#define SWAP_FLAG_DISCARD 0x10000 + +#ifndef __MLIBC_ABI_ONLY + +int swapon(const char *, int); +int swapoff(const char *); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SWAP_H */ diff --git a/lib/mlibc/options/linux/include/sys/sysinfo.h b/lib/mlibc/options/linux/include/sys/sysinfo.h new file mode 100644 index 0000000..917f861 --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/sysinfo.h @@ -0,0 +1,34 @@ +#ifndef _SYS_SYSINFO_H +#define _SYS_SYSINFO_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct sysinfo { + long uptime; + unsigned long loads[3]; + unsigned long totalram; + unsigned long freeram; + unsigned long sharedram; + unsigned long bufferram; + unsigned long totalswap; + unsigned long freeswap; + unsigned short procs; + unsigned long totalhigh; + unsigned long freehigh; + unsigned int mem_unit; + char _f[20 - 2 * sizeof(long) - sizeof(int)]; // Padding to 64 bytes according to my man page +}; + +#ifndef __MLIBC_ABI_ONLY + +int sysinfo(struct sysinfo *); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif // _SYS_SYSINFO_H diff --git a/lib/mlibc/options/linux/include/sys/sysmacros.h b/lib/mlibc/options/linux/include/sys/sysmacros.h new file mode 100644 index 0000000..230858b --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/sysmacros.h @@ -0,0 +1,35 @@ +#ifndef _SYS_SYSMACROS_H +#define _SYS_SYSMACROS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +__MLIBC_INLINE_DEFINITION unsigned int __mlibc_dev_major( + unsigned long long int __dev) { + return ((__dev >> 8) & 0xfff) | ((unsigned int)(__dev >> 32) & ~0xfff); +} + +__MLIBC_INLINE_DEFINITION unsigned int __mlibc_dev_minor( + unsigned long long int __dev) { + return (__dev & 0xff) | ((unsigned int)(__dev >> 12) & ~0xff); +} + +__MLIBC_INLINE_DEFINITION unsigned long long int __mlibc_dev_makedev( + unsigned int __major, unsigned int __minor) { + return ((__minor & 0xff) | ((__major & 0xfff) << 8) + | (((unsigned long long int)(__minor & ~0xff)) << 12) + | (((unsigned long long int)(__major & ~0xfff)) << 32)); +} + +#define major(dev) __mlibc_dev_major(dev) +#define minor(dev) __mlibc_dev_minor(dev) +#define makedev(major, minor) __mlibc_dev_makedev(major, minor) + +#ifdef __cplusplus +} +#endif + +#endif // _SYS_SYSMACROS_H diff --git a/lib/mlibc/options/linux/include/sys/timerfd.h b/lib/mlibc/options/linux/include/sys/timerfd.h new file mode 100644 index 0000000..b8a2932 --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/timerfd.h @@ -0,0 +1,32 @@ +#ifndef _SYS_TIMERFD_H +#define _SYS_TIMERFD_H + +// musl includes those. Refactor and remove them? +#include +#include + +#define TFD_NONBLOCK O_NONBLOCK +#define TFD_CLOEXEC O_CLOEXEC + +#define TFD_TIMER_ABSTIME 1 +#define TFD_TIMER_CANCEL_ON_SET (1 << 1) + +#ifdef __cplusplus +extern "C" { +#endif + +struct itimerspec; + +#ifndef __MLIBC_ABI_ONLY + +int timerfd_create(int, int); +int timerfd_settime(int, int, const struct itimerspec *, struct itimerspec *); +int timerfd_gettime(int, struct itimerspec *); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif // _SYS_TIMERFD_H diff --git a/lib/mlibc/options/linux/include/sys/vfs.h b/lib/mlibc/options/linux/include/sys/vfs.h new file mode 100644 index 0000000..61a6aa3 --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/vfs.h @@ -0,0 +1,16 @@ + +#ifndef _SYS_VFS_H +#define _SYS_VFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef __cplusplus +} +#endif + +#endif // _SYS_VFS_H + diff --git a/lib/mlibc/options/linux/include/sys/vt.h b/lib/mlibc/options/linux/include/sys/vt.h new file mode 100644 index 0000000..d9dfbd9 --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/vt.h @@ -0,0 +1,6 @@ +#ifndef _SYS_VT_H +#define _SYS_VT_H + +#include + +#endif // _SYS_VT_H diff --git a/lib/mlibc/options/linux/include/sys/xattr.h b/lib/mlibc/options/linux/include/sys/xattr.h new file mode 100644 index 0000000..e54c58c --- /dev/null +++ b/lib/mlibc/options/linux/include/sys/xattr.h @@ -0,0 +1,38 @@ +#ifndef _MLIBC_LINUX_SYS_XATTR_H +#define _MLIBC_LINUX_SYS_XATTR_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __MLIBC_ABI_ONLY + +int setxattr(const char *path, const char *name, const void *val, size_t size, + int flags); +int lsetxattr(const char *path, const char *name, const void *val, size_t size, + int flags); +int fsetxattr(int fd, const char *name, const void *val, size_t size, + int flags); + +ssize_t getxattr(const char *path, const char *name, void *val, size_t size); +ssize_t lgetxattr(const char *path, const char *name, void *val, size_t size); +ssize_t fgetxattr(int fd, const char *name, void *val, size_t size); + +ssize_t listxattr(const char *path, char *list, size_t size); +ssize_t llistxattr(const char *path, char *list, size_t size); +ssize_t flistxattr(int fd, char *list, size_t size); + +int removexattr(const char *path, const char *name); +int lremovexattr(const char *path, const char *name); +int fremovexattr(int fd, const char *name); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _MLIBC_LINUX_SYS_XATTR_H */ -- cgit v1.2.3