From 45ff2bfcb34228ef8d36306a9691d1e540a6468a Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Fri, 19 Aug 2016 11:18:40 -0300 Subject: Consolidate posix_fallocate{64} implementations 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 macro SYSCALL_LL{64} is used to handle the offset argument along with the new INTERNAL_SYSCALL_CALL macro to define correct argument count for internal INTERNAL_SYSCALL call. Tested on x86_64, i686, x32, aarch64, ppc64le, and armhf. * io/Makefile (tests): Add tst-posix_fallocate and tst-posix_fallocate64. * io/tst-posix_fallocate-common.c: New file. * io/tst-posix_fallocate.c: Likewise. * io/tst-posix_fallocate64.c: Likewise. * 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/x86_64/syscalls.list (pwrite64): Add __libc_pwrite64 alias used by posix_fallocate64. --- .../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 | 6 +-- sysdeps/unix/sysv/linux/posix_fallocate64.c | 14 ++++--- .../unix/sysv/linux/wordsize-64/posix_fallocate.c | 46 ---------------------- .../sysv/linux/wordsize-64/posix_fallocate64.c | 1 - sysdeps/unix/sysv/linux/x86_64/syscalls.list | 2 +- 9 files changed, 11 insertions(+), 135 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 (limited to 'sysdeps/unix/sysv') 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 e652e5bec3..0000000000 --- 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 - . */ - -#include -#include - -#define posix_fallocate static internal_fallocate -#include -#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 d5659e0367..0000000000 --- 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 - . */ - -#include -#include - -extern int __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len); -#define __posix_fallocate64_l64 static internal_fallocate64 -#include -#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 b3fe81bc8c..0000000000 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fallocate.c +++ /dev/null @@ -1 +0,0 @@ -#include 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 f466f13e45..0000000000 --- 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 fc9ac37893..139cb562fe 100644 --- a/sysdeps/unix/sysv/linux/posix_fallocate.c +++ b/sysdeps/unix/sysv/linux/posix_fallocate.c @@ -27,10 +27,8 @@ int posix_fallocate (int fd, __off_t offset, __off_t len) { INTERNAL_SYSCALL_DECL (err); - int res = INTERNAL_SYSCALL (fallocate, err, 6, fd, 0, - __LONG_LONG_PAIR (offset >> 31, offset), - __LONG_LONG_PAIR (len >> 31, len)); - + int res = INTERNAL_SYSCALL_CALL (fallocate, err, fd, 0, + SYSCALL_LL (offset), SYSCALL_LL (len)); if (! INTERNAL_SYSCALL_ERROR_P (res, err)) return 0; if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP) diff --git a/sysdeps/unix/sysv/linux/posix_fallocate64.c b/sysdeps/unix/sysv/linux/posix_fallocate64.c index 4a0a722448..557580eea9 100644 --- a/sysdeps/unix/sysv/linux/posix_fallocate64.c +++ b/sysdeps/unix/sysv/linux/posix_fallocate64.c @@ -28,12 +28,14 @@ int __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len) { INTERNAL_SYSCALL_DECL (err); - 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)); - +#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_CALL (fallocate, err, fd, 0, + SYSCALL_LL64 (offset), SYSCALL_LL64 (len)); +#endif if (! INTERNAL_SYSCALL_ERROR_P (res, err)) return 0; if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP) 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 8caee318d5..0000000000 --- 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 - . */ - -#include -#include - -#define posix_fallocate static internal_fallocate -#include -#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 f466f13e45..0000000000 --- a/sysdeps/unix/sysv/linux/wordsize-64/posix_fallocate64.c +++ /dev/null @@ -1 +0,0 @@ -/* posix_fallocate64 is in posix_fallocate.c */ diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list index bcf63701de..8aed2f4635 100644 --- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list +++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list @@ -8,7 +8,7 @@ msgrcv - msgrcv Ci:ibnii __msgrcv msgrcv msgsnd - msgsnd Ci:ibni __msgsnd msgsnd pread64 - pread64 Ci:ipii __libc_pread __libc_pread64 __pread64 pread64 __pread pread preadv64 - preadv Ci:ipii preadv64 preadv -pwrite64 - pwrite64 Ci:ipii __libc_pwrite __pwrite64 pwrite64 __pwrite pwrite +pwrite64 - pwrite64 Ci:ipii __libc_pwrite __libc_pwrite64 __pwrite64 pwrite64 __pwrite pwrite pwritev64 - pwritev Ci:ipii pwritev64 pwritev shmat - shmat i:ipi __shmat shmat shmctl - shmctl i:iip __shmctl shmctl -- cgit 1.4.1