From patchwork Thu Jun 8 21:13:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 103411 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp2632566qgd; Thu, 8 Jun 2017 14:15:13 -0700 (PDT) X-Received: by 10.98.16.220 with SMTP id 89mr22109070pfq.210.1496956512952; Thu, 08 Jun 2017 14:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496956512; cv=none; d=google.com; s=arc-20160816; b=GGqdMHVOFsxe2xrJKEBXVlew1+kdr3cXHJwaV/mq8ONe7hSJc15QiAb8/MslbWTlV7 QnDuVpons/41s1HfdwKbujVgrn0fxRhI6YyR0s/BPLySRLuR1EiVNbkLL4DKQ9Xi5Ads HjLytauldIbmy6kyW18wcaKSOMgB1vQlfNGPNOe5ekJtf28W7ZVSvtNXV+2SDzet9I30 Zux5m9ug1jkgJrVHTN9Dv7d2ig0xwg6qZjyJmbhwkCzrVPqnac6sA9RDU+CAMZql+zzT jObZVMxfC4zhkOQ5614UXLivdL0uOuJsqnhgi1/ScfbFkDE5WEFwMNzNZgEHGkthS1VC DHjA== 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=t8wtAE4RtkCAhnN0dQBEByKMBknWZ7ebw2knGykLcYU=; b=j7JXQ7RKcl411qT47kMhbu5BKxTUm5z/2EE4Tw99mn8l43phqpDaI1cTqn7/P3Aqnn F/zCSrraEFS8KjkI/1HO26+2E7TvYTdreYyhRcqqTVfbqHnnBtpfjvnBQ66cMA7LAS33 SwkALpYOMg+5ZUyHIjpcM0aMySCsxUpwnuNqj6wj1lHX1LnPdXZkVKdu25/yNc5qTXw4 7CM+PUSVq8bIwx6PU040MmePW1AjHwy8QHPT8jmR4biXYa78Gf3PCEwAON0SZiWJ8pLC deVxMR+l4j3z6bYslWaZS+ZEJT4RwB7jg4LDQ5O2FNcAFnEpbTBLcgc0YW44RDk19K+R jWlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-80205-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-80205-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 76si5201888pfp.320.2017.06.08.14.15.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jun 2017 14:15:12 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-80205-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; spf=pass (google.com: domain of libc-alpha-return-80205-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-80205-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=HPOW7f/uMKnX2KNUuBn+uzpoicCoq6J 1TLHb2XmYpMDMXINtsFKOOTtFjczcwixqL0DTUwTdokgQQE9TgoEH79FocUHcCkV Lm95H87Q7fxGqwIf6jNmbwEPkf47ZIWQI+7tf67YISPG2SmngfneVuSKHqWn79tS qGtGtDfPlebA= 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=tGH4DkU9SGP28rfvXxMmRHjtjDQ=; b=CLQsW rfBubJf6Uq6karq6aq0IhvkcHNITh1YRLpb8vMkTeg+ZBxaZIfhWPdrWNSff0qzX POHJBFV19EJotQjT2/rwrLnS+sVMNQW5lNlEiVqxKU+ifXPy4aFGnrycJ8QdkQAS 37QOsupxCP31xxlpOfQn/hc9ek4U6Y+gvXn2fo= Received: (qmail 39099 invoked by alias); 8 Jun 2017 21:14:04 -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 38973 invoked by uid 89); 8 Jun 2017 21:14:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f171.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=t8wtAE4RtkCAhnN0dQBEByKMBknWZ7ebw2knGykLcYU=; b=pgW/tJmDMWMRBFslIwzfsELUbc6fTefKdX0DksBdoaw0MbUzUZdrKA4TcrkghdnbgN 6mGCw+UWG4J8bE+QbYXsfwK99RTQ3yMm6uETOG1W2KHAfjb6SxgybYRIYHX5OMJq9W/P J4cl0x6BmH/j8JQ8vwPxMCbVzLj4bTky2DQCH10ssGMKYPJkGR5rvH8emceWRT1gvl83 RcTxyt7WD7VtcRfeddNlYngrb1aBX/CNVU0lWrVACpHMEK11pu3SsdCDZCR+k88DBDVs PCEyGdwwkWJ98GhnaMvIKTtRlkVNsTtJ+phtWKZrgVSBqormKk/igOO8a0pU4BIoUJV2 q5xg== X-Gm-Message-State: AKS2vOzs6pYpnWkAxfQbBJvisr53d9yznaK4DGnRN9hq9Yxvbp2XsFbl 9zNMSF/F5XH+rd9CAdDJFA== X-Received: by 10.200.34.230 with SMTP id g35mr3015538qta.65.1496956434866; Thu, 08 Jun 2017 14:13:54 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 05/17] posix: Consolidate glob implementation Date: Thu, 8 Jun 2017 18:13:19 -0300 Message-Id: <1496956411-25594-6-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1496956411-25594-1-git-send-email-adhemerval.zanella@linaro.org> References: <1496956411-25594-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates the glob implementation. The main changes are: * Remove specific defines required for multiple compilation in same unit (GLOB_ONLY_P, NO_GLOB_PATTERN_P and GLOB_COMPAT_BUILD). To allow using the same code to build compat version on Linux, extra units are used instead (oldglob.c). * Both globfree and GNU extension glob_pattern_p are now on their files. This simplifies the creation of compat symbol when required. * Also similar to glob/glob64, a new globfree64 is file is added with an empty implementatio as default. * On Linux all implementation now uses a default one with the exception of alpha (which requires a specific versioning) and s390-32 (which different than other 32 bits with support for v2.1 symbol does not add a compat symbol). * Move i386 olddirent.h header to Linux default directory, since it is the only header with this name and it is shared among different architectures (and used on compat glob symbol). Checked on x86_64-linux-gnu and i686-linux-gnu. * posix/Makefile (routines): Add globfree, globfree64, and glob_pattern_p. * posix/glob.c: Remove GLOB_ONLY_P, GLOB_COMPAT_BUILD, and NO_GLOB_PATTERN_P define usage. (globfree): Move to its own file. (__glob_pattern_type): Likewise. (__glob_pattern_p): Likewise. * posix/glob_internal.h: New file. * posix/glob_pattern_p.c: Likewise. * posix/globfree.c: Likewise. * posix/globfree64.c: Likewise. * sysdeps/gnu/glob64.c: Remove file. * sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Add oldglob. * sysdeps/unix/sysv/linux/alpha/Makefile [$(subdir) = posix] (sysdep_routines): Remove rule. * sysdeps/unix/sysv/linux/alpha/glob.c: Remove file. * sysdeps/unix/sysv/linux/arm/glob64.c: Likewise. * sysdeps/wordsize-64/glob.c: Likewise. * sysdeps/unix/sysv/linux/m68k/glob64.c: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c: Likewise. * sysdeps/unix/sysv/linux/wordsize-64/glob64.c: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/glob.c: Likewise. * sysdeps/wordsize-64/glob64.c: Likewise. * sysdeps/unix/sysv/linux/alpha/glob64.c: New file. * sysdeps/unix/sysv/linux/alpha/globfree.c: Likewise. * sysdeps/unix/sysv/linux/glob.c: Likewise. * sysdeps/unix/sysv/linux/glob64.c: Likewise. * sysdeps/unix/sysv/linux/globfree.c: Likewise. * sysdeps/unix/sysv/linux/globfree64.c: Likewise. * sysdeps/unix/sysv/linux/i386/alphasort64.c: include olddirent.h using relative path instead of absolute one. * sysdeps/unix/sysv/linux/i386/getdents64.c: Likewise. * sysdeps/unix/sysv/linux/i386/readdir64.c: Likewise. * sysdeps/unix/sysv/linux/i386/readdir64_r.c: Likewise. * sysdeps/unix/sysv/linux/i386/versionsort64.c: Likewise. * sysdeps/unix/sysv/linux/i386/olddirent.h: Move to ... * sysdeps/unix/sysv/linux/olddirent.h: ... here. * sysdeps/unix/sysv/linux/i386/glob64.c: Move to ... * sysdeps/unix/sysv/linux/oldglob.c: ... here. * sysdeps/unix/sysv/linux/i386/glob64.c: Remove file. * sysdeps/unix/sysv/linux/oldglob.c: New file. * sysdeps/unix/sysv/linux/s390/s390-32/glob64.c: New file. * sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c: Likewise. --- posix/Makefile | 2 +- posix/glob.c | 82 +--------------------- posix/glob_internal.h | 57 +++++++++++++++ posix/glob_pattern_p.c | 29 ++++++++ posix/globfree.c | 37 ++++++++++ posix/globfree64.c | 27 +++++++ sysdeps/gnu/glob64.c | 25 ------- sysdeps/unix/sysv/linux/Makefile | 2 +- sysdeps/unix/sysv/linux/alpha/Makefile | 4 -- sysdeps/unix/sysv/linux/alpha/{glob.c => glob64.c} | 11 --- sysdeps/unix/sysv/linux/alpha/globfree.c | 36 ++++++++++ sysdeps/unix/sysv/linux/arm/glob64.c | 1 - sysdeps/unix/sysv/linux/glob.c | 23 ++++++ sysdeps/unix/sysv/linux/glob64.c | 55 +++++++++++++++ sysdeps/unix/sysv/linux/globfree.c | 23 ++++++ sysdeps/unix/sysv/linux/globfree64.c | 0 sysdeps/unix/sysv/linux/i386/alphasort64.c | 2 +- sysdeps/unix/sysv/linux/i386/getdents64.c | 2 +- sysdeps/unix/sysv/linux/i386/readdir64.c | 2 +- sysdeps/unix/sysv/linux/i386/readdir64_r.c | 2 +- sysdeps/unix/sysv/linux/i386/versionsort64.c | 2 +- sysdeps/unix/sysv/linux/m68k/glob64.c | 1 - sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c | 1 - sysdeps/unix/sysv/linux/{i386 => }/olddirent.h | 0 .../unix/sysv/linux/{i386/glob64.c => oldglob.c} | 53 ++++---------- sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c | 1 - sysdeps/unix/sysv/linux/s390/s390-32/glob64.c | 20 ++++++ sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c | 2 + sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c | 1 - sysdeps/unix/sysv/linux/wordsize-64/glob64.c | 2 - sysdeps/unix/sysv/linux/x86_64/x32/glob.c | 1 - sysdeps/wordsize-64/glob.c | 8 --- sysdeps/wordsize-64/glob64.c | 1 - 33 files changed, 330 insertions(+), 185 deletions(-) create mode 100644 posix/glob_internal.h create mode 100644 posix/glob_pattern_p.c create mode 100644 posix/globfree.c create mode 100644 posix/globfree64.c delete mode 100644 sysdeps/gnu/glob64.c rename sysdeps/unix/sysv/linux/alpha/{glob.c => glob64.c} (78%) create mode 100644 sysdeps/unix/sysv/linux/alpha/globfree.c delete mode 100644 sysdeps/unix/sysv/linux/arm/glob64.c create mode 100644 sysdeps/unix/sysv/linux/glob.c create mode 100644 sysdeps/unix/sysv/linux/glob64.c create mode 100644 sysdeps/unix/sysv/linux/globfree.c create mode 100644 sysdeps/unix/sysv/linux/globfree64.c delete mode 100644 sysdeps/unix/sysv/linux/m68k/glob64.c delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c rename sysdeps/unix/sysv/linux/{i386 => }/olddirent.h (100%) rename sysdeps/unix/sysv/linux/{i386/glob64.c => oldglob.c} (61%) delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/glob64.c create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/glob64.c delete mode 100644 sysdeps/unix/sysv/linux/x86_64/x32/glob.c delete mode 100644 sysdeps/wordsize-64/glob.c delete mode 100644 sysdeps/wordsize-64/glob64.c -- 2.7.4 diff --git a/posix/Makefile b/posix/Makefile index 1001e54..38cbce9 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -45,7 +45,7 @@ routines := \ getpgid setpgid getpgrp bsd-getpgrp setpgrp getsid setsid \ getresuid getresgid setresuid setresgid \ pathconf sysconf fpathconf \ - glob glob64 fnmatch regex \ + glob glob64 globfree globfree64 glob_pattern_p fnmatch regex \ confstr \ getopt getopt1 \ sched_setp sched_getp sched_sets sched_gets sched_yield sched_primax \ diff --git a/posix/glob.c b/posix/glob.c index 250bff1..dc13e26 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -37,8 +37,6 @@ #include /* Needed on stupid SunOS for assert. */ -#ifndef GLOB_ONLY_P - #include #if !defined POSIX && defined _POSIX_VERSION # define POSIX @@ -90,6 +88,8 @@ #include +#include "glob_internal.h" + #ifdef _SC_GETPW_R_SIZE_MAX # define GETPW_R_SIZE_MAX() sysconf (_SC_GETPW_R_SIZE_MAX) #else @@ -168,8 +168,6 @@ readdir_result_might_be_dir (struct readdir_result d) D_INO_TO_RESULT (source) \ } -#endif /* !defined GLOB_ONLY_P */ - /* Call gl_readdir on STREAM. This macro can be overridden to reduce type safety if an old interface version needs to be supported. */ #ifndef GL_READDIR @@ -252,7 +250,6 @@ static bool size_add_wrapv (size_t a, size_t b, size_t *r); static bool glob_use_alloca (size_t alloca_used, size_t len); /* We must not compile this function twice. */ -#ifndef GLOB_COMPAT_BUILD static bool size_add_wrapv (size_t a, size_t b, size_t *r) { @@ -271,7 +268,6 @@ glob_use_alloca (size_t alloca_used, size_t len) return (!size_add_wrapv (alloca_used, len, &size) && __libc_use_alloca (size)); } -#endif static int glob_in_dir (const char *pattern, const char *directory, int flags, int (*errfunc) (const char *, int), @@ -279,7 +275,6 @@ static int glob_in_dir (const char *pattern, const char *directory, extern int __glob_pattern_type (const char *pattern, int quote) attribute_hidden; -#ifndef GLOB_ONLY_P static int prefix_array (const char *prefix, char **array, size_t n) __THROWNL; static int collated_compare (const void *, const void *) __THROWNL; @@ -308,7 +303,6 @@ next_brace_sub (const char *cp, int flags) return *cp != '\0' ? cp : NULL; } -#endif /* !defined GLOB_ONLY_P */ /* Do glob searching for PATTERN, placing results in PGLOB. The bits defined above may be set in FLAGS. @@ -1355,26 +1349,6 @@ libc_hidden_def (glob) #endif -#ifndef GLOB_ONLY_P - -/* Free storage allocated in PGLOB by a previous `glob' call. */ -void -globfree (glob_t *pglob) -{ - if (pglob->gl_pathv != NULL) - { - size_t i; - for (i = 0; i < pglob->gl_pathc; ++i) - free (pglob->gl_pathv[pglob->gl_offs + i]); - free (pglob->gl_pathv); - pglob->gl_pathv = NULL; - } -} -#if defined _LIBC && !defined globfree -libc_hidden_def (globfree) -#endif - - /* Do a collated comparison of A and B. */ static int collated_compare (const void *a, const void *b) @@ -1451,58 +1425,6 @@ prefix_array (const char *dirname, char **array, size_t n) } -/* We must not compile this function twice. */ -#ifndef NO_GLOB_PATTERN_P -int -__glob_pattern_type (const char *pattern, int quote) -{ - const char *p; - int ret = 0; - - for (p = pattern; *p != '\0'; ++p) - switch (*p) - { - case '?': - case '*': - return 1; - - case '\\': - if (quote) - { - if (p[1] != '\0') - ++p; - ret |= 2; - } - break; - - case '[': - ret |= 4; - break; - - case ']': - if (ret & 4) - return 1; - break; - } - - return ret; -} - -/* Return nonzero if PATTERN contains any metacharacters. - Metacharacters can be quoted with backslashes if QUOTE is nonzero. */ -int -__glob_pattern_p (const char *pattern, int quote) -{ - return __glob_pattern_type (pattern, quote) == 1; -} -# ifdef _LIBC -weak_alias (__glob_pattern_p, glob_pattern_p) -# endif -#endif - -#endif /* !defined GLOB_ONLY_P */ - - /* Like `glob', but PATTERN is a final pathname component, and matches are searched for in DIRECTORY. The GLOB_NOSORT bit in FLAGS is ignored. No sorting is ever done. diff --git a/posix/glob_internal.h b/posix/glob_internal.h new file mode 100644 index 0000000..d989a98 --- /dev/null +++ b/posix/glob_internal.h @@ -0,0 +1,57 @@ +/* Shared definition for glob and glob_pattern_p. + Copyright (C) 2017 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 + . */ + +#ifndef GLOB_INTERNAL_H +# define GLOB_INTERNAL_H + +static inline int +__glob_pattern_type (const char *pattern, int quote) +{ + const char *p; + int ret = 0; + + for (p = pattern; *p != '\0'; ++p) + switch (*p) + { + case '?': + case '*': + return 1; + + case '\\': + if (quote) + { + if (p[1] != '\0') + ++p; + ret |= 2; + } + break; + + case '[': + ret |= 4; + break; + + case ']': + if (ret & 4) + return 1; + break; + } + + return ret; +} + +#endif /* GLOB_INTERNAL_H */ diff --git a/posix/glob_pattern_p.c b/posix/glob_pattern_p.c new file mode 100644 index 0000000..6e451f2 --- /dev/null +++ b/posix/glob_pattern_p.c @@ -0,0 +1,29 @@ +/* Return nonzero if PATTERN contains any metacharacters. + Copyright (C) 2017 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 +#include "glob_internal.h" + +/* Return nonzero if PATTERN contains any metacharacters. + Metacharacters can be quoted with backslashes if QUOTE is nonzero. */ +int +__glob_pattern_p (const char *pattern, int quote) +{ + return __glob_pattern_type (pattern, quote) == 1; +} +weak_alias (__glob_pattern_p, glob_pattern_p) diff --git a/posix/globfree.c b/posix/globfree.c new file mode 100644 index 0000000..4ebd142 --- /dev/null +++ b/posix/globfree.c @@ -0,0 +1,37 @@ +/* Frees the dynamically allocated storage from an earlier call to glob. + Copyright (C) 2017 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 +#include + +/* Free storage allocated in PGLOB by a previous `glob' call. */ +void +globfree (glob_t *pglob) +{ + if (pglob->gl_pathv != NULL) + { + size_t i; + for (i = 0; i < pglob->gl_pathc; ++i) + free (pglob->gl_pathv[pglob->gl_offs + i]); + free (pglob->gl_pathv); + pglob->gl_pathv = NULL; + } +} +#ifndef globfree +libc_hidden_def (globfree) +#endif diff --git a/posix/globfree64.c b/posix/globfree64.c new file mode 100644 index 0000000..cce288e --- /dev/null +++ b/posix/globfree64.c @@ -0,0 +1,27 @@ +/* Frees the dynamically allocated storage from an earlier call to glob. + Copyright (C) 2017 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 +#include + +/* Free storage allocated in PGLOB by a previous `glob' call. */ +void +globfree64 (glob64_t *pglob) +{ +} +libc_hidden_def (globfree64) diff --git a/sysdeps/gnu/glob64.c b/sysdeps/gnu/glob64.c deleted file mode 100644 index 250ff07..0000000 --- a/sysdeps/gnu/glob64.c +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include -#include - -#define dirent dirent64 -#define __readdir(dirp) __readdir64 (dirp) - -#define glob_t glob64_t -#define glob(pattern, flags, errfunc, pglob) \ - glob64 (pattern, flags, errfunc, pglob) -#define globfree(pglob) globfree64 (pglob) - -#undef stat -#define stat stat64 -#undef __lstat -#define __lstat(file, buf) __lxstat64 (_STAT_VER, file, buf) - -#define NO_GLOB_PATTERN_P 1 - -#define COMPILE_GLOB64 1 - -#include - -libc_hidden_def (glob64) -libc_hidden_def (globfree64) diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 99b3f9d..68bfc17 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -147,7 +147,7 @@ endif ifeq ($(subdir),posix) sysdep_headers += bits/initspin.h -sysdep_routines += sched_getcpu +sysdep_routines += sched_getcpu oldglob tests += tst-affinity tst-affinity-pid diff --git a/sysdeps/unix/sysv/linux/alpha/Makefile b/sysdeps/unix/sysv/linux/alpha/Makefile index 47bd189..50f4fb1 100644 --- a/sysdeps/unix/sysv/linux/alpha/Makefile +++ b/sysdeps/unix/sysv/linux/alpha/Makefile @@ -1,7 +1,3 @@ -ifeq ($(subdir),posix) -sysdep_routines += oldglob -endif - ifeq ($(subdir),stdlib) gen-as-const-headers += ucontext-offsets.sym endif diff --git a/sysdeps/unix/sysv/linux/alpha/glob.c b/sysdeps/unix/sysv/linux/alpha/glob64.c similarity index 78% rename from sysdeps/unix/sysv/linux/alpha/glob.c rename to sysdeps/unix/sysv/linux/alpha/glob64.c index 2d7d287..dd86d15 100644 --- a/sysdeps/unix/sysv/linux/alpha/glob.c +++ b/sysdeps/unix/sysv/linux/alpha/glob64.c @@ -16,36 +16,25 @@ . */ #define glob64 __no_glob64_decl -#define globfree64 __no_globfree64_decl -#include #include #include /* For Linux/Alpha we have to make the glob symbols versioned. */ #define glob(pattern, flags, errfunc, pglob) \ __new_glob (pattern, flags, errfunc, pglob) -#define globfree(pglob) \ - __new_globfree (pglob) /* We need prototypes for these new names. */ extern int __new_glob (const char *__pattern, int __flags, int (*__errfunc) (const char *, int), glob_t *__pglob); -extern void __new_globfree (glob_t *__pglob); #include #undef glob -#undef globfree #undef glob64 -#undef globfree64 versioned_symbol (libc, __new_glob, glob, GLIBC_2_1); -versioned_symbol (libc, __new_globfree, globfree, GLIBC_2_1); libc_hidden_ver (__new_glob, glob) -libc_hidden_ver (__new_globfree, globfree) weak_alias (__new_glob, glob64) -weak_alias (__new_globfree, globfree64) -libc_hidden_ver (__new_globfree, globfree64) diff --git a/sysdeps/unix/sysv/linux/alpha/globfree.c b/sysdeps/unix/sysv/linux/alpha/globfree.c new file mode 100644 index 0000000..9d159f1 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/globfree.c @@ -0,0 +1,36 @@ +/* Frees the dynamically allocated storage from an earlier call to glob. + Copyright (C) 2017 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 globfree64 __no_globfree64_decl + +#include +#include + +#define globfree(pglob) __new_globfree (pglob) +extern void __new_globfree (glob_t *__pglob); + +#include + +#undef globfree +#undef globfree64 + +versioned_symbol (libc, __new_globfree, globfree, GLIBC_2_1); +libc_hidden_ver (__new_globfree, globfree) + +weak_alias (__new_globfree, globfree64) +libc_hidden_ver (__new_globfree, globfree64) diff --git a/sysdeps/unix/sysv/linux/arm/glob64.c b/sysdeps/unix/sysv/linux/arm/glob64.c deleted file mode 100644 index 82a9a29..0000000 --- a/sysdeps/unix/sysv/linux/arm/glob64.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/glob.c b/sysdeps/unix/sysv/linux/glob.c new file mode 100644 index 0000000..153ba8c --- /dev/null +++ b/sysdeps/unix/sysv/linux/glob.c @@ -0,0 +1,23 @@ +/* Find pathnames matching a pattern. + Copyright (C) 2017 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 + +#ifndef __OFF_T_MATCHES_OFF64_T +# include +#endif diff --git a/sysdeps/unix/sysv/linux/glob64.c b/sysdeps/unix/sysv/linux/glob64.c new file mode 100644 index 0000000..6ff6611 --- /dev/null +++ b/sysdeps/unix/sysv/linux/glob64.c @@ -0,0 +1,55 @@ +/* Find pathnames matching a pattern. + Copyright (C) 2017 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 + +#ifdef __OFF_T_MATCHES_OFF64_T +# define glob64 __no_glob64_decl +# include +# undef glob64 +weak_alias (glob, glob64) +#else +# include +# include +# include + +# define dirent dirent64 +# define __readdir(dirp) __readdir64 (dirp) + +# define glob_t glob64_t +# define glob(pattern, flags, errfunc, pglob) \ + __glob64 (pattern, flags, errfunc, pglob) +# define globfree(pglob) globfree64 (pglob) + +# undef stat +# define stat stat64 + +# define COMPILE_GLOB64 1 + +# include + +# include "shlib-compat.h" + +# ifdef GLOB_NO_OLD_VERSION +strong_alias (__glob64, glob64) +libc_hidden_def (glob64) +# else +versioned_symbol (libc, __glob64, glob64, GLIBC_2_2); +libc_hidden_ver (__glob64, glob64) +# endif +#endif diff --git a/sysdeps/unix/sysv/linux/globfree.c b/sysdeps/unix/sysv/linux/globfree.c new file mode 100644 index 0000000..d615510 --- /dev/null +++ b/sysdeps/unix/sysv/linux/globfree.c @@ -0,0 +1,23 @@ +/* Frees the dynamically allocated storage from an earlier call to glob. + Copyright (C) 2017 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 globfree64 __no_globfree64_decl +#include +#undef globfree64 +weak_alias (globfree, globfree64) +libc_hidden_ver (globfree, globfree64) diff --git a/sysdeps/unix/sysv/linux/globfree64.c b/sysdeps/unix/sysv/linux/globfree64.c new file mode 100644 index 0000000..e69de29 diff --git a/sysdeps/unix/sysv/linux/i386/alphasort64.c b/sysdeps/unix/sysv/linux/i386/alphasort64.c index d5fd47a..04b29b6 100644 --- a/sysdeps/unix/sysv/linux/i386/alphasort64.c +++ b/sysdeps/unix/sysv/linux/i386/alphasort64.c @@ -30,7 +30,7 @@ versioned_symbol (libc, __alphasort64, alphasort64, GLIBC_2_2); #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) -#include +#include int __old_alphasort64 (const struct __old_dirent64 **a, diff --git a/sysdeps/unix/sysv/linux/i386/getdents64.c b/sysdeps/unix/sysv/linux/i386/getdents64.c index e8b257f..2010bbf 100644 --- a/sysdeps/unix/sysv/linux/i386/getdents64.c +++ b/sysdeps/unix/sysv/linux/i386/getdents64.c @@ -28,7 +28,7 @@ #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) -#include +#include #define __GETDENTS __old_getdents64 #define DIRENT_TYPE struct __old_dirent64 diff --git a/sysdeps/unix/sysv/linux/i386/readdir64.c b/sysdeps/unix/sysv/linux/i386/readdir64.c index f80b6a7..bd2375f 100644 --- a/sysdeps/unix/sysv/linux/i386/readdir64.c +++ b/sysdeps/unix/sysv/linux/i386/readdir64.c @@ -31,7 +31,7 @@ versioned_symbol (libc, __readdir64, readdir64, GLIBC_2_2); #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) -#include +#include #define __READDIR attribute_compat_text_section __old_readdir64 #define __GETDENTS __old_getdents64 diff --git a/sysdeps/unix/sysv/linux/i386/readdir64_r.c b/sysdeps/unix/sysv/linux/i386/readdir64_r.c index 344fd53..8c0262d 100644 --- a/sysdeps/unix/sysv/linux/i386/readdir64_r.c +++ b/sysdeps/unix/sysv/linux/i386/readdir64_r.c @@ -31,7 +31,7 @@ versioned_symbol (libc, __readdir64_r, readdir64_r, GLIBC_2_2); #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) -#include +#include #define __READDIR_R attribute_compat_text_section __old_readdir64_r #define __GETDENTS __old_getdents64 diff --git a/sysdeps/unix/sysv/linux/i386/versionsort64.c b/sysdeps/unix/sysv/linux/i386/versionsort64.c index 3e1c6ea..87f2f95 100644 --- a/sysdeps/unix/sysv/linux/i386/versionsort64.c +++ b/sysdeps/unix/sysv/linux/i386/versionsort64.c @@ -30,7 +30,7 @@ versioned_symbol (libc, __versionsort64, versionsort64, GLIBC_2_2); #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) -#include +#include int __old_versionsort64 (const struct __old_dirent64 **a, diff --git a/sysdeps/unix/sysv/linux/m68k/glob64.c b/sysdeps/unix/sysv/linux/m68k/glob64.c deleted file mode 100644 index 82a9a29..0000000 --- a/sysdeps/unix/sysv/linux/m68k/glob64.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c b/sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c deleted file mode 100644 index 33918ea..0000000 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c +++ /dev/null @@ -1 +0,0 @@ -/* glob64 is in glob.c */ diff --git a/sysdeps/unix/sysv/linux/i386/olddirent.h b/sysdeps/unix/sysv/linux/olddirent.h similarity index 100% rename from sysdeps/unix/sysv/linux/i386/olddirent.h rename to sysdeps/unix/sysv/linux/olddirent.h diff --git a/sysdeps/unix/sysv/linux/i386/glob64.c b/sysdeps/unix/sysv/linux/oldglob.c similarity index 61% rename from sysdeps/unix/sysv/linux/i386/glob64.c rename to sysdeps/unix/sysv/linux/oldglob.c index 2dcbe33..af934f9 100644 --- a/sysdeps/unix/sysv/linux/i386/glob64.c +++ b/sysdeps/unix/sysv/linux/oldglob.c @@ -1,5 +1,5 @@ -/* Two glob variants with 64-bit support, for dirent64 and __olddirent64. - Copyright (C) 1998-2017 Free Software Foundation, Inc. +/* Find pathnames matching a pattern. Compatibility version. + Copyright (C) 2017 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 @@ -16,61 +16,32 @@ License along with the GNU C Library; if not, see . */ -#include #include -#include - -#define dirent dirent64 -#define __readdir(dirp) __readdir64 (dirp) - -#define glob_t glob64_t -#define glob(pattern, flags, errfunc, pglob) \ - __glob64 (pattern, flags, errfunc, pglob) -#define globfree(pglob) globfree64 (pglob) - -#undef stat -#define stat stat64 -#undef __lstat -#define __lstat(file, buf) __lxstat64 (_STAT_VER, file, buf) - -#define NO_GLOB_PATTERN_P 1 - -#define COMPILE_GLOB64 1 - -#include - #include "shlib-compat.h" -libc_hidden_def (globfree64) - -versioned_symbol (libc, __glob64, glob64, GLIBC_2_2); -libc_hidden_ver (__glob64, glob64) - -#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) +#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) \ + && !defined(GLOB_NO_OLD_VERSION) -#include +#include int __old_glob64 (const char *__pattern, int __flags, int (*__errfunc) (const char *, int), glob64_t *__pglob); -#undef dirent +#define glob_t glob64_t +#define globfree(pglob) globfree64 (pglob) +#undef stat +#define stat stat64 + #define dirent __old_dirent64 -#undef GL_READDIR -# define GL_READDIR(pglob, stream) \ +#define GL_READDIR(pglob, stream) \ ((struct __old_dirent64 *) (pglob)->gl_readdir (stream)) -#undef __readdir #define __readdir(dirp) __old_readdir64 (dirp) -#undef glob #define glob(pattern, flags, errfunc, pglob) \ __old_glob64 (pattern, flags, errfunc, pglob) #define convert_dirent __old_convert_dirent -#define glob_in_dir __old_glob_in_dir -#define GLOB_ATTRIBUTE attribute_compat_text_section -#define GLOB_ONLY_P 1 - -#define GLOB_COMPAT_BUILD 1 +#define GLOB_ATTRIBUTE attribute_compat_text_section #include diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c deleted file mode 100644 index 82a9a29..0000000 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/glob64.c b/sysdeps/unix/sysv/linux/s390/s390-32/glob64.c new file mode 100644 index 0000000..b00dc54 --- /dev/null +++ b/sysdeps/unix/sysv/linux/s390/s390-32/glob64.c @@ -0,0 +1,20 @@ +/* Find pathnames matching a pattern. S390-32 Linux version. + Copyright (C) 2017 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 GLOB_NO_OLD_VERSION +#include diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c b/sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c new file mode 100644 index 0000000..56d7d12 --- /dev/null +++ b/sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c @@ -0,0 +1,2 @@ +#define GLOB_NO_OLD_VERSION +#include diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c b/sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c deleted file mode 100644 index 82a9a29..0000000 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/wordsize-64/glob64.c b/sysdeps/unix/sysv/linux/wordsize-64/glob64.c deleted file mode 100644 index eab7703..0000000 --- a/sysdeps/unix/sysv/linux/wordsize-64/glob64.c +++ /dev/null @@ -1,2 +0,0 @@ -/* This file is here so sysdeps/gnu/glob64.c doesn't take precedence. */ -#include diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/glob.c b/sysdeps/unix/sysv/linux/x86_64/x32/glob.c deleted file mode 100644 index e542747..0000000 --- a/sysdeps/unix/sysv/linux/x86_64/x32/glob.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/wordsize-64/glob.c b/sysdeps/wordsize-64/glob.c deleted file mode 100644 index 082faf1..0000000 --- a/sysdeps/wordsize-64/glob.c +++ /dev/null @@ -1,8 +0,0 @@ -#define glob64 __no_glob64_decl -#define globfree64 __no_globfree64_decl -#include -#undef glob64 -#undef globfree64 -weak_alias (glob, glob64) -weak_alias (globfree, globfree64) -libc_hidden_ver (globfree, globfree64) diff --git a/sysdeps/wordsize-64/glob64.c b/sysdeps/wordsize-64/glob64.c deleted file mode 100644 index 33918ea..0000000 --- a/sysdeps/wordsize-64/glob64.c +++ /dev/null @@ -1 +0,0 @@ -/* glob64 is in glob.c */