Fix {INLINE,INTERNAL}_SYSCALL macros for x32
commit78ca091cdd2ca1db94cc5ff27613f75237b8bc8f
authorAdhemerval Zanella <adhemerval.zanella@linaro.com>
Wed, 13 Jul 2016 09:50:05 +0000 (13 10:50 +0100)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 22 Aug 2017 20:27:02 +0000 (22 17:27 -0300)
tree257611ebac841bf851bd453cc4d4fb3c7226a492
parent453a493d2b61b1eb3cadee544e6791dab45c167a
Fix {INLINE,INTERNAL}_SYSCALL macros for x32

The problem for x32 is the {INTERNAL,INLINE}_SYSCALL C macros explicit
cast the arguments to 'long int', thus passing as 32 bits arguments
that should be passed to 64 bits.

Previous x32 implementation uses the auto-generated syscalls from
assembly macros (syscalls.list), so the {INTERNAL,INLINE}_SYSCALL
macros are never used with 64 bit argument in x32 (which are
internally broken for this ILP).

To fix it I used a strategy similar to MIPS64n32 (although both
ABI differs for some syscalls on how top pass 64-bits arguments)
where argument types for kernel call are defined using GCC extension
'typeof' with a arithmetic operation.  This allows 64-bits arguments
to be defined while 32-bits argument will still passed as 32-bits.

I also cleanup the {INLINE,INTERNAL}_SYSCALL definition by defining
'inline_syscallX' instead of constructing the argument passing using
macros (it adds some readability) and removed the ununsed
INTERNAL_SYSCALL_NCS_TYPES define (since the patch idea is exactly to
avoid requiric explicit types passing).

Tested on x86_64 and x32.

* sysdeps/unix/sysv/linux/x86_64/sysdep.h
(INTERNAL_SYSCALL_NCS_TYPES): Remove define.
(LOAD_ARGS_0): Likewise.
(LOAD_ARGS_1): Likewise.
(LOAD_ARGS_2): Likewise.
(LOAD_ARGS_3): Likewise.
(LOAD_ARGS_4): Likewise.
(LOAD_ARGS_5): Likewise.
(LOAD_ARGS_6): Likewise.
(LOAD_REGS_0): Likewise.
(LOAD_REGS_1): Likewise.
(LOAD_REGS_2): Likewise.
(LOAD_REGS_3): Likewise.
(LOAD_REGS_4): Likewise.
(LOAD_REGS_5): Likewise.
(LOAD_REGS_6): Likewise.
(ASM_ARGS_0): Likewise.
(ASM_ARGS_1): Likewise.
(ASM_ARGS_2): Likewise.
(ASM_ARGS_3): Likewise.
(ASM_ARGS_4): Likewise.
(ASM_ARGS_5): Likewise.
(ASM_ARGS_6): Likewise.
(LOAD_ARGS_TYPES_1): Likewise.
(LOAD_ARGS_TYPES_2): Likewise.
(LOAD_ARGS_TYPES_3): Likewise.
(LOAD_ARGS_TYPES_4): Likewise.
(LOAD_ARGS_TYPES_5): Likewise.
(LOAD_ARGS_TYPES_6): Likewise.
(LOAD_REGS_TYPES_1): Likewise.
(LOAD_REGS_TYPES_2): Likewise.
(LOAD_REGS_TYPES_3): Likewise.
(LOAD_REGS_TYPES_4): Likewise.
(LOAD_REGS_TYPES_5): Likewise.
(LOAD_REGS_TYPES_6): Likewise.
(TYPEFY): New define.
(ARGIFY): Likewise.
(internal_syscall0): Likewise.
(internal_syscall1): Likewise.
(internal_syscall2): Likewise.
(internal_syscall3): Likewise.
(internal_syscall4): Likewise.
(internal_syscall5): Likewise.
(internal_syscall6): Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/times.c
(INTERNAL_SYSCALL_NCS): Remove define.
(internal_syscall1): Add define.
ChangeLog
sysdeps/unix/sysv/linux/x86_64/sysdep.h
sysdeps/unix/sysv/linux/x86_64/x32/times.c