This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v3 2/3] Consolidate fallocate{64} implementations
- From: Yury Norov <ynorov at caviumnetworks dot com>
- To: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- Cc: <libc-alpha at sourceware dot org>
- Date: Wed, 29 Jun 2016 11:40:05 +0300
- Subject: Re: [PATCH v3 2/3] Consolidate fallocate{64} implementations
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp dot mailfrom=Yuri dot Norov at caviumnetworks dot com;
- References: <1467140654-5335-1-git-send-email-adhemerval dot zanella at linaro dot org> <1467140654-5335-2-git-send-email-adhemerval dot zanella at linaro dot org>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
On Tue, Jun 28, 2016 at 04:04:13PM -0300, Adhemerval Zanella wrote:
> Change from previous version:
>
> - Remove __WORDSIZE and __ASSUME_OFF_DIFF_OFF64 usage.
>
> --
>
> This patch consolidates all the fallocate{64} implementation for Linux
> in only one (sysdeps/unix/sysv/linux/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.
>
> Checked on x86_64, x32, i386, aarch64, and ppc64le.
>
[...]
> diff --git a/sysdeps/unix/sysv/linux/fallocate.c b/sysdeps/unix/sysv/linux/fallocate.c
> index 6a58a5f..a38e9a6 100644
> --- a/sysdeps/unix/sysv/linux/fallocate.c
> +++ b/sysdeps/unix/sysv/linux/fallocate.c
> @@ -19,17 +19,12 @@
> #include <fcntl.h>
> #include <sysdep-cancel.h>
>
> -
> +#ifndef __OFF_T_MATCHES_OFF64_T
> /* Reserve storage for the data of the file associated with FD. */
> int
> fallocate (int fd, int mode, __off_t offset, __off_t len)
> {
> -#ifdef __NR_fallocate
> return SYSCALL_CANCEL (fallocate, fd, mode,
> - __LONG_LONG_PAIR (offset >> 31, offset),
> - __LONG_LONG_PAIR (len >> 31, len));
> -#else
> - __set_errno (ENOSYS);
> - return -1;
> -#endif
> + SYSCALL_LL (offset), SYSCALL_LL (len));
> }
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/fallocate64.c b/sysdeps/unix/sysv/linux/fallocate64.c
> index 8e76d6f..d466095 100644
> --- a/sysdeps/unix/sysv/linux/fallocate64.c
> +++ b/sysdeps/unix/sysv/linux/fallocate64.c
> @@ -24,14 +24,10 @@
> int
> fallocate64 (int fd, int mode, __off64_t offset, __off64_t len)
> {
> -#ifdef __NR_fallocate
> return SYSCALL_CANCEL (fallocate, fd, mode,
> - __LONG_LONG_PAIR ((long int) (offset >> 32),
> - (long int) offset),
> - __LONG_LONG_PAIR ((long int) (len >> 32),
> - (long int) len));
> -#else
> - __set_errno (ENOSYS);
> - return -1;
> -#endif
> + SYSCALL_LL64 (offset), SYSCALL_LL64 (len));
> }
> +
> +#ifdef __OFF_T_MATCHES_OFF64_T
> +weak_alias (fallocate64, fallocate)
> +#endif
This redirection is also needed for posix_fadvise() and
posix_fallocate(). See my recent patch.
https://sourceware.org/ml/libc-alpha/2016-06/msg00958.html
Yury.