Place no_sanitize attributes in a GCC-compliant way
authorIvan Maidanski <ivmai@mail.ru>
Mon, 20 Nov 2017 21:10:08 +0000 (00:10 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 21 Nov 2017 07:56:17 +0000 (10:56 +0300)
Now the attributes precede the function prototypes (the format is:
<attribute> void f(void) <body>).

* finalize.c (GC_should_invoke_finalizers): Move
GC_ATTR_NO_SANITIZE_THREAD attribute to the beginning of the function
prototype (even before GC_API, GC_INNER or static).
* malloc.c (fill_size_map): Likewise.
* mark.c (GC_noop1, GC_mark_from, GC_push_all_eager): Likewise.
* mark.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager):
Likewise.
* misc.c [THREADS] (next_random_no): Likewise.
* os_dep.c [MPROTECT_VDB && THREADS && AO_HAVE_test_and_set_acquire]
(async_set_pht_entry_from_index): Likewise.
* os_dep.c [MPROTECT_VDB] (is_header_found_async): Likewise.
* pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS]
(update_last_stop_count): Likewise.
* pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS
&& GC_ENABLE_SUSPEND_THREAD] (set_suspended_ext_flag,
GC_resume_thread): Likewise.
* pthread_support.c [THREAD_SANITIZER && (USE_SPIN_LOCK
|| !NO_PTHREAD_TRYLOCK)] (is_collecting): Likewise.
* pthread_support.c [USE_SPIN_LOCK] (set_last_spins_and_high_spin_max,
reset_spin_max): Likewise.
* mark.c (GC_mark_from, GC_push_all_eager): Move
GC_ATTR_NO_SANITIZE_ADDR, GC_ATTR_NO_SANITIZE_MEMORY attributes to the
beginning of the function prototype.
* mach_dep.c (GC_with_callee_saves_pushed): Likewise.
* mark.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager):
Likewise.

finalize.c
mach_dep.c
malloc.c
mark.c
misc.c
os_dep.c
pthread_stop_world.c
pthread_support.c

index aaed8d4..06accb8 100644 (file)
@@ -1182,8 +1182,8 @@ GC_INNER void GC_finalize(void)
 /* Returns true if it is worth calling GC_invoke_finalizers. (Useful if */
 /* finalizers can only be called from some kind of "safe state" and     */
 /* getting into that safe state is expensive.)                          */
+GC_ATTR_NO_SANITIZE_THREAD
 GC_API int GC_CALL GC_should_invoke_finalizers(void)
-                                                GC_ATTR_NO_SANITIZE_THREAD
 {
   return GC_fnlz_roots.finalize_now != NULL;
 }
index ccc1de6..1029141 100644 (file)
 /* Ensure that either registers are pushed, or callee-save registers    */
 /* are somewhere on the stack, and then call fn(arg, ctxt).             */
 /* ctxt is either a pointer to a ucontext_t we generated, or NULL.      */
+GC_ATTR_NO_SANITIZE_ADDR
 GC_INNER void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *),
                                           volatile ptr_t arg)
