]> granicus.if.org Git - libatomic_ops/commitdiff
Workaround MSan warning about uninitialized data read by generalized store
authorIvan Maidanski <ivmai@mail.ru>
Thu, 16 Feb 2017 06:43:25 +0000 (09:43 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 16 Feb 2017 06:43:25 +0000 (09:43 +0300)
* src/atomic_ops.h [__has_feature(memory_sanitizer)]
(AO_MEMORY_SANITIZER): Define.
* src/atomic_ops.h [AO_MEMORY_SANITIZER] (AO_ATTR_NO_SANITIZE_MEMORY):
Likewise.
* src/atomic_ops/generalize-small.h: Regenerate.
* src/atomic_ops/generalize-small.template
[AO_HAVE_XSIZE_compare_and_swap_write && !AO_HAVE_XSIZE_store_write]
(AO_XSIZE_store_write): Add AO_ATTR_NO_SANITIZE_MEMORY attribute.
* src/atomic_ops/generalize-small.template
[AO_HAVE_XSIZE_compare_and_swap && !AO_HAVE_XSIZE_store]
(AO_XSIZE_store): Likewise.
* src/atomic_ops/generalize-small.template
[AO_HAVE_XSIZE_compare_and_swap_release && !AO_HAVE_XSIZE_store_release]
(AO_XSIZE_store_release): Likewise.
* src/atomic_ops/generalize-small.template
[AO_HAVE_XSIZE_compare_and_swap_full && !AO_HAVE_XSIZE_store_full]
(AO_XSIZE_store_full): Likewise.

src/atomic_ops.h
src/atomic_ops/generalize-small.h
src/atomic_ops/generalize-small.template

index 8e516abcc1ee3a8426c185b631b91ff0dcadcd54..171f10005c2278d9fafe254daf8af4c537c50664 100644 (file)
 # if __has_feature(address_sanitizer)
 #   define AO_ADDRESS_SANITIZER
 # endif
+# if __has_feature(memory_sanitizer)
+#   define AO_MEMORY_SANITIZER
+# endif
 #endif
 
+#ifndef AO_ATTR_NO_SANITIZE_MEMORY
+# ifdef AO_MEMORY_SANITIZER
+#   define AO_ATTR_NO_SANITIZE_MEMORY __attribute__((no_sanitize("memory")))
+# else
+#   define AO_ATTR_NO_SANITIZE_MEMORY /* empty */
+# endif
+#endif /* !AO_ATTR_NO_SANITIZE_MEMORY */
+
 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
 # define AO_compiler_barrier() __asm__ __volatile__("" : : : "memory")
 #elif defined(_MSC_VER) || defined(__DMC__) || defined(__BORLANDC__) \
index 37d1d219d666eb148787d8ed09db7986c706bc66..94538af9f0b9725532737c79d28da3e032741a79 100644 (file)
     && !defined(AO_HAVE_char_store_write)
   AO_INLINE void
   AO_char_store_write(volatile unsigned/**/char *addr, unsigned/**/char new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     unsigned/**/char old_val;
 
 #if defined(AO_HAVE_char_compare_and_swap) && !defined(AO_HAVE_char_store)
   AO_INLINE void
   AO_char_store(volatile unsigned/**/char *addr, unsigned/**/char new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     unsigned/**/char old_val;
 
     && !defined(AO_HAVE_char_store_release)
   AO_INLINE void
   AO_char_store_release(volatile unsigned/**/char *addr, unsigned/**/char new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     unsigned/**/char old_val;
 
     && !defined(AO_HAVE_char_store_full)
   AO_INLINE void
   AO_char_store_full(volatile unsigned/**/char *addr, unsigned/**/char new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     unsigned/**/char old_val;
 
     && !defined(AO_HAVE_short_store_write)
   AO_INLINE void
   AO_short_store_write(volatile unsigned/**/short *addr, unsigned/**/short new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     unsigned/**/short old_val;
 
 #if defined(AO_HAVE_short_compare_and_swap) && !defined(AO_HAVE_short_store)
   AO_INLINE void
   AO_short_store(volatile unsigned/**/short *addr, unsigned/**/short new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     unsigned/**/short old_val;
 
     && !defined(AO_HAVE_short_store_release)
   AO_INLINE void
   AO_short_store_release(volatile unsigned/**/short *addr, unsigned/**/short new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     unsigned/**/short old_val;
 
     && !defined(AO_HAVE_short_store_full)
   AO_INLINE void
   AO_short_store_full(volatile unsigned/**/short *addr, unsigned/**/short new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     unsigned/**/short old_val;
 
     && !defined(AO_HAVE_int_store_write)
   AO_INLINE void
   AO_int_store_write(volatile unsigned *addr, unsigned new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     unsigned old_val;
 
 #if defined(AO_HAVE_int_compare_and_swap) && !defined(AO_HAVE_int_store)
   AO_INLINE void
   AO_int_store(volatile unsigned *addr, unsigned new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     unsigned old_val;
 
     && !defined(AO_HAVE_int_store_release)
   AO_INLINE void
   AO_int_store_release(volatile unsigned *addr, unsigned new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     unsigned old_val;
 
     && !defined(AO_HAVE_int_store_full)
   AO_INLINE void
   AO_int_store_full(volatile unsigned *addr, unsigned new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     unsigned old_val;
 
     && !defined(AO_HAVE_store_write)
   AO_INLINE void
   AO_store_write(volatile AO_t *addr, AO_t new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     AO_t old_val;
 
 #if defined(AO_HAVE_compare_and_swap) && !defined(AO_HAVE_store)
   AO_INLINE void
   AO_store(volatile AO_t *addr, AO_t new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     AO_t old_val;
 
     && !defined(AO_HAVE_store_release)
   AO_INLINE void
   AO_store_release(volatile AO_t *addr, AO_t new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     AO_t old_val;
 
     && !defined(AO_HAVE_store_full)
   AO_INLINE void
   AO_store_full(volatile AO_t *addr, AO_t new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     AO_t old_val;
 
     && !defined(AO_HAVE_double_store_write)
   AO_INLINE void
   AO_double_store_write(volatile AO_double_t *addr, AO_double_t new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     AO_double_t old_val;
 
 #if defined(AO_HAVE_double_compare_and_swap) && !defined(AO_HAVE_double_store)
   AO_INLINE void
   AO_double_store(volatile AO_double_t *addr, AO_double_t new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     AO_double_t old_val;
 
     && !defined(AO_HAVE_double_store_release)
   AO_INLINE void
   AO_double_store_release(volatile AO_double_t *addr, AO_double_t new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     AO_double_t old_val;
 
     && !defined(AO_HAVE_double_store_full)
   AO_INLINE void
   AO_double_store_full(volatile AO_double_t *addr, AO_double_t new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     AO_double_t old_val;
 
index ac916a5834e2c4f4d350383ae0f7a523b2ef2ad6..328f43e7ecb0d9ba349a968de8951d558c222e09 100644 (file)
     && !defined(AO_HAVE_XSIZE_store_write)
   AO_INLINE void
   AO_XSIZE_store_write(volatile XCTYPE *addr, XCTYPE new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     XCTYPE old_val;
 
 #if defined(AO_HAVE_XSIZE_compare_and_swap) && !defined(AO_HAVE_XSIZE_store)
   AO_INLINE void
   AO_XSIZE_store(volatile XCTYPE *addr, XCTYPE new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     XCTYPE old_val;
 
     && !defined(AO_HAVE_XSIZE_store_release)
   AO_INLINE void
   AO_XSIZE_store_release(volatile XCTYPE *addr, XCTYPE new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     XCTYPE old_val;
 
     && !defined(AO_HAVE_XSIZE_store_full)
   AO_INLINE void
   AO_XSIZE_store_full(volatile XCTYPE *addr, XCTYPE new_val)
+                                                AO_ATTR_NO_SANITIZE_MEMORY
   {
     XCTYPE old_val;