Skip to content
Permalink
Browse files

Use explicit_bzero() if available

  • Loading branch information...
jedisct1 committed Mar 5, 2019
1 parent 1514e4d commit c9b4bea198e2057c452b3bfd558753149c8b06d3
Showing with 12 additions and 0 deletions.
  1. +8 −0 impl/common.h
  2. +4 −0 impl/core.h
@@ -39,6 +39,14 @@
# define SIZE_MAX ((size_t) -1)
#endif

#ifdef __OpenBSD__
# define HAVE_EXPLICIT_BZERO 1
#elif defined(__GLIBC__) && defined(__GLIBC_PREREQ) && defined(_GNU_SOURCE)
# if __GLIBC_PREREQ(2, 25)
# define HAVE_EXPLICIT_BZERO 1
# endif
#endif

#define COMPILER_ASSERT(X) (void) sizeof(char[(X) ? 1 : -1])

#define ROTL32(x, b) (uint32_t)(((x) << (b)) | ((x) >> (32 - (b))))
@@ -10,12 +10,16 @@ hydro_init(void)
void
hydro_memzero(void *pnt, size_t len)
{
#ifdef HAVE_EXPLICIT_BZERO
explicit_bzero(pnt, len);
#else
volatile unsigned char *volatile pnt_ = (volatile unsigned char *volatile) pnt;
size_t i = (size_t) 0U;

while (i < len) {
pnt_[i++] = 0U;
}
#endif
}

void

0 comments on commit c9b4bea

Please sign in to comment.
You can’t perform that action at this time.