public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 3/4] Consolidate pread/pread64 implementations
  2016-02-25 20:19 [PATCH v4 0/4] Cancellation entrypoint refactor Adhemerval Zanella
@ 2016-02-25 20:19 ` Adhemerval Zanella
  2016-04-10  4:15   ` Mike Frysinger
  2016-04-14 18:54   ` Florian Weimer
  2016-02-25 20:19 ` [PATCH 1/4] Define __ASSUME_ALIGNED_REGISTER_PAIRS for missing ports Adhemerval Zanella
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 20+ messages in thread
From: Adhemerval Zanella @ 2016-02-25 20:19 UTC (permalink / raw)
  To: libc-alpha; +Cc: Adhemerval Zanella

From: Adhemerval Zanella <adhemerval.zanella@linaro.com>

This patch consolidates all the pread/pread64 implementation for Linux
in only one (sysdeps/unix/sysv/linux/pread.c).  It also removes the
syscall from the auto-generation using assembly macros.

For pread{64} offset argument placement the new SYSCALL_LL{64} macro
is used.  For pread ports that do not define __NR_pread will use
__NR_pread64 and for pread64 ports that dot define __NR_pread64 will
use __NR_pread for the syscall.

Checked on x86_64, x32, i386, aarch64, and ppc64le.

	* sysdeps/unix/sysv/linux/arm/pread.c: Remove file.
	* sysdeps/unix/sysv/linux/arm/pread64.c: Likewise.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/pread.c: Likewise.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/pread64.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/pread.c: Likewise,
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/pread64.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/pread64.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list (pread): Remove
	syscall generation.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
	[__NR_pread64] (__NR_pread): Remove define.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h:
	[__NR_pread64] (__NR_pread): Likewise.
	* sysdeps/unix/sysv/linux/pread.c [__NR_pread64] (__NR_pread): Remove
	define.
	(__libc_pread): Use SYSCALL_LL macro on offset argument.
	* sysdeps/unix/sysv/linux/pread64.c [__NR_pread64] (__NR_pread):
	Remove define.
	(__libc_pread64): Use SYSCALL_LL64 macro on offset argument.
	* sysdeps/unix/sysv/linux/sh/pread.c: Rewrite using default
	Linux implementation as base.
	* sysdeps/unix/sysv/linux/sh/pread64.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/pread.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/pread64.c: Likewise.
---
 sysdeps/unix/sysv/linux/arm/pread.c                | 36 ---------------
 sysdeps/unix/sysv/linux/arm/pread64.c              | 37 ---------------
 .../unix/sysv/linux/generic/wordsize-32/pread.c    | 37 ---------------
 .../unix/sysv/linux/generic/wordsize-32/pread64.c  | 34 --------------
 sysdeps/unix/sysv/linux/mips/kernel-features.h     |  1 +
 sysdeps/unix/sysv/linux/mips/pread.c               | 54 ----------------------
 sysdeps/unix/sysv/linux/mips/pread64.c             | 50 --------------------
 sysdeps/unix/sysv/linux/powerpc/powerpc32/pread.c  | 34 --------------
 .../unix/sysv/linux/powerpc/powerpc32/pread64.c    | 35 --------------
 sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h |  7 ---
 sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h |  7 ---
 sysdeps/unix/sysv/linux/pread.c                    | 25 +++-------
 sysdeps/unix/sysv/linux/pread64.c                  | 23 ++++-----
 sysdeps/unix/sysv/linux/sh/pread.c                 | 30 ++----------
 sysdeps/unix/sysv/linux/sh/pread64.c               | 30 ++----------
 sysdeps/unix/sysv/linux/wordsize-64/pread64.c      |  1 -
 sysdeps/unix/sysv/linux/wordsize-64/syscalls.list  |  1 -
 18 files changed, 53 insertions(+), 414 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/arm/pread.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/pread64.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/pread.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/pread64.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/pread.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/pread64.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/pread.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/pread64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/pread64.c

diff --git a/sysdeps/unix/sysv/linux/arm/pread.c b/sysdeps/unix/sysv/linux/arm/pread.c
deleted file mode 100644
index 8c9b878..0000000
--- a/sysdeps/unix/sysv/linux/arm/pread.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#include <endian.h>
-#include <unistd.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-ssize_t
-__libc_pread (int fd, void *buf, size_t count, off_t offset)
-{
-  /* In the ARM EABI, 64-bit values are aligned to even/odd register
-     pairs for syscalls.  */
-  return SYSCALL_CANCEL (pread64, fd, buf, count, 0,
-			 __LONG_LONG_PAIR (offset >> 31, offset));
-}
-
-strong_alias (__libc_pread, __pread)
-weak_alias (__libc_pread, pread)
diff --git a/sysdeps/unix/sysv/linux/arm/pread64.c b/sysdeps/unix/sysv/linux/arm/pread64.c
deleted file mode 100644
index 3364b6a..0000000
--- a/sysdeps/unix/sysv/linux/arm/pread64.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#include <endian.h>
-#include <unistd.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-ssize_t
-__libc_pread64 (int fd, void *buf, size_t count, off64_t offset)
-{
-  /* In the ARM EABI, 64-bit values are aligned to even/odd register
-     pairs for syscalls.  */
-  return SYSCALL_CANCEL (pread64, fd, buf, count, 0,
-			 __LONG_LONG_PAIR ((off_t) (offset >> 32),
-					   (off_t) (offset & 0xffffffff)));
-}
-
-weak_alias (__libc_pread64, __pread64)
-weak_alias (__libc_pread64, pread64)
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/pread.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/pread.c
deleted file mode 100644
index 0dff648..0000000
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/pread.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright (C) 2011-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
-   Based on work contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <assert.h>
-#include <errno.h>
-#include <endian.h>
-#include <unistd.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-ssize_t
-__libc_pread (int fd, void *buf, size_t count, off_t offset)
-{
-  assert (sizeof (offset) == 4);
-  return SYSCALL_CANCEL (pread64, fd,
-                         buf, count, __ALIGNMENT_ARG
-                         __LONG_LONG_PAIR (offset >> 31, offset));
-}
-strong_alias (__libc_pread, __pread)
-weak_alias (__libc_pread, pread)
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/pread64.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/pread64.c
deleted file mode 100644
index 8931900..0000000
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/pread64.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright (C) 2011-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
-   Based on work contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#include <endian.h>
-#include <unistd.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-ssize_t
-__libc_pread64 (int fd, void *buf, size_t count, off64_t offset)
-{
-  return SYSCALL_CANCEL (pread64, fd, buf, count, __ALIGNMENT_ARG
-                         __LONG_LONG_PAIR ((off_t) (offset >> 32),
-                                           (off_t) (offset & 0xffffffff)));
-}
-weak_alias (__libc_pread64, __pread64) weak_alias (__libc_pread64, pread64)
diff --git a/sysdeps/unix/sysv/linux/mips/kernel-features.h b/sysdeps/unix/sysv/linux/mips/kernel-features.h
index 17ab696..7cb32cd 100644
--- a/sysdeps/unix/sysv/linux/mips/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/mips/kernel-features.h
@@ -58,4 +58,5 @@
    pass 64-bits values through syscalls.  */
 #if _MIPS_SIM == _ABIN32
 # define __ASSUME_WORDSIZE64_ILP32	1
+# define __ASSUME_OFF_DIFF_OFF64        1
 #endif
diff --git a/sysdeps/unix/sysv/linux/mips/pread.c b/sysdeps/unix/sysv/linux/mips/pread.c
deleted file mode 100644
index 02755cb..0000000
--- a/sysdeps/unix/sysv/linux/mips/pread.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <assert.h>
-#include <errno.h>
-#ifndef NO_SGIDEFS_H
-#include <sgidefs.h>
-#endif
-#include <unistd.h>
-#include <endian.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-#ifdef __NR_pread64             /* Newer kernels renamed but it's the same.  */
-# ifdef __NR_pread
-#  error "__NR_pread and __NR_pread64 both defined???"
-# endif
-# define __NR_pread __NR_pread64
-#endif
-
-
-ssize_t
-__libc_pread (int fd, void *buf, size_t count, off_t offset)
-{
-#if _MIPS_SIM != _ABI64
-  assert (sizeof (offset) == 4);
-#endif
-
-#if _MIPS_SIM == _ABIN32 || _MIPS_SIM == _ABI64
-  return SYSCALL_CANCEL (pread, fd, buf, count, offset);
-#else
-  return SYSCALL_CANCEL (pread, fd, buf, count, 0,
-			 __LONG_LONG_PAIR (offset >> 31, offset));
-#endif
-}
-
-strong_alias (__libc_pread, __pread)
-weak_alias (__libc_pread, pread)
diff --git a/sysdeps/unix/sysv/linux/mips/pread64.c b/sysdeps/unix/sysv/linux/mips/pread64.c
deleted file mode 100644
index ed0e91c..0000000
--- a/sysdeps/unix/sysv/linux/mips/pread64.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#ifndef NO_SGIDEFS_H
-#include <sgidefs.h>
-#endif
-#include <unistd.h>
-#include <endian.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-#ifdef __NR_pread64             /* Newer kernels renamed but it's the same.  */
-# ifdef __NR_pread
-#  error "__NR_pread and __NR_pread64 both defined???"
-# endif
-# define __NR_pread __NR_pread64
-#endif
-
-
-ssize_t
-__libc_pread64 (int fd, void *buf, size_t count, off64_t offset)
-{
-#if _MIPS_SIM == _ABIN32 || _MIPS_SIM == _ABI64
-  return SYSCALL_CANCEL (pread, fd, buf, count, offset);
-#else
-  return SYSCALL_CANCEL (pread, fd, buf, count, 0,
-			 __LONG_LONG_PAIR ((off_t) (offset >> 32),
-					   (off_t) (offset & 0xffffffff)));
-#endif
-}
-
-weak_alias (__libc_pread64, __pread64)
-weak_alias (__libc_pread64, pread64)
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/pread.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/pread.c
deleted file mode 100644
index 2d67013..0000000
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/pread.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <assert.h>
-#include <errno.h>
-#include <unistd.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-ssize_t
-__libc_pread (int fd, void *buf, size_t count, off_t offset)
-{
-  /* On PPC32 64bit values are aligned in odd/even register pairs.  */
-  return SYSCALL_CANCEL (pread, fd, buf, count, 0, offset >> 31, offset);
-}
-
-strong_alias (__libc_pread, __pread)
-weak_alias (__libc_pread, pread)
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/pread64.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/pread64.c
deleted file mode 100644
index 712ab72..0000000
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/pread64.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#include <unistd.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-
-ssize_t
-__libc_pread64 (int fd, void *buf, size_t count, off64_t offset)
-{
-  /* On PPC32 64bit values are aligned in odd/even register pairs.  */
-  return SYSCALL_CANCEL (pread, fd, buf, count, 0, (long) (offset >> 32),
-			 (long) offset);
-}
-
-weak_alias (__libc_pread64, __pread64)
-weak_alias (__libc_pread64, pread64)
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
index 6d8990c..0dc18da 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
@@ -26,13 +26,6 @@
    Handle them here so they can be catched by both C and assembler stubs in
    glibc.  */
 
