LibC: Cleanup and fix missing LibC headers

This commit is contained in:
Bananymous 2024-08-28 17:07:58 +03:00
parent d559339f5f
commit 57300687ff
4 changed files with 161 additions and 95 deletions

View File

@ -12,6 +12,9 @@ __BEGIN_DECLS
#define RTLD_GLOBAL 3
#define RTLD_LOCAL 4
#define RTLD_NEXT ((void*)-1)
#define RTLD_DEFAULT ((void*) 0)
int dlclose(void* handle);
char* dlerror(void);
void* dlopen(const char* file, int mode);

View File

@ -52,11 +52,9 @@ __BEGIN_DECLS
#define PTHREAD_SCOPE_PROCESS 23
#define PTHREAD_SCOPE_SYSTEM 24
#if 0
#define PTHREAD_COND_INITIALIZER
#define PTHREAD_MUTEX_INITIALIZER
#define PTHREAD_RWLOCK_INITIALIZER
#endif
#define PTHREAD_COND_INITIALIZER (pthread_cond_t)0
#define PTHREAD_MUTEX_INITIALIZER (pthread_mutex_t)0
#define PTHREAD_RWLOCK_INITIALIZER (pthread_rwlock_t)0
int pthread_atfork(void (*prepare)(void), void (*parent)(void), void(*child)(void));
int pthread_attr_destroy(pthread_attr_t* attr);

View File

@ -46,16 +46,43 @@ struct sigevent
#define SIGABRT 1
#define SIGALRM 2
#define SIGBUS 3
#define BUS_ADRALN 1
#define BUS_ADRERR 2
#define BUS_OBJERR 3
#define SIGCHLD 4
#define CLD_EXITED 1
#define CLD_KILLED 2
#define CLD_DUMPED 3
#define CLD_TRAPPED 4
#define CLD_STOPPED 5
#define CLD_CONTINUED 6
#define SIGCONT 5
#define SIGFPE 6
#define FPE_INTDIV 1
#define FPE_INTOVF 2
#define FPE_FLTDIV 3
#define FPE_FLTOVF 4
#define FPE_FLTUND 5
#define FPE_FLTRES 6
#define FPE_FLTINV 7
#define FPE_FLTSUB 8
#define SIGHUP 7
#define SIGILL 8
#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 SIGINT 9
#define SIGKILL 10
#define SIGPIPE 11
#define SIGQUIT 12
#define SIGSEGV 13
#define SEGV_MAPERR 1
#define SEGV_ACCERR 2
#define SIGSTOP 14
#define SIGTERM 15
#define SIGTSTP 16
@ -64,6 +91,12 @@ struct sigevent
#define SIGUSR1 19
#define SIGUSR2 20
#define SIGPOLL 21
#define POLL_IN 1
#define POLL_OUT 2
#define POLL_MSG 3
#define POLL_ERR 4
#define POLL_PRI 5
#define POLL_HUP 6
#define SIGPROF 22
#define SIGSYS 23
#define SIGTRAP 24
@ -75,6 +108,12 @@ struct sigevent
#define SIGRTMIN 30
#define SIGRTMAX (SIGRTMIN+32)
#define SI_USER 10
#define SI_QUEUE 11
#define SI_TIMER 12
#define SI_ASYNCIO 13
#define SI_MESGQ 14
#define _SIGMIN SIGABRT
#define _SIGMAX SIGRTMAX
@ -101,7 +140,46 @@ typedef struct
int ss_flags; /* Flags. */
} stack_t;
typedef struct {} mcontext_t;
enum
{
#if defined(__x86_64__)
REG_RAX,
REG_RBX,
REG_RCX,
REG_RDX,
REG_RDI,
REG_RSI,
REG_RSP,
REG_RBP,
REG_RIP,
REG_R8,
REG_R9,
REG_R10,
REG_R11,
REG_R12,
REG_R13,
REG_R14,
REG_R15,
#elif defined(__i686__)
REG_EAX,
REG_EBX,
REG_ECX,
REG_EDX,
REG_EDI,
REG_ESI,
REG_ESP,
REG_EBP,
REG_EIP,
#else
#error
#endif
__REG_COUNT
};
typedef struct
{
long gregs[__REG_COUNT];
} mcontext_t;
typedef struct __ucontext_t
{
@ -132,11 +210,6 @@ struct sigaction
void (*sa_sigaction)(int, siginfo_t*, void*); /* Pointer to a signal-catching function. */
};
// TODO: The <signal.h> header shall define the symbolic constants in the
// Code column of the following table for use as values of si_code
// that are signal-specific or non-signal-specific reasons why the
// signal was generated.
int kill(pid_t pid, int sig);
int killpg(pid_t pgpr, int sig);
void psiginfo(const siginfo_t* pinfo, const char* message);

View File

@ -149,15 +149,7 @@ __BEGIN_DECLS
#if !defined(__ssize_t_defined) && (defined(__need_all_types) || defined(__need_ssize_t))
#define __ssize_t_defined 1
#if __SIZEOF_SIZE_T__ == __SIZEOF_INT__
typedef int ssize_t;
#elif __SIZEOF_SIZE_T__ == __SIZEOF_LONG__
typedef long ssize_t;
#elif __SIZEOF_SIZE_T__ == __SIZEOF_LONG_LONG__
typedef long long ssize_t;
#else
#error "unsupported sizeof(size_t)"
#endif
typedef __PTRDIFF_TYPE__ ssize_t;
#endif
#undef __need_ssize_t