bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] Implement fallback for explicit_bzero using jump to volatile


From: roucaries . bastien
Subject: [PATCH 2/2] Implement fallback for explicit_bzero using jump to volatile pointer
Date: Sat, 23 Jan 2021 11:22:11 +0000

From: Bastien Roucariès <rouca@debian.org>

Signed-off-by: Bastien Roucariès <rouca@debian.org>
---
 lib/explicit_bzero.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/explicit_bzero.c b/lib/explicit_bzero.c
index 71a1cca3b0..c39f20164b 100644
--- a/lib/explicit_bzero.c
+++ b/lib/explicit_bzero.c
@@ -54,11 +54,10 @@ explicit_bzero (void *s, size_t len)
   explicit_memset (s, '\0', len);
 #elif HAVE_MEMSET_S
   (void) memset_s (s, len, '\0', len);
-#else
+#elif defined __GNUC__
   memset (s, '\0', len);
-# if defined __GNUC__
 /* Compiler barrier.  */
-#  if !defined __clang__
+# if !defined __clang__
   asm volatile ("" ::: "memory");
 #  else
    /* See https://bugs.llvm.org/show_bug.cgi?id=15495#c11
@@ -70,5 +69,8 @@ explicit_bzero (void *s, size_t len)
   __asm__ volatile("" : : "g"(s) : "memory");
 #  endif
 # endif
+#else
+  void * (* const volatile volatile_memset)(void *, int, size_t) = memset;
+  (void) volatile_memset (s, '\0', len);
 #endif
 }
-- 
2.29.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]