[2/4] Consolidate off_t/off64_t syscall argument passing

Message ID 1447855356-4140-3-git-send-email-adhemerval.zanella@linaro.org
State Committed
Headers

Commit Message

Adhemerval Zanella Netto Nov. 18, 2015, 2:02 p.m. UTC
  From: Adhemerval Zanella <adhemerval.zanella@linaro.com>

This patch add two new macros to use along with off_t and off64_t argument
syscalls.  The rationale for this change is:

1. Remove multiple implementations for the same syscall for different
   architectures (for instance, pread have 6 different implementations).

2. Also remove the requirement to use syscall wrappers for cancellable
   entrypoints.

The macro usage should be used along __ALIGNMENT_ARG to follow ABI constrains
for architecture where it applies.  For instance, pread can be rewritten as:

  return SYSCALL_CANCEL (pread, fd, buf, count,
                         __ALIGNMENT_ARG SYSCALL_LL (offset));

Another macro, SYSCALL_LL64, is provided for off64_t.

The changes itself are not currently used in any implementation, so no
code change is expected.

	* sysdeps/unix/sysv/linux/aarch64/sysdep.h (SYSCALL_LL): New
	macro.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/alpha/sysdep.h (SYSCALL_LL): Likewise.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/arm/sysdep.h (SYSCALL_LL): New macro.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/generic/sysdep.h (__NR__llseek): Define only
	if it is not already defined.
	* sysdeps/unix/sysv/linux/hppa/sysdep.h (SYSCALL_LL): New macro.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/i386/sysdep.h (SYSCALL_LL): Likewise.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/ia64/sysdep.h (SYSCALL_LL): Likewise.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/m68k/sysdep.h (SYSCALL_LL): Likewise.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/sysdep.h (SYSCALL_LL):
	Likewise.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h (SYSCALL_LL): New
	Macro.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h (SYSCALL_LL):
	New macro.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h (SYSCALL_LL):
	Likewise.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/nios2/sysdep.h (SYSCALL_LL): Likewise.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h (SYSCALL_LL):
	New macro.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h (SYSCALL_LL):
	Likewise.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h (SYSCALL_LL):
	Likewise.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h (SYSCALL_LL):
	Likewise.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/sh/sysdep.h (SYSCALL_LL):
	Likewise.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h (SYSCALL_LL):
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h (SYSCALL_LL64):
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/sysdep.h: Include generic sysdep.h.
	* sysdeps/unix/sysv/linux/tile/sysdep.h (SYSCALL_LL): New macro.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h (SYSCALL_LL): Likewise.
	(SYSCALL_LL64): Likewise.
---
 sysdeps/unix/sysv/linux/aarch64/sysdep.h           |  3 ++
 sysdeps/unix/sysv/linux/alpha/sysdep.h             |  5 ++
 sysdeps/unix/sysv/linux/arm/sysdep.h               |  7 +++
 sysdeps/unix/sysv/linux/generic/sysdep.h           |  2 +
 sysdeps/unix/sysv/linux/hppa/sysdep.h              |  7 +++
 sysdeps/unix/sysv/linux/i386/sysdep.h              |  7 +++
 sysdeps/unix/sysv/linux/ia64/sysdep.h              |  5 ++
 sysdeps/unix/sysv/linux/m68k/sysdep.h              |  7 +++
 sysdeps/unix/sysv/linux/microblaze/sysdep.h        |  7 +++
 sysdeps/unix/sysv/linux/mips/mips32/sysdep.h       |  7 +++
 sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h   |  5 ++
 sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h   |  5 ++
 sysdeps/unix/sysv/linux/nios2/sysdep.h             |  6 +++
 sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h |  7 +++
 sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h |  5 ++
 sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h      |  7 +++
 sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h      |  5 ++
 sysdeps/unix/sysv/linux/sh/sysdep.h                |  7 +++
 sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h     |  6 +++
 sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h     |  4 ++
 sysdeps/unix/sysv/linux/sparc/sysdep.h             |  1 +
 sysdeps/unix/sysv/linux/tile/sysdep.h              |  6 +++
 sysdeps/unix/sysv/linux/x86_64/sysdep.h            |  6 +++
 24 files changed, 189 insertions(+)
  

Comments

