From patchwork Fri Mar 2 18:59:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 130575 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1602430lja; Fri, 2 Mar 2018 11:01:02 -0800 (PST) X-Google-Smtp-Source: AG47ELtBpgv1UqDxeCdWs+PuCE6osFEGiVta9LD8Poo1qp3kRrgkBYJQMfGnnI4tyGxCM8UYXLvP X-Received: by 2002:a17:902:8c93:: with SMTP id t19-v6mr6082745plo.304.1520017262458; Fri, 02 Mar 2018 11:01:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520017262; cv=none; d=google.com; s=arc-20160816; b=ImpY0iM7bM77jKzSIBc2rxs/iPAokz9el0PUIO/KvZPUemHnZ7ml/i5z6mPgZ/y3to NWk1uiWQGls6gep9i+E4FoU+YWlkNQRJGvOdEJXfrT8WhSxRnVlPkSVZ7Rl4spgiShJK RuazT1SME8/sry5iC2gzF44mH9/xhavY9FstXPpQuNyYWJ5KcWX7hmRap1stLbr9hjkM dRLGAOmB2UA728M/YYKiew0X789CtM990PQuVzfGm4GT1sYPii1ZeQnqPAW/icw6y0eL 5Vh5FVePEr3r1YBcG1RjGCEM+op9hLsPE8QCakpDqI513mHla1F//NyYjHW56k8O3Cqm Vtfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=Ttne6RfRWZNqK+bAAGmZbf6rQnt3WMRo6KZ5qk8Um3o=; b=xa4Z+s2Tn/nS2dkdsi1NpQpitDhTScB/3xIAIlPrQvwJySXcKsTb4DlZUnMcAn2tGV aUX+y/sJoN7clc64LPy2wREpsNAdTxBRRoZdRCju21Hd4QGgRA/gS7Cm4QKTowPMJjQJ fmL9c+fXdXCGVObtHHO95unLDOJ6GKqgw4S+zTknCpAW5eJ3wt2pnHpZ9oaT83+MEaRW HEBOXBKMFNjL/BCnd7sTL5qb2P8t1cab1Y//OP0gol8ZgYaxHSkZfO3Kq+lugERB9997 PMf10ODWD/w+XxK2YM/4+6wNa7IMPdGBYVZYve6pVaCiBbI3u+2MJ5jff2r5k9cXvNO0 1Vkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=vr/7Qt8Z; spf=pass (google.com: domain of libc-alpha-return-90741-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-90741-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id p8-v6si2793139plk.642.2018.03.02.11.01.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Mar 2018 11:01:02 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-90741-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=vr/7Qt8Z; spf=pass (google.com: domain of libc-alpha-return-90741-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-90741-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=OpihLZFUU1RzYe1RJ8AzG0QBvZyVJfQ 4Pdk0qLXFY9I74U6V/Yt8eWPHjic1eMhmJxii0sWxeEwUb6aUBNpI4fFU6+di6+x oTYvmmX2z1bbrRZglo5SWNLFd0FqcIXUeTPBCyuOay2+AGBn6r+tX6LHlzUzKCAV yJL4/hEq8Bxw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=S0rHK298Td/uKPYRUQptf/RCblQ=; b=vr/7Q t8ZP2IeG7OX1lKiOSlLw0VQIZmp+0qz+g1I6z5biZ8W/8aYP6DNex7ZOphRHa+yo ZiIHVJmqWZxk8ClCJRFUTH4pqn55P+G4JzEVBaWt24GA5u1EDMUkP4m4t8A2+iDM 4GnXkoREDLBcrHFuVnDTZT+bGA6td//n9d+2Ek= Received: (qmail 98799 invoked by alias); 2 Mar 2018 18:59:54 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 98062 invoked by uid 89); 2 Mar 2018 18:59:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f193.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Ttne6RfRWZNqK+bAAGmZbf6rQnt3WMRo6KZ5qk8Um3o=; b=oMbYiJ74/RSVPfAidMspJH/ja0oioBDiWPYOZCpq2X/OErS2JZ6GInVxUxtTTvOvLh 38rEKoYMDcUBYGiUCS7E3hJFye9641GR3mSgHkqPK5Ka/yXeRXJVTpmEdTmOmLHElDfX eigmsrsmGU6kTLhHlBjmufh5hO2inIy/njsx77vMg+Dp3RZiDPSRA/Lm5wMo+tataLGj 5jP8oMZqIn+/WyjCLquXIbunzcOfwpbZtiLCfMcEMZ3b2fk67Xr8gSOWSKXN6IPvLSb5 Sbm+zlhiQSzVMoQbKiQXr61kT1o01hfsjYH+yhfoEB6UIgYaSCdEFavOaTTS7Z9vZ1Yf uPcQ== X-Gm-Message-State: AElRT7G9v/6j3yaR32KeyOtcVBV3RFaXnp2T+w8ilAMC4y08a7lhLthq f1fw8d5kcaDjeJvPnb5RC/yD4Qy5AUg= X-Received: by 10.200.83.12 with SMTP id t12mr10445659qtn.333.1520017180603; Fri, 02 Mar 2018 10:59:40 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 7/7] Consolidate getdirentries{64} implementation Date: Fri, 2 Mar 2018 15:59:25 -0300 Message-Id: <1520017165-15830-7-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1520017165-15830-1-git-send-email-adhemerval.zanella@linaro.org> References: <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 -- 2.7.4 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 @@ . */ #include -#include - -#ifndef GETDIRENTRIES -# define GETDIRENTRIES getdirentries -# define __GETDENTS __getdents -#else -# define off_t off64_t -# define __lseek __lseek64 -#endif + +#if !_DIRENT_MATCHES_DIRENT64 +# include 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 + . */ + +#define getdirentries __no_getdirentries_decl +#include +#undef getdirentries +#include + +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. */