mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: Optimized C memset
Date: Tue, 27 Aug 2013 11:34:54 -0400	[thread overview]
Message-ID: <20130827153454.GT20515@brightrain.aerifal.cx> (raw)
In-Reply-To: <521CC3A1.1050706@barfooze.de>

On Tue, Aug 27, 2013 at 05:20:01PM +0200, John Spencer wrote:
> On 08/27/2013 04:21 PM, Rich Felker wrote:
> >One of the things I think our users like about musl versus glibc
> >is that, for the vast majority of the code, you can fully determine
> >what it's doing without reading other implementation-specific files
> >that define magic macros for things you might not understand -- and
> >that you can take the code and drop it into another project without
> >having to find all the implementation-internal headers it depends on.
> >
> >If something needs to be changed about the logic for may_alias, a
> >simple grep -r will find all the source files it's in and makes it
> >easy to change several occurrences. So I tend to think preserving
> >readability and ease of reuse are more important than avoiding
> >duplication, but if others agree with you, I wouldn't be entirely
> >opposed to adding a "string_impl.h" or similar header with some shared
> >preprocessor logic for all of the string functions that might be doing
> >sketchy things with aliasing and alignment. I'd appreciate comments on
> >this matter from others on which way we should go.
> 
> 
> my feeling is that we should stick to our current policy of minor
> macros being defined in the TUs that use them, making it both
> simpler to read, and faster to compile (less work for the
> preprocessor).
> 
> sufficiently complex macros can go to internal headers instead, so
> there's only one spot to be taken care of.

Indeed, while it's tempting to do something like defining "repr32",
"repr64", etc. types (with may_alias attribute) in a common header, I
think it makes the code a lot less clear, and actually more difficult
to maintain if requirements of individual translation units change
(for example some want to use fixed bit sizes, others want to use
system word size).

What may be beneficial, however, is putting the logic for whether
aliasing rule exemptions are possible at all, and the attribute to use
to get them, into a shared header file. However I'm not convinced that
this logic is anymore complex than "#ifdef __GNUC__", so I think for
now I'd like to start off just doing it simple, and possibly switch
later as more string functions are adapted to document their aliasing
to the compiler. I've always found that if factoring out this kind of
logic is beneficial, the right way to factor it emerges while actually
implementing the code rather than by trying to guess ahead of time
what will be best.

Rich


  reply	other threads:[~2013-08-27 15:34 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
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 [this message]
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=20130827153454.GT20515@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --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).