[v3,2/2] posix: Implement preadv2 and pwritev2

Message ID CAMe9rOpv__CTeKLz34grWkquP6fC4dbq2LNaQXxK+ELiUeBy5w@mail.gmail.com
State New, archived
Headers

Commit Message

H.J. Lu June 4, 2017, 1:42 p.m. UTC
  On Sat, Jun 3, 2017 at 8:28 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> On Jun 03 2017, "H.J. Lu" <hjl.tools@gmail.com> wrote:
>
>> X32 inherits LO_HI_LONG from x86-64.  If we change x86-64
>> LO_HI_LONG, x32 needs to redefine LO_HI_LONG.
>
> Your LO_HI_LONG_FLAGS doesn't work for x32 either.
>

My patch redefined LO_HI_LONG_FLAGS for x32.   Here is an alternate
patch which defines different LO_HI_LONGs for x86-64 and x32.

Tested on x86-64 and x32.
  

Comments

Zack Weinberg June 4, 2017, 3:02 p.m. UTC | #1
On 06/04/2017 09:42 AM, H.J. Lu wrote:
> On Sat, Jun 3, 2017 at 8:28 AM, Andreas Schwab <schwab@linux-m68k.org> wrote:
>> On Jun 03 2017, "H.J. Lu" <hjl.tools@gmail.com> wrote:
>>
>>> X32 inherits LO_HI_LONG from x86-64.  If we change x86-64
>>> LO_HI_LONG, x32 needs to redefine LO_HI_LONG.
>>
>> Your LO_HI_LONG_FLAGS doesn't work for x32 either.
>>
> 
> My patch redefined LO_HI_LONG_FLAGS for x32.   Here is an alternate
> patch which defines different LO_HI_LONGs for x86-64 and x32.
> 
> Tested on x86-64 and x32.

This patch looks good to me, but since today is Sunday, please wait at
least 24 hours for any other comments before committing.

zw
  

Patch

From a9a12a727f6bed053ce1396ec44a754585de4167 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 2 Jun 2017 18:31:16 -0700
Subject: [PATCH] x86-64: Update LO_HI_LONG for p{readv,writev}{64}v2

The kernel interface for p{readv,writev}{64}v is

(unsigned long fd, {const }struct iovec *iov, unsigned long vlen,
 unsigned long pos_l, unsigned long pos_h)

Except for targets which define __ARCH_WANT_COMPAT_SYS_PREADV64 and
__ARCH_WANT_COMPAT_SYS_PWRITEV64,

(unsigned long fd, {const }struct iovec *iov, unsigned long vlen,
 off64_t pos)

is used for p{readv,writev}{64}v.  X32 is the only such target.  The
LO_HI_LONG macro is used to pass offset to the pos_l and pos_h pair.
Since pos_h is ignored when size of offset == sizeof of pos_l, x86-64
has

 #define LO_HI_LONG(val) (val)

But the kernel interface for p{readv,writev}{64}v2 is

(unsigned long fd, {const }struct iovec *iov, unsigned long vlen,
 unsigned long pos_l, unsigned long pos_h, int flags)

Except for targets which define __ARCH_WANT_COMPAT_SYS_PREADV64V2 and
__ARCH_WANT_COMPAT_SYS_PWRITEV64V2,

(unsigned long fd, {const }struct iovec *iov, unsigned long vlen,
 off64_t pos, int flags)

is used for p{readv,writev}{64}v2.  X32 is the only such target.  Update
x86-64 LO_HI_LONG to pass 0 as the high part of the offset argument for
p{readv,writev}{64}v2 and define a different LO_HI_LONG for x32 to only
pass one argument for offset.

Tested on x32 and x86-64.

	* sysdeps/unix/sysv/linux/x86_64/sysdep.h (LO_HI_LONG): Pass
	0 as the high part of offset.
	* sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h (LO_HI_LONG): New.
---
 sysdeps/unix/sysv/linux/x86_64/sysdep.h     | 2 +-
 sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index 7b8bd79..880e496 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -387,6 +387,6 @@ 
 
 /* How to pass the off{64}_t argument on p{readv,writev}{64}.  */
 #undef LO_HI_LONG
-#define LO_HI_LONG(val) (val)
+#define LO_HI_LONG(val) (val), 0
 
 #endif /* linux/x86_64/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h
index f90fcfa..04c73a2 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h
@@ -22,4 +22,8 @@ 
 #include <sysdeps/unix/sysv/linux/x86_64/sysdep.h>
 #include <sysdeps/x86_64/x32/sysdep.h>
 
+/* How to pass the off{64}_t argument on p{readv,writev}{64}.  */
+#undef LO_HI_LONG
+#define LO_HI_LONG(val) (val)
+
 #endif /* linux/x86_64/x32/sysdep.h */
-- 
2.9.4