1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
/* See LICENSE file for copyright and license details. */
#include "common.h"
#if defined(memset_s)
#elif defined(explicit_bzero) || defined(__OpenBSD__)
#elif defined(explicit_memset)
#else
LIBAR2_HIDDEN__
extern void *(*const volatile libar2_internal_explicit_memset__)(void *, int, size_t);
void *(*const volatile libar2_internal_explicit_memset__)(void *, int, size_t) = &memset;
#endif
/* libar2_internal_erase__ is intended for the test code to use, because it replaces `libar2_erase` */
#if defined(__clang__) /* before __GNUC__ because that is also set in clang */
# if __has_attribute(optnone)
__attribute__((optnone))
# endif
#elif defined(__GNUC__)
# if __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ >= 40400
__attribute__((optimize("O0")))
# endif
#endif
#ifdef LIBAR2_WEAKLY_LINKED__
LIBAR2_WEAKLY_LINKED__
#endif
void
libar2_internal_erase__(volatile void *mem_, size_t size)
{
void *mem = *(void **)(void *)&mem_;
#if defined(memset_s)
memset_s(mem, size);
#elif defined(explicit_bzero) || defined(__OpenBSD__)
explicit_bzero(mem, size);
#elif defined(explicit_memset)
explicit_memset(mem, 0, size);
#else
libar2_internal_explicit_memset__(mem, 0, size);
#endif
}
#if defined(__GNUC__)
LIBAR2_PUBLIC__ LIBAR2_WEAKLY_LINKED__
extern void libar2_erase(volatile void *, size_t) __attribute__((__alias__("libar2_internal_erase__")));
#else
void
libar2_erase(volatile void *mem, size_t size)
{
libar2_internal_erase__(mem, size);
}
#endif
/* Typo in version 1.0 */
#if defined(__GNUC__)
LIBAR2_PUBLIC__ LIBAR2_WEAKLY_LINKED__
extern void libar2_earse(volatile void *, size_t) __attribute__((__alias__("libar2_internal_erase__")));
#else
LIBAR2_PUBLIC__ LIBAR2_WEAKLY_LINKED__
void libar2_earse(volatile void *mem, size_t size);
void
libar2_earse(volatile void *mem, size_t size)
{
libar2_internal_erase__(mem, size);
}
#endif
|