]> granicus.if.org Git - libatomic_ops/commitdiff
2010-05-30 Ivan Maidanski <ivmai@mail.ru> (really Bradley Smith) libatomic_ops-7_2alpha5-20100601
authorivmai <ivmai>
Sun, 30 May 2010 15:00:01 +0000 (15:00 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 25 Jul 2011 12:03:26 +0000 (16:03 +0400)
* src/atomic_ops/sysdeps/gcc/avr32.h (AO_test_and_set): Use
"register long" (instead of "int") for "ret" variable.
* src/atomic_ops/sysdeps/gcc/avr32.h (AO_test_and_set): Replace
with AO_test_and_set_full (same for AO_HAVE_test_and_set).
* src/atomic_ops/sysdeps/gcc/avr32.h (AO_compare_and_swap_full):
New function implemented.

ChangeLog
src/atomic_ops/sysdeps/gcc/avr32.h

index eb6f94d06d8c2c07a16f79fce4c6bb5b051c4b69..36a06453c55eb85a37b4500caba35a9f59b6b18d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-05-30  Ivan Maidanski <ivmai@mail.ru> (really Bradley Smith)
+
+       * src/atomic_ops/sysdeps/gcc/avr32.h (AO_test_and_set): Use
+       "register long" (instead of "int") for "ret" variable.
+       * src/atomic_ops/sysdeps/gcc/avr32.h (AO_test_and_set): Replace
+       with AO_test_and_set_full (same for AO_HAVE_test_and_set).
+       * src/atomic_ops/sysdeps/gcc/avr32.h (AO_compare_and_swap_full):
+       New function implemented.
+
 2010-05-22  Ivan Maidanski <ivmai@mail.ru>
 
        * src/atomic_ops/sysdeps/Makefile.am (nobase_sysdep_HEADERS):
index cd43c19b419bff3c03f3191fb98a7ba92220f51d..7a2fbed195d424fbbc3d76bffb75ed1bc9b99f8f 100644 (file)
 #include "../test_and_set_t_is_ao_t.h"
 
 AO_INLINE AO_TS_VAL_t
-AO_test_and_set(volatile AO_TS_t *addr)
+AO_test_and_set_full(volatile AO_TS_t *addr)
 {
-        int ret;
+        register long ret;
 
         __asm__ __volatile__(
-                "xchg %[old], %[mem], %[newv]"
-                : [old] "=&r"(ret)
-                : [mem] "r"(addr), [newv] "r"(1)
+                "xchg %[oldval], %[mem], %[newval]"
+                : [oldval] "=&r"(ret)
+                : [mem] "r"(addr), [newval] "r"(1)
                 : "memory");
 
-        return ret;
+        return (AO_TS_VAL_t)ret;
 }
-#define AO_HAVE_test_and_set
+#define AO_HAVE_test_and_set_full
+
+AO_INLINE int
+AO_compare_and_swap_full(volatile AO_t *addr, AO_t old, AO_t new_val)
+{
+       register long ret;
+
+       __asm__ __volatile__(
+               "1: ssrf    5\n"
+               "   ld.w    %[res], %[mem]\n"
+               "   eor     %[res], %[oldval]\n"
+               "   brne    2f\n"
+               "   stcond  %[mem], %[newval]\n"
+               "   brne    1b\n"
+               "2:\n"
+               : [res] "=&r"(ret), [mem] "=m"(*addr)
+               : "m"(*addr), [newval] "r"(new_val), [oldval] "r"(old)
+               : "cc", "memory");
+
+       return (int)ret;
+}
+#define AO_HAVE_compare_and_swap_full