public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Subject: [PATCH 7/7] Consolidate getdirentries{64} implementation
Date: Fri, 02 Mar 2018 18:59:00 -0000	[thread overview]
Message-ID: <1520017165-15830-7-git-send-email-adhemerval.zanella@linaro.org> (raw)
In-Reply-To: <1520017165-15830-1-git-send-email-adhemerval.zanella@linaro.org>

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.  */
-- 
2.7.4

  parent reply	other threads:[~2018-03-02 18:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-02 18:59 [PATCH 1/7] Assume O_DIRECTORY for opendir Adhemerval Zanella
2018-03-02 18:59 ` [PATCH 4/7] Consolidate Linux getdents{64} implementation Adhemerval Zanella
2018-03-09 18:10   ` Adhemerval Zanella
2018-04-17 19:42     ` Adhemerval Zanella
2018-04-19 17:29       ` Joseph Myers
2018-04-19 18:23         ` Adhemerval Zanella
2018-03-02 18:59 ` [PATCH 6/7] Consolidate alphasort{64} and versionsort{64} implementation Adhemerval Zanella
2018-03-02 20:33   ` Joseph Myers
2018-03-06 11:28     ` Adhemerval Zanella
2018-04-23 18:01   ` Adhemerval Zanella
2018-03-02 18:59 ` Adhemerval Zanella [this message]
2018-04-25 19:49   ` [PATCH 7/7] Consolidate getdirentries{64} implementation Adhemerval Zanella
2018-03-02 18:59 ` [PATCH 5/7] Consolidate scandir{at}{64} implementation Adhemerval Zanella
2018-04-20 13:50   ` Adhemerval Zanella
2018-04-20 15:30   ` Florian Weimer
2018-04-20 15:56     ` Adhemerval Zanella
2018-03-02 18:59 ` [PATCH 2/7] Define _DIRENT_MATCHES_DIRENT64 regardless Adhemerval Zanella
2018-03-02 19:30   ` Andreas Schwab
2018-03-02 18:59 ` [PATCH 3/7] Consolidate Linux readdir{64}{_r} implementation Adhemerval Zanella
2018-04-06 19:49   ` Adhemerval Zanella
2018-04-02 13:59 ` [PATCH 1/7] Assume O_DIRECTORY for opendir Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1520017165-15830-7-git-send-email-adhemerval.zanella@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).