From adfdcceb8aad478bc3c5692fb3aff045c0c8ef37 Mon Sep 17 00:00:00 2001 From: riastradh Date: Mon, 24 Jun 2013 04:21:19 +0000 Subject: 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. --- common/lib/libc/string/consttime_bcmp.c | 19 ------------------- common/lib/libc/string/consttime_memequal.c | 19 +++++++++++++++++++ common/lib/libc/string/explicit_bzero.c | 22 ---------------------- common/lib/libc/string/explicit_memset.c | 22 ++++++++++++++++++++++ 4 files changed, 41 insertions(+), 41 deletions(-) delete mode 100644 common/lib/libc/string/consttime_bcmp.c create mode 100644 common/lib/libc/string/consttime_memequal.c delete mode 100644 common/lib/libc/string/explicit_bzero.c create mode 100644 common/lib/libc/string/explicit_memset.c (limited to 'common/lib/libc/string') diff --git a/common/lib/libc/string/consttime_bcmp.c b/common/lib/libc/string/consttime_bcmp.c deleted file mode 100644 index e6c0b31c17e..00000000000 --- a/common/lib/libc/string/consttime_bcmp.c +++ /dev/null @@ -1,19 +0,0 @@ -/* $NetBSD: consttime_bcmp.c,v 1.1 2012/08/30 12:16:49 drochner Exp $ */ - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#include -#define consttime_bcmp __consttime_bcmp -#else -#include -#endif - -int -consttime_bcmp(const void *b1, const void *b2, size_t len) -{ - const char *c1 = b1, *c2 = b2; - int res = 0; - - while (len --) - res |= *c1++ ^ *c2++; - return res; -} diff --git a/common/lib/libc/string/consttime_memequal.c b/common/lib/libc/string/consttime_memequal.c new file mode 100644 index 00000000000..969e53295fe --- /dev/null +++ b/common/lib/libc/string/consttime_memequal.c @@ -0,0 +1,19 @@ +/* $NetBSD: consttime_memequal.c,v 1.1 2013/06/24 04:21:19 riastradh Exp $ */ + +#if !defined(_KERNEL) && !defined(_STANDALONE) +#include +#define consttime_memequal __consttime_memequal +#else +#include +#endif + +int +consttime_memequal(const void *b1, const void *b2, size_t len) +{ + const char *c1 = b1, *c2 = b2; + int res = 0; + + while (len --) + res |= *c1++ ^ *c2++; + return res; +} diff --git a/common/lib/libc/string/explicit_bzero.c b/common/lib/libc/string/explicit_bzero.c deleted file mode 100644 index c34410cfdde..00000000000 --- a/common/lib/libc/string/explicit_bzero.c +++ /dev/null @@ -1,22 +0,0 @@ -/* $NetBSD: explicit_bzero.c,v 1.1 2012/08/30 12:16:49 drochner Exp $ */ - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#include -#define explicit_bzero __explicit_bzero -#define explicit_memset_impl __explicit_memset_impl -#else -#include -#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_bzero(void *b, size_t len) -{ - - (*explicit_memset_impl)(b, 0, len); -} 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 +#define explicit_memset __explicit_memset +#define explicit_memset_impl __explicit_memset_impl +#else +#include +#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); +} -- cgit