-#ifdef __NR_pread64
-# ifdef __NR_pread
-#  error "__NR_pread and __NR_pread64 both defined???"
-# endif
-# define __NR_pread __NR_pread64
-#endif
-
 #ifdef __NR_pwrite64
 # ifdef __NR_pwrite
 #  error "__NR_pwrite and __NR_pwrite64 both defined???"
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
index 91fd096..6e27223 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
@@ -33,13 +33,6 @@
    Handle them here so they can be catched by both C and assembler stubs in
    glibc.  */
 
-#ifdef __NR_pread64
-# ifdef __NR_pread
-#  error "__NR_pread and __NR_pread64 both defined???"
-# endif
-# define __NR_pread __NR_pread64
-#endif
-
 #ifdef __NR_pwrite64
 # ifdef __NR_pwrite
 #  error "__NR_pwrite and __NR_pwrite64 both defined???"
diff --git a/sysdeps/unix/sysv/linux/pread.c b/sysdeps/unix/sysv/linux/pread.c
index 4aa3c67..5663092 100644
--- a/sysdeps/unix/sysv/linux/pread.c
+++ b/sysdeps/unix/sysv/linux/pread.c
@@ -16,33 +16,22 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
-#include <errno.h>
-#include <endian.h>
 #include <unistd.h>
-
 #include <sysdep-cancel.h>
-#include <sys/syscall.h>
 
-#ifdef __NR_pread64		/* Newer kernels renamed but it's the same.  */
-# ifdef __NR_pread
-#  error "__NR_pread and __NR_pread64 both defined???"
-# endif
-# define __NR_pread __NR_pread64
-#endif
+#if __WORDSIZE != 64 || defined (__ASSUME_OFF_DIFF_OFF64)
 
+# ifndef __NR_pread
+#  define __NR_pread __NR_pread64
+# endif
 
 ssize_t
 __libc_pread (int fd, void *buf, size_t count, off_t offset)
 {
-  ssize_t result;
-
-  assert (sizeof (offset) == 4);
-  result = SYSCALL_CANCEL (pread, fd, buf, count,
-			   __LONG_LONG_PAIR (offset >> 31, offset));
-
-  return result;
+  return SYSCALL_CANCEL (pread, fd, buf, count,
+			 __ALIGNMENT_ARG SYSCALL_LL (offset));
 }
 
 strong_alias (__libc_pread, __pread)
 weak_alias (__libc_pread, pread)
+#endif
diff --git a/sysdeps/unix/sysv/linux/pread64.c b/sysdeps/unix/sysv/linux/pread64.c
index 7b5019a..c599f76 100644
--- a/sysdeps/unix/sysv/linux/pread64.c
+++ b/sysdeps/unix/sysv/linux/pread64.c
@@ -16,28 +16,25 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <endian.h>
 #include <unistd.h>
-
 #include <sysdep-cancel.h>
-#include <sys/syscall.h>
 
-#ifdef __NR_pread64		/* Newer kernels renamed but it's the same.  */
-# ifdef __NR_pread
-#  error "__NR_pread and __NR_pread64 both defined???"
-# endif
-# define __NR_pread __NR_pread64
+#ifndef __NR_pread64
+# define __NR_pread64 __NR_pread
 #endif
 
-
 ssize_t
 __libc_pread64 (int fd, void *buf, size_t count, off64_t offset)
 {
-  return SYSCALL_CANCEL (pread, fd, buf, count,
-			 __LONG_LONG_PAIR ((off_t) (offset >> 32),
-					   (off_t) (offset & 0xffffffff)));
+  return SYSCALL_CANCEL (pread64, fd, buf, count,
+			 __ALIGNMENT_ARG SYSCALL_LL64 (offset));
 }
 
 weak_alias (__libc_pread64, __pread64)
 weak_alias (__libc_pread64, pread64)
+
+#if __WORDSIZE == 64 && !defined (__ASSUME_OFF_DIFF_OFF64)
+strong_alias (__libc_pread64, __libc_pread)
+weak_alias (__libc_pread64, __pread)
+weak_alias (__libc_pread64, pread)
+#endif
diff --git a/sysdeps/unix/sysv/linux/sh/pread.c b/sysdeps/unix/sysv/linux/sh/pread.c
index 8afada5..d3f99f3 100644
--- a/sysdeps/unix/sysv/linux/sh/pread.c
+++ b/sysdeps/unix/sysv/linux/sh/pread.c
@@ -16,28 +16,8 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
-#include <errno.h>
-#include <unistd.h>
-#include <endian.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-#ifdef __NR_pread64             /* Newer kernels renamed but it's the same.  */
-# ifdef __NR_pread
-#  error "__NR_pread and __NR_pread64 both defined???"
-# endif
-# define __NR_pread __NR_pread64
-#endif
-
-
-ssize_t
-__libc_pread (int fd, void *buf, size_t count, off_t offset)
-{
-  return SYSCALL_CANCEL (pread, fd, buf, count, 0,
-			 __LONG_LONG_PAIR (offset >> 31, offset));
-}
-
-strong_alias (__libc_pread, __pread)
-weak_alias (__libc_pread, pread)
+/* SH4 ABI does not really require argument alignment for 64-bits, but
+   the kernel interface for pread adds a dummy long argument before the
+   offset.  */
+#define __ALIGNMENT_ARG
+#include <sysdeps/unix/sysv/linux/pread.c>
diff --git a/sysdeps/unix/sysv/linux/sh/pread64.c b/sysdeps/unix/sysv/linux/sh/pread64.c
index cfc751d..b2e8a25 100644
--- a/sysdeps/unix/sysv/linux/sh/pread64.c
+++ b/sysdeps/unix/sysv/linux/sh/pread64.c
@@ -16,28 +16,8 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <unistd.h>
-#include <endian.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-#ifdef __NR_pread64             /* Newer kernels renamed but it's the same.  */
-# ifdef __NR_pread
-#  error "__NR_pread and __NR_pread64 both defined???"
-# endif
-# define __NR_pread __NR_pread64
-#endif
-
-
-ssize_t
-__libc_pread64 (int fd, void *buf, size_t count, off64_t offset)
-{
-  return SYSCALL_CANCEL (pread, fd, buf, count, 0,
-			 __LONG_LONG_PAIR ((off_t) (offset >> 32),
-					   (off_t) (offset & 0xffffffff)));
-}
-
-weak_alias (__libc_pread64, __pread64)
-weak_alias (__libc_pread64, pread64)
+/* SH4 ABI does not really require argument alignment for 64-bits, but
+   the kernel interface for pread adds a dummy long argument before the
+   offset.  */
+#define __ALIGNMENT_ARG
+#include <sysdeps/unix/sysv/linux/pread64.c>
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/pread64.c b/sysdeps/unix/sysv/linux/wordsize-64/pread64.c
deleted file mode 100644
index b7f298d..0000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/pread64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* Empty since the pread syscall is equivalent.  */
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
index 19cc6d9..7d5f6a5 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
@@ -3,7 +3,6 @@
 # Whee! 64-bit systems naturally implement llseek.
 llseek		EXTRA	lseek		i:iii	__libc_lseek	__lseek lseek __libc_lseek64 __llseek llseek __lseek64 lseek64
 lseek		llseek	-
-pread		-	pread		Ci:ibni	__libc_pread	__libc_pread64 __pread pread __pread64 pread64
 pwrite		-	pwrite		Ci:ibni	__libc_pwrite	__libc_pwrite64 __pwrite pwrite __pwrite64 pwrite64
 fstatfs		-	fstatfs		i:ip	__fstatfs	fstatfs fstatfs64 __fstatfs64
 statfs		-	statfs		i:sp	__statfs	statfs statfs64
-- 
1.9.1

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 4/4] Consolidate pwrite/pwrite64 implementations
  2016-02-25 20:19 [PATCH v4 0/4] Cancellation entrypoint refactor Adhemerval Zanella
  2016-02-25 20:19 ` [PATCH 3/4] Consolidate pread/pread64 implementations Adhemerval Zanella
  2016-02-25 20:19 ` [PATCH 1/4] Define __ASSUME_ALIGNED_REGISTER_PAIRS for missing ports Adhemerval Zanella
@ 2016-02-25 20:19 ` Adhemerval Zanella
  2016-04-10  4:16   ` Mike Frysinger
  2016-02-25 20:23 ` [PATCH 2/4] Consolidate off_t/off64_t syscall argument passing Adhemerval Zanella
  2016-03-08  9:57 ` [PATCH v4 0/4] Cancellation entrypoint refactor Adhemerval Zanella
  4 siblings, 1 reply; 20+ messages in thread
From: Adhemerval Zanella @ 2016-02-25 20:19 UTC (permalink / raw)
  To: libc-alpha; +Cc: Adhemerval Zanella

From: Adhemerval Zanella <adhemerval.zanella@linaro.com>

This patch consolidates all the pwrite/pwrite64 implementation for Linux
in only one (sysdeps/unix/sysv/linux/pwrite{64}.c).  It also removes the
syscall from the auto-generation using assembly macros.

For pwrite{64} offset argument placement the new SYSCALL_LL{64} macro
is used.  For pwrite ports that do not define __NR_pwrite will use
__NR_pwrite64 and for pwrite64 ports that dot define __NR_pwrite64 will
use __NR_pwrite for the syscall.

Checked on x86_64, x32, i386, aarch64, and ppc64le.

	* sysdeps/unix/sysv/linux/arm/pwrite.c: Remove file.
	* sysdeps/unix/sysv/linux/arm/pwrite64.c: Likewise.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/pwrite.c: Likewise.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/pwrite64.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite64.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/pwrite64.c: Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list (prite): Remove
	syscalls generation.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
	[__NR_pwrite64] (__NR_write): Remove define.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
	[__NR_pwrite64] (__NR_write): Remove define.
	* sysdeps/unix/sysv/linux/pwrite.c [__NR_pwrite64] (__NR_pwrite):
	Remove define.
	(__libc_pwrite): Use SYSCALL_LL macro on offset argument.
	* sysdeps/unix/sysv/linux/pwrite64.c [__NR_pwrite64] (__NR_pwrite):
	Remove define.
	(__libc_pwrite64): Use SYSCALL_LL64 macro on offset argument.
	* sysdeps/unix/sysv/linux/sh/pwrite.c: Rewrite using default
	Linux implementation as base.
	* sysdeps/unix/sysv/linux/sh/pwrite64.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/pwrite.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/pwrite64.c: Likewise.
