os/ossrv/genericopenlibs/cppstdlib/stl/src/sparc_atomic.s
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cppstdlib/stl/src/sparc_atomic.s	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,68 @@
     1.4 +        .section        ".text",#alloc,#execinstr
     1.5 +          .align 8
     1.6 +          .skip 16
     1.7 +
     1.8 +
     1.9 +  /*
    1.10 +  **  int _STLP_atomic_exchange (void *pvalue, int value)
    1.11 +  */
    1.12 +
    1.13 +          .type   _STLP_atomic_exchange,#function
    1.14 +          .global _STLP_atomic_exchange
    1.15 +          .align  8
    1.16 +
    1.17 +_STLP_atomic_exchange:
    1.18 +0:
    1.19 +          ld      [%o0], %o2              ! Set the current value
    1.20 +          mov     %o1, %o3                ! Set the new value
    1.21 +!          swap     [%o0], %o3             ! Do the compare and swap
    1.22 +          cas     [%o0], %o2, %o3
    1.23 +          cmp     %o2, %o3                ! Check whether successful
    1.24 +          bne     0b                      ! Retry upon failure
    1.25 +          stbar
    1.26 +          mov     %o2, %o0                ! Set the new value
    1.27 +          retl                            ! return
    1.28 +          nop
    1.29 +          .size   _STLP_atomic_exchange,(.-_STLP_atomic_exchange)
    1.30 +
    1.31 +  /* int _STLP_atomic_increment (void *pvalue) */
    1.32 +
    1.33 +          .type   _STLP_atomic_increment,#function
    1.34 +          .global _STLP_atomic_increment
    1.35 +          .align  8
    1.36 +_STLP_atomic_increment:
    1.37 +1:
    1.38 +          ld      [%o0], %o2              ! set the current
    1.39 +          add             %o2, 0x1, %o3                   ! Increment and store current
    1.40 +!          swap     [%o0], %o3         ! Do the compare and swap
    1.41 +          cas     [%o0], %o2, %o3
    1.42 +          cmp     %o3, %o2                ! Check whether successful
    1.43 +          bne     1b                                         ! Retry if we failed.
    1.44 +          membar  #LoadLoad | #LoadStore  ! Ensure the cas finishes before
    1.45 +                                          ! returning
    1.46 +          nop
    1.47 +          retl                            ! return
    1.48 +          nop
    1.49 +
    1.50 +          .size   _STLP_atomic_increment,(.-_STLP_atomic_increment)
    1.51 +
    1.52 +
    1.53 +  /* int _STLP_atomic_decrement (void *pvalue) */
    1.54 +          .type   _STLP_atomic_decrement,#function
    1.55 +          .global _STLP_atomic_decrement
    1.56 +          .align  8
    1.57 +
    1.58 +_STLP_atomic_decrement:
    1.59 +2:
    1.60 +          ld      [%o0], %o2              ! set the current
    1.61 +          sub     %o2, 0x1, %o3                   ! decrement and store current
    1.62 +!          swap    [%o0], %o3         ! Do the compare and swap
    1.63 +          cas     [%o0], %o2, %o3
    1.64 +          cmp     %o3, %o2                ! Check whether successful
    1.65 +          bne     2b                                         ! Retry if we failed.
    1.66 +          membar  #LoadLoad | #LoadStore  ! Ensure the cas finishes before
    1.67 +          nop
    1.68 +                                          ! returning
    1.69 +          retl                            ! return
    1.70 +          nop
    1.71 +          .size   _STLP_atomic_decrement,(.-_STLP_atomic_decrement)