This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Consolidate fallocate/fallocate64 implementations
- From: Arnd Bergmann <arnd at arndb dot de>
- To: libc-alpha at sourceware dot org
- Cc: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- Date: Mon, 27 Jun 2016 23:43:44 +0200
- Subject: Re: [PATCH] Consolidate fallocate/fallocate64 implementations
- Authentication-results: sourceware.org; auth=none
- References: <1467056073-8061-1-git-send-email-adhemerval dot zanella at linaro dot org>
On Monday, June 27, 2016 4:34:33 PM CEST Adhemerval Zanella wrote:
> diff --git a/sysdeps/unix/sysv/linux/fallocate.c b/sysdeps/unix/sysv/linux/fallocate.c
> index 6a58a5f..e648a73 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>
>
> +#if __WORDSIZE != 64 || defined (__ASSUME_OFF_DIFF_OFF64)
> /* Reserve storage for the data of the file associated with FD. */
> int
> fallocate (int fd, int mode, __off_t offset, __off_t len)
> {
> return SYSCALL_CANCEL (fallocate, fd, mode,
> + 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..176caa8 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)
> {
> return SYSCALL_CANCEL (fallocate, fd, mode,
> + SYSCALL_LL64 (offset), SYSCALL_LL64 (len));
> }
> +
> +#if __WORDSIZE == 64 && !defined (__ASSUME_OFF_DIFF_OFF64)
> +weak_alias (fallocate64, fallocate)
> +#endif
>
How should this work for new 32-bit architectures when they do
not set __ASSUME_OFF_DIFF_OFF64?
It looks like you have two identical implementations then, though
you would want to have just one of them plus an alias.
Maybe the "__WORDSIZE == 64" check can simply be dropped and all
existing 32-bit architectures set __ASSUME_OFF_DIFF_OFF64 instead?
Arnd