Implement C23 memset_explicit (bug 32378)
Collin Funk
collin.funk1@gmail.com
Sat Sep 27 23:42:12 GMT 2025
Hi Paul,
Paul Eggert <eggert@cs.ucla.edu> writes:
> On 2025-09-26 13:29, Joseph Myers wrote:
>> That's a key question for review of this patch. Should it be visible for
>> __USE_MISC as well as __GLIBC_USE (ISOC23)?
>
> The C23 function memccpy is visible if __USE_MISC, so there's
> reasonable precedent for making memset_explicit visible too (which is
> what I'd advocate anyway - I love exposure!).
>
> I guess I'm not seeing why we'd want to be shy about visibility here.
The memccpy case is a bit different since glibc has had that function
for a very long time. From looking at archives it appears to have been
introduced by the 8th edition of Research Unix and then added to 2.11BSD
[1]. I guess the C standard people thought it was useful enough to add
to C23 after decades.
Here is the description of __USE_MISC from include/features.h:
__USE_MISC Define things from 4.3BSD or System V Unix.
So memccpy aligns perfectly with that description, it is an extension
that was provided in 4.3BSD.
It looks like memset_explicit was a C standard invention for C23. So I
don't think it makes much sense to use here. People like you and I who
like modern C features and do not care about many symbols being visible
can use _GNU_SOURCE.
Collin
[1] https://www.tuhs.org/cgi-bin/utree.pl
More information about the Libc-alpha
mailing list