---
 sysdeps/unix/sysv/linux/arm/pwrite.c               | 36 ---------------
 sysdeps/unix/sysv/linux/arm/pwrite64.c             | 38 ---------------
 .../unix/sysv/linux/generic/wordsize-32/pwrite.c   | 36 ---------------
 .../unix/sysv/linux/generic/wordsize-32/pwrite64.c | 35 --------------
 sysdeps/unix/sysv/linux/mips/pwrite.c              | 54 ----------------------
 sysdeps/unix/sysv/linux/mips/pwrite64.c            | 51 --------------------
 sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite.c | 35 --------------
 .../unix/sysv/linux/powerpc/powerpc32/pwrite64.c   | 36 ---------------
 sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h | 11 -----
 sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h | 11 -----
 sysdeps/unix/sysv/linux/pwrite.c                   | 25 +++-------
 sysdeps/unix/sysv/linux/pwrite64.c                 | 23 ++++-----
 sysdeps/unix/sysv/linux/sh/pwrite.c                | 30 ++----------
 sysdeps/unix/sysv/linux/sh/pwrite64.c              | 31 ++-----------
 sysdeps/unix/sysv/linux/wordsize-64/pwrite64.c     |  1 -
 sysdeps/unix/sysv/linux/wordsize-64/syscalls.list  |  1 -
 17 files changed, 52 insertions(+), 427 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/arm/pwrite.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/pwrite64.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/pwrite.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/pwrite64.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/pwrite.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/pwrite64.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/pwrite64.c

diff --git a/sysdeps/unix/sysv/linux/arm/pwrite.c b/sysdeps/unix/sysv/linux/arm/pwrite.c
deleted file mode 100644
index d4132f1..0000000
--- a/sysdeps/unix/sysv/linux/arm/pwrite.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#include <endian.h>
-#include <unistd.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-ssize_t
-__libc_pwrite (int fd, const void *buf, size_t count, off_t offset)
-{
-  /* In the ARM EABI, 64-bit values are aligned to even/odd register
-     pairs for syscalls.  */
-  return SYSCALL_CANCEL (pwrite64, fd, buf, count, 0,
-			 __LONG_LONG_PAIR (offset >> 31, offset));
-}
-
-strong_alias (__libc_pwrite, __pwrite)
-weak_alias (__libc_pwrite, pwrite)
diff --git a/sysdeps/unix/sysv/linux/arm/pwrite64.c b/sysdeps/unix/sysv/linux/arm/pwrite64.c
deleted file mode 100644
index 1b70560..0000000
--- a/sysdeps/unix/sysv/linux/arm/pwrite64.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#include <endian.h>
-#include <unistd.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-ssize_t
-__libc_pwrite64 (int fd, const void *buf, size_t count, off64_t offset)
-{
-  /* In the ARM EABI, 64-bit values are aligned to even/odd register
-     pairs for syscalls.  */
-  return SYSCALL_CANCEL (pwrite64, fd, buf, count, 0,
-			 __LONG_LONG_PAIR ((off_t) (offset >> 32),
-					   (off_t) (offset & 0xffffffff)));
-}
-
-weak_alias (__libc_pwrite64, __pwrite64)
-libc_hidden_weak (__pwrite64)
-weak_alias (__libc_pwrite64, pwrite64)
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/pwrite.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/pwrite.c
deleted file mode 100644
index f9f1e0d..0000000
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/pwrite.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright (C) 2011-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
-   Based on work contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <assert.h>
-#include <errno.h>
-#include <endian.h>
-#include <unistd.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-ssize_t
-__libc_pwrite (int fd, const void *buf, size_t count, off_t offset)
-{
-  assert (sizeof (offset) == 4);
-  return SYSCALL_CANCEL (pwrite64, fd, buf, count, __ALIGNMENT_ARG
-                         __LONG_LONG_PAIR (offset >> 31, offset));
-}
-strong_alias (__libc_pwrite, __pwrite)
-weak_alias (__libc_pwrite, pwrite)
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/pwrite64.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/pwrite64.c
deleted file mode 100644
index 53aaa47..0000000
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/pwrite64.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (C) 2011-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
-   Based on work contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#include <endian.h>
-#include <unistd.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-ssize_t
-__libc_pwrite64 (int fd, const void *buf, size_t count, off64_t offset)
-{
-  return SYSCALL_CANCEL (pwrite64, fd, buf, count, __ALIGNMENT_ARG
-                         __LONG_LONG_PAIR ((off_t) (offset >> 32),
-                                           (off_t) (offset & 0xffffffff)));
-}
-weak_alias (__libc_pwrite64, __pwrite64)
-libc_hidden_weak (__pwrite64) weak_alias (__libc_pwrite64, pwrite64)
diff --git a/sysdeps/unix/sysv/linux/mips/pwrite.c b/sysdeps/unix/sysv/linux/mips/pwrite.c
deleted file mode 100644
index 31dea3a..0000000
--- a/sysdeps/unix/sysv/linux/mips/pwrite.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <assert.h>
-#include <errno.h>
-#ifndef NO_SGIDEFS_H
-#include <sgidefs.h>
-#endif
-#include <unistd.h>
-#include <endian.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-#ifdef __NR_pwrite64            /* Newer kernels renamed but it's the same.  */
-# ifdef __NR_pwrite
-#  error "__NR_pwrite and __NR_pwrite64 both defined???"
-# endif
-# define __NR_pwrite __NR_pwrite64
-#endif
-
-
-ssize_t
-__libc_pwrite (int fd, const void *buf, size_t count, off_t offset)
-{
-#if _MIPS_SIM != _ABI64
-  assert (sizeof (offset) == 4);
-#endif
-
-#if _MIPS_SIM == _ABIN32 || _MIPS_SIM == _ABI64
-  return SYSCALL_CANCEL (pwrite, fd, buf, count, offset);
-#else
-  return SYSCALL_CANCEL (pwrite, fd, buf, count, 0,
-			 __LONG_LONG_PAIR (offset >> 31, offset));
-#endif
-}
-
-strong_alias (__libc_pwrite, __pwrite)
-weak_alias (__libc_pwrite, pwrite)
diff --git a/sysdeps/unix/sysv/linux/mips/pwrite64.c b/sysdeps/unix/sysv/linux/mips/pwrite64.c
deleted file mode 100644
index 1905c57..0000000
--- a/sysdeps/unix/sysv/linux/mips/pwrite64.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ralf Baechle <ralf@gnu.org>, 1998.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#ifndef NO_SGIDEFS_H
-#include <sgidefs.h>
-#endif
-#include <unistd.h>
-#include <endian.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-#ifdef __NR_pwrite64            /* Newer kernels renamed but it's the same.  */
-# ifdef __NR_pwrite
-#  error "__NR_pwrite and __NR_pwrite64 both defined???"
-# endif
-# define __NR_pwrite __NR_pwrite64
-#endif
-
-
-ssize_t
-__libc_pwrite64 (int fd, const void *buf, size_t count, off64_t offset)
-{
-#if _MIPS_SIM == _ABIN32 || _MIPS_SIM == _ABI64
-  return SYSCALL_CANCEL (pwrite, fd, buf, count, offset);
-#else
-  return SYSCALL_CANCEL (pwrite, fd, buf, count, 0,
-			 __LONG_LONG_PAIR ((off_t) (offset >> 32),
-					   (off_t) (offset & 0xffffffff)));
-#endif
-}
-
-weak_alias (__libc_pwrite64, __pwrite64)
-libc_hidden_weak (__pwrite64)
-weak_alias (__libc_pwrite64, pwrite64)
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite.c
deleted file mode 100644
index 4001b47..0000000
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <assert.h>
-#include <errno.h>
-#include <unistd.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-
-ssize_t
-__libc_pwrite (int fd, const void *buf, size_t count, off_t offset)
-{
-  /* On PPC32 64bit values are aligned in odd/even register pairs.  */
-  return SYSCALL_CANCEL (pwrite, fd, buf, count, 0, offset >> 31, offset);
-}
-
-strong_alias (__libc_pwrite, __pwrite)
-weak_alias (__libc_pwrite, pwrite)
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite64.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite64.c
deleted file mode 100644
index 8a513fa..0000000
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite64.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#include <unistd.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-
-ssize_t
-__libc_pwrite64 (int fd, const void *buf, size_t count, off64_t offset)
-{
-  /* On PPC32 64bit values are aligned in odd/even register pairs.  */
-  return SYSCALL_CANCEL (pwrite, fd, buf, count, 0, (long) (offset >> 32),
-			 (long) offset);
-}
-
-weak_alias (__libc_pwrite64, __pwrite64)
-libc_hidden_weak (__pwrite64)
-weak_alias (__libc_pwrite64, pwrite64)
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
index 0dc18da..273d78b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
@@ -22,17 +22,6 @@
 #include <sysdeps/unix/powerpc/sysdep.h>
 #include <tls.h>
 
-/* Some systen calls got renamed over time, but retained the same semantics.
-   Handle them here so they can be catched by both C and assembler stubs in
-   glibc.  */
-
-#ifdef __NR_pwrite64
-# ifdef __NR_pwrite
-#  error "__NR_pwrite and __NR_pwrite64 both defined???"
-# endif
-# define __NR_pwrite __NR_pwrite64
-#endif
-
 /* 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/powerpc/powerpc64/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
index 6e27223..0b034cd 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
@@ -29,17 +29,6 @@
 #include <errno.h>
 #endif
 
-/* Some systen calls got renamed over time, but retained the same semantics.
-   Handle them here so they can be catched by both C and assembler stubs in
-   glibc.  */
-
-#ifdef __NR_pwrite64
-# ifdef __NR_pwrite
-#  error "__NR_pwrite and __NR_pwrite64 both defined???"
-# endif
-# define __NR_pwrite __NR_pwrite64
-#endif
-
 /* 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/pwrite.c b/sysdeps/unix/sysv/linux/pwrite.c
index d02862a..ca3014f 100644
--- a/sysdeps/unix/sysv/linux/pwrite.c
+++ b/sysdeps/unix/sysv/linux/pwrite.c
@@ -16,33 +16,22 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
-#include <errno.h>
-#include <endian.h>
 #include <unistd.h>
-
 #include <sysdep-cancel.h>
-#include <sys/syscall.h>
 
-#ifdef __NR_pwrite64		/* Newer kernels renamed but it's the same.  */
-# ifdef __NR_pwrite
-#  error "__NR_pwrite and __NR_pwrite64 both defined???"
-# endif
-# define __NR_pwrite __NR_pwrite64
-#endif
+#if __WORDSIZE != 64 || defined (__ASSUME_OFF_DIFF_OFF64)
 
