mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Jens Gustedt <jens.gustedt@inria.fr>
To: musl@lists.openwall.com
Subject: Re: Optimized C memset
Date: Tue, 27 Aug 2013 10:52:55 +0200	[thread overview]
Message-ID: <1377593575.25996.289.camel@eris.loria.fr> (raw)
In-Reply-To: <20130827083020.GA4503@brightrain.aerifal.cx>

[-- Attachment #1: Type: text/plain, Size: 1760 bytes --]

Hello,

Am Dienstag, den 27.08.2013, 04:30 -0400 schrieb Rich Felker:
> One aspect of this code that may appear ugly at first is the usage of
> the __GNUC__ macro.

It not only *appears* to be ugly :)

You already have a slight inconsistency in that at one point the code
depends on a particular version of "gcc" and other part only depends
on the fact that the __GNUC__ macro is set.

There are a lot of compilers out there faking to be a gcc of some
version and that are not always feature consistent with the gcc
version that they are claming to fake. ICC is notorious for that. So
to my opinion this is a dangerous path to follow. (I don't know about
any problems with the __may_alias__ attribute, though)

To make this easier to maintain, I'd suggest to introduce a special
feature test macro, something like __has_may_alias__, and have that
set at the beginning of the file in a section that is clearly
dedicated to compile time feature detection. Other compilers may have
different syntax for such a feature (a _Pragma comes in mind) and may
be detected quite differently than by gcc version numbering.

Such specific feature test macros is the way that clang goes, and from
my experience this is much easier to maintain and to understand when
you stumble on such #ifdef'ed code. You not only know that this needs
a special version of a compiler, but also for what reason.

Best

Jens


-- 
:: INRIA Nancy Grand Est :: http://www.loria.fr/~gustedt/   ::
:: AlGorille ::::::::::::::: office Nancy : +33 383593090   ::
:: ICube :::::::::::::: office Strasbourg : +33 368854536   ::
:: ::::::::::::::::::::::::::: gsm France : +33 651400183   ::
:: :::::::::::::::::::: gsm international : +49 15737185122 ::




[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2013-08-27  8:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-27  8:30 Rich Felker
2013-08-27  8:52 ` Jens Gustedt [this message]
2013-08-27  9:17   ` Rich Felker
2013-08-27  9:50     ` Jens Gustedt
2013-08-27 14:21       ` Rich Felker
2013-08-27 14:34         ` Luca Barbato
2013-08-27 14:39           ` Rich Felker
2013-08-27 15:20         ` John Spencer
2013-08-27 15:34           ` Rich Felker
2013-08-27 16:22 ` Optimized C memset [v2] Rich Felker
2013-08-27 17:28   ` Jeremy Huntwork
2013-08-27 21:27     ` Rich Felker
2013-08-28  0:05   ` Andre Renaud
2013-08-28  1:24     ` Rich Felker

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=1377593575.25996.289.camel@eris.loria.fr \
    --to=jens.gustedt@inria.fr \
    --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).