Update libc

This commit is contained in:
Alex
2023-05-03 06:40:31 +03:00
parent f01eed8dd2
commit cf3a5599a4
18 changed files with 530 additions and 50 deletions

View File

@@ -5,20 +5,20 @@
// extern void (*__fini_array_start []) (void) __attribute__((weak));
// extern void (*__fini_array_end []) (void) __attribute__((weak));
typedef void (*CallPtr)(void);
extern CallPtr __init_array_start[0], __init_array_end[0];
extern CallPtr __fini_array_start[0], __fini_array_end[0];
typedef void (*fct)(void);
extern fct __init_array_start[0], __init_array_end[0];
extern fct __fini_array_start[0], __fini_array_end[0];
// TODO: This is not working properly
void __libc_init_array(void)
{
// for (CallPtr *func = __init_array_start; func != __init_array_end; func++)
// (*func)();
for (fct *func = __init_array_start; func != __init_array_end; func++)
(*func)();
}
void __libc_fini_array(void)
{
// for (CallPtr *func = __fini_array_start; func != __fini_array_end; func++)
// (*func)();
for (fct *func = __fini_array_start; func != __fini_array_end; func++)
(*func)();
}

View File

@@ -32,7 +32,6 @@ int fseek(FILE *stream, long offset, int whence)
stream->offset = offset;
break;
case SEEK_CUR:
stream->offset += offset;
break;
case SEEK_END:
// stream->offset = syscall1(_FileLength, (uint64_t)File->KernelPrivate) + offset;

View File

@@ -28,3 +28,8 @@ int puts(const char *s)
for (int i = 0; s[i] != '\0'; i++)
fputc(s[i], stdout);
}
void perror(const char *__s)
{
fputs(__s, stderr);
}

View File

@@ -6,19 +6,23 @@
void abort(void)
{
__asm__ __volatile__("syscall"
:
: "a"(0), "D"(-0xAB057)
: "rcx", "r11", "memory");
while (1)
;
}
int atexit(void (*function)(void))
{
return 0;
return 1;
}
void exit(int status)
{
while (1)
;
_exit(status);
}
int atoi(const char *nptr)
@@ -64,7 +68,7 @@ void free(void *Address)
int system(const char *command)
{
return 0;
return -1;
}
double atof(const char *nptr)

17
libc/src/std/spawn.c Normal file
View File

@@ -0,0 +1,17 @@
#include <spawn.h>
int posix_spawn(pid_t *pid, const char *path,
const posix_spawn_file_actions_t *file_actions,
const posix_spawnattr_t *attrp,
char *const argv[],
char *const envp[])
{
}
int posix_spawnp(pid_t *pid, const char *file,
const posix_spawn_file_actions_t *file_actions,
const posix_spawnattr_t *attrp,
char *const argv[],
char *const envp[])
{
}

14
libc/src/std/sys/wait.c Normal file
View File

@@ -0,0 +1,14 @@
#include <sys/wait.h>
pid_t wait(int *wstatus)
{
return waitpid(-1, &wstatus, 0);
}
pid_t waitpid(pid_t pid, int *wstatus, int options)
{
}
int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options)
{
}

44
libc/src/std/uni/exe.c Normal file
View File

@@ -0,0 +1,44 @@
#include <unistd.h>
#include <stddef.h>
#include <errno.h>
#include "../../../Kernel/syscalls.h"
int execl(const char *pathname, const char *arg, ...)
{
return -1;
}
int execlp(const char *file, const char *arg, ...)
{
return -1;
}
int execle(const char *pathname, const char *arg, ...)
{
return -1;
}
int execv(const char *pathname, char *const argv[])
{
return -1;
}
int execvp(const char *file, char *const argv[])
{
return -1;
}
int execvpe(const char *file, char *const argv[], char *const envp[])
{
return -1;
}
int execve(const char *pathname, char *const argv[], char *const envp[])
{
return -1;
}
pid_t fork(void)
{
return syscall0(_Fork);
}