Add syscall

This commit is contained in:
Ziyao 2022-03-21 16:50:35 +08:00
parent 6f26800d69
commit fb09e1ff06
2 changed files with 60 additions and 0 deletions

View File

@ -23,6 +23,7 @@ static __inline long __syscall2(long n, long a1, long a2)
return ret;
}
static __inline long __syscall3(long n, long a1, long a2, long a3)
{
unsigned long ret;
@ -31,6 +32,7 @@ static __inline long __syscall3(long n, long a1, long a2, long a3)
return ret;
}
/*
static __inline long __syscall4(long n, long a1, long a2, long a3, long a4)
{
unsigned long ret;
@ -60,6 +62,14 @@ static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long
"d"(a3), "r"(r10), "r"(r8), "r"(r9) : "rcx", "r11", "memory");
return ret;
}
*/
long int __syscall4(long int n,long int a1,long int a2,long int a3,
long int a4);
long int __syscall5(long int n,long int a1,long int a2,long int a3,
long int a4,long int a5);
long int __syscall6(long int n,long int a1,long int a2,long int a3,
long int a4,long int a5,long int a6);
#define VDSO_USEFUL
#define VDSO_CGT_SYM "__vdso_clock_gettime"

View File

@ -0,0 +1,50 @@
/*
musl-tcc
File:/src/unistd/x86_64/syscall.S
Copyright(c) 2022 ziyao.
*/
.global __syscall4,__syscall5,__syscall6
/*
long int __syscall4(long int n, long int a1,long int a2,
long int a2,long int a3,long int a4);
n %rdi
a1 %rsi
a2 %rdx
a3 %rcx
a4 %r8
*/
.type __syscall4,@function
__syscall4:
movq %rdi, %rax
movq %rsi, %rdi
movq %rdx, %rsi
movq %rcx, %rdx
movq %r8, %r10
syscall
retq
.type __syscall5,@function
__syscall5:
movq %rdi, %rax
movq %rsi, %rdi
movq %rdx, %rsi
movq %rcx, %rdx
movq %r8, %r10
movq %r9, %r8
syscall
retq
.type __syscall6,@function
__syscall6:
movq %rdi, %rax
movq %rsi, %rdi
movq %rdx, %rsi
movq %rcx, %rdx
movq %r8, %r10
movq %r9, %r8
popq %r9 // The last argument is stored on the stack
syscall
retq