user: implement mlibc as the libc, finally.

It's finally done..

Signed-off-by: kaguya <vpshinomiya@protonmail.com>
This commit is contained in:
kaguya
2026-05-02 03:31:49 -04:00
parent 2fa39ad85a
commit 9a9b91c940
2387 changed files with 152741 additions and 315 deletions
+12
View File
@@ -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 */
+24
View File
@@ -0,0 +1,24 @@
#ifndef _ABIBITS_SIGEVENT_H
#define _ABIBITS_SIGEVENT_H
#include <abi-bits/sigval.h>
#include <abi-bits/pid_t.h>
#ifdef __cplusplus
extern "C" {
#endif
struct sigevent {
int sigev_notify;
int sigev_signo;
union sigval sigev_value;
void (*sigev_notify_function)(union sigval);
/* MISSING: sigev_notify_attributes */
};
#ifdef __cplusplus
}
#endif
#endif /* _ABIBITS_SIGEVENT_H */
+179
View File
@@ -0,0 +1,179 @@
#ifndef _ABIBITS_SIGNAL_H
#define _ABIBITS_SIGNAL_H
#include <abi-bits/pid_t.h>
#include <abi-bits/uid_t.h>
#include <abi-bits/sigevent.h>
#include <bits/size_t.h>
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
/* 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 CLD_EXITED 1
#define CLD_KILLED 2
#define CLD_DUMPED 3
#define CLD_TRAPPED 4
#define CLD_STOPPED 5
#define CLD_CONTINUED 6
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 */
+36
View File
@@ -0,0 +1,36 @@
#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 */
@@ -0,0 +1,14 @@
#ifndef _ABIBITS_UTMP_DEFINES_H
#define _ABIBITS_UTMP_DEFINES_H
#define EMPTY 0
#define RUN_LVL 1
#define BOOT_TIME 2
#define NEW_TIME 3
#define OLD_TIME 4
#define INIT_PROCESS 5
#define LOGIN_PROCESS 6
#define USER_PROCESS 7
#define DEAD_PROCESS 8
#endif /* _ABIBITS_UTMP_DEFINES_H */
+36
View File
@@ -0,0 +1,36 @@
#ifndef _ABIBITS_UTMPX_H
#define _ABIBITS_UTMPX_H
#include <abi-bits/pid_t.h>
#include <bits/posix/timeval.h>
#define __UT_HOSTSIZE 256
#define __UT_NAMESIZE 32
#define __UT_LINESIZE 32
/* Struct definition taken from musl */
struct utmpx {
short ut_type;
short __ut_pad1;
pid_t ut_pid;
char ut_line[__UT_LINESIZE];
char ut_id[4];
char ut_user[__UT_NAMESIZE];
char ut_host[__UT_HOSTSIZE];
struct {
short __e_termination;
short __e_exit;
} ut_exit;
int ut_session, __ut_pad2;
struct timeval ut_tv;
unsigned ut_addr_v6[4];
char __unused[20];
};
#define e_exit __e_exit
#define e_termination __e_termination
#define UTMPX_FILE "/var/run/utmp"
#define WTMPX_FILE "/var/log/wtmp"
#endif /* _ABIBITS_UTMPX_H */