diff mbox

[3/3] Consolidate posix_fallocate{64} implementations

Message ID 1467140654-5335-3-git-send-email-adhemerval.zanella@linaro.org
State New
Headers show

Commit Message

Adhemerval Zanella Netto June 28, 2016, 7:04 p.m. UTC
This patch consolidates all the posix_fallocate{64} implementation for Linux
in only one (sysdeps/unix/sysv/linux/posix_fallocate{64}.c).  It also removes
the syscall from the auto-generation using assembly macros.

The new macro SYSCALL_LL{64} is used to handle the offset argument.  For
INTERNAL_SYSCALL it would require pass to correct number of expect arguments
for macro call, so the same conditions that define SYSCALL_LL{64} is used
to set the correct argument number.  This could be a future cleanup in
{INTERNAL,INLINE}_SYSCALL (to avoid pass the argument number).

Tested on x86_64, i686, x32, and armhf.

        * sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate.c: Remove
        file.
        * sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate64.c:
        Likewise.
        * sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate.c: Likewise.
        * sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate64.c:
        Likewise.
        * sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c: Likewise.
        * sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate64.c: Likewise.
        * sysdeps/unix/sysv/linux/posix_fallocate.c (posix_fallocate): Use
        SYSCALL_LL to pass both offset and len arguments.
        * sysdeps/unix/sysv/linux/posix_fallocate64.c (posix_fallocate64):
        Likewise.
---
 ChangeLog                                          | 14 +++++++
 .../sysv/linux/mips/mips64/n32/posix_fallocate.c   | 37 -----------------
 .../sysv/linux/mips/mips64/n32/posix_fallocate64.c | 38 ------------------
 .../sysv/linux/mips/mips64/n64/posix_fallocate.c   |  1 -
 .../sysv/linux/mips/mips64/n64/posix_fallocate64.c |  1 -
 sysdeps/unix/sysv/linux/posix_fallocate.c          |  8 +++-
 sysdeps/unix/sysv/linux/posix_fallocate64.c        | 10 +++--
 .../unix/sysv/linux/wordsize-64/posix_fallocate.c  | 46 ----------------------
 .../sysv/linux/wordsize-64/posix_fallocate64.c     |  1 -
 9 files changed, 26 insertions(+), 130 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate64.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate64.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c
 delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate64.c
diff mbox

Patch

diff --git a/ChangeLog b/ChangeLog
index e2954e5..cac1d1d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@ 
 2016-06-28  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
+	* sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate.c: Remove
+	file.
+	* sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate64.c:
+	Likewise.
+	* sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate.c: Likewise.
+	* sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate64.c:
+	Likewise.
+	* sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c: Likewise.
+	* sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate64.c: Likewise.
+	* sysdeps/unix/sysv/linux/posix_fallocate.c (posix_fallocate): Use
+	SYSCALL_LL to pass both offset and len arguments.
+	* sysdeps/unix/sysv/linux/posix_fallocate64.c (posix_fallocate64):
+	Likewise.
+
 	* sysdeps/unix/sysv/linux/fallocate.c (fallocate): Use SYSCALL_LL
 	macro on offset argument.
 	* sysdeps/unix/sysv/linux/fallocate64.c (fallocate64): Use
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate.c b/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate.c
deleted file mode 100644
index e652e5b..0000000
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate.c
+++ /dev/null
@@ -1,37 +0,0 @@ 
-/* Copyright (C) 2007-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   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 <fcntl.h>
-#include <sysdep.h>
-
-#define posix_fallocate static internal_fallocate
-#include <sysdeps/posix/posix_fallocate.c>
-#undef posix_fallocate
-
-/* Reserve storage for the data of the file associated with FD.  */
-int
-posix_fallocate (int fd, __off_t offset, __off_t len)
-{
-  INTERNAL_SYSCALL_DECL (err);
-  int res = INTERNAL_SYSCALL (fallocate, err, 4, fd, 0, offset, len);
-
-  if (! INTERNAL_SYSCALL_ERROR_P (res, err))
-    return 0;
-  if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP)
-    return INTERNAL_SYSCALL_ERRNO (res, err);
-  return internal_fallocate (fd, offset, len);
-}
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate64.c b/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate64.c
deleted file mode 100644
index d5659e0..0000000
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fallocate64.c
+++ /dev/null
@@ -1,38 +0,0 @@ 
-/* Copyright (C) 2007-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   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 <fcntl.h>
-#include <sysdep.h>
-
-extern int __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len);
-#define __posix_fallocate64_l64 static internal_fallocate64
-#include <sysdeps/posix/posix_fallocate64.c>
-#undef __posix_fallocate64_l64
-
-/* Reserve storage for the data of the file associated with FD.  */
-int
-__posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len)
-{
-  INTERNAL_SYSCALL_DECL (err);
-  int res = INTERNAL_SYSCALL (fallocate, err, 4, fd, 0, offset, len);
-
-  if (! INTERNAL_SYSCALL_ERROR_P (res, err))
-    return 0;
-  if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP)
-    return INTERNAL_SYSCALL_ERRNO (res, err);
-  return internal_fallocate64 (fd, offset, len);
-}
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate.c b/sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate.c
deleted file mode 100644
index b3fe81b..0000000
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate.c
+++ /dev/null
@@ -1 +0,0 @@ 
-#include <sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c>
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate64.c b/sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate64.c
deleted file mode 100644
index f466f13..0000000
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate64.c
+++ /dev/null
@@ -1 +0,0 @@ 
-/* posix_fallocate64 is in posix_fallocate.c */
diff --git a/sysdeps/unix/sysv/linux/posix_fallocate.c b/sysdeps/unix/sysv/linux/posix_fallocate.c
index fc9ac37..de9d706 100644
--- a/sysdeps/unix/sysv/linux/posix_fallocate.c
+++ b/sysdeps/unix/sysv/linux/posix_fallocate.c
@@ -27,9 +27,13 @@  int
 posix_fallocate (int fd, __off_t offset, __off_t len)
 {
   INTERNAL_SYSCALL_DECL (err);
+#if __WORDSIZE == 64 || defined __ASSUME_WORDSIZE64_ILP32
+  int res = INTERNAL_SYSCALL (fallocate, err, 4, fd, 0,
+			      SYSCALL_LL (offset), SYSCALL_LL (len));
+# else
   int res = INTERNAL_SYSCALL (fallocate, err, 6, fd, 0,
-			      __LONG_LONG_PAIR (offset >> 31, offset),
-			      __LONG_LONG_PAIR (len >> 31, len));
+			      SYSCALL_LL (offset), SYSCALL_LL (len));
+# endif
 
   if (! INTERNAL_SYSCALL_ERROR_P (res, err))
     return 0;