Mike Frysinger Dec. 29, 2015, 5:24 p.m. UTC | #1
On 18 Nov 2015 12:02, Adhemerval Zanella wrote:
> This patch add two new macros to use along with off_t and off64_t argument
> syscalls.  The rationale for this change is:
> 
> 1. Remove multiple implementations for the same syscall for different
>    architectures (for instance, pread have 6 different implementations).
> 
> 2. Also remove the requirement to use syscall wrappers for cancellable
>    entrypoints.
> 
> The macro usage should be used along __ALIGNMENT_ARG to follow ABI constrains
> for architecture where it applies.  For instance, pread can be rewritten as:
> 
>   return SYSCALL_CANCEL (pread, fd, buf, count,
>                          __ALIGNMENT_ARG SYSCALL_LL (offset));
> 
> Another macro, SYSCALL_LL64, is provided for off64_t.
> 
> The changes itself are not currently used in any implementation, so no
> code change is expected.

a quick scan looks like you're doing this purely along 32-bit/64-bit lines.
why not add the 32-bit definition to sysdeps/unix/sysv/linux/sysdep.h and
the 64-bit definition to sysdeps/unix/sysv/linux/wordsize-64/sysdep.h ?

sysdeps/unix/sysv/linux/sysdep.h:
#ifndef SYSCALL_LL
# define SYSCALL_LL ...
#endif

sysdeps/unix/sysv/linux/wordsize-64/sysdep.h:
#define SYSCALL_LL ...
#include <sysdeps/unix/sysv/linux/sysdep.h>

you would have to update all the 64-bit arches to pull in the wordsize-64
header since it looks like sysdep.h has a lot of direct includes rather
than stacking & using include_next.
-mike
  
Adhemerval Zanella Netto Jan. 4, 2016, 12:33 p.m. UTC | #2
On 29-12-2015 15:24, Mike Frysinger wrote:
> On 18 Nov 2015 12:02, Adhemerval Zanella wrote:
>> This patch add two new macros to use along with off_t and off64_t argument
>> syscalls.  The rationale for this change is:
>>
>> 1. Remove multiple implementations for the same syscall for different
>>    architectures (for instance, pread have 6 different implementations).
>>
>> 2. Also remove the requirement to use syscall wrappers for cancellable
>>    entrypoints.
>>
>> The macro usage should be used along __ALIGNMENT_ARG to follow ABI constrains
>> for architecture where it applies.  For instance, pread can be rewritten as:
>>
>>   return SYSCALL_CANCEL (pread, fd, buf, count,
>>                          __ALIGNMENT_ARG SYSCALL_LL (offset));
>>
>> Another macro, SYSCALL_LL64, is provided for off64_t.
>>
>> The changes itself are not currently used in any implementation, so no
>> code change is expected.
> 
> a quick scan looks like you're doing this purely along 32-bit/64-bit lines.
> why not add the 32-bit definition to sysdeps/unix/sysv/linux/sysdep.h and
> the 64-bit definition to sysdeps/unix/sysv/linux/wordsize-64/sysdep.h ?
> 
> sysdeps/unix/sysv/linux/sysdep.h:
> #ifndef SYSCALL_LL
> # define SYSCALL_LL ...
> #endif
> 
> sysdeps/unix/sysv/linux/wordsize-64/sysdep.h:
> #define SYSCALL_LL ...
> #include <sysdeps/unix/sysv/linux/sysdep.h>
> 
> you would have to update all the 64-bit arches to pull in the wordsize-64
> header since it looks like sysdep.h has a lot of direct includes rather
> than stacking & using include_next.
> -mike
> 

I think it can be done, however I would like to avoid creating and setting
the 64-bit arches to use the new header disassociated if the arch actually
use the wordsize-64 implementation (I see this to be a follow up cleanup).
  
