From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id BD2E41F5AE for ; Sun, 6 Jun 2021 23:22:37 +0000 (UTC) Received: from localhost ([::1]:48162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lq26G-0004cT-KK for normalperson@yhbt.net; Sun, 06 Jun 2021 19:22:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lq26D-0004cH-Ge for bug-gnulib@gnu.org; Sun, 06 Jun 2021 19:22:33 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.217]:28986) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lq26A-00056X-H8 for bug-gnulib@gnu.org; Sun, 06 Jun 2021 19:22:33 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1623021747; cv=none; d=strato.com; s=strato-dkim-0002; b=E/e51BYEHLWcXl9iOe/JUrv21G0I/F3tTmJfJJvyHDykywLz5pMpvzXbKWDplAsEe8 rfFExDL8r8LViWq1ztHxMK9GkJtfQWAF5fRyN/PuUrmTMs/cerTGLQWBAiSvrs79hF3C 13v9usByPiwgLWI9eaL4Vz6oiJ9P6toEvtsct5DZb5BE44yyRkOB51Hp5hv2QLtD3v81 D0a7FVQawhXpfWgXvQ8UYo/abH1WphSdTEeqWyaTxml0z1qAppEm62ImzZRqXQ2EhWNk Fj9efh9PG4WFPnc0qKv6SLxEppIh6TDBphMx+i39jYrxKIZuRwwIjzuwQa9qnhidhvpn OltQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1623021747; s=strato-dkim-0002; d=strato.com; h=References:In-Reply-To:Message-ID:Date:Subject:To:From:Cc:Date:From: Subject:Sender; bh=DmVKJ11sRSSkxUzOWHnLFnL3ToK9yEeJ3oTjGBnGVRU=; b=T7cUAIca+wVCJFChxAjSIZ5yv632fB8ddvl54S5kdtXLNDrQXRSoNOxEHq10BTUo2B +VTvmiHOzdk555x4+EinUhSZ1a16M5yTo54u0LRBtnUwY3KgxLovNESIfgS1zWLOwghe V9/UceXKFeU5Ysq23p5v56mvSp6UnM5z+y4PmJld+0PFuJwk/vLLAgQIBOJZz50utvgM C30bAg00JfKyRvECVBbR7pNzWEpndRU65U1E366+TGM0e7pqqIXYCXBtcmwgWYojWTPB NszA81Au0iLbdfEiRW7+IvGR08/yiEZ0C5PfxAddbCmncnwe8Rdbs+hLYxasRJKY38ZQ 3lkQ== ARC-Authentication-Results: i=1; strato.com; dkim=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1623021747; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:To:From:Cc:Date:From: Subject:Sender; bh=DmVKJ11sRSSkxUzOWHnLFnL3ToK9yEeJ3oTjGBnGVRU=; b=PU26cigff8WjPE2/lwiuhpHlId2au/1cZ+usZH99EN3nd6SGvjn1/LFJPU+x8GtiHy WcbaeGxNPHwuB3uGTRtNDjIB4wgnndvTaqHp48y60U0I2V97WN0W9yrGti/N/+sTzr8W WJKNFO+Vhf69CHf4bp/M3wlmonG+DwdNLpffR9u63zuKVXlp1QHk/q9ePMObDAmjvKze 5ngh04+LUpvfbO65vaiPXtWYsGM4M3EzB3JhGT/Vs/NBdfVSFCVIYTaBaX8x79DiZOW8 rbCHA5BjChRTqIvjwMOl7k0vqvhkxsfMRnsPVDjWNl5RisVYhDvQaZ9kja0ifUpaYt8x 1CDQ== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOHqf3z5NW" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 47.27.2 DYNA|AUTH) with ESMTPSA id q0869dx56NMRJk7 (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Mon, 7 Jun 2021 01:22:27 +0200 (CEST) From: Bruno Haible To: bug-gnulib@gnu.org Subject: dynarray, scratch_buffer: Avoid conflict with preprocessor macros owned by the system Date: Mon, 07 Jun 2021 01:22:26 +0200 Message-ID: <5090997.gcfE4oZm11@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-210-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <2616713.192FMcs1Co@omega> References: <2616713.192FMcs1Co@omega> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart3094624.4HigakSz2z" Content-Transfer-Encoding: 7Bit Received-SPF: none client-ip=81.169.146.217; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" This is a multi-part message in MIME format. --nextPart3094624.4HigakSz2z Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" > But gnulib's *overrides* the system's definition. And it > is visible after any of these header files has been included: > > lib/dynarray.h > lib/glob.in.h > lib/scratch_buffer.h > > After one of these files has been included, the application can > include any system include file, and these system include files will > typically rely on the system's definition of __* macros from . > > It's a different thing to include for the compilation of > a Gnulib .c file than to expose it through a .h file that the application > can include. In the first case, the Gnulib .c file includes a small set > of system's .h files, and therefore we can hope to have resolved the > possible conflicts in a reasonable amount of time. In the second case, > there is an uncountable number of conflicts; so, this problem will > haunt us for years if we don't fix it. > > My fix here is to process the glob-libc.h file so that it does not > rely on __* macros (that belong to the system's namespace) And likewise for dynarray.h and scratch_buffer.h. 2021-06-06 Bruno Haible scratch_buffer: Avoid conflict with prepr. macros owned by the system. * lib/scratch_buffer.h: Don't include . Define _GL_LIKELY, _GL_UNLIKELY. Include malloc/scratch_buffer.gl.h instead of malloc/scratch_buffer.h. * modules/scratch_buffer (Depends-on): Add builtin-expect. (Makefile.am): Arrange to create malloc/scratch_buffer.gl.h from malloc/scratch_buffer.h. 2021-06-06 Bruno Haible dynarray: Avoid conflict with preprocessor macros owned by the system. * lib/dynarray.h: Don't include . Define _GL_LIKELY, _GL_UNLIKELY. Include malloc/dynarray.gl.h instead of malloc/dynarray.h. Include malloc/dynarray-skeleton.gl.h instead of malloc/dynarray-skeleton.c. * modules/dynarray (Depends-on): Add builtin-expect. (Makefile.am): Arrange to create malloc/dynarray.gl.h from malloc/dynarray.h and malloc/dynarray-skeleton.gl.h from malloc/dynarray-skeleton.c. --nextPart3094624.4HigakSz2z Content-Disposition: attachment; filename="0001-dynarray-Avoid-conflict-with-preprocessor-macros-own.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0001-dynarray-Avoid-conflict-with-preprocessor-macros-own.patch" >From 0c907f7da13232908f05c415b8cec56024071906 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 7 Jun 2021 00:54:25 +0200 Subject: [PATCH 1/3] dynarray: Avoid conflict with preprocessor macros owned by the system. * lib/dynarray.h: Don't include . Define _GL_LIKELY, _GL_UNLIKELY. Include malloc/dynarray.gl.h instead of malloc/dynarray.h. Include malloc/dynarray-skeleton.gl.h instead of malloc/dynarray-skeleton.c. * modules/dynarray (Depends-on): Add builtin-expect. (Makefile.am): Arrange to create malloc/dynarray.gl.h from malloc/dynarray.h and malloc/dynarray-skeleton.gl.h from malloc/dynarray-skeleton.c. --- ChangeLog | 12 ++++++++++++ lib/dynarray.h | 10 +++++++--- modules/dynarray | 25 +++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 79fc6ff..b354ff0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2021-06-06 Bruno Haible + dynarray: Avoid conflict with preprocessor macros owned by the system. + * lib/dynarray.h: Don't include . Define _GL_LIKELY, + _GL_UNLIKELY. Include malloc/dynarray.gl.h instead of malloc/dynarray.h. + Include malloc/dynarray-skeleton.gl.h instead of + malloc/dynarray-skeleton.c. + * modules/dynarray (Depends-on): Add builtin-expect. + (Makefile.am): Arrange to create malloc/dynarray.gl.h from + malloc/dynarray.h and malloc/dynarray-skeleton.gl.h from + malloc/dynarray-skeleton.c. + +2021-06-06 Bruno Haible + glob-h: Avoid conflict with preprocessor macros owned by the system. This fixes a compilation error on DragonFly BSD 6.0. * lib/glob.in.h: Don't include . Don't define __USE_GNU. diff --git a/lib/dynarray.h b/lib/dynarray.h index 375d3da..ec64273 100644 --- a/lib/dynarray.h +++ b/lib/dynarray.h @@ -257,18 +257,22 @@ static DYNARRAY_ELEMENT * #if defined DYNARRAY_STRUCT || defined DYNARRAY_ELEMENT || defined DYNARRAY_PREFIX -# include +# ifndef _GL_LIKELY +/* Rely on __builtin_expect, as provided by the module 'builtin-expect'. */ +# define _GL_LIKELY(cond) __builtin_expect ((cond), 1) +# define _GL_UNLIKELY(cond) __builtin_expect ((cond), 0) +# endif /* Define auxiliary structs and declare auxiliary functions, common to all instantiations of dynarray. */ -# include +# include /* Define the instantiation, specified through DYNARRAY_STRUCT DYNARRAY_ELEMENT DYNARRAY_PREFIX etc. */ -# include +# include #else diff --git a/modules/dynarray b/modules/dynarray index dcdcba4..7fd444f 100644 --- a/modules/dynarray +++ b/modules/dynarray @@ -13,6 +13,7 @@ lib/malloc/dynarray_resize_clear.c Depends-on: c99 +builtin-expect libc-config stdbool stddef @@ -21,6 +22,30 @@ intprops configure.ac: Makefile.am: +BUILT_SOURCES += malloc/dynarray.gl.h malloc/dynarray-skeleton.gl.h + +malloc/dynarray.gl.h: malloc/dynarray.h + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e '/libc_hidden_proto/d' < $(srcdir)/malloc/dynarray.h; \ + } > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += malloc/dynarray.gl.h malloc/dynarray.gl.h-t + +malloc/dynarray-skeleton.gl.h: malloc/dynarray-skeleton.c + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|||g' \ + -e 's|__attribute_maybe_unused__|_GL_ATTRIBUTE_MAYBE_UNUSED|g' \ + -e 's|__attribute_nonnull__|_GL_ATTRIBUTE_NONNULL|g' \ + -e 's|__attribute_warn_unused_result__|_GL_ATTRIBUTE_NODISCARD|g' \ + -e 's|__glibc_likely|_GL_LIKELY|g' \ + -e 's|__glibc_unlikely|_GL_UNLIKELY|g' \ + < $(srcdir)/malloc/dynarray-skeleton.c; \ + } > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += malloc/dynarray-skeleton.gl.h malloc/dynarray-skeleton.gl.h-t + lib_SOURCES += malloc/dynarray_at_failure.c \ malloc/dynarray_emplace_enlarge.c \ malloc/dynarray_finalize.c \ -- 2.7.4 --nextPart3094624.4HigakSz2z Content-Disposition: attachment; filename="0002-scratch_buffer-Avoid-conflict-with-prepr.-macros-own.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0002-scratch_buffer-Avoid-conflict-with-prepr.-macros-own.patch" >From 469f9f3685c4026e79ccc8f3fb35c3eb25fd3716 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 7 Jun 2021 00:56:50 +0200 Subject: [PATCH 2/3] scratch_buffer: Avoid conflict with prepr. macros owned by the system. * lib/scratch_buffer.h: Don't include . Define _GL_LIKELY, _GL_UNLIKELY. Include malloc/scratch_buffer.gl.h instead of malloc/scratch_buffer.h. * modules/scratch_buffer (Depends-on): Add builtin-expect. (Makefile.am): Arrange to create malloc/scratch_buffer.gl.h from malloc/scratch_buffer.h. --- ChangeLog | 10 ++++++++++ lib/scratch_buffer.h | 10 +++++++--- modules/scratch_buffer | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index b354ff0..16132b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2021-06-06 Bruno Haible + scratch_buffer: Avoid conflict with prepr. macros owned by the system. + * lib/scratch_buffer.h: Don't include . Define + _GL_LIKELY, _GL_UNLIKELY. Include malloc/scratch_buffer.gl.h instead of + malloc/scratch_buffer.h. + * modules/scratch_buffer (Depends-on): Add builtin-expect. + (Makefile.am): Arrange to create malloc/scratch_buffer.gl.h from + malloc/scratch_buffer.h. + +2021-06-06 Bruno Haible + dynarray: Avoid conflict with preprocessor macros owned by the system. * lib/dynarray.h: Don't include . Define _GL_LIKELY, _GL_UNLIKELY. Include malloc/dynarray.gl.h instead of malloc/dynarray.h. diff --git a/lib/scratch_buffer.h b/lib/scratch_buffer.h index 7bb6fe8..8873577 100644 --- a/lib/scratch_buffer.h +++ b/lib/scratch_buffer.h @@ -110,14 +110,18 @@ extern void *scratch_buffer_dupfree (struct scratch_buffer *buffer, /* The implementation is imported from glibc. */ -#include - /* Avoid possible conflicts with symbols exported by the GNU libc. */ #define __libc_scratch_buffer_dupfree gl_scratch_buffer_dupfree #define __libc_scratch_buffer_grow gl_scratch_buffer_grow #define __libc_scratch_buffer_grow_preserve gl_scratch_buffer_grow_preserve #define __libc_scratch_buffer_set_array_size gl_scratch_buffer_set_array_size -#include +#ifndef _GL_LIKELY +/* Rely on __builtin_expect, as provided by the module 'builtin-expect'. */ +# define _GL_LIKELY(cond) __builtin_expect ((cond), 1) +# define _GL_UNLIKELY(cond) __builtin_expect ((cond), 0) +#endif + +#include #endif /* _GL_SCRATCH_BUFFER_H */ diff --git a/modules/scratch_buffer b/modules/scratch_buffer index cf83ab5..ede77a9 100644 --- a/modules/scratch_buffer +++ b/modules/scratch_buffer @@ -11,6 +11,7 @@ lib/malloc/scratch_buffer_set_array_size.c Depends-on: c99 +builtin-expect libc-config stdbool stddef @@ -21,6 +22,20 @@ free-posix configure.ac: Makefile.am: +BUILT_SOURCES += malloc/scratch_buffer.gl.h + +malloc/scratch_buffer.gl.h: malloc/scratch_buffer.h + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|__always_inline|inline _GL_ATTRIBUTE_ALWAYS_INLINE|g' \ + -e 's|__glibc_likely|_GL_LIKELY|g' \ + -e 's|__glibc_unlikely|_GL_UNLIKELY|g' \ + -e '/libc_hidden_proto/d' \ + < $(srcdir)/malloc/scratch_buffer.h; \ + } > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += malloc/scratch_buffer.gl.h malloc/scratch_buffer.gl.h-t + lib_SOURCES += malloc/scratch_buffer_dupfree.c \ malloc/scratch_buffer_grow.c \ malloc/scratch_buffer_grow_preserve.c \ -- 2.7.4 --nextPart3094624.4HigakSz2z--