public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-modules] gcov: Fix build on AIX
@ 2020-06-11 13:07 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2020-06-11 13:07 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:eb3480fc0fe68c0062a5548e922d530c78121cb5

commit eb3480fc0fe68c0062a5548e922d530c78121cb5
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Jun 2 16:57:35 2020 +0200

    gcov: Fix build on AIX
    
    We must guard used atomic builtins with GCOV_SUPPORTS_ATOMIC.
    The patch is tested on AIX and I'm going to push it.
    
    libgcc/ChangeLog:
    
            PR gcov-profile/95480
            * libgcov-profiler.c (GCOV_SUPPORTS_ATOMIC): Move to...
            * libgcov.h (GCOV_SUPPORTS_ATOMIC): ...here.
            (gcov_counter_add): Use GCOV_SUPPORTS_ATOMIC guard.
            (gcov_counter_set_if_null): Likewise.

Diff:
---
 libgcc/libgcov-profiler.c | 11 -----------
 libgcc/libgcov.h          | 22 ++++++++++++++++++++--
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/libgcc/libgcov-profiler.c b/libgcc/libgcov-profiler.c
index 7b171382a07..45ab93c9776 100644
--- a/libgcc/libgcov-profiler.c
+++ b/libgcc/libgcov-profiler.c
@@ -26,17 +26,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #include "libgcov.h"
 #if !defined(inhibit_libc)
 
-/* Detect whether target can support atomic update of profilers.  */
-#if __SIZEOF_LONG_LONG__ == 4 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
-#define GCOV_SUPPORTS_ATOMIC 1
-#else
-#if __SIZEOF_LONG_LONG__ == 8 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
-#define GCOV_SUPPORTS_ATOMIC 1
-#else
-#define GCOV_SUPPORTS_ATOMIC 0
-#endif
-#endif
-
 #ifdef L_gcov_interval_profiler
 /* If VALUE is in interval <START, START + STEPS - 1>, then increases the
    corresponding counter in COUNTERS.  If the VALUE is above or below
diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h
index 7c037a97878..1456100815d 100644
--- a/libgcc/libgcov.h
+++ b/libgcc/libgcov.h
@@ -85,6 +85,19 @@ typedef unsigned gcov_type_unsigned __attribute__ ((mode (QI)));
 #define GCOV_LOCKED 0
 #endif
 
+#ifndef GCOV_SUPPORTS_ATOMIC
+/* Detect whether target can support atomic update of profilers.  */
+#if __SIZEOF_LONG_LONG__ == 4 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+#define GCOV_SUPPORTS_ATOMIC 1
+#else
+#if __SIZEOF_LONG_LONG__ == 8 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
+#define GCOV_SUPPORTS_ATOMIC 1
+#else
+#define GCOV_SUPPORTS_ATOMIC 0
+#endif
+#endif
+#endif
+
 /* In libgcov we need these functions to be extern, so prefix them with
    __gcov.  In libgcov they must also be hidden so that the instance in
    the executable is not also used in a DSO.  */
@@ -377,11 +390,14 @@ gcov_get_counter_target (void)
    if USE_ATOMIC is true.  */
 
 static inline void
-gcov_counter_add (gcov_type *counter, gcov_type value, int use_atomic)
+gcov_counter_add (gcov_type *counter, gcov_type value,
+		  int use_atomic ATTRIBUTE_UNUSED)
 {
+#if GCOV_SUPPORTS_ATOMIC
   if (use_atomic)
     __atomic_fetch_add (counter, value, __ATOMIC_RELAXED);
   else
+#endif
     *counter += value;
 }
 
@@ -390,11 +406,13 @@ gcov_counter_add (gcov_type *counter, gcov_type value, int use_atomic)
 
 static inline int
 gcov_counter_set_if_null (gcov_type *counter, struct gcov_kvp *node,
-			  int use_atomic)
+			  int use_atomic ATTRIBUTE_UNUSED)
 {
+#if GCOV_SUPPORTS_ATOMIC
   if (use_atomic)
     return !__sync_val_compare_and_swap (counter, NULL, (intptr_t)node);
   else
+#endif
     {
       *counter = (intptr_t)node;
       return 1;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-11 13:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-11 13:07 [gcc/devel/c++-modules] gcov: Fix build on AIX Nathan Sidwell

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).