mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: _STRING_ARCH_unaligned or equivalent definition
Date: Sat, 24 Oct 2015 13:57:04 +0200	[thread overview]
Message-ID: <20151024115704.GM10551@port70.net> (raw)
In-Reply-To: <562B4D9B.5070100@draigBrady.com>

* P?draig Brady <P@draigBrady.com> [2015-10-24 10:21:31 +0100]:
> I was writing some code which uses faster word at a time
> but possibly unaligned access when we know that unaligned
> access is OK, i.e. #if _STRING_ARCH_unaligned provided by glibc.
> 
> I would like not to fall back to the slower path on musl.
> Is there a similar define for musl. Is is worth proposing
> a standard define somewhere?
> 

you have to negotiate with the compiler about this,
not with the libc.

this violates pointer aliasing rules and only the
compiler can give you guaranteed semantics (with
language extensions like attribute mayalias).

i don't think gcc has a predefined macro about
unaligned access (it is non-trivial to provide it
in a useful way because a platform may allow it,
but at a significant performance cost).

i think _STRING_ARCH_unaligned in glibc was not
supposed to be public api, it is used internally
to provide more efficient implementations (some
functions are implemented in the string header hence
it is publicly visible.. but don't assume such
variables will remain there after a glibc update).

when you do such low-level optimizations i think
you have to manually maintain the list of targets
the optimization is known to be valid for.


  reply	other threads:[~2015-10-24 11:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-24  9:21 Pádraig Brady
2015-10-24 11:57 ` Szabolcs Nagy [this message]
2015-10-24 19:43   ` 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=20151024115704.GM10551@port70.net \
    --to=nsz@port70.net \
    --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).