[libj6] Move _init_libc to _init_libj6

As part of the move of jsix-specific code from libc to libj6, all the
library initialization is now libj6-specific, so move it all over.
This commit is contained in:
Justin C. Miller
2021-04-07 22:53:48 -07:00
parent 0ae489f49d
commit 55c9faaa79
5 changed files with 8 additions and 9 deletions

View File

@@ -1,17 +1,15 @@
extern main
extern exit
extern _init_libc
extern _init_libj6
global _start:function (_start.end - _start)
_start:
mov rbp, rsp
mov rdi, rsp
call _init_libc
call _init_libj6
pop rdi
mov rsi, rsp
call main
mov rdi, rax

View File

@@ -1,41 +0,0 @@
#include <stdint.h>
#include <j6/init.h>
#include <j6/types.h>
static size_t __initc = 0;
static struct j6_init_value *__initv = 0;
j6_handle_t __handle_sys = j6_handle_invalid;
j6_handle_t __handle_self = j6_handle_invalid;
void
_get_init(size_t *initc, struct j6_init_value **initv)
{
if (!initc)
return;
*initc = __initc;
if (initv)
*initv = __initv;
}
void
_init_libc(uint64_t *rsp)
{
uint64_t argc = *rsp++;
rsp += argc;
__initc = *rsp++;
__initv = (struct j6_init_value *)rsp;
for (unsigned i = 0; i < __initc; ++i) {
if (__initv[i].type == j6_init_handle_other &&
__initv[i].handle.type == j6_object_type_system) {
__handle_sys = __initv[i].handle.handle;
}
else if (__initv[i].type == j6_init_handle_self &&
__initv[i].handle.type == j6_object_type_process) {
__handle_self = __initv[i].handle.handle;
}
}
}

View File

@@ -7,7 +7,6 @@ deps = ["j6"]
sources = [
"arch/x86_64/_Exit.s",
"arch/x86_64/crt0.s",
"arch/x86_64/init_libc.c",
"ctype/isalnum.c",
"ctype/isalpha.c",
"ctype/isblank.c",