@@ -250,12 +250,20 @@
(long int) resultvar; \
})
+#define MSTR_HELPER(x) #x
+#define MSTR(x) MSTR_HELPER(x)
+
#undef internal_syscall1
#define internal_syscall1(number, arg1) \
({ \
unsigned long int resultvar; \
TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
+ if (__builtin_constant_p(number)) \
+ asm volatile ("movl $" MSTR(number) ", %%eax\n\t" \
+ : /* no outputs */ \
+ : "i" (number) \
+ : "eax"); \
asm volatile ( \
"syscall\n\t" \
: "=a" (resultvar) \
@@ -272,6 +280,11 @@
TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
+ if (__builtin_constant_p(number)) \
+ asm volatile ("movl $" MSTR(number) ", %%eax\n\t" \
+ : /* no outputs */ \
+ : "i" (number) \
+ : "eax"); \
asm volatile ( \
"syscall\n\t" \
: "=a" (resultvar) \
@@ -290,6 +303,11 @@
register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \
register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
+ if (__builtin_constant_p(number)) \
+ asm volatile ("movl $" MSTR(number) ", %%eax\n\t" \
+ : /* no outputs */ \
+ : "i" (number) \
+ : "eax"); \
asm volatile ( \
"syscall\n\t" \
: "=a" (resultvar) \
@@ -310,6 +328,11 @@
register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \
register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
+ if (__builtin_constant_p(number)) \
+ asm volatile ("movl $" MSTR(number) ", %%eax\n\t" \
+ : /* no outputs */ \
+ : "i" (number) \
+ : "eax"); \
asm volatile ( \
"syscall\n\t" \
: "=a" (resultvar) \
@@ -332,6 +355,11 @@
register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \
register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
+ if (__builtin_constant_p(number)) \
+ asm volatile ("movl $" MSTR(number) ", %%eax\n\t" \
+ : /* no outputs */ \
+ : "i" (number) \
+ : "eax"); \
asm volatile ( \
"syscall\n\t" \
: "=a" (resultvar) \
@@ -357,6 +385,11 @@
register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \
register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
+ if (__builtin_constant_p(number)) \
+ asm volatile ("movl $" MSTR(number) ", %%eax\n\t" \
+ : /* no outputs */ \
+ : "i" (number) \
+ : "eax"); \
asm volatile ( \
"syscall\n\t" \
: "=a" (resultvar) \