diff -Naur libatomic_ops-7.6.12.org/src/Makefile.am libatomic_ops-7.6.12.sw/src/Makefile.am --- libatomic_ops-7.6.12.org/src/Makefile.am 2022-02-26 02:35:27.760000000 +0000 +++ libatomic_ops-7.6.12.sw/src/Makefile.am 2022-02-26 02:38:49.230000000 +0000 @@ -81,6 +81,7 @@ \ atomic_ops/sysdeps/gcc/aarch64.h \ atomic_ops/sysdeps/gcc/alpha.h \ + atomic_ops/sysdeps/gcc/sw_64.h \ atomic_ops/sysdeps/gcc/arm.h \ atomic_ops/sysdeps/gcc/avr32.h \ atomic_ops/sysdeps/gcc/cris.h \ diff -Naur libatomic_ops-7.6.12.org/src/atomic_ops/sysdeps/gcc/sw_64.h libatomic_ops-7.6.12.sw/src/atomic_ops/sysdeps/gcc/sw_64.h --- libatomic_ops-7.6.12.org/src/atomic_ops/sysdeps/gcc/sw_64.h 1970-01-01 00:00:00.000000000 +0000 +++ libatomic_ops-7.6.12.sw/src/atomic_ops/sysdeps/gcc/sw_64.h 2022-02-26 02:41:18.020000000 +0000 @@ -0,0 +1,70 @@ +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. + * Copyright (c) 1999-2003 by Hewlett-Packard Company. All rights reserved. + * + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + +#include "../loadstore/atomic_load.h" +#include "../loadstore/atomic_store.h" + +#include "../test_and_set_t_is_ao_t.h" + +#define AO_NO_DD_ORDERING + /* Data dependence does not imply read ordering. */ + +AO_INLINE void +AO_nop_full(void) +{ + __asm__ __volatile__("memb" : : : "memory"); +} +#define AO_HAVE_nop_full + +AO_INLINE void +AO_nop_write(void) +{ + __asm__ __volatile__("memb" : : : "memory"); +} +#define AO_HAVE_nop_write + +/* mb should be used for AO_nop_read(). That's the default. */ + +/* TODO: implement AO_fetch_and_add explicitly. */ + +/* We believe that ldq_l ... stq_c does not imply any memory barrier. */ +AO_INLINE int +AO_compare_and_swap(volatile AO_t *addr, + AO_t old, AO_t new_val) +{ + unsigned long was_equal; + unsigned long temp; + + __asm__ __volatile__( + " ldi %3,%1\n" + "1: lldl %0,0(%3)\n" + " cmpeq %0,%5,%2\n" + " wr_f %2\n" + " mov %4,%0\n" + " lstl %0,0(%3)\n" + " rd_f %0\n" + " beq %2,2f\n" + " beq %0,1b\n" + "2:\n" + : "=&r" (temp), "+m" (*addr), "=&r" (was_equal),"=&r"(temp) + : "r" (new_val), "Ir" (old) + :"memory"); + return (int)was_equal; +} +#define AO_HAVE_compare_and_swap + +/* TODO: implement AO_fetch_compare_and_swap */ diff -Naur libatomic_ops-7.6.12.org/src/atomic_ops.h libatomic_ops-7.6.12.sw/src/atomic_ops.h --- libatomic_ops-7.6.12.org/src/atomic_ops.h 2022-02-26 02:35:27.770000000 +0000 +++ libatomic_ops-7.6.12.sw/src/atomic_ops.h 2022-02-26 02:36:05.400000000 +0000 @@ -310,6 +310,8 @@ # elif defined(__hppa__) # include "atomic_ops/sysdeps/gcc/hppa.h" # define AO_CAN_EMUL_CAS +# elif defined(__sw_64__) +# include "atomic_ops/sysdeps/gcc/sw_64.h" # elif defined(__alpha__) # include "atomic_ops/sysdeps/gcc/alpha.h" # define AO_GENERALIZE_TWICE diff -Naur libatomic_ops-7.6.12.org/src/atomic_ops_stack.c libatomic_ops-7.6.12.sw/src/atomic_ops_stack.c --- libatomic_ops-7.6.12.org/src/atomic_ops_stack.c 2022-02-26 02:35:27.760000000 +0000 +++ libatomic_ops-7.6.12.sw/src/atomic_ops_stack.c 2022-02-26 02:38:24.530000000 +0000 @@ -180,7 +180,7 @@ /* We need to make sure that first is still the first entry on the */ /* list. Otherwise it's possible that a reinsertion of it was */ /* already started before we added the black list entry. */ -# if defined(__alpha__) && (__GNUC__ == 4) +# if (defined(__alpha__) || defined(__sw_64__)) && (__GNUC__ == 4) if (first != AO_load_acquire(list)) /* Workaround __builtin_expect bug found in */ /* gcc-4.6.3/alpha causing test_stack failure. */ @@ -196,7 +196,7 @@ } first_ptr = AO_REAL_NEXT_PTR(first); next = AO_load_next(first_ptr); -# if defined(__alpha__) && (__GNUC__ == 4) +# if (defined(__alpha__) || defined(__sw_64__)) && (__GNUC__ == 4) if (!AO_compare_and_swap_release(list, first, next)) # else if (AO_EXPECT_FALSE(!AO_compare_and_swap_release(list, first, next)))