+# ifndef __NR_pwrite
+#  define __NR_pwrite __NR_pwrite64
+# endif
 
 ssize_t
 __libc_pwrite (int fd, const void *buf, size_t count, off_t offset)
 {
-  ssize_t result;
-
-  assert (sizeof (offset) == 4);
-  result = SYSCALL_CANCEL (pwrite, fd, buf, count,
-			   __LONG_LONG_PAIR (offset >> 31, offset));
-
-  return result;
+  return SYSCALL_CANCEL (pwrite, fd, buf, count,
+			 __ALIGNMENT_ARG SYSCALL_LL (offset));
 }
 
 strong_alias (__libc_pwrite, __pwrite)
 weak_alias (__libc_pwrite, pwrite)
+#endif
diff --git a/sysdeps/unix/sysv/linux/pwrite64.c b/sysdeps/unix/sysv/linux/pwrite64.c
index d28e9b9..5a37701 100644
--- a/sysdeps/unix/sysv/linux/pwrite64.c
+++ b/sysdeps/unix/sysv/linux/pwrite64.c
@@ -16,28 +16,25 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <endian.h>
 #include <unistd.h>
-
 #include <sysdep-cancel.h>
-#include <sys/syscall.h>
 
-#ifdef __NR_pwrite64		/* Newer kernels renamed but it's the same.  */
-# ifdef __NR_pwrite
-#  error "__NR_pwrite and __NR_pwrite64 both defined???"
-# endif
-# define __NR_pwrite __NR_pwrite64
+#ifndef __NR_pwrite64
+# define __NR_pwrite64 __NR_pwrite
 #endif
 
-
 ssize_t
 __libc_pwrite64 (int fd, const void *buf, size_t count, off64_t offset)
 {
-  return SYSCALL_CANCEL (pwrite, fd, buf, count,
-			 __LONG_LONG_PAIR ((off_t) (offset >> 32),
-					   (off_t) (offset & 0xffffffff)));
+  return SYSCALL_CANCEL (pwrite64, fd, buf, count,
+			 __ALIGNMENT_ARG SYSCALL_LL64 (offset));
 }
 weak_alias (__libc_pwrite64, __pwrite64)
 libc_hidden_weak (__pwrite64)
 weak_alias (__libc_pwrite64, pwrite64)
+
+#if __WORDSIZE == 64 && !defined (__ASSUME_OFF_DIFF_OFF64)
+strong_alias (__libc_pwrite64, __libc_pwrite)
+weak_alias (__libc_pwrite64, __pwrite)
+weak_alias (__libc_pwrite64, pwrite)
+#endif
diff --git a/sysdeps/unix/sysv/linux/sh/pwrite.c b/sysdeps/unix/sysv/linux/sh/pwrite.c
index c27d356..391ed5e 100644
--- a/sysdeps/unix/sysv/linux/sh/pwrite.c
+++ b/sysdeps/unix/sysv/linux/sh/pwrite.c
@@ -16,28 +16,8 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
-#include <errno.h>
-#include <unistd.h>
-#include <endian.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-#ifdef __NR_pwrite64            /* Newer kernels renamed but it's the same.  */
-# ifdef __NR_pwrite
-#  error "__NR_pwrite and __NR_pwrite64 both defined???"
-# endif
-# define __NR_pwrite __NR_pwrite64
-#endif
-
-
-ssize_t
-__libc_pwrite (int fd, const void *buf, size_t count, off_t offset)
-{
-  return SYSCALL_CANCEL (pwrite, fd, buf, count, 0,
-			 __LONG_LONG_PAIR (offset >> 31, offset));
-}
-
-strong_alias (__libc_pwrite, __pwrite)
-weak_alias (__libc_pwrite, pwrite)
+/* SH4 ABI does not really require argument alignment for 64-bits, but
+   the kernel interface for pwrite adds a dummy long argument before the
+   offset.  */
+#define __ALIGNMENT_ARG
+#include <sysdeps/unix/sysv/linux/pwrite.c>
diff --git a/sysdeps/unix/sysv/linux/sh/pwrite64.c b/sysdeps/unix/sysv/linux/sh/pwrite64.c
index 7948cef..683a5d9 100644
--- a/sysdeps/unix/sysv/linux/sh/pwrite64.c
+++ b/sysdeps/unix/sysv/linux/sh/pwrite64.c
@@ -16,29 +16,8 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <unistd.h>
-#include <endian.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-#ifdef __NR_pwrite64            /* Newer kernels renamed but it's the same.  */
-# ifdef __NR_pwrite
-#  error "__NR_pwrite and __NR_pwrite64 both defined???"
-# endif
-# define __NR_pwrite __NR_pwrite64
-#endif
-
-
-ssize_t
-__libc_pwrite64 (int fd, const void *buf, size_t count, off64_t offset)
-{
-  return SYSCALL_CANCEL (pwrite, fd, buf, count, 0,
-			 __LONG_LONG_PAIR ((off_t) (offset >> 32),
-					   (off_t) (offset & 0xffffffff)));
-}
-
-weak_alias (__libc_pwrite64, __pwrite64)
-libc_hidden_weak (__pwrite64)
-weak_alias (__libc_pwrite64, pwrite64)
+/* SH4 ABI does not really require argument alignment for 64-bits, but
+   the kernel interface for pread adds a dummy long argument before the
+   offset.  */
+#define __ALIGNMENT_ARG
+#include <sysdeps/unix/sysv/linux/pwrite64.c>
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/pwrite64.c b/sysdeps/unix/sysv/linux/wordsize-64/pwrite64.c
deleted file mode 100644
index b7f298d..0000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/pwrite64.c
+++ /dev/null
@@ -1 +0,0 @@
-/* Empty since the pread syscall is equivalent.  */
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
index 7d5f6a5..2eb9419 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
@@ -3,7 +3,6 @@
 # Whee! 64-bit systems naturally implement llseek.
 llseek		EXTRA	lseek		i:iii	__libc_lseek	__lseek lseek __libc_lseek64 __llseek llseek __lseek64 lseek64
 lseek		llseek	-
-pwrite		-	pwrite		Ci:ibni	__libc_pwrite	__libc_pwrite64 __pwrite pwrite __pwrite64 pwrite64
 fstatfs		-	fstatfs		i:ip	__fstatfs	fstatfs fstatfs64 __fstatfs64
 statfs		-	statfs		i:sp	__statfs	statfs statfs64
 mmap		-	mmap		b:aniiii __mmap		mmap __mmap64 mmap64
-- 
1.9.1

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/4] Define __ASSUME_ALIGNED_REGISTER_PAIRS for missing ports
  2016-02-25 20:19 [PATCH v4 0/4] Cancellation entrypoint refactor Adhemerval Zanella
  2016-02-25 20:19 ` [PATCH 3/4] Consolidate pread/pread64 implementations Adhemerval Zanella
@ 2016-02-25 20:19 ` Adhemerval Zanella
  2016-04-10  4:12   ` Mike Frysinger
  2016-02-25 20:19 ` [PATCH 4/4] Consolidate pwrite/pwrite64 implementations Adhemerval Zanella
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 20+ messages in thread
From: Adhemerval Zanella @ 2016-02-25 20:19 UTC (permalink / raw)
  To: libc-alpha

This patch defines __ASSUME_ALIGNED_REGISTER_PAIRS for the missing
ports that require 64-bit value (e.g., long long) to be aligned to
an even register pair in argument passing.

No code change is expected, tested with builds for powerpc32,
mips-o32, and armhf.

	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	(__ASSUME_ALIGNED_REGISTER_PAIRS): Define.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h
	[_MIPS_SIM == _ABIO32] (__ASSUME_ALIGNED_REGISTER_PAIRS): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
	[!__powerpc64__] (__ASSUME_ALIGNED_REGISTER_PAIRS): Likewise.
---
 sysdeps/unix/sysv/linux/arm/kernel-features.h     | 4 ++++
 sysdeps/unix/sysv/linux/mips/kernel-features.h    | 6 ++++++
 sysdeps/unix/sysv/linux/powerpc/kernel-features.h | 6 ++++++
 4 files changed, 25 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/arm/kernel-features.h b/sysdeps/unix/sysv/linux/arm/kernel-features.h
index 6f1606c..1bcc34d 100644
--- a/sysdeps/unix/sysv/linux/arm/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/arm/kernel-features.h
@@ -42,3 +42,7 @@
 # undef __ASSUME_REQUEUE_PI
 # undef __ASSUME_SET_ROBUST_LIST
 #endif
+
+/* Define this if your 32-bit syscall API requires 64-bit register
+   pairs to start with an even-number register.  */
+#define __ASSUME_ALIGNED_REGISTER_PAIRS	1
diff --git a/sysdeps/unix/sysv/linux/mips/kernel-features.h b/sysdeps/unix/sysv/linux/mips/kernel-features.h
index 83f7a47..ea6a914 100644
--- a/sysdeps/unix/sysv/linux/mips/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/mips/kernel-features.h
@@ -47,3 +47,9 @@
 # undef __ASSUME_REQUEUE_PI
 # undef __ASSUME_SET_ROBUST_LIST
 #endif
+
+/* Define this if your 32-bit syscall API requires 64-bit register
+   pairs to start with an even-number register.  */
+#if _MIPS_SIM == _ABIO32
+# define __ASSUME_ALIGNED_REGISTER_PAIRS	1
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
index 14807ad..6dcd77d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
@@ -57,4 +57,10 @@
 #endif
 #define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL	1
 
+/* Define this if your 32-bit syscall API requires 64-bit register
+   pairs to start with an even-number register.  */
+#ifndef __powerpc64__
+# define __ASSUME_ALIGNED_REGISTER_PAIRS	1
+#endif
+
 #include_next <kernel-features.h>
-- 
1.9.1

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v4 0/4] Cancellation entrypoint refactor
@ 2016-02-25 20:19 Adhemerval Zanella
  2016-02-25 20:19 ` [PATCH 3/4] Consolidate pread/pread64 implementations Adhemerval Zanella
                   ` (4 more replies)
  0 siblings, 5 replies; 20+ messages in thread
From: Adhemerval Zanella @ 2016-02-25 20:19 UTC (permalink / raw)
  To: libc-alpha

Hi all,

