* [V4][0/2] explicit_bzero
@ 2021-01-23 10:49 roucaries.bastien
2021-01-23 10:49 ` [PATCH 1/2] Support clang for explicit_bzero roucaries.bastien
2021-01-23 10:49 ` [PATCH 2/2] Implement fallback for explicit_bzero using jump to volatile pointer roucaries.bastien
0 siblings, 2 replies; 5+ messages in thread
From: roucaries.bastien @ 2021-01-23 10:49 UTC (permalink / raw)
To: bug-gnulib
Sorry for the late reply
Last modification of explicit_bzero
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] Support clang for explicit_bzero
2021-01-23 10:49 [V4][0/2] explicit_bzero roucaries.bastien
@ 2021-01-23 10:49 ` roucaries.bastien
2021-01-23 10:49 ` [PATCH 2/2] Implement fallback for explicit_bzero using jump to volatile pointer roucaries.bastien
1 sibling, 0 replies; 5+ messages in thread
From: roucaries.bastien @ 2021-01-23 10:49 UTC (permalink / raw)
To: bug-gnulib; +Cc: Bastien Roucariès
From: Bastien Roucariès <rouca@debian.org>
According to https://bugs.llvm.org/show_bug.cgi?id=15495#c11
llvm need g type constraint
Signed-off-by: Bastien Roucariès <rouca@debian.org>
---
lib/explicit_bzero.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/lib/explicit_bzero.c b/lib/explicit_bzero.c
index 87fadba81a..71a1cca3b0 100644
--- a/lib/explicit_bzero.c
+++ b/lib/explicit_bzero.c
@@ -56,9 +56,19 @@ explicit_bzero (void *s, size_t len)
(void) memset_s (s, len, '\0', len);
#else
memset (s, '\0', len);
-# if defined __GNUC__ && !defined __clang__
- /* Compiler barrier. */
+# if defined __GNUC__
+/* Compiler barrier. */
+# if !defined __clang__
asm volatile ("" ::: "memory");
+# else
+ /* See https://bugs.llvm.org/show_bug.cgi?id=15495#c11
+ with asm("" ::: "memory") LLVM analyzes uses of 's'
+ and finds that the whole thing is dead and eliminates it.
+
+ Using g workarround this problem
+ */
+ __asm__ volatile("" : : "g"(s) : "memory");
+# endif
# endif
#endif
}
--
2.29.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] Implement fallback for explicit_bzero using jump to volatile pointer
2021-01-23 10:49 [V4][0/2] explicit_bzero roucaries.bastien
2021-01-23 10:49 ` [PATCH 1/2] Support clang for explicit_bzero roucaries.bastien
@ 2021-01-23 10:49 ` roucaries.bastien
1 sibling, 0 replies; 5+ messages in thread
From: roucaries.bastien @ 2021-01-23 10:49 UTC (permalink / raw)
To: bug-gnulib; +Cc: Bastien Roucariès
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..86a5fd35d7 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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] Implement fallback for explicit_bzero using jump to volatile pointer
2021-01-23 11:22 [V5] explicit_bzero roucaries.bastien
@ 2021-01-23 11:22 ` roucaries.bastien
2021-01-23 13:33 ` Bruno Haible
0 siblings, 1 reply; 5+ messages in thread
From: roucaries.bastien @ 2021-01-23 11:22 UTC (permalink / raw)
To: bug-gnulib; +Cc: Bastien Roucariès
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] Implement fallback for explicit_bzero using jump to volatile pointer
2021-01-23 11:22 ` [PATCH 2/2] Implement fallback for explicit_bzero using jump to volatile pointer roucaries.bastien
@ 2021-01-23 13:33 ` Bruno Haible
0 siblings, 0 replies; 5+ messages in thread
From: Bruno Haible @ 2021-01-23 13:33 UTC (permalink / raw)
To: bug-gnulib; +Cc: roucaries.bastien, Bastien Roucariès
> +#else
> + void * (* const volatile volatile_memset)(void *, int, size_t) = memset;
> + (void) volatile_memset (s, '\0', len);
> #endif
> }
Thanks. I applied this, adding a comment and a gnulib-style ChangeLog entry.
Bruno
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-01-23 13:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-23 10:49 [V4][0/2] explicit_bzero roucaries.bastien
2021-01-23 10:49 ` [PATCH 1/2] Support clang for explicit_bzero roucaries.bastien
2021-01-23 10:49 ` [PATCH 2/2] Implement fallback for explicit_bzero using jump to volatile pointer roucaries.bastien
-- strict thread matches above, loose matches on Subject: below --
2021-01-23 11:22 [V5] explicit_bzero roucaries.bastien
2021-01-23 11:22 ` [PATCH 2/2] Implement fallback for explicit_bzero using jump to volatile pointer roucaries.bastien
2021-01-23 13:33 ` Bruno Haible
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).