-                                          GC_ATTR_NO_SANITIZE_ADDR
 {
   volatile int dummy;
   void * volatile context = 0;
index d2b2aeb..eb0e80f 100644 (file)
--- a/malloc.c
+++ b/malloc.c
@@ -107,8 +107,8 @@ STATIC ptr_t GC_alloc_large_and_clear(size_t lb, int k, unsigned flags)
 /* acquiring the allocation lock provided the obtained value is used    */
 /* according to the pattern given in alloc.c file (see the comment      */
 /* about GC_allocobj usage and, e.g., GC_malloc_kind_global code).      */
+GC_ATTR_NO_SANITIZE_THREAD
 static void fill_size_map(size_t low_limit, size_t byte_sz, size_t granule_sz)
-                                                GC_ATTR_NO_SANITIZE_THREAD
 {
   for (; low_limit <= byte_sz; low_limit++)
     GC_size_map[low_limit] = granule_sz;
diff --git a/mark.c b/mark.c
index 090e550..efd3e22 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -48,9 +48,11 @@ void GC_noop6(word arg1 GC_ATTR_UNUSED, word arg2 GC_ATTR_UNUSED,
 # endif
 }
 
-/* Single argument version, robust against whole program analysis. */
 volatile word GC_noop_sink;
-GC_API void GC_CALL GC_noop1(word x) GC_ATTR_NO_SANITIZE_THREAD
+
+/* Single argument version, robust against whole program analysis. */
+GC_ATTR_NO_SANITIZE_THREAD
+GC_API void GC_CALL GC_noop1(word x)
 {
     GC_noop_sink = x;
 }
@@ -644,10 +646,9 @@ GC_INNER mse * GC_signal_mark_stack_overflow(mse *msp)
  * encoding, we optionally maintain a cache for the block address to
  * header mapping, we prefetch when an object is "grayed", etc.
  */
+GC_ATTR_NO_SANITIZE_ADDR GC_ATTR_NO_SANITIZE_MEMORY GC_ATTR_NO_SANITIZE_THREAD
 GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack,
                             mse *mark_stack_limit)
-                        GC_ATTR_NO_SANITIZE_ADDR GC_ATTR_NO_SANITIZE_MEMORY
-                        GC_ATTR_NO_SANITIZE_THREAD
 {
   signed_word credit = HBLKSIZE;  /* Remaining credit for marking work  */
   ptr_t current_p;      /* Pointer to current candidate ptr.            */
@@ -1588,9 +1589,8 @@ GC_API void GC_CALL GC_print_trace(word gc_no)
  * and scans the entire region immediately, in case the contents
  * change.
  */
+GC_ATTR_NO_SANITIZE_ADDR GC_ATTR_NO_SANITIZE_MEMORY GC_ATTR_NO_SANITIZE_THREAD
 GC_API void GC_CALL GC_push_all_eager(char *bottom, char *top)
-                        GC_ATTR_NO_SANITIZE_ADDR GC_ATTR_NO_SANITIZE_MEMORY
-                        GC_ATTR_NO_SANITIZE_THREAD
 {
     word * b = (word *)(((word) bottom + ALIGNMENT-1) & ~(ALIGNMENT-1));
     word * t = (word *)(((word) top) & ~(ALIGNMENT-1));
@@ -1632,10 +1632,10 @@ GC_INNER void GC_push_all_stack(ptr_t bottom, ptr_t top)
 
 #if defined(WRAP_MARK_SOME) && defined(PARALLEL_MARK)
   /* Similar to GC_push_conditional but scans the whole region immediately. */
+  GC_ATTR_NO_SANITIZE_ADDR GC_ATTR_NO_SANITIZE_MEMORY
+  GC_ATTR_NO_SANITIZE_THREAD
   GC_INNER void GC_push_conditional_eager(ptr_t bottom, ptr_t top,
                                           GC_bool all)
-                        GC_ATTR_NO_SANITIZE_ADDR GC_ATTR_NO_SANITIZE_MEMORY
-                        GC_ATTR_NO_SANITIZE_THREAD
   {
     word * b = (word *)(((word) bottom + ALIGNMENT-1) & ~(ALIGNMENT-1));
     word * t = (word *)(((word) top) & ~(ALIGNMENT-1));
diff --git a/misc.c b/misc.c
index 4ac1d86..a94ecd3 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -298,7 +298,8 @@ STATIC void GC_init_size_map(void)
 #ifdef THREADS
   /* Used to occasionally clear a bigger chunk. */
   /* TODO: Should be more random than it is ... */
-  static unsigned next_random_no(void) GC_ATTR_NO_SANITIZE_THREAD
+  GC_ATTR_NO_SANITIZE_THREAD
+  static unsigned next_random_no(void)
   {
     static unsigned random_no = 0;
     return ++random_no % 13;
index e790cac..d4ff12c 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -3107,9 +3107,10 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void)
 /* correctly.                                                           */
 #ifdef AO_HAVE_test_and_set_acquire
   GC_INNER volatile AO_TS_t GC_fault_handler_lock = AO_TS_INITIALIZER;
+
+  GC_ATTR_NO_SANITIZE_THREAD
   static void async_set_pht_entry_from_index(volatile page_hash_table db,
                                              size_t index)
-                                                GC_ATTR_NO_SANITIZE_THREAD
   {
     while (AO_test_and_set_acquire(&GC_fault_handler_lock) == AO_TS_SET) {
       /* empty */
@@ -3154,7 +3155,8 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void)
   /* race between this function and GC_install_header, GC_remove_header */
   /* should not be harmful because the added or removed header should   */
   /* be already unprotected.                                            */
-  static GC_bool is_header_found_async(void *addr) GC_ATTR_NO_SANITIZE_THREAD
+  GC_ATTR_NO_SANITIZE_THREAD
+  static GC_bool is_header_found_async(void *addr)
   {
 #   ifdef HASH_TL
       hdr *result;
index 0f96572..b5a79c3 100644 (file)
@@ -240,8 +240,8 @@ STATIC void GC_suspend_handler_inner(ptr_t dummy, void *context);
   errno = old_errno;
 }
 
+GC_ATTR_NO_SANITIZE_THREAD
 static void update_last_stop_count(GC_thread me, AO_t my_stop_count)
-                                                GC_ATTR_NO_SANITIZE_THREAD
 {
   me -> stop_info.last_stop_count = my_stop_count;
 }
@@ -435,7 +435,8 @@ STATIC void GC_restart_handler(int sig)
     /* suspend_self_inner.  The first one seems to be a false positive  */
     /* as the handler is invoked after RAISE_SIGNAL, and the 2nd one is */
     /* safe to be ignored as the flag is checked in a loop.             */
-    static void set_suspended_ext_flag(GC_thread t) GC_ATTR_NO_SANITIZE_THREAD
+    GC_ATTR_NO_SANITIZE_THREAD
+    static void set_suspended_ext_flag(GC_thread t)
     {
       t -> flags |= SUSPENDED_EXT;
     }
@@ -503,9 +504,8 @@ STATIC void GC_restart_handler(int sig)
     /* Same as for GC_suspend_thread(), TSan reports data races between */
     /* this function and GC_suspend_handler_inner, suspend_self_inner;  */
     /* it is safe to ignore them both.                                  */
-    GC_API void GC_CALL GC_resume_thread(GC_SUSPEND_THREAD_ID thread)
-                                                GC_ATTR_NO_SANITIZE_THREAD
-    {
+    GC_ATTR_NO_SANITIZE_THREAD
+    GC_API void GC_CALL GC_resume_thread(GC_SUSPEND_THREAD_ID thread) {
       GC_thread t;
       DCL_LOCK_STATE;
 
index 659d603..cbb66c5 100644 (file)
@@ -1961,7 +1961,8 @@ STATIC void GC_generic_lock(pthread_mutex_t * lock)
     && (defined(USE_SPIN_LOCK) || !defined(NO_PTHREAD_TRYLOCK))
   /* GC_collecting is a hint, a potential data race between     */
   /* GC_lock() and ENTER/EXIT_GC() is OK to ignore.             */
-  static GC_bool is_collecting(void) GC_ATTR_NO_SANITIZE_THREAD
+  GC_ATTR_NO_SANITIZE_THREAD
+  static GC_bool is_collecting(void)
   {
     return GC_collecting;
   }
@@ -1986,14 +1987,15 @@ GC_INNER volatile AO_TS_t GC_allocate_lock = AO_TS_INITIALIZER;
   /* and updates spin_max and last_spins could be ignored because these */
   /* variables are hints only.  (Atomic getters and setters are avoided */
   /* here for performance reasons.)                                     */
+  GC_ATTR_NO_SANITIZE_THREAD
   static void set_last_spins_and_high_spin_max(unsigned new_last_spins)
-                                                GC_ATTR_NO_SANITIZE_THREAD
   {
     last_spins = new_last_spins;
     spin_max = high_spin_max;
   }
 
-  static void reset_spin_max(void) GC_ATTR_NO_SANITIZE_THREAD
+  GC_ATTR_NO_SANITIZE_THREAD
+  static void reset_spin_max(void)
   {
     spin_max = low_spin_max;
   }