Mike Frysinger Jan. 5, 2016, 12:54 a.m. UTC | #3
On 04 Jan 2016 10:33, Adhemerval Zanella wrote:
> On 29-12-2015 15:24, Mike Frysinger wrote:
> > On 18 Nov 2015 12:02, Adhemerval Zanella wrote:
> >> This patch add two new macros to use along with off_t and off64_t argument
> >> syscalls.  The rationale for this change is:
> >>
> >> 1. Remove multiple implementations for the same syscall for different
> >>    architectures (for instance, pread have 6 different implementations).
> >>
> >> 2. Also remove the requirement to use syscall wrappers for cancellable
> >>    entrypoints.
> >>
> >> The macro usage should be used along __ALIGNMENT_ARG to follow ABI constrains
> >> for architecture where it applies.  For instance, pread can be rewritten as:
> >>
> >>   return SYSCALL_CANCEL (pread, fd, buf, count,
> >>                          __ALIGNMENT_ARG SYSCALL_LL (offset));
> >>
> >> Another macro, SYSCALL_LL64, is provided for off64_t.
> >>
> >> The changes itself are not currently used in any implementation, so no
> >> code change is expected.
> > 
> > a quick scan looks like you're doing this purely along 32-bit/64-bit lines.
> > why not add the 32-bit definition to sysdeps/unix/sysv/linux/sysdep.h and
> > the 64-bit definition to sysdeps/unix/sysv/linux/wordsize-64/sysdep.h ?
> > 
> > sysdeps/unix/sysv/linux/sysdep.h:
> > #ifndef SYSCALL_LL
> > # define SYSCALL_LL ...
> > #endif
> > 
> > sysdeps/unix/sysv/linux/wordsize-64/sysdep.h:
> > #define SYSCALL_LL ...
> > #include <sysdeps/unix/sysv/linux/sysdep.h>
> > 
> > you would have to update all the 64-bit arches to pull in the wordsize-64
> > header since it looks like sysdep.h has a lot of direct includes rather
> > than stacking & using include_next.
> 
> I think it can be done, however I would like to avoid creating and setting
> the 64-bit arches to use the new header disassociated if the arch actually
> use the wordsize-64 implementation (I see this to be a follow up cleanup).

can you at least do it for the 32-bit ones now and leave a TODO comment ?
-mike
  
Adhemerval Zanella Netto Jan. 5, 2016, 12:49 p.m. UTC | #4
On 04-01-2016 22:54, Mike Frysinger wrote:
> On 04 Jan 2016 10:33, Adhemerval Zanella wrote:
>> On 29-12-2015 15:24, Mike Frysinger wrote:
>>> On 18 Nov 2015 12:02, Adhemerval Zanella wrote:
>>>> This patch add two new macros to use along with off_t and off64_t argument
>>>> syscalls.  The rationale for this change is:
>>>>
>>>> 1. Remove multiple implementations for the same syscall for different
>>>>    architectures (for instance, pread have 6 different implementations).
>>>>
>>>> 2. Also remove the requirement to use syscall wrappers for cancellable
>>>>    entrypoints.
>>>>
>>>> The macro usage should be used along __ALIGNMENT_ARG to follow ABI constrains
>>>> for architecture where it applies.  For instance, pread can be rewritten as:
>>>>
>>>>   return SYSCALL_CANCEL (pread, fd, buf, count,
>>>>                          __ALIGNMENT_ARG SYSCALL_LL (offset));
>>>>
>>>> Another macro, SYSCALL_LL64, is provided for off64_t.
>>>>
>>>> The changes itself are not currently used in any implementation, so no
>>>> code change is expected.
>>>
>>> a quick scan looks like you're doing this purely along 32-bit/64-bit lines.
>>> why not add the 32-bit definition to sysdeps/unix/sysv/linux/sysdep.h and
>>> the 64-bit definition to sysdeps/unix/sysv/linux/wordsize-64/sysdep.h ?
>>>
>>> sysdeps/unix/sysv/linux/sysdep.h:
>>> #ifndef SYSCALL_LL
>>> # define SYSCALL_LL ...
>>> #endif
>>>
>>> sysdeps/unix/sysv/linux/wordsize-64/sysdep.h:
>>> #define SYSCALL_LL ...
>>> #include <sysdeps/unix/sysv/linux/sysdep.h>
>>>
>>> you would have to update all the 64-bit arches to pull in the wordsize-64
>>> header since it looks like sysdep.h has a lot of direct includes rather
>>> than stacking & using include_next.
>>
>> I think it can be done, however I would like to avoid creating and setting
>> the 64-bit arches to use the new header disassociated if the arch actually
>> use the wordsize-64 implementation (I see this to be a follow up cleanup).
> 
> can you at least do it for the 32-bit ones now and leave a TODO comment ?
> -mike
> 

Right, I will change that.
  

Patch

diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
index fe94a50..2e14b09 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
@@ -151,6 +151,9 @@ 
 
 #else /* not __ASSEMBLER__ */
 