This is a respin on previous patch.  Changes from previous version:

 * Second and third patch are merge on second one: instead of adding
   the SYSCALL_LL{64} on generic Linux sysdep and make all ports
   include the header the patch now moves the __ALIGNMENT_{ARG,COUNT}
   to Linux sysdep and add the required definition on same header.

 * Some macro evaluation fixes on SYSCALL_LL{64} macro.

--

These patches are a subset of a larger patchset I am working with the
aim to both simplify both syscall cancellation entrypoints and its
definition.

The main aim is to remove the requirement of assembly macros definition
on syscall-cancel.h and instead use C code through SYSCALL_CANCEL
macro.  This both simplify a new port creation by removing arch-specific
code requirements and also make easier to adjust current ports to the
new cancellation mechanism.

To accomplish it the idea is remove all the syscall cancellation auto
generation through syscalls.list and remove all the multiple syscall
definition across multiple ports.  So for all the cancellation
entrypoints for linux will ending have a single C implementation on
sysdep/unix/sysv/linux.

The first patch add the __ASSUME_ALIGNED_REGISTER_PAIRS on the missing
architectures that have the ABI constraint but does not define it.  
Second patch adds a new macro to use along long long syscalls arguments
for 32-bits to currect split it 2 arguments.  The third and last patch
use these new macros to consolidate the pread and pwrite syscall
definition in only one implementation.


Adhemerval Zanella (4):
  Define __ASSUME_ALIGNED_REGISTER_PAIRS for missing ports
  Consolidate off_t/off64_t syscall argument passing
  Consolidate pread/pread64 implementations
  Consolidate pwrite/pwrite64 implementations

 ChangeLog                                          | 71 ++++++++++++++++++++++
 sysdeps/unix/sysv/linux/arm/kernel-features.h      |  4 ++
 sysdeps/unix/sysv/linux/arm/pread.c                | 36 -----------
 sysdeps/unix/sysv/linux/arm/pread64.c              | 37 -----------
 sysdeps/unix/sysv/linux/arm/pwrite.c               | 36 -----------
 sysdeps/unix/sysv/linux/arm/pwrite64.c             | 38 ------------
 sysdeps/unix/sysv/linux/generic/sysdep.h           | 10 ---
 .../unix/sysv/linux/generic/wordsize-32/pread.c    | 37 -----------
 .../unix/sysv/linux/generic/wordsize-32/pread64.c  | 34 -----------
 .../unix/sysv/linux/generic/wordsize-32/pwrite.c   | 36 -----------
 .../unix/sysv/linux/generic/wordsize-32/pwrite64.c | 35 -----------
 sysdeps/unix/sysv/linux/mips/kernel-features.h     | 13 ++++
 sysdeps/unix/sysv/linux/mips/pread.c               | 54 ----------------
 sysdeps/unix/sysv/linux/mips/pread64.c             | 50 ---------------
 sysdeps/unix/sysv/linux/mips/pwrite.c              | 54 ----------------
 sysdeps/unix/sysv/linux/mips/pwrite64.c            | 51 ----------------
 sysdeps/unix/sysv/linux/powerpc/kernel-features.h  |  6 ++
 sysdeps/unix/sysv/linux/powerpc/powerpc32/pread.c  | 34 -----------
 .../unix/sysv/linux/powerpc/powerpc32/pread64.c    | 35 -----------
 sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite.c | 35 -----------
 .../unix/sysv/linux/powerpc/powerpc32/pwrite64.c   | 36 -----------
 sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h | 18 ------
 sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h | 18 ------
 sysdeps/unix/sysv/linux/pread.c                    | 25 +++-----
 sysdeps/unix/sysv/linux/pread64.c                  | 23 +++----
 sysdeps/unix/sysv/linux/pwrite.c                   | 25 +++-----
 sysdeps/unix/sysv/linux/pwrite64.c                 | 23 +++----
 sysdeps/unix/sysv/linux/sh/pread.c                 | 30 ++-------
 sysdeps/unix/sysv/linux/sh/pread64.c               | 30 ++-------
 sysdeps/unix/sysv/linux/sh/pwrite.c                | 30 ++-------
 sysdeps/unix/sysv/linux/sh/pwrite64.c              | 31 ++--------
 sysdeps/unix/sysv/linux/sysdep.h                   | 23 +++++++
 sysdeps/unix/sysv/linux/wordsize-64/pread64.c      |  1 -
 sysdeps/unix/sysv/linux/wordsize-64/pwrite64.c     |  1 -
 sysdeps/unix/sysv/linux/wordsize-64/syscalls.list  |  2 -
 sysdeps/unix/sysv/linux/x86_64/kernel-features.h   |  6 ++
 36 files changed, 177 insertions(+), 851 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/arm/pread.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/pread64.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/pwrite.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/pwrite64.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/pread.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/pread64.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/pwrite.c
 delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/pwrite64.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/pread.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/pread64.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/pwrite.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/pwrite64.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/pread.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/pread64.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/pread64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/pwrite64.c

-- 
1.9.1

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 2/4] Consolidate off_t/off64_t syscall argument passing
  2016-02-25 20:19 [PATCH v4 0/4] Cancellation entrypoint refactor Adhemerval Zanella
                   ` (2 preceding siblings ...)
  2016-02-25 20:19 ` [PATCH 4/4] Consolidate pwrite/pwrite64 implementations Adhemerval Zanella
@ 2016-02-25 20:23 ` Adhemerval Zanella
  2016-04-10  4:14   ` Mike Frysinger
  2016-03-08  9:57 ` [PATCH v4 0/4] Cancellation entrypoint refactor Adhemerval Zanella
  4 siblings, 1 reply; 20+ messages in thread
From: Adhemerval Zanella @ 2016-02-25 20:23 UTC (permalink / raw)
  To: libc-alpha; +Cc: Adhemerval Zanella

From: Adhemerval Zanella <adhemerval.zanella@linaro.com>

This patch add three new macros (SYSCALL_LL, SYSCALL_LL64, and
__ASSUME_WORDSIZE64_ILP32) 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 macro
__ASSUME_WORDSIZE64_ILP32 is used by the ABI to define is uses 64-bit register
even if ABI is ILP32 (for instance x32 and mips64-n32).

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

	* sysdeps/unix/sysv/linux/generic/sysdep.h (__ALIGNMENT_ARG): Move
	definition.
	(__ALIGNMENT_COUNT): Likewise.
	* sysdeps/unix/sysv/linux/sysdep.h (__ALIGNMENT_ARG): To here.
	(__ALIGNMENT_COUNT): Likewise.
	(SYSCALL_LL): New define.
	(SYSCALL_LL64): Likewise.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h:
	[_MIPS_SIM == _ABIO32] (__ASSUME_WORDSIZE64_ILP32): Define.
	* sysdeps/unix/sysv/linux/x86_64/kernel-features.h:
	[ILP32] (__ASUME_WORDSIZE64_ILP32): Likewise.
---
 sysdeps/unix/sysv/linux/generic/sysdep.h         | 10 ----------
 sysdeps/unix/sysv/linux/mips/kernel-features.h   |  6 ++++++
 sysdeps/unix/sysv/linux/sysdep.h                 | 23 +++++++++++++++++++++++
 sysdeps/unix/sysv/linux/x86_64/kernel-features.h |  6 ++++++
 5 files changed, 47 insertions(+), 10 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/generic/sysdep.h b/sysdeps/unix/sysv/linux/generic/sysdep.h
index 4f2c65d..b0422ff 100644
--- a/sysdeps/unix/sysv/linux/generic/sysdep.h
+++ b/sysdeps/unix/sysv/linux/generic/sysdep.h
@@ -31,13 +31,3 @@
 #define __NR_pread __NR_pread64
 #define __NR_pwrite __NR_pwrite64
 #endif
-
-/* Provide a dummy argument that can be used to force register
-   alignment for register pairs if required by the syscall ABI.  */
-#ifdef __ASSUME_ALIGNED_REGISTER_PAIRS
-#define __ALIGNMENT_ARG 0,
-#define __ALIGNMENT_COUNT(a,b) b
-#else
-#define __ALIGNMENT_ARG
-#define __ALIGNMENT_COUNT(a,b) a
-#endif
diff --git a/sysdeps/unix/sysv/linux/mips/kernel-features.h b/sysdeps/unix/sysv/linux/mips/kernel-features.h
index ea6a914..17ab696 100644
--- a/sysdeps/unix/sysv/linux/mips/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/mips/kernel-features.h
@@ -53,3 +53,9 @@
 #if _MIPS_SIM == _ABIO32
 # define __ASSUME_ALIGNED_REGISTER_PAIRS	1
 #endif
+
+/* Define that mips64-n32 is a ILP32 ABI to set the correct interface to
+   pass 64-bits values through syscalls.  */
+#if _MIPS_SIM == _ABIN32
+# define __ASSUME_WORDSIZE64_ILP32	1
+#endif
diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h
index c98fc3a..5ee73d5 100644
--- a/sysdeps/unix/sysv/linux/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sysdep.h
@@ -15,6 +15,8 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#include <bits/wordsize.h>
+
 /* Set error number and return -1.  A target may choose to return the
    internal function, __syscall_error, which sets errno and returns -1.
    We use -1l, instead of -1, so that it can be casted to (void *).  */
@@ -23,3 +25,24 @@
     __set_errno (err);				\
     -1l;					\
   })
+
+/* Provide a dummy argument that can be used to force register
+   alignment for register pairs if required by the syscall ABI.  */
+#ifdef __ASSUME_ALIGNED_REGISTER_PAIRS
+#define __ALIGNMENT_ARG 0,
+#define __ALIGNMENT_COUNT(a,b) b
+#else
+#define __ALIGNMENT_ARG
+#define __ALIGNMENT_COUNT(a,b) a
+#endif
+
+/* Provide a common macro to pass 64-bit value on syscalls.  */
+#if __WORDSIZE == 64 || defined __ASSUME_WORDSIZE64_ILP32
+# define SYSCALL_LL(val)   (val)
+# define SYSCALL_LL64(val) (val)
+#else
+#define SYSCALL_LL(val)   \
+  __LONG_LONG_PAIR ((val) >> 31, __val)
+#define SYSCALL_LL64(val) \
+  __LONG_LONG_PAIR ((long) ((val) >> 32), (long) ((val) & 0xffffffff))
+#endif
diff --git a/sysdeps/unix/sysv/linux/x86_64/kernel-features.h b/sysdeps/unix/sysv/linux/x86_64/kernel-features.h
index 0b84f11..569e8f8 100644
--- a/sysdeps/unix/sysv/linux/x86_64/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/x86_64/kernel-features.h
@@ -35,4 +35,10 @@
 # define __ASSUME_GETCPU_SYSCALL	1
 #endif
 
+/* Define that x32 is a ILP32 ABI to set the correct interface to pass
+   64-bits values through syscalls.  */
+#ifdef __ILP32__
+# define __ASSUME_WORDSIZE64_ILP32	1
+#endif
+
 #include_next <kernel-features.h>
-- 
1.9.1

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v4 0/4] Cancellation entrypoint refactor
  2016-02-25 20:19 [PATCH v4 0/4] Cancellation entrypoint refactor Adhemerval Zanella
                   ` (3 preceding siblings ...)
  2016-02-25 20:23 ` [PATCH 2/4] Consolidate off_t/off64_t syscall argument passing Adhemerval Zanella
@ 2016-03-08  9:57 ` Adhemerval Zanella
  4 siblings, 0 replies; 20+ messages in thread
