This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v3 2/3] Consolidate fallocate{64} implementations


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]