From 6ca367c8548fc5fb3638be2d6eb64d1412737525 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 30 Apr 2003 18:06:14 +0000 Subject: Update for AMD64-style syscalls. Repocopied from i386/SYS.h. Note that the syscall instruction clobbers %rcx, which is inconvenient because it is the fourth syscall argument, so we use %r10 (another scratch register) for the 4th syscall arg instead (I picked %r10 to be the same as NetBSD). int 0x80 is still possible though, and it uses %rcx as usual. Note that the syscall style syscall does *NOT* preserve all the registers, unlike int 0x80. We do not preserve the scratch registers except for %rdi and %rsi. int 0x80 does preserve everything but the return values. --- lib/libc/amd64/SYS.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/libc/amd64/SYS.h b/lib/libc/amd64/SYS.h index 1483f9d..5dc8b46 100644 --- a/lib/libc/amd64/SYS.h +++ b/lib/libc/amd64/SYS.h @@ -40,22 +40,19 @@ #include #include -#define SYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ +#define SYSCALL(x) 2: jmp PIC_PLT(HIDENAME(cerror)); \ ENTRY(__CONCAT(__sys_,x)); \ .weak CNAME(x); \ .set CNAME(x),CNAME(__CONCAT(__sys_,x)); \ .weak CNAME(__CONCAT(_,x)); \ .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \ - mov __CONCAT($SYS_,x),%eax; KERNCALL; jb 2b + mov __CONCAT($SYS_,x),%rax; KERNCALL; jb 2b #define RSYSCALL(x) SYSCALL(x); ret #define PSEUDO(x) ENTRY(__CONCAT(__sys_,x)); \ .weak CNAME(__CONCAT(_,x)); \ .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \ - mov __CONCAT($SYS_,x),%eax; KERNCALL; ret + mov __CONCAT($SYS_,x),%rax; KERNCALL; ret -/* gas messes up offset -- although we don't currently need it, do for BCS */ -#define LCALL(x,y) .byte 0x9a ; .long y; .word x - -#define KERNCALL int $0x80 +#define KERNCALL movq %rcx, %r10; syscall -- cgit v1.1