+/* No adjustment required to pass long long on syscalls.  */
+# define SYSCALL_LL(__val)   (__val)
+# define SYSCALL_LL64(__val) (__val)
 
 /* List of system calls which are supported as vsyscalls.  */
 # define HAVE_CLOCK_GETRES_VSYSCALL	1
diff --git a/sysdeps/unix/sysv/linux/alpha/sysdep.h b/sysdeps/unix/sysv/linux/alpha/sysdep.h
index aea77b4..d77e8e3 100644
--- a/sysdeps/unix/sysv/linux/alpha/sysdep.h
+++ b/sysdeps/unix/sysv/linux/alpha/sysdep.h
@@ -27,9 +27,14 @@ 
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/alpha/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 
 #include <tls.h>
 
+/* No adjustment required to pass long long on syscalls.  */
+#define SYSCALL_LL(__val)   (__val)
+#define SYSCALL_LL64(__val) (__val)
+
 /* For Linux we can use the system call table in the header file
 	/usr/include/asm/unistd.h
    of the kernel.  But these symbols do not follow the SYS_* syntax
diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.h b/sysdeps/unix/sysv/linux/arm/sysdep.h
index c8715f7..ec237dc 100644
--- a/sysdeps/unix/sysv/linux/arm/sysdep.h
+++ b/sysdeps/unix/sysv/linux/arm/sysdep.h
@@ -23,6 +23,7 @@ 
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/arm/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 
 /* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO.  */
 #include <dl-sysdep.h>
@@ -317,6 +318,12 @@  __local_syscall_error:						\
 
 #else /* not __ASSEMBLER__ */
 
+/* Macro to adjust 'long long' argument for syscalls.  */
+#define SYSCALL_LL(__val)   \
+  __LONG_LONG_PAIR (__val >> 31, __val)
+#define SYSCALL_LL64(__val) \
+  __LONG_LONG_PAIR ((long) (__val >> 32), (long) (__val & 0xffffffff))
+
 /* Define a macro which expands into the inline wrapper code for a system
    call.  */
 #undef INLINE_SYSCALL
diff --git a/sysdeps/unix/sysv/linux/generic/sysdep.h b/sysdeps/unix/sysv/linux/generic/sysdep.h
index 70e7158..e00f92d 100644
--- a/sysdeps/unix/sysv/linux/generic/sysdep.h
+++ b/sysdeps/unix/sysv/linux/generic/sysdep.h
@@ -22,7 +22,9 @@ 
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 
 /* Provide the common name to allow more code reuse.  */
+#ifndef __NR__llseek
 #define __NR__llseek __NR_llseek
+#endif
 
 #if __WORDSIZE == 64
 /* By defining the older names, glibc will build syscall wrappers for
diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep.h b/sysdeps/unix/sysv/linux/hppa/sysdep.h
index 2cae70f..c5fcace 100644
--- a/sysdeps/unix/sysv/linux/hppa/sysdep.h
+++ b/sysdeps/unix/sysv/linux/hppa/sysdep.h
@@ -24,6 +24,7 @@ 
 #include <sysdeps/unix/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/hppa/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 
 /* Defines RTLD_PRIVATE_ERRNO.  */
 #include <dl-sysdep.h>
@@ -351,6 +352,12 @@  L(pre_end):					ASM_LINE_SEP	\
 
 #else
 
+/* Macro to adjust 'long long' argument for syscalls.  */
+#define SYSCALL_LL(__val) \
+  __LONG_LONG_PAIR (__val >> 31, __val)
+#define SYSCALL_LL64(__val) \
+  __LONG_LONG_PAIR ((long) (__val >> 32), (long) (__val & 0xffffffff))
+
 /* GCC has to be warned that a syscall may clobber all the ABI
    registers listed as "caller-saves", see page 8, Table 2
    in section 2.2.6 of the PA-RISC RUN-TIME architecture
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index dbe5654..58a72c8 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -22,6 +22,7 @@ 
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/i386/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 /* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO.  */
 #include <dl-sysdep.h>
 #include <tls.h>
@@ -233,6 +234,12 @@ 
 
 #else	/* !__ASSEMBLER__ */
 
