xref: /netbsd-src/common/lib/libc/string/explicit_memset.c (revision b7152c324c52acdae196766ae19dab96f1d64ea1)
1 /* $NetBSD: explicit_memset.c,v 1.5 2024/11/02 02:43:48 riastradh Exp $ */
2 
3 /*
4  * Written by Matthias Drochner <drochner@NetBSD.org>.
5  * Public domain.
6  */
7 
8 #if !defined(_KERNEL) && !defined(_STANDALONE)
9 #include "namespace.h"
10 #include <string.h>
11 #ifdef __weak_alias
12 __weak_alias(explicit_memset,_explicit_memset)
13 __strong_alias(memset_explicit,_explicit_memset)	/* C23 */
14 #endif
15 #define explicit_memset_impl __explicit_memset_impl
16 #else
17 #include <lib/libkern/libkern.h>
18 #endif
19 
20 /*
21  * The use of a volatile pointer guarantees that the compiler
22  * will not optimise the call away.
23  */
24 void *(* volatile explicit_memset_impl)(void *, int, size_t) = memset;
25 
26 void *
27 explicit_memset(void *b, int c, size_t len)
28 {
29 
30 	return (*explicit_memset_impl)(b, c, len);
31 }
32