From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: Re: thoughts on reallocarray, explicit_bzero?
Date: Wed, 11 Jun 2014 08:59:12 -0400 [thread overview]
Message-ID: <20140611125912.GQ179@brightrain.aerifal.cx> (raw)
In-Reply-To: <loom.20140611T115517-929@post.gmane.org>
On Wed, Jun 11, 2014 at 09:59:56AM +0000, Thorsten Glaser wrote:
> Szabolcs Nagy <nsz <at> port70.net> writes:
>
> > static size_t sizemul(size_t a, size_t b)
> > {
> > return b>1 && a>1 && a>-1/b ? -1 : a*b;
> > }
>
> There is no -1 in size_t. (And *you* complain about OpenBSD checks…)
The standard way (especially for generic programming, but it's usable
anywhere) to get the max value for an unsigned type is to convert -1.
b and a*b both have type size_t, so...
> > i don't see how the openbsd explicit_bzero stops the
> > compiler to do optimizations..
>
> On OpenBSD: by being in libc which is not built with LTO.
> I’ve wondered about how to do this either. Maybe:
Yeah, that's a poor hack. We still probably have some places where
"extern" is used as a compiler barrier, but it's wrong, and I'm
working to identify and remove them all.
> void
> explicit_bzero(void *s, size_t n)
> {
> bzero(s, n);
> __lto_boundary
> }
>
> Then you #define __lto_boundary to something like
> __asm__ volatile ("" : : : "memory");
> or
> __sync_synchronize();
> or some C11 barrier function.
These are not sufficient. It would probably need to be:
__asm__ volatile ("" : : "r"(s) : "memory");
or similar. This is because volatility and memory-clobber only
provide a barrier with respect to objects which exist in memory, and
at the point of the asm (after transformations which do not disturb
the observable behavior of the program), the pointed-to object with
automatic storage does not exist.
Rich
prev parent reply other threads:[~2014-06-11 12:59 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-19 15:31 Isaac Dunham
2014-05-19 15:43 ` Rich Felker
2014-05-19 16:19 ` Daniel Cegiełka
2014-05-20 6:19 ` Rich Felker
2014-05-20 15:50 ` Daniel Cegiełka
2014-05-19 15:44 ` Daniel Cegiełka
2014-05-19 16:16 ` Rich Felker
2014-05-19 16:30 ` Daniel Cegiełka
2014-05-19 16:32 ` Szabolcs Nagy
2015-01-28 22:01 ` Daniel Cegiełka
2015-01-28 22:34 ` Daniel Cegiełka
2015-01-28 22:38 ` Nathan McSween
2015-01-28 22:54 ` Daniel Cegiełka
2015-01-28 23:02 ` Josiah Worcester
2015-01-29 2:19 ` Rich Felker
2015-01-29 4:03 ` Brent Cook
2015-01-29 4:15 ` Rich Felker
2015-01-29 9:30 ` Daniel Cegiełka
2015-01-29 10:04 ` Szabolcs Nagy
2015-01-29 10:31 ` Daniel Cegiełka
2015-01-29 10:54 ` Daniel Cegiełka
2014-05-19 16:25 ` Szabolcs Nagy
2014-05-19 16:45 ` Daniel Cegiełka
2014-05-19 16:58 ` Rich Felker
2014-05-19 16:55 ` Rich Felker
2014-05-19 18:12 ` Szabolcs Nagy
2014-05-19 22:08 ` Andy Lutomirski
2014-05-20 0:41 ` Szabolcs Nagy
2014-06-11 9:59 ` Thorsten Glaser
2014-06-11 12:59 ` Rich Felker [this message]
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=20140611125912.GQ179@brightrain.aerifal.cx \
--to=dalias@libc.org \
--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).