| 1 |
/* |
|---|
| 2 |
* Copyright (c) 2005-2009, OmniTI Computer Consulting, Inc. |
|---|
| 3 |
* All rights reserved. |
|---|
| 4 |
* |
|---|
| 5 |
* Redistribution and use in source and binary forms, with or without |
|---|
| 6 |
* modification, are permitted provided that the following conditions are |
|---|
| 7 |
* met: |
|---|
| 8 |
* |
|---|
| 9 |
* * Redistributions of source code must retain the above copyright |
|---|
| 10 |
* notice, this list of conditions and the following disclaimer. |
|---|
| 11 |
* * Redistributions in binary form must reproduce the above |
|---|
| 12 |
* copyright notice, this list of conditions and the following |
|---|
| 13 |
* disclaimer in the documentation and/or other materials provided |
|---|
| 14 |
* with the distribution. |
|---|
| 15 |
* * Neither the name OmniTI Computer Consulting, Inc. nor the names |
|---|
| 16 |
* of its contributors may be used to endorse or promote products |
|---|
| 17 |
* derived from this software without specific prior written |
|---|
| 18 |
* permission. |
|---|
| 19 |
* |
|---|
| 20 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|---|
| 21 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|---|
| 22 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|---|
| 23 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|---|
| 24 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|---|
| 25 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|---|
| 26 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|---|
| 27 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|---|
| 28 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|---|
| 29 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|---|
| 30 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 31 |
*/ |
|---|
| 32 |
|
|---|
| 33 |
#if defined(__sparcv9) || defined(__sparc) |
|---|
| 34 |
|
|---|
| 35 |
.section ".text" |
|---|
| 36 |
.align 8 |
|---|
| 37 |
.skip 24 |
|---|
| 38 |
.align 4 |
|---|
| 39 |
|
|---|
| 40 |
.global noit_atomic_cas32 |
|---|
| 41 |
noit_atomic_cas32: |
|---|
| 42 |
cas [%o0],%o2,%o1 |
|---|
| 43 |
mov %o1,%o0 |
|---|
| 44 |
retl |
|---|
| 45 |
nop |
|---|
| 46 |
.type noit_atomic_cas32,2 |
|---|
| 47 |
.size noit_atomic_cas32,(.-noit_atomic_cas32) |
|---|
| 48 |
#endif |
|---|
| 49 |
#if defined(__sparcv9) |
|---|
| 50 |
.section ".text" |
|---|
| 51 |
.align 8 |
|---|
| 52 |
.skip 24 |
|---|
| 53 |
.align 4 |
|---|
| 54 |
|
|---|
| 55 |
.global noit_atomic_cas64 |
|---|
| 56 |
noit_atomic_cas64: |
|---|
| 57 |
casx [%o0],%o2,%o1 |
|---|
| 58 |
mov %o1,%o0 |
|---|
| 59 |
retl |
|---|
| 60 |
nop |
|---|
| 61 |
.type noit_atomic_cas64,2 |
|---|
| 62 |
.size noit_atomic_cas64,(.-noit_atomic_cas64) |
|---|
| 63 |
|
|---|
| 64 |
.section ".text" |
|---|
| 65 |
.align 8 |
|---|
| 66 |
.skip 24 |
|---|
| 67 |
.align 4 |
|---|
| 68 |
|
|---|
| 69 |
.global noit_atomic_casptr |
|---|
| 70 |
noit_atomic_casptr: |
|---|
| 71 |
casx [%o0],%o2,%o1 |
|---|
| 72 |
mov %o1,%o0 |
|---|
| 73 |
retl |
|---|
| 74 |
nop |
|---|
| 75 |
.type noit_atomic_casptr,2 |
|---|
| 76 |
.size noit_atomic_casptr,(.-noit_atomic_casptr) |
|---|
| 77 |
|
|---|
| 78 |
#elif defined(__sparc) |
|---|
| 79 |
.section ".text" |
|---|
| 80 |
.align 8 |
|---|
| 81 |
.skip 24 |
|---|
| 82 |
.align 4 |
|---|
| 83 |
|
|---|
| 84 |
.global noit_atomic_cas64 |
|---|
| 85 |
noit_atomic_cas64: |
|---|
| 86 |
cas [%o0],%o2,%o1 |
|---|
| 87 |
mov %o1,%o0 |
|---|
| 88 |
retl |
|---|
| 89 |
nop |
|---|
| 90 |
.type noit_atomic_cas64,2 |
|---|
| 91 |
.size noit_atomic_cas64,(.-noit_atomic_cas64) |
|---|
| 92 |
|
|---|
| 93 |
.section ".text" |
|---|
| 94 |
.align 8 |
|---|
| 95 |
.skip 24 |
|---|
| 96 |
.align 4 |
|---|
| 97 |
|
|---|
| 98 |
.global noit_atomic_casptr |
|---|
| 99 |
noit_atomic_casptr: |
|---|
| 100 |
cas [%o0],%o2,%o1 |
|---|
| 101 |
mov %o1,%o0 |
|---|
| 102 |
retl |
|---|
| 103 |
nop |
|---|
| 104 |
.type noit_atomic_casptr,2 |
|---|
| 105 |
.size noit_atomic_casptr,(.-noit_atomic_casptr) |
|---|
| 106 |
|
|---|
| 107 |
#elif defined(__amd64) || defined(__i386) |
|---|
| 108 |
|
|---|
| 109 |
#if defined(__amd64) |
|---|
| 110 |
.code64 |
|---|
| 111 |
#endif |
|---|
| 112 |
.globl noit_atomic_cas32 |
|---|
| 113 |
.type noit_atomic_cas32, @function |
|---|
| 114 |
.globl noit_atomic_casptr |
|---|
| 115 |
.type noit_atomic_casptr, @function |
|---|
| 116 |
.globl noit_atomic_cas64 |
|---|
| 117 |
.type noit_atomic_cas64, @function |
|---|
| 118 |
|
|---|
| 119 |
.section .text,"ax" |
|---|
| 120 |
.align 16 |
|---|
| 121 |
noit_atomic_cas64: |
|---|
| 122 |
#if defined(__amd64) |
|---|
| 123 |
movq %rdx,%rax |
|---|
| 124 |
lock |
|---|
| 125 |
cmpxchgq %rsi,(%rdi) |
|---|
| 126 |
#else |
|---|
| 127 |
pushl %ebx |
|---|
| 128 |
pushl %esi |
|---|
| 129 |
movl 0xc(%esp),%esi |
|---|
| 130 |
movl 0x18(%esp),%eax |
|---|
| 131 |
movl 0x1c(%esp),%edx |
|---|
| 132 |
movl 0x10(%esp),%ebx |
|---|
| 133 |
movl 0x14(%esp),%ecx |
|---|
| 134 |
lock |
|---|
| 135 |
cmpxchg8b (%esi) |
|---|
| 136 |
popl %esi |
|---|
| 137 |
popl %ebx |
|---|
| 138 |
#endif |
|---|
| 139 |
ret |
|---|
| 140 |
.size noit_atomic_cas64, . - noit_atomic_cas64 |
|---|
| 141 |
|
|---|
| 142 |
.align 16 |
|---|
| 143 |
noit_atomic_cas32: |
|---|
| 144 |
#if defined(__amd64) |
|---|
| 145 |
movl %edx,%eax |
|---|
| 146 |
lock |
|---|
| 147 |
cmpxchgl %esi,(%rdi) |
|---|
| 148 |
#else |
|---|
| 149 |
movl 4(%esp), %edx |
|---|
| 150 |
movl 8(%esp), %ecx |
|---|
| 151 |
movl 12(%esp), %eax |
|---|
| 152 |
lock |
|---|
| 153 |
cmpxchgl %ecx, (%edx) |
|---|
| 154 |
#endif |
|---|
| 155 |
ret |
|---|
| 156 |
.size noit_atomic_cas32, . - noit_atomic_cas32 |
|---|
| 157 |
.align 16 |
|---|
| 158 |
noit_atomic_casptr: |
|---|
| 159 |
#if defined(__amd64) |
|---|
| 160 |
movq %rdx,%rax |
|---|
| 161 |
lock |
|---|
| 162 |
cmpxchgq %rsi,(%rdi) |
|---|
| 163 |
#else |
|---|
| 164 |
movl 4(%esp), %edx |
|---|
| 165 |
movl 8(%esp), %ecx |
|---|
| 166 |
movl 12(%esp), %eax |
|---|
| 167 |
lock |
|---|
| 168 |
cmpxchgl %ecx, (%edx) |
|---|
| 169 |
#endif |
|---|
| 170 |
ret |
|---|
| 171 |
.size noit_atomic_casptr, . - noit_atomic_casptr |
|---|
| 172 |
|
|---|
| 173 |
#else |
|---|
| 174 |
#error "No atomics for this architecture?!" |
|---|
| 175 |
#endif |
|---|