+/* Macro to adjust 'long long' argument for syscalls.  */
+#define SYSCALL_LL(__val) \
+  __LONG_LONG_PAIR (__val >> 31, __val)
+#define SYSCALL_LL64(__val) \
+  __LONG_LONG_PAIR ((long) (__val >> 32), (long) (__val & 0xffffffff))
+
 extern int __syscall_error (int)
   attribute_hidden __attribute__ ((__regparm__ (1)));
 
diff --git a/sysdeps/unix/sysv/linux/ia64/sysdep.h b/sysdeps/unix/sysv/linux/ia64/sysdep.h
index eafcc7a..1b34109 100644
--- a/sysdeps/unix/sysv/linux/ia64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/ia64/sysdep.h
@@ -22,6 +22,7 @@ 
 
 #include <sysdeps/unix/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 #include <sysdeps/ia64/sysdep.h>
 #include <dl-sysdep.h>
 #include <tls.h>
@@ -186,6 +187,10 @@ 
 
 #else /* not __ASSEMBLER__ */
 
+/* No adjustment required to pass long long on syscalls.  */
+#define SYSCALL_LL(__val)   (__val)
+#define SYSCALL_LL64(__val) (__val)
+
 #define BREAK_INSN_1(num) "break " #num ";;\n\t"
 #define BREAK_INSN(num) BREAK_INSN_1(num)
 
diff --git a/sysdeps/unix/sysv/linux/m68k/sysdep.h b/sysdeps/unix/sysv/linux/m68k/sysdep.h
index e55446c..be3183c 100644
--- a/sysdeps/unix/sysv/linux/m68k/sysdep.h
+++ b/sysdeps/unix/sysv/linux/m68k/sysdep.h
@@ -18,6 +18,7 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <sysdeps/unix/sysv/linux/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 #include <tls.h>
 
 /* Defines RTLD_PRIVATE_ERRNO.  */
@@ -221,6 +222,12 @@  SYSCALL_ERROR_LABEL:							      \
 
 #else /* not __ASSEMBLER__ */
 
+/* Macro to adjust 'long long' argument for syscalls.  */
+#define SYSCALL_LL(__val) \
+  __LONG_LONG_PAIR (__val >> 31, __val)
+#define SYSCALL_LL64(__val) \
+  __LONG_LONG_PAIR ((long) (__val >> 32), (long) (__val & 0xffffffff))
+
 /* Define a macro which expands into the inline wrapper code for a system
    call.  */
 #undef INLINE_SYSCALL
diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep.h b/sysdeps/unix/sysv/linux/microblaze/sysdep.h
index 75dd11f..675c3ea 100644
--- a/sysdeps/unix/sysv/linux/microblaze/sysdep.h
+++ b/sysdeps/unix/sysv/linux/microblaze/sysdep.h
@@ -22,6 +22,7 @@ 
 #include <sysdeps/unix/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/microblaze/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 
 /* Defines RTLD_PRIVATE_ERRNO.  */
 #include <dl-sysdep.h>
@@ -163,6 +164,12 @@  SYSCALL_ERROR_LABEL_DCL:                            \
 
 #else /* not __ASSEMBLER__ */
 
+/* Macro to adjust 'long long' argument for syscalls.  */
+#define SYSCALL_LL(__val) \
+  __LONG_LONG_PAIR (__val >> 31, __val)
+#define SYSCALL_LL64(__val) \
+  __LONG_LONG_PAIR ((long) (__val >> 32), (long) (__val & 0xffffffff))
+
 /* Define a macro which expands into the inline wrapper code for a system
    call.  */
 # undef INLINE_SYSCALL
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
index cb8f4a8..8dbec9c 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
@@ -21,6 +21,7 @@ 
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/mips/mips32/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 
 #include <tls.h>
 
@@ -46,6 +47,12 @@ 
 
 #else   /* ! __ASSEMBLER__ */
 
+/* Macro to adjust 'long long' argument for syscalls.  */
+#define SYSCALL_LL(__val) \
+  __LONG_LONG_PAIR (__val >> 31, offset)
+#define SYSCALL_LL64(__val) \
+  __LONG_LONG_PAIR ((long) (__val >> 32), (long) (__val & 0xffffffff))
+
 /* Define a macro which expands into the inline wrapper code for a system
    call.  */
 #undef INLINE_SYSCALL
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
index b97bf0b..e6b2b66 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
@@ -21,6 +21,7 @@ 
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/mips/mips64/n32/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 
 #include <tls.h>
 
@@ -44,6 +45,10 @@ 
 
 #else   /* ! __ASSEMBLER__ */
 
