From patchwork Fri Sep 1 23:50:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Eggert X-Patchwork-Id: 22570 Received: (qmail 85443 invoked by alias); 1 Sep 2017 23:50:36 -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 85434 invoked by uid 89); 1 Sep 2017 23:50:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-22.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_PASS, UNSUBSCRIBE_BODY autolearn=ham version=3.3.2 spammy=201709 X-HELO: zimbra.cs.ucla.edu Subject: Re: [PATCH 05/18] posix: Rewrite to use struct scratch_buffer instead of extend_alloca To: Adhemerval Zanella , libc-alpha@sourceware.org Cc: Florian Weimer References: <1502463044-4042-1-git-send-email-adhemerval.zanella@linaro.org> <1502463044-4042-6-git-send-email-adhemerval.zanella@linaro.org> From: Paul Eggert Message-ID: <8fff8bd4-a635-0c5e-2cef-4d4153a1741c@cs.ucla.edu> Date: Fri, 1 Sep 2017 16:50:28 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1502463044-4042-6-git-send-email-adhemerval.zanella@linaro.org> Thanks, I merged that patch into Gnulib; see: http://lists.gnu.org/archive/html/bug-gnulib/2017-09/msg00002.html This means Gnulib starts sharing scratch_buffer.h etc. with glibc, which entails some minor and safe changes to those files on the glibc side. Plus, glibc glob.c can be simplified slightly now. Please see the attached patch, which I hope can be folded into the next iteration of this glibc patchset. From 05cc71685fb0e177233655c4d499ad223ffe9a6f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 1 Sep 2017 16:37:15 -0700 Subject: [PATCH] Merge glob-related changes from Gnulib * include/scratch_buffer.h (struct scratch_buffer): Use portable method to align buffer, instead of relying on GCC's __attribute__ ((aligned (...))), so that this can be compiled with non-GCC compilers when used as part of Gnulib. * malloc/scratch_buffer_grow.c: * malloc/scratch_buffer_grow_preserve.c: * malloc/scratch_buffer_set_array_size.c: Include first thing, if !_LIBC. Remove stray top-level ";" that non-GCC compilers reject. * misc/sys/cdefs.h: Do not include and if __WORDSIZE is already defined, so that Gnulib-using code does not include these nonexistent files. * posix/glob.c: Minor simplifications due to Gnulib changes: do not include , and do not define __set_errno. does that via another method for glob.c. --- include/scratch_buffer.h | 3 +-- malloc/scratch_buffer_grow.c | 6 +++++- malloc/scratch_buffer_grow_preserve.c | 6 +++++- malloc/scratch_buffer_set_array_size.c | 6 +++++- misc/sys/cdefs.h | 8 ++++++-- posix/glob.c | 8 -------- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/include/scratch_buffer.h b/include/scratch_buffer.h index dd17a4a7e1..bb04662eb2 100644 --- a/include/scratch_buffer.h +++ b/include/scratch_buffer.h @@ -66,8 +66,7 @@ struct scratch_buffer { void *data; /* Pointer to the beginning of the scratch area. */ size_t length; /* Allocated space at the data pointer, in bytes. */ - char __space[1024] - __attribute__ ((aligned (__alignof__ (max_align_t)))); + max_align_t __space[(1023 + sizeof (max_align_t)) / sizeof (max_align_t)]; }; /* Initializes *BUFFER so that BUFFER->data points to BUFFER->__space diff --git a/malloc/scratch_buffer_grow.c b/malloc/scratch_buffer_grow.c index 22bae506a1..d2df028654 100644 --- a/malloc/scratch_buffer_grow.c +++ b/malloc/scratch_buffer_grow.c @@ -16,6 +16,10 @@ License along with the GNU C Library; if not, see . */ +#ifndef _LIBC +# include +#endif + #include #include @@ -49,4 +53,4 @@ __libc_scratch_buffer_grow (struct scratch_buffer *buffer) buffer->length = new_length; return true; } -libc_hidden_def (__libc_scratch_buffer_grow); +libc_hidden_def (__libc_scratch_buffer_grow) diff --git a/malloc/scratch_buffer_grow_preserve.c b/malloc/scratch_buffer_grow_preserve.c index 18543ef85b..9268615311 100644 --- a/malloc/scratch_buffer_grow_preserve.c +++ b/malloc/scratch_buffer_grow_preserve.c @@ -16,6 +16,10 @@ License along with the GNU C Library; if not, see . */ +#ifndef _LIBC +# include +#endif + #include #include #include @@ -60,4 +64,4 @@ __libc_scratch_buffer_grow_preserve (struct scratch_buffer *buffer) buffer->length = new_length; return true; } -libc_hidden_def (__libc_scratch_buffer_grow_preserve); +libc_hidden_def (__libc_scratch_buffer_grow_preserve) diff --git a/malloc/scratch_buffer_set_array_size.c b/malloc/scratch_buffer_set_array_size.c index 8ab6d9d300..6fcc115340 100644 --- a/malloc/scratch_buffer_set_array_size.c +++ b/malloc/scratch_buffer_set_array_size.c @@ -16,6 +16,10 @@ License along with the GNU C Library; if not, see . */ +#ifndef _LIBC +# include +#endif + #include #include #include @@ -57,4 +61,4 @@ __libc_scratch_buffer_set_array_size (struct scratch_buffer *buffer, buffer->length = new_length; return true; } -libc_hidden_def (__libc_scratch_buffer_set_array_size); +libc_hidden_def (__libc_scratch_buffer_set_array_size) diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index cfd39d5302..d4dd8d0418 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -415,8 +415,12 @@ [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })] #endif -#include -#include +/* The #ifndef lets Gnulib avoid including these on non-glibc + platforms, where the includes typically do not exist. */ +#ifndef __WORDSIZE +# include +# include +#endif #if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH # define __LDBL_COMPAT 1 diff --git a/posix/glob.c b/posix/glob.c index c0ee4dacb5..7ddc2c8d70 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -15,10 +15,6 @@ License along with the GNU C Library; if not, see . */ -#ifndef _LIBC -# include -#endif - #include #include @@ -39,10 +35,6 @@ #endif #include -#ifndef __set_errno -# define __set_errno(val) errno = (val) -#endif - #include #include #include -- 2.13.5