Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180501210553.GV1392@brightrain.aerifal.cx>
Date: Tue, 1 May 2018 17:05:53 -0400
From: Rich Felker <dalias@...c.org>
To: Patrick Oppenlander <patrick.oppenlander@...il.com>
Cc: musl@...ts.openwall.com
Subject: Re: Some questions

On Tue, May 01, 2018 at 10:10:45AM +1000, Patrick Oppenlander wrote:
> On Mon, Apr 30, 2018 at 1:16 PM, Rich Felker <dalias@...c.org> wrote:
> > On Mon, Apr 30, 2018 at 12:52:06PM +1000, Patrick Oppenlander wrote:
> >> - sigisemptyset uses bss. Could be implemented in a similar fashion to
> >> sigemptyset, save bss & would probably be faster.
> >
> > Ahh, yes. I wonder if gcc has any way to force const zero objects into
> > rodata rather than bss..? In any case memcmp is not an efficient way
> > to implement this, so maybe it should be changed.
> 
> Doing this:
> 
> diff --git a/src/signal/sigisemptyset.c b/src/signal/sigisemptyset.c
> index 312c66cf..28f74203 100644
> --- a/src/signal/sigisemptyset.c
> +++ b/src/signal/sigisemptyset.c
> @@ -4,6 +4,6 @@
> 
>  int sigisemptyset(const sigset_t *set)
>  {
> -       static const unsigned long zeroset[_NSIG/8/sizeof(long)];
> +       static const unsigned long zeroset[_NSIG/8/sizeof(long)] = {};
>         return !memcmp(set, &zeroset, _NSIG/8);
>  }
> 
> Makes it go into rodata.
> 
> I agree that it should probably be rewritten to not use memcmp.

I'm just changing it to avoid memcmp. This gets rid of the bss and
makes the code smaller.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.