aboutsummaryrefslogtreecommitdiffstats
path: root/libar2_erase.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-02-16 20:23:12 +0100
committerMattias Andrée <maandree@kth.se>2022-02-16 20:23:12 +0100
commit35a9fff4df5571bdbdeeef71843b5b1671d34271 (patch)
tree37bcddf5a25c9df37a36468b09322fc155b76be5 /libar2_erase.c
parentAdd coverage test (diff)
downloadlibar2-35a9fff4df5571bdbdeeef71843b5b1671d34271.tar.gz
libar2-35a9fff4df5571bdbdeeef71843b5b1671d34271.tar.bz2
libar2-35a9fff4df5571bdbdeeef71843b5b1671d34271.tar.xz
More tests and some small improvements
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libar2_erase.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/libar2_erase.c b/libar2_erase.c
index f4fa2d3..0e3174e 100644
--- a/libar2_erase.c
+++ b/libar2_erase.c
@@ -14,6 +14,11 @@ void *(*const volatile libar2_internal_explicit_memset__)(void *, int, size_t) =
#endif
+/* libar2_internal_erase__ is intended for the test code to use, because it replaces `libar2_erase` */
+# if defined(__GNUC__)
+__attribute__((visibility("hidden")))
+# endif
+void libar2_internal_erase__(volatile void *mem, size_t size);
#if defined(__clang__) /* before __GNUC__ because that is also set in clang */
# if __has_attribute(optnone)
__attribute__((optnone))
@@ -27,7 +32,7 @@ __attribute__((optimize("O0")))
LIBAR2_WEAKLY_LINKED__
#endif
void
-libar2_erase(volatile void *mem_, size_t size)
+libar2_internal_erase__(volatile void *mem_, size_t size)
{
void *mem = *(void **)(void *)&mem_;
#if defined(memset_s)
@@ -41,15 +46,29 @@ libar2_erase(volatile void *mem_, size_t 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__
-extern __typeof(libar2_erase) libar2_earse __attribute__((__weak__, __alias__("libar2_erase")));
+LIBAR2_PUBLIC__ LIBAR2_WEAKLY_LINKED__
+extern void libar2_earse(volatile void *, size_t) __attribute__((__alias__("libar2_internal_erase__")));
#else
-LIBAR2_PUBLIC__ void libar2_earse(volatile void *mem, size_t size);
+LIBAR2_PUBLIC__ LIBAR2_WEAKLY_LINKED__
+void libar2_earse(volatile void *mem, size_t size);
void
libar2_earse(volatile void *mem, size_t size)
{
- libar2_erase(mem, size);
+ libar2_internal_erase__(mem, size);
}
#endif