From: Bruno Haible <bruno@clisp.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: Simon Josefsson <simon@josefsson.org>, bug-gnulib@gnu.org
Subject: Re: explicit_bzero and -std=c99
Date: Sun, 27 Nov 2022 19:24:25 +0100 [thread overview]
Message-ID: <6449031.tM3a2QDmDi@nimes> (raw)
In-Reply-To: <4ba22843-7491-b610-bf42-45b99fa302a0@cs.ucla.edu>
Paul Eggert wrote:
> > 2) Is there no other way to implement explicit_bzero without 'asm'?
> > There is a another fallback code using volatile pointers, but I'm not
> > sure it really has the same semantics.
>
> That fallback should work, though it's a bit slower.
I'm afraid that the fallback code
/* Invoke memset through a volatile function pointer. This defeats compiler
optimizations. */
void * (* const volatile volatile_memset) (void *, int, size_t) = memset;
(void) volatile_memset (s, '\0', len);
will stop working, as compilers get "smarter".
The other code based on asm is not so likely to break, since it is documented
that "Using the "memory" clobber effectively forms a read/write memory barrier
for the compiler." [1]
Bruno
[1] https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Extended-Asm.html
prev parent reply other threads:[~2022-11-27 18:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CALAySuJi-gG53FDojZtMwZ9e254o3LbdAxnjZA6esN3724ZXLg@mail.gmail.com>
[not found] ` <87tu2kps44.fsf@latte>
2022-11-27 11:27 ` explicit_bzero and -std=c99 Simon Josefsson via Gnulib discussion list
2022-11-27 17:48 ` Bruno Haible
2022-11-28 10:32 ` Simon Josefsson via Gnulib discussion list
2022-11-29 14:49 ` Bruno Haible
2022-11-27 18:05 ` Paul Eggert
2022-11-27 18:08 ` Paul Eggert
2022-11-27 18:24 ` Bruno Haible [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
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6449031.tM3a2QDmDi@nimes \
--to=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
--cc=eggert@cs.ucla.edu \
--cc=simon@josefsson.org \
/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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).