![]() |
|
Message-ID: <CAJgzZor+c3goq41NZQs9UNpzZg01Bfm20+=p=_bd4JbD8gFKvw@mail.gmail.com> Date: Wed, 4 Jun 2025 13:35:53 -0400 From: enh <enh@...gle.com> To: musl@...ts.openwall.com Subject: Re: c23 memset_explicit() did memset_explicit() make it in, or was this blocked on rewriting explicit_bzero() to call memset_explicit()? (we're starting to see more users and thus more portability problems.) On Tue, Mar 19, 2024 at 8:59 AM Aaron Peter Bachmann <aaron_ng@...de.at> wrote: > > I recognized neither > https://git.musl-libc.org/cgit/musl > nor > https://forge.icube.unistra.fr/icps/musl/-/branches > seem to include c23 memset_explicit(). > Or it slipped my attention. > > So I provide a patch. It compiles but is otherwise untested. > It is trivial enough that you would spot an error when merging. > No guards for c23 as mem is a reserved prefix. > It closely follows explicit_bzero.c. So I assume it fits into the coding > style musl uses. > > Regards, Aaron Peter Bachmann > > > diff --git a/include/string.h b/include/string.h > index 83e2b946..563b3b0a 100644 > --- a/include/string.h > +++ b/include/string.h > @@ -27,6 +27,7 @@ extern "C" { > void *memcpy (void *__restrict, const void *__restrict, size_t); > void *memmove (void *, const void *, size_t); > void *memset (void *, int, size_t); > +void *memset_explicit(void *, int, size_t); > int memcmp (const void *, const void *, size_t); > void *memchr (const void *, int, size_t); > > diff --git a/src/string/memset_explicit.c b/src/string/memset_explicit.c > new file mode 100644 > index 00000000..ac54f0cf > --- /dev/null > +++ b/src/string/memset_explicit.c > @@ -0,0 +1,8 @@ > +#include <string.h> > + > +void *memset_explicit(void *d, int c, size_t n) > +{ > + d = memset(d, c, n); > + __asm__ __volatile__ ("" : : "r"(d) : "memory"); > + return d; > +} >
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.