[libj6] Create libj6
Pull syscall code out of libc and create new libj6. This should eventually become a vDSO, but for now it can still be a static lib. Also renames all the _syscall_* symbol names to j6_*
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
extern _syscall_process_exit
|
||||
extern j6_process_exit
|
||||
global _PDCLIB_Exit
|
||||
_PDCLIB_Exit:
|
||||
; arg should already be in rdi
|
||||
jmp _syscall_process_exit
|
||||
jmp j6_process_exit
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
%macro SYSCALL 2
|
||||
global _syscall_%1
|
||||
_syscall_%1:
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
|
||||
; args should already be in rdi, etc, but rcx will
|
||||
; get stomped, so stash it in r10, which isn't a
|
||||
; callee-saved register, but also isn't used in the
|
||||
; function call ABI.
|
||||
mov r10, rcx
|
||||
|
||||
mov rax, %2
|
||||
syscall
|
||||
; result is now already in rax, so just return
|
||||
|
||||
pop rbp
|
||||
ret
|
||||
%endmacro
|
||||
|
||||
%define SYSCALL(n, name) SYSCALL name, n
|
||||
%define SYSCALL(n, name, a) SYSCALL name, n
|
||||
%define SYSCALL(n, name, a, b) SYSCALL name, n
|
||||
%define SYSCALL(n, name, a, b, c) SYSCALL name, n
|
||||
%define SYSCALL(n, name, a, b, c, d) SYSCALL name, n
|
||||
%define SYSCALL(n, name, a, b, c, d, e) SYSCALL name, n
|
||||
|
||||
%include "j6/tables/syscalls.inc"
|
||||
@@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <j6/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SYSCALL(n, name, ...) j6_status_t _syscall_ ## name (__VA_ARGS__);
|
||||
#include "j6/tables/syscalls.inc"
|
||||
#undef SYSCALL
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <stdint.h>
|
||||
#include <j6/errors.h>
|
||||
#include <j6libc/syscalls.h>
|
||||
#include <j6/syscalls.h>
|
||||
//void *sbrk(intptr_t) __attribute__ ((weak));
|
||||
|
||||
static j6_handle_t __core_handle = 0;
|
||||
@@ -19,7 +19,7 @@ void *sbrk(intptr_t i)
|
||||
if (i < 0)
|
||||
return (void*)-1;
|
||||
|
||||
j6_status_t result = _syscall_vma_create_map(&__core_handle, i, __core_base, 1);
|
||||
j6_status_t result = j6_vma_create_map(&__core_handle, i, __core_base, 1);
|
||||
if (result != j6_status_ok)
|
||||
return (void*)-1;
|
||||
|
||||
@@ -28,7 +28,7 @@ void *sbrk(intptr_t i)
|
||||
}
|
||||
|
||||
size_t new_size = __core_size + i;
|
||||
j6_status_t result = _syscall_vma_resize(__core_handle, &new_size);
|
||||
j6_status_t result = j6_vma_resize(__core_handle, &new_size);
|
||||
if (result != j6_status_ok)
|
||||
return (void*)-1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user