![]() |
|
Message-ID: <20250605214253.GD1827@brightrain.aerifal.cx> Date: Thu, 5 Jun 2025 17:42:53 -0400 From: Rich Felker <dalias@...c.org> To: enh <enh@...gle.com> Cc: musl@...ts.openwall.com Subject: Re: c23 memset_explicit() On Wed, Jun 04, 2025 at 01:35:53PM -0400, enh wrote: > 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.) I don't think it's blocked. I just haven't gone thru and started merging C23 stuff yet. Whether to rewrite explicit_bzero in terms of it is a separate question. Rich > 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.