Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/common/lib/libc/arch/m68k/atomic Add a few __sync_* and atom...



details:   https://anonhg.NetBSD.org/src/rev/cb6b7f8e23ce
branches:  trunk
changeset: 793541:cb6b7f8e23ce
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Feb 18 16:19:28 2014 +0000

description:
Add a few __sync_* and atomic functions.

diffstat:

 common/lib/libc/arch/m68k/atomic/atomic_add.S  |  27 +++++++++-
 common/lib/libc/arch/m68k/atomic/atomic_cas.S  |  71 +++++++++++++++++++++++++-
 common/lib/libc/arch/m68k/atomic/atomic_swap.S |  28 +++++++++-
 3 files changed, 123 insertions(+), 3 deletions(-)

diffs (166 lines):

diff -r dddc05de502c -r cb6b7f8e23ce common/lib/libc/arch/m68k/atomic/atomic_add.S
--- a/common/lib/libc/arch/m68k/atomic/atomic_add.S     Tue Feb 18 13:21:04 2014 +0000
+++ b/common/lib/libc/arch/m68k/atomic/atomic_add.S     Tue Feb 18 16:19:28 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atomic_add.S,v 1.6 2013/07/16 23:24:18 matt Exp $      */
+/*     $NetBSD: atomic_add.S,v 1.7 2014/02/18 16:19:28 martin Exp $    */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -66,3 +66,28 @@
 STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_32_nv)
 ATOMIC_OP_ALIAS(atomic_add_ptr_nv,_atomic_add_32_nv)
 STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_32_nv)
