From patchwork Tue May 12 22:51:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland McGrath X-Patchwork-Id: 6683 Received: (qmail 39885 invoked by alias); 12 May 2015 22:51:41 -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 39872 invoked by uid 89); 12 May 2015 22:51:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 X-HELO: topped-with-meat.com MIME-Version: 1.0 From: Roland McGrath To: "GNU C. Library" Subject: [PATCH 2/3 roland/scandir] Break __scandir_cancel_handler out into its own file. In-Reply-To: Roland McGrath's message of Tuesday, 12 May 2015 15:50:45 -0700 <20150512225045.45B202C3AB9@topped-with-meat.com> References: <20150512225045.45B202C3AB9@topped-with-meat.com> Message-Id: <20150512225137.C42AC2C3AB9@topped-with-meat.com> Date: Tue, 12 May 2015 15:51:37 -0700 (PDT) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=SvUDtp+0 c=1 sm=1 tr=0 a=WkljmVdYkabdwxfqvArNOQ==:117 a=14OXPxybAAAA:8 a=kj9zAlcOel0A:10 a=hOe2yjtxAAAA:8 a=mDV3o1hIAAAA:8 a=heYJ6C7uYePu3EdKxKcA:9 a=CjuIK1q_8ugA:10 If there are no objections, I'll commit this shortly. Thanks, Roland 2015-05-12 Roland McGrath * dirent/scandirat.c (__scandir_cancel_handler): Function moved ... * dirent/scandir-cancel.c: ... to this new file. * dirent/Makefile (routines): Add it. * dirent/scandirat64.c (SKIP_SCANDIR_CANCEL): Macro removed. * sysdeps/unix/sysv/linux/i386/scandir64.c (SKIP_SCANDIR_CANCEL): Macro removed. * include/dirent.h (__scandir_cancel_handler): Add attribute_hidden. diff --git a/dirent/Makefile b/dirent/Makefile index 3c71ccf..2a97649 100644 --- a/dirent/Makefile +++ b/dirent/Makefile @@ -27,7 +27,7 @@ routines := opendir closedir readdir readdir_r rewinddir \ seekdir telldir scandir alphasort versionsort \ getdents getdents64 dirfd readdir64 readdir64_r scandir64 \ alphasort64 versionsort64 fdopendir \ - scandirat scandirat64 + scandirat scandirat64 scandir-cancel tests := list tst-seekdir opendir-tst1 bug-readdir1 tst-fdopendir \ tst-fdopendir2 tst-scandir tst-scandir64 diff --git a/dirent/scandir-cancel.c b/dirent/scandir-cancel.c new file mode 100644 index 0000000..549a4f8 --- /dev/null +++ b/dirent/scandir-cancel.c @@ -0,0 +1,31 @@ +/* Cancellation handler used in scandir* implementations. + Copyright (C) 1992-2015 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 + . */ + +#include + +void +__scandir_cancel_handler (void *arg) +{ + struct scandir_cancel_struct *cp = arg; + void **v = cp->v; + + for (size_t i = 0; i < cp->cnt; ++i) + free (v[i]); + free (v); + (void) __closedir (cp->dp); +} diff --git a/dirent/scandirat.c b/dirent/scandirat.c index 004b152..d7ae5e5 100644 --- a/dirent/scandirat.c +++ b/dirent/scandirat.c @@ -36,21 +36,6 @@ # define SCANDIRAT_WEAK_ALIAS #endif -#ifndef SKIP_SCANDIR_CANCEL -void -__scandir_cancel_handler (void *arg) -{ - struct scandir_cancel_struct *cp = arg; - size_t i; - void **v = cp->v; - - for (i = 0; i < cp->cnt; ++i) - free (v[i]); - free (v); - (void) __closedir (cp->dp); -} -#endif - int SCANDIRAT (dfd, dir, namelist, select, cmp) diff --git a/dirent/scandirat64.c b/dirent/scandirat64.c index c9a6186..fcdd1a9 100644 --- a/dirent/scandirat64.c +++ b/dirent/scandirat64.c @@ -23,7 +23,6 @@ #define SCANDIRAT scandirat64 #define READDIR __readdir64 #define DIRENT_TYPE struct dirent64 -#define SKIP_SCANDIR_CANCEL 1 #include "scandirat.c" diff --git a/include/dirent.h b/include/dirent.h index 2e797ae..c50bd23 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -46,9 +46,10 @@ extern int __versionsort64 (const struct dirent64 **a, extern DIR *__alloc_dir (int fd, bool close_fd, int flags, const struct stat64 *statp) internal_function; -extern void __scandir_cancel_handler (void *arg); extern __typeof (rewinddir) __rewinddir; +extern void __scandir_cancel_handler (void *arg) attribute_hidden; + libc_hidden_proto (__rewinddir) extern __typeof (scandirat) __scandirat; libc_hidden_proto (__scandirat) diff --git a/sysdeps/unix/sysv/linux/i386/scandir64.c b/sysdeps/unix/sysv/linux/i386/scandir64.c index 6dafa84..824bf84 100644 --- a/sysdeps/unix/sysv/linux/i386/scandir64.c +++ b/sysdeps/unix/sysv/linux/i386/scandir64.c @@ -21,7 +21,6 @@ #define SCANDIRAT scandirat64 #define READDIR __readdir64 #define DIRENT_TYPE struct dirent64 -#define SKIP_SCANDIR_CANCEL 1 #include