Skip to content

Commit

Permalink
Enable __STDC_WANT_LIB_EXT1__ to get memset_s
Browse files Browse the repository at this point in the history
As we switch to C11, the availability of the memset_s function under Macos is
detected by autoconf. The explicit_bzero.c module will use it to implement
explicit_bzero(3) on that system.

According to N1570, Annex K, in order for the string.h header to declare
memset_s(), we need to define __STDC_WANT_LIB_EXT1__ as 1 before including the
header file.  The libc implementation is in turn supposed to define
__STDC_LIB_EXT1__ in the header, to claim that the interfaces of Annex K are
implemented as dictated by the standard.

In theory, we should be using memset_s() only if __STDC_LIB_EXT1__ is defined,
but we know that memset_s() exists thanks to autoconf. Since the Macos libc
does not define __STDC_LIB_EXT1__, we can not be 100% sure that the memset_s()
function is implemented in a standard way.
  • Loading branch information
dacav committed Jan 24, 2025
1 parent abe1439 commit 7dbddf0
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions explicit_bzero.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Written by Ted Unangst
*/

#define __STDC_WANT_LIB_EXT1__ 1
#include <string.h>

/*
Expand Down

0 comments on commit 7dbddf0

Please sign in to comment.