+STRONG_ALIAS(__sync_add_and_fetch_4,_atomic_add_32_nv)
+
+ENTRY(_atomic_add_16_nv)
+       movl    4(%sp), %a0
+1:     movw    (%a0), %d0
+       movw    %d0, %d1
+       addw    8(%sp), %d0
+       casw    %d1, %d0, (%a0)
+       bne     1b
+       rts
+END(_atomic_add_16_nv)
+
+STRONG_ALIAS(__sync_add_and_fetch_2,_atomic_add_16_nv)
+
+ENTRY(_atomic_add_8_nv)
+       movl    4(%sp), %a0
+1:     movb    (%a0), %d0
+       movb    %d0, %d1
+       addb    8(%sp), %d0
+       casb    %d1, %d0, (%a0)
+       bne     1b
+       rts
+END(_atomic_add_8_nv)
+
+STRONG_ALIAS(__sync_add_and_fetch_1,_atomic_add_8_nv)
diff -r dddc05de502c -r cb6b7f8e23ce common/lib/libc/arch/m68k/atomic/atomic_cas.S
--- a/common/lib/libc/arch/m68k/atomic/atomic_cas.S     Tue Feb 18 13:21:04 2014 +0000
+++ b/common/lib/libc/arch/m68k/atomic/atomic_cas.S     Tue Feb 18 16:19:28 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atomic_cas.S,v 1.7 2013/07/16 23:24:18 matt Exp $      */
+/*     $NetBSD: atomic_cas.S,v 1.8 2014/02/18 16:19:28 martin Exp $    */
 
 /*-
  * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
@@ -50,6 +50,7 @@
 STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32)
 ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_32)
 STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32)
+STRONG_ALIAS(__sync_val_compare_and_swap_4,_atomic_cas_32)
 
 ATOMIC_OP_ALIAS(atomic_cas_32_ni,_atomic_cas_32)
 STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32)
@@ -59,3 +60,71 @@
 STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_32)
 ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_32)
 STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_32)
+
+ENTRY(__sync_bool_compare_and_swap_4)
+       movl    4(%sp), %a0
+       movl    8(%sp), %d3
+       movl    %d3, %d2
+       movl    12(%sp), %d1
+       casl    %d3, %d1, (%a0)
+       /* %d3 now contains the old value */
+       clrl    %d0     /* assume it did not work */
+       cmpl    %d3, %d2
+       bne     1f
+       movl    #1, %d0 /* return success */
+1:     rts
+END(__sync_bool_compare_and_swap_4)
+
+ENTRY(_atomic_cas_16)
+       movl    4(%sp), %a0
+       movw    8(%sp), %d0
+       movw    10(%sp), %d1
+       casw    %d0, %d1, (%a0)
+       /* %d0 now contains the old value */
+       rts
+END(_atomic_cas_16)
+
+ATOMIC_OP_ALIAS(atomic_cas_16,_atomic_cas_16)
+STRONG_ALIAS(__sync_val_compare_and_swap_2,_atomic_cas_16)
+
+ENTRY(__sync_bool_compare_and_swap_2)
+       movl    4(%sp), %a0
+       movw    8(%sp), %d3
+       movw    %d3, %d2
+       movw    10(%sp), %d1
+       casw    %d3, %d1, (%a0)
+       /* %d3 now contains the old value */
+       clrl    %d0     /* assume it did not work */
+       cmpw    %d3, %d2
+       bne     1f
+       movl    #1, %d0 /* return success */
+1:     rts
+END(__sync_bool_compare_and_swap_2)
+
+ENTRY(_atomic_cas_8)
+       movl    4(%sp), %a0
+       movb    8(%sp), %d0
+       movb    9(%sp), %d1
+       casb    %d0, %d1, (%a0)
+       /* %d0 now contains the old value */
+       rts
+END(_atomic_cas_8)
+
+ATOMIC_OP_ALIAS(atomic_cas_8,_atomic_cas_8)
+STRONG_ALIAS(__sync_val_compare_and_swap_1,_atomic_cas_8)
+
+
+ENTRY(__sync_bool_compare_and_swap_1)
+       movl    4(%sp), %a0
+       movb    8(%sp), %d3
+       movb    %d3, %d2
+       movb    9(%sp), %d1
+       casb    %d3, %d1, (%a0)
+       /* %d3 now contains the old value */
+       clrl    %d0     /* assume it did not work */
+       cmpb    %d3, %d2
+       bne     1f
+       movl    #1, %d0 /* return success */
+1:     rts
+END(__sync_bool_compare_and_swap_1)
+
diff -r dddc05de502c -r cb6b7f8e23ce common/lib/libc/arch/m68k/atomic/atomic_swap.S
--- a/common/lib/libc/arch/m68k/atomic/atomic_swap.S    Tue Feb 18 13:21:04 2014 +0000
+++ b/common/lib/libc/arch/m68k/atomic/atomic_swap.S    Tue Feb 18 16:19:28 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atomic_swap.S,v 1.6 2013/07/16 23:24:18 matt Exp $     */
+/*     $NetBSD: atomic_swap.S,v 1.7 2014/02/18 16:19:28 martin Exp $   */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -50,3 +50,29 @@
 STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_32)
 ATOMIC_OP_ALIAS(atomic_swap_ptr,_atomic_swap_32)
 STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_32)
+STRONG_ALIAS(__sync_lock_test_and_set_4,_atomic_swap_32)
+
+
+ENTRY(_atomic_swap_16)
+       movl    4(%sp), %a0
+1:     movw    (%a0), %d0
+       movw    8(%sp), %d1
+       casw    %d0, %d1, (%a0)
+       bne     1b
+       /* %d0 now contains the old value */
+       rts
+END(_atomic_swap_16)
+ATOMIC_OP_ALIAS(atomic_swap_16,_atomic_swap_16)
+STRONG_ALIAS(__sync_lock_test_and_set_2,_atomic_swap_16)
+
+ENTRY(_atomic_swap_8)
+       movl    4(%sp), %a0
+1:     movb    (%a0), %d0
+       movb    8(%sp), %d1
+       casb    %d0, %d1, (%a0)
+       bne     1b
+       /* %d0 now contains the old value */
+       rts
+END(_atomic_swap_8)
+ATOMIC_OP_ALIAS(atomic_swap_8,_atomic_swap_8)
+STRONG_ALIAS(__sync_lock_test_and_set_1,_atomic_swap_8)



Home | Main Index | Thread Index | Old Index