Chromium Code Reviews| Index: lss/linux_syscall_support.h |
| =================================================================== |
| --- lss/linux_syscall_support.h (revision 17) |
| +++ lss/linux_syscall_support.h (working copy) |
| @@ -103,6 +103,7 @@ |
| #include <signal.h> |
| #include <stdarg.h> |
| #include <stddef.h> |
| +#include <stdint.h> |
| #include <string.h> |
| #include <sys/ptrace.h> |
| #include <sys/resource.h> |
| @@ -1753,6 +1754,15 @@ |
| return res; |
| } |
| #elif defined(__x86_64__) |
| + /* x32 has 32bit longs, but the syscall interface is 64bit */ |
| + #ifdef __ILP32__ |
| + #define LSS_SC_ARG(a) (sizeof(a) == 8 ? \ |
|
Mark Seaborn
2013/02/28 17:46:53
"SC" is rather cryptic. Maybe "LSS_SYSCALL_ARG" i
vapier
2013/02/28 21:51:48
Done.
|
| + (unsigned long long)(a) : \ |
| + (unsigned long long)(uintptr_t)(a)) |
|
Mark Seaborn
2013/02/28 17:46:53
I don't understand why you have a double cast here
vapier
2013/02/28 21:51:48
on x32, pointers are 32bit. syscall args are 64bi
Mark Seaborn
2013/03/01 23:15:40
I don't think using ?: is going to protect you fro
vapier
2013/03/01 23:21:49
sure, i didn't mean to indicate it does entirely s
Mark Seaborn
2013/03/04 16:52:44
Having extra code that only reduces the number of
|
| + #else |
| + #define LSS_SC_ARG(a) (long)(a) |
|
Mark Seaborn
2013/02/28 17:46:53
Should this be "((long)(a))"?
vapier
2013/02/28 21:51:48
it could be. in practice it doesn't matter. i'll
|
| + #endif |
| + |
| /* There are no known problems with any of the _syscallX() macros |
| * currently shipping for x86_64, but we still need to be able to define |
| * our own version so that we can override the location of the errno |
| @@ -1793,7 +1803,7 @@ |
| #endif |
| #undef LSS_BODY |
| #define LSS_BODY(type,name, ...) \ |
| - long __res; \ |
| + long long __res; \ |
| __asm__ __volatile__(LSS_ENTRYPOINT \ |
| : "=a" (__res) : "0" (__NR_##name), \ |
| ##__VA_ARGS__ : "r11", "rcx", "memory"); \ |
| @@ -1806,18 +1816,18 @@ |
| #undef _syscall1 |
| #define _syscall1(type,name,type1,arg1) \ |
| type LSS_NAME(name)(type1 arg1) { \ |
| - LSS_BODY(type, name, "D" ((long)(arg1))); \ |
| + LSS_BODY(type, name, "D" (LSS_SC_ARG(arg1))); \ |
| } |
| #undef _syscall2 |
| #define _syscall2(type,name,type1,arg1,type2,arg2) \ |
| type LSS_NAME(name)(type1 arg1, type2 arg2) { \ |
| - LSS_BODY(type, name, "D" ((long)(arg1)), "S" ((long)(arg2))); \ |
| + LSS_BODY(type, name, "D" (LSS_SC_ARG(arg1)), "S" (LSS_SC_ARG(arg2))); \ |
| } |
| #undef _syscall3 |
| #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ |
| type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3) { \ |
| - LSS_BODY(type, name, "D" ((long)(arg1)), "S" ((long)(arg2)), \ |
| - "d" ((long)(arg3))); \ |
| + LSS_BODY(type, name, "D" (LSS_SC_ARG(arg1)), "S" (LSS_SC_ARG(arg2)), \ |
| + "d" (LSS_SC_ARG(arg3))); \ |
| } |
| #undef _syscall4 |
| #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ |
| @@ -1825,8 +1835,9 @@ |
| long __res; \ |
| __asm__ __volatile__("movq %5,%%r10;" LSS_ENTRYPOINT : \ |
| "=a" (__res) : "0" (__NR_##name), \ |
| - "D" ((long)(arg1)), "S" ((long)(arg2)), "d" ((long)(arg3)), \ |
| - "r" ((long)(arg4)) : "r10", "r11", "rcx", "memory"); \ |
| + "D" (LSS_SC_ARG(arg1)), "S" (LSS_SC_ARG(arg2)), \ |
| + "d" (LSS_SC_ARG(arg3)), "r" (LSS_SC_ARG(arg4)) \ |
| + : "r10", "r11", "rcx", "memory"); \ |
| LSS_RETURN(type, __res); \ |
| } |
| #undef _syscall5 |
| @@ -1837,9 +1848,9 @@ |
| long __res; \ |
| __asm__ __volatile__("movq %5,%%r10; movq %6,%%r8;" LSS_ENTRYPOINT :\ |
| "=a" (__res) : "0" (__NR_##name), \ |
| - "D" ((long)(arg1)), "S" ((long)(arg2)), "d" ((long)(arg3)), \ |
| - "r" ((long)(arg4)), "r" ((long)(arg5)) : \ |
| - "r8", "r10", "r11", "rcx", "memory"); \ |
| + "D" (LSS_SC_ARG(arg1)), "S" (LSS_SC_ARG(arg2)), \ |
| + "d" (LSS_SC_ARG(arg3)), "r" (LSS_SC_ARG(arg4)), \ |
| + "r" (LSS_SC_ARG(arg5)) : "r8", "r10", "r11", "rcx", "memory"); \ |
| LSS_RETURN(type, __res); \ |
| } |
| #undef _syscall6 |
| @@ -1851,9 +1862,10 @@ |
| __asm__ __volatile__("movq %5,%%r10; movq %6,%%r8; movq %7,%%r9;" \ |
| LSS_ENTRYPOINT : \ |
| "=a" (__res) : "0" (__NR_##name), \ |
| - "D" ((long)(arg1)), "S" ((long)(arg2)), "d" ((long)(arg3)), \ |
| - "r" ((long)(arg4)), "r" ((long)(arg5)), "r" ((long)(arg6)) : \ |
| - "r8", "r9", "r10", "r11", "rcx", "memory"); \ |
| + "D" (LSS_SC_ARG(arg1)), "S" (LSS_SC_ARG(arg2)), \ |
| + "d" (LSS_SC_ARG(arg3)), "r" (LSS_SC_ARG(arg4)), \ |
| + "r" (LSS_SC_ARG(arg5)), "r" (LSS_SC_ARG(arg6)) : "r8", "r9", \ |
| + "r10", "r11", "rcx", "memory"); \ |
| LSS_RETURN(type, __res); \ |
| } |
| LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, |
| @@ -1922,9 +1934,10 @@ |
| "1:\n" |
| : "=a" (__res) |
| : "0"(-EINVAL), "i"(__NR_clone), "i"(__NR_exit), |
| - "r"(fn), "S"(child_stack), "D"(flags), "r"(arg), |
| - "d"(parent_tidptr), "r"(newtls), |
| - "r"(child_tidptr) |
| + "r"(LSS_SC_ARG(fn)), "S"(LSS_SC_ARG(child_stack)), |
|
Mark Seaborn
2013/02/28 17:46:53
Line is >80 characters. Please put the arguments
vapier
2013/02/28 21:51:48
Done.
|
| + "D"(LSS_SC_ARG(flags)), "r"(LSS_SC_ARG(arg)), |
| + "d"(LSS_SC_ARG(parent_tidptr)), "r"(LSS_SC_ARG(newtls)), |
|
Mark Seaborn
2013/02/28 17:46:53
Same here.
vapier
2013/02/28 21:51:48
Done.
|
| + "r"(LSS_SC_ARG(child_tidptr)) |
| : "rsp", "memory", "r8", "r10", "r11", "rcx"); |
| } |
| LSS_RETURN(int, __res); |