[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:
15
src/libraries/j6/include/j6/syscalls.h
Normal file
15
src/libraries/j6/include/j6/syscalls.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <j6/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SYSCALL(n, name, ...) j6_status_t j6_ ## name (__VA_ARGS__);
|
||||
#include "j6/tables/syscalls.inc"
|
||||
#undef SYSCALL
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
28
src/libraries/j6/syscalls.s
Normal file
28
src/libraries/j6/syscalls.s
Normal file
@@ -0,0 +1,28 @@
|
||||
%macro SYSCALL 2
|
||||
global j6_%1
|
||||
j6_%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"
|
||||
Reference in New Issue
Block a user