+/* No adjustment required to pass long long on syscalls.  */
+#define SYSCALL_LL(__val)   (__val)
+#define SYSCALL_LL64(__val) (__val)
+
 /* Convert X to a long long, without losing any bits if it is one
    already or warning if it is a 32-bit pointer.  */
 #define ARGIFY(X) ((long long) (__typeof__ ((X) - (X))) (X))
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
index 6bbeeb0..f6732f0 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
@@ -21,6 +21,7 @@ 
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/mips/mips64/n64/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 
 #include <tls.h>
 
@@ -44,6 +45,10 @@ 
 
 #else   /* ! __ASSEMBLER__ */
 
+/* No adjustment required to pass long long on syscalls.  */
+#define SYSCALL_LL(__val)   (__val)
+#define SYSCALL_LL64(__val) (__val)
+
 /* Define a macro which expands into the inline wrapper code for a system
    call.  */
 #undef INLINE_SYSCALL
diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.h b/sysdeps/unix/sysv/linux/nios2/sysdep.h
index 66a77f4..e047210 100644
--- a/sysdeps/unix/sysv/linux/nios2/sysdep.h
+++ b/sysdeps/unix/sysv/linux/nios2/sysdep.h
@@ -137,6 +137,12 @@ 
 
 #else /* __ASSEMBLER__ */
 
+/* Macro to adjust 'long long' argument for syscalls.  */
+#define SYSCALL_LL(__val) \
+  __LONG_LONG_PAIR (__val >> 31, __val)
+#define SYSCALL_LL64(__val) \
+  __LONG_LONG_PAIR ((long) (__val >> 32), (long) (__val & 0xffffffff))
+
 /* In order to get __set_errno() definition in INLINE_SYSCALL.  */
 #include <errno.h>
 
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
index 7f389e4..c25f824 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
@@ -20,6 +20,7 @@ 
 
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/powerpc/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 #include <tls.h>
 
 /* Some systen calls got renamed over time, but retained the same semantics.
@@ -51,6 +52,12 @@ 
 
 # include <errno.h>
 
+/* Macro to adjust 'long long' argument for syscalls.  */
+# define SYSCALL_LL(__val)   \
+   __LONG_LONG_PAIR (offset >> 31, offset)
+# define SYSCALL_LL64(__val) \
+   __LONG_LONG_PAIR ((long) (__val >> 32), (long) __val)
+
 /* Define a macro which expands inline into the wrapper code for a VDSO
    call. This use is for internal calls that do not need to handle errors
    normally. It will never touch errno.
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
index 6803cce..c4bee54 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
@@ -22,6 +22,7 @@ 
 
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/powerpc/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 #include <tls.h>
 
 /* Define __set_errno() for INLINE_SYSCALL macro below.  */
@@ -62,6 +63,10 @@ 
 
 #endif /* __ASSEMBLER__ */
 
+/* No adjustment required to pass long long on syscalls.  */
+#define SYSCALL_LL(__val)   (__val)
+#define SYSCALL_LL64(__val) (__val)
+
 /* This version is for internal uses when there is no desire
    to set errno */
 #define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, type, nr, args...)   \
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
index d29b685..3e03c5c 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
@@ -22,6 +22,7 @@ 
 #include <sysdeps/s390/s390-32/sysdep.h>
 #include <sysdeps/unix/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 #include <dl-sysdep.h>	/* For RTLD_PRIVATE_ERRNO.  */
 #include <tls.h>
 
@@ -179,6 +180,12 @@ 
 
 #endif /* __ASSEMBLER__ */
 
