Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Sat, 8 Apr 2017 16:57:04 +0200
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: byteswap.h

* Joakim Sindholt <opensource@...sha.com> [2017-04-07 20:07:42 +0200]:
> On Fri, Apr 07, 2017 at 07:53:09PM +0200, fab10 wrote:
> > I had a look at byteswap.h and it seems to me that the code is not very 
> > efficient. Every function in this header could be translated in a single 
> > assembly instruction with the gcc intrinsics:
> > 
> > __builtin_bswap16
> > __builtin_bswap32
> > __builtin_bswap64
> > 
> > Is there a reason to not use these gcc intrinsics?
> > 
> > Bye
> > 
> 
> While musl does employ GNU C features in quite a few places it's just
> plain unnecessary here.
> 
rarely in public headers though which have to
be portable to all c source parser tools.
builtins  would need to be conditional on __GNUC__
and we still need the portable code as a fallback
which is harder to maintain and test

> https://godbolt.org/g/eLZWwI
> 
> When optimized those functions yield a single bswap instruction anyway,
> because GCC is smart enough to deduce this.

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.