From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14300 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH 2/2] use the correct attributes for ___errno_location Date: Sat, 29 Jun 2019 17:49:44 -0400 Message-ID: <20190629214944.GO1506@brightrain.aerifal.cx> References: <20190629212244.42963-1-samuel@sholland.org> <20190629212244.42963-3-samuel@sholland.org> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="178974"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-14316-gllmg-musl=m.gmane.org@lists.openwall.com Sat Jun 29 23:50:01 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1hhLEN-000kQu-K6 for gllmg-musl@m.gmane.org; Sat, 29 Jun 2019 23:49:59 +0200 Original-Received: (qmail 14157 invoked by uid 550); 29 Jun 2019 21:49:57 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 14137 invoked from network); 29 Jun 2019 21:49:57 -0000 Content-Disposition: inline In-Reply-To: <20190629212244.42963-3-samuel@sholland.org> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:14300 Archived-At: On Sat, Jun 29, 2019 at 04:22:44PM -0500, Samuel Holland wrote: > In the public header, __errno_location is declared with the "const" > attribute, conditional on __GNUC__. Ensure that its internal alias has > the same attributes. > --- > src/errno/__errno_location.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/src/errno/__errno_location.c b/src/errno/__errno_location.c > index 7f9d6027..b59919c3 100644 > --- a/src/errno/__errno_location.c > +++ b/src/errno/__errno_location.c > @@ -6,4 +6,8 @@ int *__errno_location(void) > return &__pthread_self()->errno_val; > } > > -weak_alias(__errno_location, ___errno_location); > +weak_alias(__errno_location, ___errno_location) > +#ifdef __GNUC__ > +__attribute__((const)) > +#endif > +; > -- > 2.21.0 Thanks for catching this. It's probably a significant regression in codegen. I think the attribute should be on the declaration in src/include/errno.h though, not on the weak_alias definition. Most importantly this is needed for it to affect codegen in the callers. But it's also for consistency with the approach of having attributes on the declarations rather than the definitions (to ensure everyone gets a consistent view of them), and to avoid assumptions about what the weak_alias macro expands to. Rich