+/* Macro to adjust 'long long' argument for syscalls.  */
+#define SYSCALL_LL(__val)   \
+  __LONG_LONG_PAIR (__val >> 31, __val)
+#define SYSCALL_LL64(__val) \
+  __LONG_LONG_PAIR ((long) (__val >> 32), (long) (__val & 0xffffffff))
+
 #undef INLINE_SYSCALL
 #define INLINE_SYSCALL(name, nr, args...)				      \
   ({									      \
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
index a373207..c7b3ad4 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
@@ -23,6 +23,7 @@ 
 #include <sysdeps/s390/s390-64/sysdep.h>
 #include <sysdeps/unix/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 #include <dl-sysdep.h>	/* For RTLD_PRIVATE_ERRNO.  */
 #include <tls.h>
 
@@ -185,6 +186,10 @@ 
 
 #endif /* __ASSEMBLER__ */
 
+/* No adjustment required to pass long long on syscalls.  */
+#define SYSCALL_LL(__val)   (__val)
+#define SYSCALL_LL64(__val) (__val)
+
 #undef INLINE_SYSCALL
 #define INLINE_SYSCALL(name, nr, args...)				      \
   ({									      \
diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.h b/sysdeps/unix/sysv/linux/sh/sysdep.h
index ab5b2c3..5a6c6a2 100644
--- a/sysdeps/unix/sysv/linux/sh/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sh/sysdep.h
@@ -23,6 +23,7 @@ 
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/sh/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 #include <tls.h>
 
 /* For Linux we can use the system call table in the header file
@@ -191,6 +192,12 @@ 
 
 #else /* not __ASSEMBLER__ */
 
+/* Macro to adjust 'long long' argument for syscalls.  */
+#define SYSCALL_LL(__val)   \
+  __LONG_LONG_PAIR (__val >> 31, __val)
+#define SYSCALL_LL64(__val) \
+  __LONG_LONG_PAIR ((long) (__val >> 32), (long) (__val & 0xffffffff))
+
 #define SYSCALL_INST_STR0	"trapa #0x10\n\t"
 #define SYSCALL_INST_STR1	"trapa #0x11\n\t"
 #define SYSCALL_INST_STR2	"trapa #0x12\n\t"
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
index e37e534..50d68cb 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
@@ -107,6 +107,12 @@  ENTRY(name);					\
 
 #else  /* __ASSEMBLER__ */
 
+/* Macro to adjust 'long long' argument for syscalls.  */
+#define SYSCALL_LL(__val) \
+  __LONG_LONG_PAIR (__val >> 31, __val)
+#define SYSCALL_LL64(__val) \
+  __LONG_LONG_PAIR ((long) (__val >> 32), (long) (__val & 0xffffffff))
+
 #define __SYSCALL_STRING						\
 	"ta	0x10;"							\
 	"bcc	1f;"							\
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
index 5b76f15..ef08ad3 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
@@ -116,6 +116,10 @@  ENTRY(name);					\
 
 #else  /* __ASSEMBLER__ */
 
+/* No adjustment required to pass long long on syscalls.  */
+#define SYSCALL_LL(__val)   (__val)
+#define SYSCALL_LL64(__val) (__val)
+
 #define __SYSCALL_STRING						\
 	"ta	0x6d;"							\
 	"bcc,pt	%%xcc, 1f;"						\
diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h
index c9843de..0d20b5d 100644
--- a/sysdeps/unix/sysv/linux/sparc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h
@@ -22,6 +22,7 @@ 
 #include <sysdeps/unix/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/sparc/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 
 #ifdef __ASSEMBLER__
 
diff --git a/sysdeps/unix/sysv/linux/tile/sysdep.h b/sysdeps/unix/sysv/linux/tile/sysdep.h
index d1268de..1a36d32 100644
--- a/sysdeps/unix/sysv/linux/tile/sysdep.h
+++ b/sysdeps/unix/sysv/linux/tile/sysdep.h
@@ -78,6 +78,12 @@ 
 
 #include <errno.h>
 
+/* Macro to adjust 'long long' argument for syscalls.  */
+#define SYSCALL_LL(__val)   \
+  __LONG_LONG_PAIR (__val >> 31, __val)
+#define SYSCALL_LL64(__val) \
+  __LONG_LONG_PAIR ((long) (__val >> 32), (long) (__val & 0xffffffff))
+
 /* Define a macro which expands inline into the wrapper code for a system
    call.  */
 # undef INLINE_SYSCALL
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index fc132f6..f85f8f9 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -21,6 +21,7 @@ 
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/x86_64/sysdep.h>
+#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 #include <tls.h>
 
 #if IS_IN (rtld)
@@ -188,6 +189,11 @@ 
 # define DOARGS_6 DOARGS_5
 
 #else	/* !__ASSEMBLER__ */
+
+/* No adjustment required to pass long long on syscalls.  */
+# define SYSCALL_LL(__val)   (__val)
+# define SYSCALL_LL64(__val) (__val)
+
 /* Define a macro which expands inline into the wrapper code for a system
    call.  */
 # undef INLINE_SYSCALL