emacs-diffs
[Top][All Lists]
Advanced

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

master 7c9841b: Update from Gnulib by running admin/merge-gnulib


From: Paul Eggert
Subject: master 7c9841b: Update from Gnulib by running admin/merge-gnulib
Date: Sat, 23 Jan 2021 14:37:56 -0500 (EST)

branch: master
commit 7c9841b8428edfbc369eccf54788b668d4b27328
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>

    Update from Gnulib by running admin/merge-gnulib
---
 lib/cdefs.h          |  6 ++++--
 lib/explicit_bzero.c | 16 +++++++++++++---
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/lib/cdefs.h b/lib/cdefs.h
index de74f42..17a0919 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -320,14 +320,16 @@
 #endif
 
 /* The nonnull function attribute marks pointer parameters that
-   must not be NULL.  Do not define __nonnull if it is already defined,
-   for portability when this file is used in Gnulib.  */
+   must not be NULL.  */
 #ifndef __nonnull
 # if __GNUC_PREREQ (3,3) || __glibc_has_attribute (__nonnull__)
 #  define __nonnull(params) __attribute__ ((__nonnull__ params))
 # else
 #  define __nonnull(params)
 # endif
+#elif !defined __GLIBC__
+# undef __nonnull
+# define __nonnull(params) _GL_ATTRIBUTE_NONNULL (params)
 #endif
 
 /* If fortification mode, we warn about unused results of certain
diff --git a/lib/explicit_bzero.c b/lib/explicit_bzero.c
index feea444..f50ed08 100644
--- a/lib/explicit_bzero.c
+++ b/lib/explicit_bzero.c
@@ -54,11 +54,21 @@ 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__ && !defined __clang__
   memset (s, '\0', len);
-# if defined __GNUC__ && !defined __clang__
   /* Compiler barrier.  */
   asm volatile ("" ::: "memory");
-# endif
+#elif defined __clang__
+  memset (s, '\0', len);
+  /* 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 <https://bugs.llvm.org/show_bug.cgi?id=15495#c11>.  */
+  __asm__ volatile ("" : : "g"(s) : "memory");
+#else
+  /* Invoke memset through a volatile function pointer.  This defeats compiler
+     optimizations.  */
+  void * (* const volatile volatile_memset) (void *, int, size_t) = memset;
+  (void) volatile_memset (s, '\0', len);
 #endif
 }



reply via email to

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