mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Pedro Falcato <pedro.falcato@gmail.com>
To: musl@lists.openwall.com
Cc: James Tirta Halim <tirtajames45@gmail.com>
Subject: Re: [musl] [PATCH] add memcmpeq: memcmp that returns length of first mismatch
Date: Thu, 29 Feb 2024 00:02:04 +0000	[thread overview]
Message-ID: <CAKbZUD2XSZ4MdoS0JoyhJU=1yxVQywqzpRTuLrMPusKtYgOoSA@mail.gmail.com> (raw)
In-Reply-To: <Pine.BSM.4.64L.2402282312460.1531@herc.mirbsd.org>

On Wed, Feb 28, 2024 at 11:18 PM Thorsten Glaser <tg@mirbsd.de> wrote:
>
> Markus Wichmann dixit:
>
> >> > > +        for (; n >= sizeof(word) && *(word *)p1 == *(word *)p2; p1+=sizeof(word), p2+=sizeof(word), n-=sizeof(word));
>
> Very much UB.
>
> >4. All the other musl C code avoids misaligned word access. I don't know
> >which architecture/ABI doesn't allow it, but it is nevertheless the
>
> Almost all of them. i386/amd64 penalise it heavily and it can cause

Small note: This isn't quite true for remotely modern x86, unaligned
accesses are pretty cheap compared to extra branches, and this fact is
abused very frequently in optimized stringops implementations (see
every optimized memcpy - which use overlapping loads and stores,
effectively abusing unaligned mem ops).

-- 
Pedro

  reply	other threads:[~2024-02-29  0:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27 14:07 James Tirta Halim
2024-02-27 14:49 ` Rich Felker
2024-02-27 14:51   ` Rich Felker
2024-02-28  4:40     ` Markus Wichmann
2024-02-28 23:14       ` Thorsten Glaser
2024-02-29  0:02         ` Pedro Falcato [this message]
2024-02-29  0:10           ` Thorsten Glaser
2024-02-29  0:57             ` Robert Clausecker
2024-02-29  1:13               ` Pedro Falcato
2024-02-29  4:19         ` Markus Wichmann

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='CAKbZUD2XSZ4MdoS0JoyhJU=1yxVQywqzpRTuLrMPusKtYgOoSA@mail.gmail.com' \
    --to=pedro.falcato@gmail.com \
    --cc=musl@lists.openwall.com \
    --cc=tirtajames45@gmail.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).