diff options
| author | riastradh <riastradh@NetBSD.org> | 2013-06-24 04:21:19 +0000 |
|---|---|---|
| committer | riastradh <riastradh@NetBSD.org> | 2013-06-24 04:21:19 +0000 |
| commit | adfdcceb8aad478bc3c5692fb3aff045c0c8ef37 (patch) | |
| tree | ee62fd1d002750ee339715e953885019cf401475 /common/lib/libc/string/explicit_memset.c | |
| parent | 8fcb059d64019ef3a03b90cb11f6c6d47aeeb6b9 (diff) | |
Replace consttime_bcmp/explicit_bzero by consttime_memequal/explicit_memset.
consttime_memequal is the same as the old consttime_bcmp.
explicit_memset is to memset as explicit_bzero was to bcmp.
Passes amd64 release and i386/ALL, but I'm sure I missed some spots,
so please let me know.
Diffstat (limited to 'common/lib/libc/string/explicit_memset.c')
| -rw-r--r-- | common/lib/libc/string/explicit_memset.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/common/lib/libc/string/explicit_memset.c b/common/lib/libc/string/explicit_memset.c new file mode 100644 index 00000000000..181cf188628 --- /dev/null +++ b/common/lib/libc/string/explicit_memset.c @@ -0,0 +1,22 @@ +/* $NetBSD: explicit_memset.c,v 1.1 2013/06/24 04:21:19 riastradh Exp $ */ + +#if !defined(_KERNEL) && !defined(_STANDALONE) +#include <string.h> +#define explicit_memset __explicit_memset +#define explicit_memset_impl __explicit_memset_impl +#else +#include <lib/libkern/libkern.h> +#endif + +/* + * The use of a volatile pointer guarantees that the compiler + * will not optimise the call away. + */ +void *(* volatile explicit_memset_impl)(void *, int, size_t) = memset; + +void +explicit_memset(void *b, int c, size_t len) +{ + + (*explicit_memset_impl)(b, c, len); +} |