From: Adhemerval Zanella @ 2016-03-08  9:57 UTC (permalink / raw)
  To: libc-alpha

Ping.

On 26-02-2016 03:19, Adhemerval Zanella wrote:
> Hi all,
> 
> This is a respin on previous patch.  Changes from previous version:
> 
>  * Second and third patch are merge on second one: instead of adding
>    the SYSCALL_LL{64} on generic Linux sysdep and make all ports
>    include the header the patch now moves the __ALIGNMENT_{ARG,COUNT}
>    to Linux sysdep and add the required definition on same header.
> 
>  * Some macro evaluation fixes on SYSCALL_LL{64} macro.
> 
> --
> 
> These patches are a subset of a larger patchset I am working with the
> aim to both simplify both syscall cancellation entrypoints and its
> definition.
> 
> The main aim is to remove the requirement of assembly macros definition
> on syscall-cancel.h and instead use C code through SYSCALL_CANCEL
> macro.  This both simplify a new port creation by removing arch-specific
> code requirements and also make easier to adjust current ports to the
> new cancellation mechanism.
> 
> To accomplish it the idea is remove all the syscall cancellation auto
> generation through syscalls.list and remove all the multiple syscall
> definition across multiple ports.  So for all the cancellation
> entrypoints for linux will ending have a single C implementation on
> sysdep/unix/sysv/linux.
> 
> The first patch add the __ASSUME_ALIGNED_REGISTER_PAIRS on the missing
> architectures that have the ABI constraint but does not define it.  
> Second patch adds a new macro to use along long long syscalls arguments
> for 32-bits to currect split it 2 arguments.  The third and last patch
> use these new macros to consolidate the pread and pwrite syscall
> definition in only one implementation.
> 
> 
> Adhemerval Zanella (4):
>   Define __ASSUME_ALIGNED_REGISTER_PAIRS for missing ports
>   Consolidate off_t/off64_t syscall argument passing
>   Consolidate pread/pread64 implementations
>   Consolidate pwrite/pwrite64 implementations
> 
>  ChangeLog                                          | 71 ++++++++++++++++++++++
>  sysdeps/unix/sysv/linux/arm/kernel-features.h      |  4 ++
>  sysdeps/unix/sysv/linux/arm/pread.c                | 36 -----------
>  sysdeps/unix/sysv/linux/arm/pread64.c              | 37 -----------
>  sysdeps/unix/sysv/linux/arm/pwrite.c               | 36 -----------
>  sysdeps/unix/sysv/linux/arm/pwrite64.c             | 38 ------------
>  sysdeps/unix/sysv/linux/generic/sysdep.h           | 10 ---
>  .../unix/sysv/linux/generic/wordsize-32/pread.c    | 37 -----------
>  .../unix/sysv/linux/generic/wordsize-32/pread64.c  | 34 -----------
>  .../unix/sysv/linux/generic/wordsize-32/pwrite.c   | 36 -----------
>  .../unix/sysv/linux/generic/wordsize-32/pwrite64.c | 35 -----------
>  sysdeps/unix/sysv/linux/mips/kernel-features.h     | 13 ++++
>  sysdeps/unix/sysv/linux/mips/pread.c               | 54 ----------------
>  sysdeps/unix/sysv/linux/mips/pread64.c             | 50 ---------------
>  sysdeps/unix/sysv/linux/mips/pwrite.c              | 54 ----------------
>  sysdeps/unix/sysv/linux/mips/pwrite64.c            | 51 ----------------
>  sysdeps/unix/sysv/linux/powerpc/kernel-features.h  |  6 ++
>  sysdeps/unix/sysv/linux/powerpc/powerpc32/pread.c  | 34 -----------
>  .../unix/sysv/linux/powerpc/powerpc32/pread64.c    | 35 -----------
>  sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite.c | 35 -----------
>  .../unix/sysv/linux/powerpc/powerpc32/pwrite64.c   | 36 -----------
>  sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h | 18 ------
>  sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h | 18 ------
>  sysdeps/unix/sysv/linux/pread.c                    | 25 +++-----
>  sysdeps/unix/sysv/linux/pread64.c                  | 23 +++----
>  sysdeps/unix/sysv/linux/pwrite.c                   | 25 +++-----
>  sysdeps/unix/sysv/linux/pwrite64.c                 | 23 +++----
>  sysdeps/unix/sysv/linux/sh/pread.c                 | 30 ++-------
>  sysdeps/unix/sysv/linux/sh/pread64.c               | 30 ++-------
>  sysdeps/unix/sysv/linux/sh/pwrite.c                | 30 ++-------
>  sysdeps/unix/sysv/linux/sh/pwrite64.c              | 31 ++--------
>  sysdeps/unix/sysv/linux/sysdep.h                   | 23 +++++++
>  sysdeps/unix/sysv/linux/wordsize-64/pread64.c      |  1 -
>  sysdeps/unix/sysv/linux/wordsize-64/pwrite64.c     |  1 -
>  sysdeps/unix/sysv/linux/wordsize-64/syscalls.list  |  2 -
>  sysdeps/unix/sysv/linux/x86_64/kernel-features.h   |  6 ++
>  36 files changed, 177 insertions(+), 851 deletions(-)
>  delete mode 100644 sysdeps/unix/sysv/linux/arm/pread.c
>  delete mode 100644 sysdeps/unix/sysv/linux/arm/pread64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/arm/pwrite.c
>  delete mode 100644 sysdeps/unix/sysv/linux/arm/pwrite64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/pread.c
>  delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/pread64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/pwrite.c
>  delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/pwrite64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/mips/pread.c
>  delete mode 100644 sysdeps/unix/sysv/linux/mips/pread64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/mips/pwrite.c
>  delete mode 100644 sysdeps/unix/sysv/linux/mips/pwrite64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/pread.c
>  delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/pread64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite.c
>  delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/pwrite64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/pread64.c
>  delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/pwrite64.c
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/4] Define __ASSUME_ALIGNED_REGISTER_PAIRS for missing ports
  2016-02-25 20:19 ` [PATCH 1/4] Define __ASSUME_ALIGNED_REGISTER_PAIRS for missing ports Adhemerval Zanella
@ 2016-04-10  4:12   ` Mike Frysinger
  2016-04-11 12:17     ` Adhemerval Zanella
  0 siblings, 1 reply; 20+ messages in thread
From: Mike Frysinger @ 2016-04-10  4:12 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 484 bytes --]

On 25 Feb 2016 17:19, Adhemerval Zanella wrote:
> --- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
>  
> +/* Define this if your 32-bit syscall API requires 64-bit register
> +   pairs to start with an even-number register.  */
> +#ifndef __powerpc64__
> +# define __ASSUME_ALIGNED_REGISTER_PAIRS	1
> +#endif

i'm not familiar with the ABI at this level, but does this also apply
to the new LE ABI ?
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/4] Consolidate off_t/off64_t syscall argument passing
  2016-02-25 20:23 ` [PATCH 2/4] Consolidate off_t/off64_t syscall argument passing Adhemerval Zanella
@ 2016-04-10  4:14   ` Mike Frysinger
  2016-04-11 12:18     ` Adhemerval Zanella
  0 siblings, 1 reply; 20+ messages in thread
From: Mike Frysinger @ 2016-04-10  4:14 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha, Adhemerval Zanella

[-- Attachment #1: Type: text/plain, Size: 545 bytes --]

On 25 Feb 2016 17:19, Adhemerval Zanella wrote:
> --- a/sysdeps/unix/sysv/linux/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/sysdep.h
>
> +/* Provide a dummy argument that can be used to force register
> +   alignment for register pairs if required by the syscall ABI.  */
> +#ifdef __ASSUME_ALIGNED_REGISTER_PAIRS
> +#define __ALIGNMENT_ARG 0,
> +#define __ALIGNMENT_COUNT(a,b) b
> +#else
> +#define __ALIGNMENT_ARG
> +#define __ALIGNMENT_COUNT(a,b) a
> +#endif

while not a new issue, should the return be parenthesized ?
i.e. (b) and (a) ?
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/4] Consolidate pread/pread64 implementations
  2016-02-25 20:19 ` [PATCH 3/4] Consolidate pread/pread64 implementations Adhemerval Zanella
@ 2016-04-10  4:15   ` Mike Frysinger
  2016-04-14 18:54   ` Florian Weimer
  1 sibling, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2016-04-10  4:15 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha, Adhemerval Zanella

[-- Attachment #1: Type: text/plain, Size: 527 bytes --]

On 25 Feb 2016 17:19, Adhemerval Zanella wrote:
> This patch consolidates all the pread/pread64 implementation for Linux
> in only one (sysdeps/unix/sysv/linux/pread.c).  It also removes the
> syscall from the auto-generation using assembly macros.
> 
> For pread{64} offset argument placement the new SYSCALL_LL{64} macro
> is used.  For pread ports that do not define __NR_pread will use
> __NR_pread64 and for pread64 ports that dot define __NR_pread64 will
> use __NR_pread for the syscall.

seems OK now
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 4/4] Consolidate pwrite/pwrite64 implementations
  2016-02-25 20:19 ` [PATCH 4/4] Consolidate pwrite/pwrite64 implementations Adhemerval Zanella
@ 2016-04-10  4:16   ` Mike Frysinger
  0 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2016-04-10  4:16 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha, Adhemerval Zanella

[-- Attachment #1: Type: text/plain, Size: 541 bytes --]

On 25 Feb 2016 17:19, Adhemerval Zanella wrote:
> This patch consolidates all the pwrite/pwrite64 implementation for Linux
> in only one (sysdeps/unix/sysv/linux/pwrite{64}.c).  It also removes the
> syscall from the auto-generation using assembly macros.
> 
> For pwrite{64} offset argument placement the new SYSCALL_LL{64} macro
> is used.  For pwrite ports that do not define __NR_pwrite will use
> __NR_pwrite64 and for pwrite64 ports that dot define __NR_pwrite64 will
> use __NR_pwrite for the syscall.

seems OK now
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/4] Define __ASSUME_ALIGNED_REGISTER_PAIRS for missing ports
  2016-04-10  4:12   ` Mike Frysinger
