userspace/libc: implement std more functions

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
2025-01-27 23:30:07 +02:00
parent f5a813380b
commit 2f71bccef2
15 changed files with 597 additions and 55 deletions

View File

@ -59,7 +59,7 @@ extern "C"
#define DT_TMO
int alphasort(const struct dirent **, const struct dirent **);
int closedir(DIR *);
int closedir(DIR *dirp);
int dirfd(DIR *);
DIR *fdopendir(int);
DIR *opendir(const char *);

View File

@ -23,6 +23,8 @@ extern "C"
{
#endif // __cplusplus
#include <sys/types.h>
typedef struct f_owner_ex
{
int type; /* Discriminator for pid. */

View File

@ -90,9 +90,9 @@ extern "C"
int feof(FILE *);
int ferror(FILE *);
int fflush(FILE *stream);
int fgetc(FILE *);
int fgetc(FILE *stream);
int fgetpos(FILE *restrict, fpos_t *restrict);
char *fgets(char *restrict, int, FILE *restrict);
char *fgets(char *restrict s, int n, FILE *restrict stream);
int fileno(FILE *);
void flockfile(FILE *);
FILE *fmemopen(void *restrict, size_t, const char *restrict);
@ -119,7 +119,7 @@ extern "C"
ssize_t getline(char **restrict, size_t *restrict, FILE *restrict);
FILE *open_memstream(char **, size_t *);
int pclose(FILE *);
void perror(const char *);
void perror(const char *s);
FILE *popen(const char *, const char *);
int printf(const char *restrict format, ...);
int putc(int c, FILE *stream);
@ -134,8 +134,8 @@ extern "C"
int scanf(const char *restrict, ...);
void setbuf(FILE *restrict, char *restrict);
int setvbuf(FILE *restrict, char *restrict, int, size_t);
int snprintf(char *restrict, size_t, const char *restrict, ...);
int sprintf(char *restrict, const char *restrict, ...);
int snprintf(char *restrict s, size_t n, const char *restrict format, ...);
int sprintf(char *restrict s, const char *restrict format, ...);
int sscanf(const char *restrict, const char *restrict, ...);
FILE *tmpfile(void);
char *tmpnam(char *);

View File

@ -51,7 +51,7 @@ extern "C"
long a64l(const char *);
void abort(void);
int abs(int);
int abs(int i);
int atexit(void (*func)(void));
double atof(const char *);
int atoi(const char *);
@ -66,7 +66,7 @@ extern "C"
char *fcvt(double, int, int *, int *);
void free(void *ptr);
char *gcvt(double, int, char *);
char *getenv(const char *);
char *getenv(const char *name);
int getsubopt(char **, char *const *, char **);
int grantpt(int);
char *initstate(unsigned int, char *, size_t);

View File

@ -36,7 +36,7 @@ extern "C"
char *stpcpy(char *restrict, const char *restrict);
char *stpncpy(char *restrict, const char *restrict, size_t);
char *strcat(char *restrict, const char *restrict);
char *strchr(const char *, int);
char *strchr(const char *s, int c);
int strcmp(const char *s1, const char *s2);
int strcoll(const char *, const char *);
int strcoll_l(const char *, const char *, locale_t);
@ -48,19 +48,19 @@ extern "C"
int strerror_r(int, char *, size_t);
size_t strlcat(char *restrict, const char *restrict, size_t);
size_t strlcpy(char *restrict, const char *restrict, size_t);
size_t strlen(const char *);
size_t strlen(const char *s);
char *strncat(char *restrict, const char *restrict, size_t);
int strncmp(const char *, const char *, size_t);
int strncmp(const char *s1, const char *s2, size_t n);
char *strncpy(char *restrict, const char *restrict, size_t);
char *strndup(const char *, size_t);
size_t strnlen(const char *, size_t);
char *strpbrk(const char *, const char *);
char *strpbrk(const char *s1, const char *s2);
char *strrchr(const char *, int);
char *strsignal(int);
size_t strspn(const char *, const char *);
char *strsignal(int signum);
size_t strspn(const char *s1, const char *s2);
char *strstr(const char *, const char *);
char *strtok(char *restrict, const char *restrict);
char *strtok_r(char *restrict, const char *restrict, char **restrict);
char *strtok(char *restrict s, const char *restrict sep);
char *strtok_r(char *restrict s, const char *restrict sep, char **restrict state);
size_t strxfrm(char *restrict, const char *restrict, size_t);
size_t strxfrm_l(char *restrict, const char *restrict, size_t, locale_t);

View File

@ -91,8 +91,8 @@ extern "C"
int fstatat(int, const char *restrict, struct stat *restrict, int);
int futimens(int, const struct timespec[2]);
int lstat(const char *restrict, struct stat *restrict);
int mkdir(const char *, mode_t);
int mkdirat(int, const char *, mode_t);
int mkdir(const char *path, mode_t mode);
int mkdirat(int fd, const char *path, mode_t mode);
int mkfifo(const char *, mode_t);
int mkfifoat(int, const char *, mode_t);
int mknod(const char *, mode_t, dev_t);

View File

@ -54,9 +54,9 @@ extern "C"
typedef unsigned int id_t;
typedef int pid_t;
pid_t wait(int *);
int waitid(idtype_t, id_t, siginfo_t *, int);
pid_t waitpid(pid_t, int *, int);
pid_t wait(int *stat_loc);
int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options);
pid_t waitpid(pid_t pid, int *stat_loc, int options);
#ifdef __cplusplus
}

View File

@ -57,9 +57,10 @@ extern "C"
extern char *optarg;
extern int optind, opterr, optopt;
extern char **environ;
int access(const char *, int);
unsigned int alarm(unsigned int);
unsigned int alarm(unsigned int seconds);
int brk(void *);
int chdir(const char *);
int chroot(const char *);
@ -72,12 +73,12 @@ extern "C"
int dup(int);
int dup2(int, int);
void encrypt(char[64], int);
int execl(const char *, const char *, ...);
int execle(const char *, const char *, ...);
int execlp(const char *, const char *, ...);
int execv(const char *, char *const[]);
int execve(const char *, char *const[], char *const[]);
int execvp(const char *, char *const[]);
int execl(const char *path, const char *arg0, ... /*, (char *)0 */);
int execle(const char *path, const char *arg0, ... /*, (char *)0, char *const envp[]*/);
int execlp(const char *file, const char *arg0, ... /*, (char *)0 */);
int execv(const char *path, char *const argv[]);
int execve(const char *path, char *const argv[], char *const envp[]);
int execvp(const char *file, char *const argv[]);
void _exit(int);
int fchown(int, uid_t, gid_t);
int fchdir(int);
@ -128,7 +129,7 @@ extern "C"
int setreuid(uid_t, uid_t);
pid_t setsid(void);
int setuid(uid_t);
unsigned int sleep(unsigned int);
unsigned int sleep(unsigned int seconds);
void swab(const void *, void *, ssize_t);
int symlink(const char *, const char *);
void sync(void);