These comments were wrong. Remove them instead of fixing them, since now that we have this small header file, it's much easier to follow the preprocessor conditionals. Cc: Christian Göttsche <cgzones@googlemail.com> Cc: Serge Hallyn <serge@hallyn.com> Cc: Iker Pedrosa <ipedrosa@redhat.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
34 lines
737 B
C
34 lines
737 B
C
/*
|
|
* SPDX-FileCopyrightText: 2022-2023, Christian Göttsche <cgzones@googlemail.com>
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
|
|
#ifndef SHADOW_INCLUDE_LIBMISC_MEMZERO_H_
|
|
#define SHADOW_INCLUDE_LIBMISC_MEMZERO_H_
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <stddef.h>
|
|
#include <string.h>
|
|
#include <strings.h>
|
|
|
|
|
|
#ifdef HAVE_MEMSET_EXPLICIT
|
|
# define memzero(ptr, size) memset_explicit((ptr), 0, (size))
|
|
#elif defined HAVE_EXPLICIT_BZERO
|
|
# define memzero(ptr, size) explicit_bzero((ptr), (size))
|
|
#else
|
|
static inline void memzero(void *ptr, size_t size)
|
|
{
|
|
ptr = memset(ptr, '\0', size);
|
|
__asm__ __volatile__ ("" : : "r"(ptr) : "memory");
|
|
}
|
|
#endif
|
|
|
|
#define strzero(s) memzero(s, strlen(s)) /* warning: evaluates twice */
|
|
|
|
|
|
#endif // include guard
|