diff --git a/sysdeps/unix/sysv/linux/posix_fallocate64.c b/sysdeps/unix/sysv/linux/posix_fallocate64.c
index 4a0a722..c85125a 100644
--- a/sysdeps/unix/sysv/linux/posix_fallocate64.c
+++ b/sysdeps/unix/sysv/linux/posix_fallocate64.c
@@ -28,11 +28,13 @@  int
 __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len)
 {
   INTERNAL_SYSCALL_DECL (err);
+#if __WORDSIZE == 64 || defined __ASSUME_WORDSIZE64_ILP32
+  int res = INTERNAL_SYSCALL (fallocate, err, 4, fd, 0,
+			      SYSCALL_LL64 (offset), SYSCALL_LL64 (len));
+#else
   int res = INTERNAL_SYSCALL (fallocate, err, 6, fd, 0,
-			      __LONG_LONG_PAIR ((long int) (offset >> 32),
-						(long int) offset),
-			      __LONG_LONG_PAIR ((long int) (len >> 32),
-						(long int) len));
+			      SYSCALL_LL64 (offset), SYSCALL_LL64 (len));
+#endif
 
   if (! INTERNAL_SYSCALL_ERROR_P (res, err))
     return 0;
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c b/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c
deleted file mode 100644
index 8caee31..0000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate.c
+++ /dev/null
@@ -1,46 +0,0 @@ 
-/* Copyright (C) 2007-2016 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   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 <fcntl.h>
-#include <sysdep.h>
-
-#define posix_fallocate static internal_fallocate
-#include <sysdeps/posix/posix_fallocate.c>
-#undef posix_fallocate
-
-/* Reserve storage for the data of the file associated with FD.  */
-int
-posix_fallocate (int fd, __off_t offset, __off_t len)
-{
-  INTERNAL_SYSCALL_DECL (err);
-#ifdef INTERNAL_SYSCALL_TYPES
-  int res = INTERNAL_SYSCALL_TYPES (fallocate, err, 4, int, fd,
-				    int, 0, off_t, offset,
-				    off_t, len);
-#else
-  int res = INTERNAL_SYSCALL (fallocate, err, 4, fd, 0, offset, len);
-#endif
-
-  if (! INTERNAL_SYSCALL_ERROR_P (res, err))
-    return 0;
-
-  if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP)
-    return INTERNAL_SYSCALL_ERRNO (res, err);
-
-  return internal_fallocate (fd, offset, len);
-}
-weak_alias (posix_fallocate, posix_fallocate64)
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate64.c b/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate64.c
deleted file mode 100644
index f466f13..0000000
--- a/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate64.c
+++ /dev/null
@@ -1 +0,0 @@ 
-/* posix_fallocate64 is in posix_fallocate.c */