@ 2016-04-11 12:17     ` Adhemerval Zanella
  0 siblings, 0 replies; 20+ messages in thread
From: Adhemerval Zanella @ 2016-04-11 12:17 UTC (permalink / raw)
  To: libc-alpha



On 10-04-2016 01:12, Mike Frysinger wrote:
> On 25 Feb 2016 17:19, Adhemerval Zanella wrote:
>> --- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
>> +++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
>>  
>> +/* Define this if your 32-bit syscall API requires 64-bit register
>> +   pairs to start with an even-number register.  */
>> +#ifndef __powerpc64__
>> +# define __ASSUME_ALIGNED_REGISTER_PAIRS	1
>> +#endif
> 
> i'm not familiar with the ABI at this level, but does this also apply
> to the new LE ABI ?
> -mike
> 

New LE ABI is just for 64-bits.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/4] Consolidate off_t/off64_t syscall argument passing
  2016-04-10  4:14   ` Mike Frysinger
@ 2016-04-11 12:18     ` Adhemerval Zanella
  2016-04-11 13:07       ` Adhemerval Zanella
  0 siblings, 1 reply; 20+ messages in thread
From: Adhemerval Zanella @ 2016-04-11 12:18 UTC (permalink / raw)
  To: libc-alpha, Adhemerval Zanella



On 10-04-2016 01:14, Mike Frysinger wrote:
> On 25 Feb 2016 17:19, Adhemerval Zanella wrote:
>> --- a/sysdeps/unix/sysv/linux/sysdep.h
>> +++ b/sysdeps/unix/sysv/linux/sysdep.h
>>
>> +/* Provide a dummy argument that can be used to force register
>> +   alignment for register pairs if required by the syscall ABI.  */
>> +#ifdef __ASSUME_ALIGNED_REGISTER_PAIRS
>> +#define __ALIGNMENT_ARG 0,
>> +#define __ALIGNMENT_COUNT(a,b) b
>> +#else
>> +#define __ALIGNMENT_ARG
>> +#define __ALIGNMENT_COUNT(a,b) a
>> +#endif
> 
> while not a new issue, should the return be parenthesized ?
> i.e. (b) and (a) ?
> -mike
> 

I will change that, thanks.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/4] Consolidate off_t/off64_t syscall argument passing
  2016-04-11 12:18     ` Adhemerval Zanella
@ 2016-04-11 13:07       ` Adhemerval Zanella
  0 siblings, 0 replies; 20+ messages in thread
From: Adhemerval Zanella @ 2016-04-11 13:07 UTC (permalink / raw)
  To: libc-alpha, Adhemerval Zanella



On 11-04-2016 09:17, Adhemerval Zanella wrote:
> 
> 
> On 10-04-2016 01:14, Mike Frysinger wrote:
>> On 25 Feb 2016 17:19, Adhemerval Zanella wrote:
>>> --- a/sysdeps/unix/sysv/linux/sysdep.h
>>> +++ b/sysdeps/unix/sysv/linux/sysdep.h
>>>
>>> +/* Provide a dummy argument that can be used to force register
>>> +   alignment for register pairs if required by the syscall ABI.  */
>>> +#ifdef __ASSUME_ALIGNED_REGISTER_PAIRS
>>> +#define __ALIGNMENT_ARG 0,
>>> +#define __ALIGNMENT_COUNT(a,b) b
>>> +#else
>>> +#define __ALIGNMENT_ARG
>>> +#define __ALIGNMENT_COUNT(a,b) a
>>> +#endif
>>
>> while not a new issue, should the return be parenthesized ?
>> i.e. (b) and (a) ?
>> -mike
>>
> 
> I will change that, thanks.

In fact we can not change it: some functions uses the define as
__ALIGNMENT_COUNT (3, 4) and some ports uses to correct select
the LOAD_ARGS_{3,4} in syscall generation (nios2).  Using 
parenthesis leads it to evaluate as LOAD_ARGS_(3) and this
issuing a build issue (this can be fixed I think, but it is
not the idea of this patch).

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/4] Consolidate pread/pread64 implementations
  2016-02-25 20:19 ` [PATCH 3/4] Consolidate pread/pread64 implementations Adhemerval Zanella
  2016-04-10  4:15   ` Mike Frysinger
@ 2016-04-14 18:54   ` Florian Weimer
  2016-04-14 19:38     ` Adhemerval Zanella
  1 sibling, 1 reply; 20+ messages in thread
From: Florian Weimer @ 2016-04-14 18:54 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha, Adhemerval Zanella

On 02/25/2016 09:19 PM, Adhemerval Zanella wrote:
> From: Adhemerval Zanella<adhemerval.zanella@linaro.com>
>
> This patch consolidates all the pread/pread64 implementation for Linux
> in only one (sysdeps/unix/sysv/linux/pread.c).  It also removes the
> syscall from the auto-generation using assembly macros.

This may have broken pread and pread64 on 32-bit arm.  I'm trying to get 
more details.

FAIL: debug/tst-chk1
FAIL: debug/tst-chk2
FAIL: debug/tst-chk3
FAIL: debug/tst-chk4
FAIL: debug/tst-chk5
FAIL: debug/tst-chk6
FAIL: debug/tst-lfschk1
FAIL: debug/tst-lfschk2
FAIL: debug/tst-lfschk3
FAIL: debug/tst-lfschk4
FAIL: debug/tst-lfschk5
FAIL: debug/tst-lfschk6
FAIL: posix/tst-preadwrite
FAIL: posix/tst-preadwrite64

The debug/* failures have:

Failure on line 1006
Failure on line 1009
Failure on line 1013
Failure on line 1032
Failure on line 1035
Failure on line 1039

Also corresponding to pread, pread64.

Florian

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/4] Consolidate pread/pread64 implementations
  2016-04-14 18:54   ` Florian Weimer
@ 2016-04-14 19:38     ` Adhemerval Zanella
  2016-04-14 20:54       ` Florian Weimer
  0 siblings, 1 reply; 20+ messages in thread
From: Adhemerval Zanella @ 2016-04-14 19:38 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha, Adhemerval Zanella



On 14-04-2016 15:54, Florian Weimer wrote:
> On 02/25/2016 09:19 PM, Adhemerval Zanella wrote:
>> From: Adhemerval Zanella<adhemerval.zanella@linaro.com>
>>
>> This patch consolidates all the pread/pread64 implementation for Linux
>> in only one (sysdeps/unix/sysv/linux/pread.c).  It also removes the
>> syscall from the auto-generation using assembly macros.
> 
> This may have broken pread and pread64 on 32-bit arm.  I'm trying to get more details.
> 
> FAIL: debug/tst-chk1
> FAIL: debug/tst-chk2
> FAIL: debug/tst-chk3
> FAIL: debug/tst-chk4
> FAIL: debug/tst-chk5
> FAIL: debug/tst-chk6
> FAIL: debug/tst-lfschk1
> FAIL: debug/tst-lfschk2
> FAIL: debug/tst-lfschk3
> FAIL: debug/tst-lfschk4
> FAIL: debug/tst-lfschk5
> FAIL: debug/tst-lfschk6
> FAIL: posix/tst-preadwrite
> FAIL: posix/tst-preadwrite64
> 
> The debug/* failures have:
> 
> Failure on line 1006
> Failure on line 1009
> Failure on line 1013
> Failure on line 1032
> Failure on line 1035
> Failure on line 1039
> 
> Also corresponding to pread, pread64.
> 
> Florian

It is because sysdeps/unix/sysv/linux/sysdep.h now requires if
__ASSUME_ALIGNED_REGISTER_PAIRS is defined or not to correctly
set __ALIGNMENT_ARG and __ALIGNMENT_COUNT.

Previously arm pread64 set a 0 after the count argument, which
is not set by __ALIGNMENT_ARG.  The following patch fixes it:

---

diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h
index 4ac4c00..f2d7e05 100644
--- a/sysdeps/unix/sysv/linux/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sysdep.h
@@ -16,6 +16,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <bits/wordsize.h>
+#include <kernel-features.h>
 
 /* Set error number and return -1.  A target may choose to return the
    internal function, __syscall_error, which sets errno and returns -1.

---

This was an overlook from my part: the __ALIGNMENT_{ARG,COUNT} definition
was moved from another header to this one in a patch iteration and I did
not care to actually remake the tests on arm to check if everthing was ok.

I will push it soon.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/4] Consolidate pread/pread64 implementations
  2016-04-14 19:38     ` Adhemerval Zanella
@ 2016-04-14 20:54       ` Florian Weimer
  0 siblings, 0 replies; 20+ messages in thread
From: Florian Weimer @ 2016-04-14 20:54 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha, Adhemerval Zanella

On 04/14/2016 09:38 PM, Adhemerval Zanella wrote:

> This was an overlook from my part: the __ALIGNMENT_{ARG,COUNT} definition
> was moved from another header to this one in a patch iteration and I did
> not care to actually remake the tests on arm to check if everthing was ok.
>
> I will push it soon.

I've verified that the master branch no longer has the test suite 
failures.  Thanks for fixing this so quickly.

Florian

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/4] Define __ASSUME_ALIGNED_REGISTER_PAIRS for missing ports
  2016-02-23 15:17 [PATCH v2 " Adhemerval Zanella
@ 2016-02-23 15:17 ` Adhemerval Zanella
  0 siblings, 0 replies; 20+ messages in thread
From: Adhemerval Zanella @ 2016-02-23 15:17 UTC (permalink / raw)
  To: libc-alpha

This patch defines __ASSUME_ALIGNED_REGISTER_PAIRS for the missing
ports that require 64-bit value (e.g., long long) to be aligned to
an even register pair in argument passing.

No code change is expected, tested with builds for powerpc32,
mips-o32, and armhf.

	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	(__ASSUME_ALIGNED_REGISTER_PAIRS): Define.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h
	[_MIPS_SIM == _ABIO32] (__ASSUME_ALIGNED_REGISTER_PAIRS): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
	[!__powerpc64__] (__ASSUME_ALIGNED_REGISTER_PAIRS): Likewise.
---
 sysdeps/unix/sysv/linux/arm/kernel-features.h     | 4 ++++
 sysdeps/unix/sysv/linux/mips/kernel-features.h    | 6 ++++++
 sysdeps/unix/sysv/linux/powerpc/kernel-features.h | 6 ++++++
 4 files changed, 25 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/arm/kernel-features.h b/sysdeps/unix/sysv/linux/arm/kernel-features.h
index 6f1606c..1bcc34d 100644
--- a/sysdeps/unix/sysv/linux/arm/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/arm/kernel-features.h
@@ -42,3 +42,7 @@
 # undef __ASSUME_REQUEUE_PI
 # undef __ASSUME_SET_ROBUST_LIST
 #endif
+
+/* Define this if your 32-bit syscall API requires 64-bit register
+   pairs to start with an even-number register.  */
+#define __ASSUME_ALIGNED_REGISTER_PAIRS	1
diff --git a/sysdeps/unix/sysv/linux/mips/kernel-features.h b/sysdeps/unix/sysv/linux/mips/kernel-features.h
index 83f7a47..ea6a914 100644
--- a/sysdeps/unix/sysv/linux/mips/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/mips/kernel-features.h
@@ -47,3 +47,9 @@
 # undef __ASSUME_REQUEUE_PI
 # undef __ASSUME_SET_ROBUST_LIST
 #endif
