From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11228 Path: news.gmane.org!.POSTED!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: byteswap.h Date: Sat, 8 Apr 2017 16:57:04 +0200 Message-ID: <20170408145703.GB2082@port70.net> References: <225ea64f-f051-1a61-0ba2-db9f27d1ba68@gmail.com> <20170407180742.GB8704@wirbelwind> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1491663440 30956 195.159.176.226 (8 Apr 2017 14:57:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 8 Apr 2017 14:57:20 +0000 (UTC) User-Agent: Mutt/1.6.0 (2016-04-01) To: musl@lists.openwall.com Original-X-From: musl-return-11243-gllmg-musl=m.gmane.org@lists.openwall.com Sat Apr 08 16:57:16 2017 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.84_2) (envelope-from ) id 1cwrnd-0007DD-5N for gllmg-musl@m.gmane.org; Sat, 08 Apr 2017 16:57:13 +0200 Original-Received: (qmail 7838 invoked by uid 550); 8 Apr 2017 14:57:16 -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 7814 invoked from network); 8 Apr 2017 14:57:16 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <20170407180742.GB8704@wirbelwind> Xref: news.gmane.org gmane.linux.lib.musl.general:11228 Archived-At: * Joakim Sindholt [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.