This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 7/7] Consolidate getdirentries{64} implementation
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: libc-alpha at sourceware dot org
- Date: Wed, 25 Apr 2018 16:45:05 -0300
- Subject: Re: [PATCH 7/7] Consolidate getdirentries{64} implementation
- Autocrypt: addr=adhemerval dot zanella at linaro dot org; prefer-encrypt=mutual; keydata= xsFNBFcVGkoBEADiQU2x/cBBmAVf5C2d1xgz6zCnlCefbqaflUBw4hB/bEME40QsrVzWZ5Nq 8kxkEczZzAOKkkvv4pRVLlLn/zDtFXhlcvQRJ3yFMGqzBjofucOrmdYkOGo0uCaoJKPT186L NWp53SACXguFJpnw4ODI64ziInzXQs/rUJqrFoVIlrPDmNv/LUv1OVPKz20ETjgfpg8MNwG6 iMizMefCl+RbtXbIEZ3TE/IaDT/jcOirjv96lBKrc/pAL0h/O71Kwbbp43fimW80GhjiaN2y WGByepnkAVP7FyNarhdDpJhoDmUk9yfwNuIuESaCQtfd3vgKKuo6grcKZ8bHy7IXX1XJj2X/ BgRVhVgMHAnDPFIkXtP+SiarkUaLjGzCz7XkUn4XAGDskBNfbizFqYUQCaL2FdbW3DeZqNIa nSzKAZK7Dm9+0VVSRZXP89w71Y7JUV56xL/PlOE+YKKFdEw+gQjQi0e+DZILAtFjJLoCrkEX w4LluMhYX/X8XP6/C3xW0yOZhvHYyn72sV4yJ1uyc/qz3OY32CRy+bwPzAMAkhdwcORA3JPb kPTlimhQqVgvca8m+MQ/JFZ6D+K7QPyvEv7bQ7M+IzFmTkOCwCJ3xqOD6GjX3aphk8Sr0dq3 4Awlf5xFDAG8dn8Uuutb7naGBd/fEv6t8dfkNyzj6yvc4jpVxwARAQABzUlBZGhlbWVydmFs IFphbmVsbGEgTmV0dG8gKExpbmFybyBWUE4gS2V5KSA8YWRoZW1lcnZhbC56YW5lbGxhQGxp bmFyby5vcmc+wsF3BBMBCAAhBQJXFRpKAhsDBQsJ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IoFsN8+gFN3i8Is3u12u8xGudcBPvpoy4OoG
- Openpgp: preference=signencrypt
- References: <1520017165-15830-1-git-send-email-adhemerval.zanella@linaro.org> <1520017165-15830-7-git-send-email-adhemerval.zanella@linaro.org>
I will commit this shortly if no one opposes it.
On 02/03/2018 15:59, Adhemerval Zanella wrote:
> This patch consolidates Linux getdirentries{64} implementation on just
> the default sysdeps/unix/sysv/linux/getdirentries{64} ones. The default
> implementation handles the Linux requirements:
>
> * getdirentries is only built for _DIRENT_MATCHES_DIRENT64 being 0.
>
> * getdirentries64 is always built and aliased to getdents for ABIs
> that define _DIRENT_MATCHES_DIRENT64 to 1.
>
> Checked on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
> sparcv9-linux-gnu, sparc64-linux-gnu, powerpc-linux-gnu, and
> powerpc64le-linux-gnu.
>
> * sysdeps/unix/sysv/linux/getdirentries.c (getdirentries): Build iff
> _DIRENT_MATCHES_DIRENT64 is not defined.
> * sysdeps/unix/sysv/linux/getdirentries64.c (getdirentries64): Open
> implementation and alias to getdirentries if _DIRENT_MATCHES_DIRENT64
> is defined.
> * sysdeps/unix/sysv/linux/wordsize-64/getdirentries.c: Remove file.
> * sysdeps/unix/sysv/linux/wordsize-64/getdirentries64.c: Remove file.
> ---
> ChangeLog | 8 +++++
> sysdeps/unix/sysv/linux/getdirentries.c | 21 +++++------
> sysdeps/unix/sysv/linux/getdirentries64.c | 41 ++++++++++++++++++++--
> .../unix/sysv/linux/wordsize-64/getdirentries.c | 3 --
> .../unix/sysv/linux/wordsize-64/getdirentries64.c | 1 -
> 5 files changed, 54 insertions(+), 20 deletions(-)
> delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/getdirentries.c
> delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/getdirentries64.c
>
> diff --git a/sysdeps/unix/sysv/linux/getdirentries.c b/sysdeps/unix/sysv/linux/getdirentries.c
> index bc40292..23f626b 100644
> --- a/sysdeps/unix/sysv/linux/getdirentries.c
> +++ b/sysdeps/unix/sysv/linux/getdirentries.c
> @@ -16,26 +16,21 @@
> <http://www.gnu.org/licenses/>. */
>
> #include <dirent.h>
> -#include <unistd.h>
> -
> -#ifndef GETDIRENTRIES
> -# define GETDIRENTRIES getdirentries
> -# define __GETDENTS __getdents
> -#else
> -# define off_t off64_t
> -# define __lseek __lseek64
> -#endif
> +
> +#if !_DIRENT_MATCHES_DIRENT64
> +# include <unistd.h>
>
> ssize_t
> -GETDIRENTRIES (int fd, char *buf, size_t nbytes, off_t *basep)
> +getdirentries (int fd, char *buf, size_t nbytes, off_t *basep)
> {
> - off_t base = __lseek (fd, (off_t) 0, SEEK_CUR);
> - ssize_t result;
> + off_t base = __lseek (fd, 0, SEEK_CUR);
>
> - result = __GETDENTS (fd, buf, nbytes);
> + ssize_t result = __getdents (fd, buf, nbytes);
>
> if (result != -1)
> *basep = base;
>
> return result;
> }
> +
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/getdirentries64.c b/sysdeps/unix/sysv/linux/getdirentries64.c
> index e486a36..c1a23a7 100644
> --- a/sysdeps/unix/sysv/linux/getdirentries64.c
> +++ b/sysdeps/unix/sysv/linux/getdirentries64.c
> @@ -1,3 +1,38 @@
> -#define GETDIRENTRIES getdirentries64
> -#define __GETDENTS __getdents64
> -#include "getdirentries.c"
> +/* Copyright (C) 1993-2018 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/>. */
> +
> +#define getdirentries __no_getdirentries_decl
> +#include <dirent.h>
> +#undef getdirentries
> +#include <unistd.h>
> +
> +ssize_t
> +getdirentries64 (int fd, char *buf, size_t nbytes, off64_t *basep)
> +{
> + off64_t base = __lseek64 (fd, (off_t) 0, SEEK_CUR);
> +
> + ssize_t result = __getdents64 (fd, buf, nbytes);
> +
> + if (result != -1)
> + *basep = base;
> +
> + return result;
> +}
> +
> +#if _DIRENT_MATCHES_DIRENT64
> +weak_alias (getdirentries64, getdirentries)
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/getdirentries.c b/sysdeps/unix/sysv/linux/wordsize-64/getdirentries.c
> deleted file mode 100644
> index 298d1e9..0000000
> --- a/sysdeps/unix/sysv/linux/wordsize-64/getdirentries.c
> +++ /dev/null
> @@ -1,3 +0,0 @@
> -#include "../getdirentries.c"
> -
> -weak_alias (getdirentries, getdirentries64)
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/getdirentries64.c b/sysdeps/unix/sysv/linux/wordsize-64/getdirentries64.c
> deleted file mode 100644
> index 622baf0..0000000
> --- a/sysdeps/unix/sysv/linux/wordsize-64/getdirentries64.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -/* Defined in getdirentries.c. */
>