+
+/* Define this if your 32-bit syscall API requires 64-bit register
+   pairs to start with an even-number register.  */
+#if _MIPS_SIM == _ABIO32
+# define __ASSUME_ALIGNED_REGISTER_PAIRS	1
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
index 14807ad..6dcd77d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
@@ -57,4 +57,10 @@
 #endif
 #define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL	1
 
+/* Define this if your 32-bit syscall API requires 64-bit register
+   pairs to start with an even-number register.  */
+#ifndef __powerpc64__
+# define __ASSUME_ALIGNED_REGISTER_PAIRS	1
+#endif
+
 #include_next <kernel-features.h>
-- 
1.9.1

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/4] Define __ASSUME_ALIGNED_REGISTER_PAIRS for missing ports
  2016-01-07 17:18 ` [PATCH 1/4] Define __ASSUME_ALIGNED_REGISTER_PAIRS for missing ports Adhemerval Zanella
@ 2016-01-07 19:53   ` Mike Frysinger
  0 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2016-01-07 19:53 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 150 bytes --]

On 07 Jan 2016 15:18, Adhemerval Zanella wrote:
> +#if _MIPS_SIM == _ABIO32
> +#define __ASSUME_ALIGNED_REGISTER_PAIRS	1

indent by one space ?
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/4] Define __ASSUME_ALIGNED_REGISTER_PAIRS for missing ports
  2016-01-07 17:18 [PATCH 0/4] Cancellation entrypoint refactor Adhemerval Zanella
@ 2016-01-07 17:18 ` Adhemerval Zanella
  2016-01-07 19:53   ` Mike Frysinger
  0 siblings, 1 reply; 20+ messages in thread
From: Adhemerval Zanella @ 2016-01-07 17:18 UTC (permalink / raw)
  To: libc-alpha

This patch defines __ASSUME_ALIGNED_REGISTER_PAIRS for the missing
ports that require 64-bit value (e.g., long long) to be aligned to
an even register pair in argument passing.

No code change is expected, tested with builds for powerpc32,
mips-o32, and armhf.

	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	(__ASSUME_ALIGNED_REGISTER_PAIRS): Define.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h
	[_MIPS_SIM == _ABIO32] (__ASSUME_ALIGNED_REGISTER_PAIRS): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
	[!__powerpc64__] (__ASSUME_ALIGNED_REGISTER_PAIRS): Likewise.
---
 ChangeLog                                         | 9 +++++++++
 sysdeps/unix/sysv/linux/arm/kernel-features.h     | 4 ++++
 sysdeps/unix/sysv/linux/mips/kernel-features.h    | 6 ++++++
 sysdeps/unix/sysv/linux/powerpc/kernel-features.h | 6 ++++++
 4 files changed, 25 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/arm/kernel-features.h b/sysdeps/unix/sysv/linux/arm/kernel-features.h
index 6f1606c..1bcc34d 100644
--- a/sysdeps/unix/sysv/linux/arm/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/arm/kernel-features.h
@@ -42,3 +42,7 @@
 # undef __ASSUME_REQUEUE_PI
 # undef __ASSUME_SET_ROBUST_LIST
 #endif
+
+/* Define this if your 32-bit syscall API requires 64-bit register
+   pairs to start with an even-number register.  */
+#define __ASSUME_ALIGNED_REGISTER_PAIRS	1
diff --git a/sysdeps/unix/sysv/linux/mips/kernel-features.h b/sysdeps/unix/sysv/linux/mips/kernel-features.h
index 83f7a47..586871d 100644
--- a/sysdeps/unix/sysv/linux/mips/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/mips/kernel-features.h
@@ -47,3 +47,9 @@
 # undef __ASSUME_REQUEUE_PI
 # undef __ASSUME_SET_ROBUST_LIST
 #endif
+
+/* Define this if your 32-bit syscall API requires 64-bit register
+   pairs to start with an even-number register.  */
+#if _MIPS_SIM == _ABIO32
+#define __ASSUME_ALIGNED_REGISTER_PAIRS	1
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
index 14807ad..6dcd77d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
@@ -57,4 +57,10 @@
 #endif
 #define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL	1
 
+/* Define this if your 32-bit syscall API requires 64-bit register
+   pairs to start with an even-number register.  */
+#ifndef __powerpc64__
+# define __ASSUME_ALIGNED_REGISTER_PAIRS	1
+#endif
+
 #include_next <kernel-features.h>
-- 
1.9.1

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/4] Define __ASSUME_ALIGNED_REGISTER_PAIRS for missing ports
  2015-11-18 14:03 [PATCH 0/4] Cancellation entrypoint refactor Adhemerval Zanella
@ 2015-11-18 14:02 ` Adhemerval Zanella
  0 siblings, 0 replies; 20+ messages in thread
From: Adhemerval Zanella @ 2015-11-18 14:02 UTC (permalink / raw)
  To: libc-alpha

This patch defines __ASSUME_ALIGNED_REGISTER_PAIRS for the missing
ports that require 64-bit value (e.g., long long) to be aligned to
an even register pair in argument passing.

No code change is expected, tested with builds for powerpc32,
mips-o32, and armhf.

	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	(__ASSUME_ALIGNED_REGISTER_PAIRS): Define.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h
	[_MIPS_SIM == _ABIO32] (__ASSUME_ALIGNED_REGISTER_PAIRS): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
	[!__powerpc64__] (__ASSUME_ALIGNED_REGISTER_PAIRS): Likewise.
---
 sysdeps/unix/sysv/linux/arm/kernel-features.h     | 4 ++++
 sysdeps/unix/sysv/linux/mips/kernel-features.h    | 6 ++++++
 sysdeps/unix/sysv/linux/powerpc/kernel-features.h | 6 ++++++
 4 files changed, 25 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/arm/kernel-features.h b/sysdeps/unix/sysv/linux/arm/kernel-features.h
index cb407db..8aadbd9 100644
--- a/sysdeps/unix/sysv/linux/arm/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/arm/kernel-features.h
@@ -42,3 +42,7 @@
 # undef __ASSUME_REQUEUE_PI
 # undef __ASSUME_SET_ROBUST_LIST
 #endif
+
+/* Define this if your 32-bit syscall API requires 64-bit register
+   pairs to start with an even-number register.  */
+#define __ASSUME_ALIGNED_REGISTER_PAIRS	1
diff --git a/sysdeps/unix/sysv/linux/mips/kernel-features.h b/sysdeps/unix/sysv/linux/mips/kernel-features.h
index 50d9328..9080338 100644
--- a/sysdeps/unix/sysv/linux/mips/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/mips/kernel-features.h
@@ -47,3 +47,9 @@
 # undef __ASSUME_REQUEUE_PI
 # undef __ASSUME_SET_ROBUST_LIST
 #endif
+
+/* Define this if your 32-bit syscall API requires 64-bit register
+   pairs to start with an even-number register.  */
+#if _MIPS_SIM == _ABIO32
+#define __ASSUME_ALIGNED_REGISTER_PAIRS	1
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
index 8a536cf..83d36e8 100644
--- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
@@ -57,4 +57,10 @@
 #endif
 #define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL	1
 
+/* Define this if your 32-bit syscall API requires 64-bit register
+   pairs to start with an even-number register.  */
+#ifndef __powerpc64__
+# define __ASSUME_ALIGNED_REGISTER_PAIRS	1
+#endif
+
 #include_next <kernel-features.h>
-- 
1.9.1

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2016-04-14 20:54 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-25 20:19 [PATCH v4 0/4] Cancellation entrypoint refactor Adhemerval Zanella
2016-02-25 20:19 ` [PATCH 3/4] Consolidate pread/pread64 implementations Adhemerval Zanella
2016-04-10  4:15   ` Mike Frysinger
2016-04-14 18:54   ` Florian Weimer
2016-04-14 19:38     ` Adhemerval Zanella
2016-04-14 20:54       ` Florian Weimer
2016-02-25 20:19 ` [PATCH 1/4] Define __ASSUME_ALIGNED_REGISTER_PAIRS for missing ports Adhemerval Zanella
2016-04-10  4:12   ` Mike Frysinger
2016-04-11 12:17     ` Adhemerval Zanella
2016-02-25 20:19 ` [PATCH 4/4] Consolidate pwrite/pwrite64 implementations Adhemerval Zanella
2016-04-10  4:16   ` Mike Frysinger
2016-02-25 20:23 ` [PATCH 2/4] Consolidate off_t/off64_t syscall argument passing Adhemerval Zanella
2016-04-10  4:14   ` Mike Frysinger
2016-04-11 12:18     ` Adhemerval Zanella
2016-04-11 13:07       ` Adhemerval Zanella
2016-03-08  9:57 ` [PATCH v4 0/4] Cancellation entrypoint refactor Adhemerval Zanella
  -- strict thread matches above, loose matches on Subject: below --
2016-02-23 15:17 [PATCH v2 " Adhemerval Zanella
2016-02-23 15:17 ` [PATCH 1/4] Define __ASSUME_ALIGNED_REGISTER_PAIRS for missing ports Adhemerval Zanella
2016-01-07 17:18 [PATCH 0/4] Cancellation entrypoint refactor Adhemerval Zanella
2016-01-07 17:18 ` [PATCH 1/4] Define __ASSUME_ALIGNED_REGISTER_PAIRS for missing ports Adhemerval Zanella
2016-01-07 19:53   ` Mike Frysinger
2015-11-18 14:03 [PATCH 0/4] Cancellation entrypoint refactor Adhemerval Zanella
2015-11-18 14:02 ` [PATCH 1/4] Define __ASSUME_ALIGNED_REGISTER_PAIRS for missing ports Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).