mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH 2/2] use the correct attributes for ___errno_location
Date: Sat, 29 Jun 2019 17:49:44 -0400	[thread overview]
Message-ID: <20190629214944.GO1506@brightrain.aerifal.cx> (raw)
In-Reply-To: <20190629212244.42963-3-samuel@sholland.org>

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


  reply	other threads:[~2019-06-29 21:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-29 21:22 [PATCH 0/2] Resolve compiler warnings in master Samuel Holland
2019-06-29 21:22 ` [PATCH 1/2] resolve -Wrestrict warnings Samuel Holland
2019-06-29 21:22 ` [PATCH 2/2] use the correct attributes for ___errno_location Samuel Holland
2019-06-29 21:49   ` Rich Felker [this message]
2019-06-29 21:46 ` [PATCH 0/2] Resolve compiler warnings in master Rich Felker
2019-06-29 23:05   ` Samuel Holland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190629214944.GO1506@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).