From: Bastien Roucariès Date: Sat, 23 Jan 2021 11:22:10 +0000 (+0000) Subject: explicit_bzero: Add support for clang. X-Git-Tag: v1.0~3130 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=ac8adb391d472cfa4154d8ec930e950be65a11d1;p=gnulib.git explicit_bzero: Add support for clang. * lib/explicit_bzero.c (explicit_bzero): Add a compiler barrier for clang. --- diff --git a/ChangeLog b/ChangeLog index 8fa2e1535f..e7101e1bf1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2021-01-23 Bastien Roucariès + + explicit_bzero: Add support for clang. + * lib/explicit_bzero.c (explicit_bzero): Add a compiler barrier for + clang. + 2021-01-21 Paul Eggert Port FALLTHROUGH to clang 3.4 and earlier diff --git a/lib/explicit_bzero.c b/lib/explicit_bzero.c index 87fadba81a..4eb057462b 100644 --- a/lib/explicit_bzero.c +++ b/lib/explicit_bzero.c @@ -59,6 +59,12 @@ explicit_bzero (void *s, size_t len) # if defined __GNUC__ && !defined __clang__ /* Compiler barrier. */ asm volatile ("" ::: "memory"); +# elif defined __clang__ + /* Compiler barrier. */ + /* With asm ("" ::: "memory") LLVM analyzes uses of 's' and finds that the + whole thing is dead and eliminates it. Use 'g' to work around this + problem. See . */ + __asm__ volatile ("" : : "g"(s) : "memory"); # endif #endif }