Commit ed3c4fba authored by Cyrill Gorcunov's avatar Cyrill Gorcunov

syscalls: Get rid of mnemonic names for registers

Use explicit registers name instead just to be sure it
wont cause side effects on most gcc versions.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
parent 48371f72
...@@ -11,30 +11,42 @@ ...@@ -11,30 +11,42 @@
static always_inline long syscall0(int nr) static always_inline long syscall0(int nr)
{ {
long ret; long ret;
asm volatile("syscall" asm volatile(
: "=a" (ret) "movl %1, %%eax \t\n"
: "a" (nr) "syscall \t\n"
: "memory"); "movq %%rax, %0 \t\n"
: "=r"(ret)
: "g" ((int)nr)
: "rax", "memory");
return ret; return ret;
} }
static always_inline long syscall1(int nr, unsigned long arg0) static always_inline long syscall1(int nr, unsigned long arg0)
{ {
long ret; long ret;
asm volatile("syscall" asm volatile(
: "=a" (ret) "movl %1, %%eax \t\n"
: "a" (nr), "D" (arg0) "movq %2, %%rdi \t\n"
: "memory"); "syscall \t\n"
"movq %%rax, %0 \t\n"
: "=r"(ret)
: "g" ((int)nr), "g" (arg0)
: "rax", "rdi", "memory");
return ret; return ret;
} }
static always_inline long syscall2(int nr, unsigned long arg0, unsigned long arg1) static always_inline long syscall2(int nr, unsigned long arg0, unsigned long arg1)
{ {
long ret; long ret;
asm volatile("syscall" asm volatile(
: "=a" (ret) "movl %1, %%eax \t\n"
: "a" (nr), "D" (arg0), "S" (arg1) "movq %2, %%rdi \t\n"
: "memory"); "movq %3, %%rsi \t\n"
"syscall \t\n"
"movq %%rax, %0 \t\n"
: "=r"(ret)
: "g" ((int)nr), "g" (arg0), "g" (arg1)
: "rax", "rdi", "rsi", "memory");
return ret; return ret;
} }
...@@ -42,10 +54,16 @@ static always_inline long syscall3(int nr, unsigned long arg0, unsigned long arg ...@@ -42,10 +54,16 @@ static always_inline long syscall3(int nr, unsigned long arg0, unsigned long arg
unsigned long arg2) unsigned long arg2)
{ {
long ret; long ret;
asm volatile("syscall" asm volatile(
: "=a" (ret) "movl %1, %%eax \t\n"
: "a" (nr), "D" (arg0), "S" (arg1), "d" (arg2) "movq %2, %%rdi \t\n"
: "memory"); "movq %3, %%rsi \t\n"
"movq %4, %%rdx \t\n"
"syscall \t\n"
"movq %%rax, %0 \t\n"
: "=r"(ret)
: "g" ((int)nr), "g" (arg0), "g" (arg1), "g" (arg2)
: "rax", "rdi", "rsi", "rdx", "memory");
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment