libc: add linux headers

Yeah

Signed-off-by: kaguya <vpshinomiya@protonmail.com>
This commit is contained in:
kaguya
2026-05-03 00:48:24 -04:00
parent ef14a52b49
commit f7aa6f913a
43 changed files with 1550 additions and 3 deletions
@@ -0,0 +1,49 @@
#ifndef _BITS_LINUX_CPU_SET_H
#define _BITS_LINUX_CPU_SET_H
#ifdef __cplusplus
extern "C" {
#endif
#include <bits/cpu_set.h>
#include <bits/size_t.h>
#include <limits.h>
#include <stdlib.h>
#ifndef __MLIBC_ABI_ONLY
cpu_set_t *__mlibc_cpu_alloc(int __num_cpus);
size_t __mlibc_cpu_alloc_size(int __num_cpus);
void __mlibc_cpu_zero(const size_t __setsize, cpu_set_t *__set);
void __mlibc_cpu_set(const int __cpu, const size_t __setsize, cpu_set_t *__set);
void __mlibc_cpu_clear(const int __cpu, const size_t __setsize, cpu_set_t *__set);
int __mlibc_cpu_isset(const int __cpu, const size_t __setsize, const cpu_set_t *__set);
int __mlibc_cpu_count(const size_t __setsize, const cpu_set_t *__set);
#define CPU_ALLOC_SIZE(n) __mlibc_cpu_alloc_size((n))
#define CPU_ALLOC(n) __mlibc_cpu_alloc((n))
#define CPU_FREE(set) free((set))
#define CPU_ZERO_S(setsize, set) __mlibc_cpu_zero((setsize), (set))
#define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t), set)
#define CPU_SET_S(cpu, setsize, set) __mlibc_cpu_set((cpu), (setsize), (set))
#define CPU_SET(cpu, set) CPU_SET_S(cpu, sizeof(cpu_set_t), set)
#define CPU_CLR_S(cpu, setsize, set) __mlibc_cpu_clear((cpu), (setsize), (set))
#define CPU_CLR(cpu, set) CPU_CLR_S(cpu, sizeof(cpu_set_t), set)
#define CPU_ISSET_S(cpu, setsize, set) __mlibc_cpu_isset((cpu), (setsize), (set))
#define CPU_ISSET(cpu, set) CPU_ISSET_S(cpu, sizeof(cpu_set_t), set)
#define CPU_COUNT_S(setsize, set) __mlibc_cpu_count((setsize), (set))
#define CPU_COUNT(set) CPU_COUNT_S(sizeof(cpu_set_t), set)
#endif /* !__MLIBC_ABI_ONLY */
#ifdef __cplusplus
}
#endif
#endif /* _BITS_LINUX_CPU_SET_H */
@@ -0,0 +1,63 @@
#ifndef _BITS_LINUX_SCHED_H
#define _BITS_LINUX_SCHED_H
#ifdef __cplusplus
extern "C" {
#endif
#include <abi-bits/pid_t.h>
#include <bits/size_t.h>
#include <bits/linux/cpu_set.h>
#define CLONE_VM 0x00000100
#define CLONE_FS 0x00000200
#define CLONE_FILES 0x00000400
#define CLONE_SIGHAND 0x00000800
#define CLONE_PIDFD 0x00001000
#define CLONE_PTRACE 0x00002000
#define CLONE_VFORK 0x00004000
#define CLONE_PARENT 0x00008000
#define CLONE_THREAD 0x00010000
#define CLONE_NEWNS 0x00020000
#define CLONE_SYSVSEM 0x00040000
#define CLONE_SETTLS 0x00080000
#define CLONE_PARENT_SETTID 0x00100000
#define CLONE_CHILD_CLEARTID 0x00200000
#define CLONE_DETACHED 0x00400000
#define CLONE_UNTRACED 0x00800000
#define CLONE_CHILD_SETTID 0x01000000
#define CLONE_NEWCGROUP 0x02000000
#define CLONE_NEWUTS 0x04000000
#define CLONE_NEWIPC 0x08000000
#define CLONE_NEWUSER 0x10000000
#define CLONE_NEWPID 0x20000000
#define CLONE_NEWNET 0x40000000
#define CLONE_IO 0x80000000
#define CLONE_CLEAR_SIGHAND 0x100000000ULL
#define CLONE_INTO_CGROUP 0x200000000ULL
#ifndef __MLIBC_ABI_ONLY
int sched_getscheduler(pid_t __pid);
int sched_setaffinity(pid_t __pid, size_t __cpusetsize, const cpu_set_t *__mask);
int sched_getaffinity(pid_t __pid, size_t __cpusetsize, cpu_set_t *__mask);
int unshare(int flags);
int clone(int (*)(void *), void *, int, void *, ...);
/* Glibc extension */
int sched_getcpu(void);
#if defined(_GNU_SOURCE)
int setns(int fd, int nstype);
#endif /* _GNU_SOURCE */
#endif /* !__MLIBC_ABI_ONLY */
#ifdef __cplusplus
}
#endif
#endif /* _BITS_LINUX_SCHED_H */
@@ -0,0 +1,20 @@
#ifndef _BITS_LINUX_STAT_H
#define _BITS_LINUX_STAT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <abi-bits/statx.h>
#ifndef __MLIBC_ABI_ONLY
int statx(int __dirfd, const char *__pathname, int __flags, unsigned int __mask, struct statx *__statxbuf);
#endif /* !__MLIBC_ABI_ONLY */
#ifdef __cplusplus
}
#endif
#endif /* _BITS_LINUX_STAT_H */
@@ -0,0 +1,30 @@
#ifndef _BITS_LINUX_UIO_H
#define _BITS_LINUX_UIO_H
#include <abi-bits/pid_t.h>
#include <bits/posix/iovec.h>
#include <bits/ssize_t.h>
#include <mlibc-config.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __MLIBC_ABI_ONLY
ssize_t process_vm_readv(pid_t pid,
const struct iovec *local_iov, unsigned long liovcnt,
const struct iovec *remote_iov, unsigned long riovcnt,
unsigned long flags);
ssize_t process_vm_writev(pid_t pid,
const struct iovec *local_iov, unsigned long liovcnt,
const struct iovec *remote_iov, unsigned long riovcnt,
unsigned long flags);
#endif /* !__MLIBC_ABI_ONLY */
#ifdef __cplusplus
}
#endif
#endif /* _BITS_LINUX_UIO_H */
@@ -0,0 +1,21 @@
#ifndef _BITS_LINUX_UNISTD_H
#define _BITS_LINUX_UNISTD_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __MLIBC_ABI_ONLY
int dup3(int __fd, int __newfd, int __flags);
int vhangup(void);
int getdtablesize(void);
int syncfs(int __fd);
#endif /* !__MLIBC_ABI_ONLY */
#ifdef __cplusplus
}
#endif
#endif /* _BITS_LINUX_UNISTD_H */
@@ -0,0 +1,71 @@
#ifndef _BITS_LINUX_UTMP_H
#define _BITS_LINUX_UTMP_H
#include <abi-bits/pid_t.h>
#include <abi-bits/utmp-defines.h>
#include <bits/posix/timeval.h>
#include <bits/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#define UT_LINESIZE 32
#define UT_NAMESIZE 32
#define UT_HOSTSIZE 256
#define UTMP_FILENAME UTMP_FILE
#define WTMP_FILENAME WTMP_FILE
struct exit_status {
short int e_termination;
short int e_exit;
};
struct utmp {
short ut_type;
pid_t ut_pid;
char ut_line[UT_LINESIZE];
char ut_id[4];
char ut_user[UT_NAMESIZE];
char ut_host[UT_HOSTSIZE];
struct exit_status ut_exit;
long ut_session;
struct timeval ut_tv;
__mlibc_int32 ut_addr_v6[4];
char __unused[20];
};
struct lastlog {
time_t ll_time;
char ll_line[UT_LINESIZE];
char ll_host[UT_HOSTSIZE];
};
/* Hacks for compability reasons */
#define ut_name ut_user
#ifndef _NO_UT_TIME
#define ut_time ut_tv.tv_sec
#endif
#define ut_xtime ut_tv.tv_sec
#define ut_addr ut_addr_v6[0]
#ifndef __MLIBC_ABI_ONLY
void setutent(void);
struct utmp *getutent(void);
int getutent_r(struct utmp *__buf, struct utmp **__res);
void endutent(void);
struct utmp *pututline(const struct utmp *__line);
struct utmp *getutline(const struct utmp *__line);
struct utmp *getutid(const struct utmp *__id);
int utmpname(const char *__file);
void updwtmp(const char *wtmp_file, const struct utmp *ut);
#endif /* !__MLIBC_ABI_ONLY */
#ifdef __cplusplus
}
#endif
#endif /* _BITS_LINUX_UTMP_H */