Tested on hppa64-hp-hpux11.11.  Committed to trunk.

Dave
---

hpux: Fix detection of atomic support when profiling

The pa target lacks atomic sync compare and swap instructions.
These are implemented as libcalls and in libatomic.  As on linux,
we lie about their availability.

This fixes the gcov-30.c test on hppa64-hpux11.

2025-05-19  John David Anglin  <dang...@gcc.gnu.org>

gcc/ChangeLog:

        * config/pa/pa-hpux.h (TARGET_HAVE_LIBATOMIC): Define.
        (HAVE_sync_compare_and_swapqi): Likewise.
        (HAVE_sync_compare_and_swaphi): Likewise.
        (HAVE_sync_compare_and_swapsi): Likewise.
        (HAVE_sync_compare_and_swapdi): Likewise.

diff --git a/gcc/config/pa/pa-hpux.h b/gcc/config/pa/pa-hpux.h
index 74e30eda9b5..1439447fdbe 100644
--- a/gcc/config/pa/pa-hpux.h
+++ b/gcc/config/pa/pa-hpux.h
@@ -114,3 +114,17 @@ along with GCC; see the file COPYING3.  If not see
 
 #undef TARGET_LIBC_HAS_FUNCTION
 #define TARGET_LIBC_HAS_FUNCTION no_c99_libc_has_function
+
+/* Assume we have libatomic if sync libcalls are disabled.  */
+#undef TARGET_HAVE_LIBATOMIC
+#define TARGET_HAVE_LIBATOMIC (!flag_sync_libcalls)
+
+/* The SYNC operations are implemented as library functions, not
+   INSN patterns.  As a result, the HAVE defines for the patterns are
+   not defined.  We need to define them to generate the corresponding
+   __GCC_HAVE_SYNC_COMPARE_AND_SWAP_* and __GCC_ATOMIC_*_LOCK_FREE
+   defines.  */
+#define HAVE_sync_compare_and_swapqi (flag_sync_libcalls)
+#define HAVE_sync_compare_and_swaphi (flag_sync_libcalls)
+#define HAVE_sync_compare_and_swapsi (flag_sync_libcalls)
+#define HAVE_sync_compare_and_swapdi (flag_sync_libcalls)

Reply via email to