| 1 |
/* |
|---|
| 2 |
* Copyright (c) 2007, OmniTI Computer Consulting, Inc. |
|---|
| 3 |
* All rights reserved. |
|---|
| 4 |
*/ |
|---|
| 5 |
|
|---|
| 6 |
#if defined(__sparcv9) || defined(__sparc) |
|---|
| 7 |
|
|---|
| 8 |
.section ".text" |
|---|
| 9 |
.align 8 |
|---|
| 10 |
.skip 24 |
|---|
| 11 |
.align 4 |
|---|
| 12 |
|
|---|
| 13 |
.global noit_atomic_cas32 |
|---|
| 14 |
noit_atomic_cas32: |
|---|
| 15 |
cas [%o0],%o2,%o1 |
|---|
| 16 |
mov %o1,%o0 |
|---|
| 17 |
retl |
|---|
| 18 |
nop |
|---|
| 19 |
.type noit_atomic_cas32,2 |
|---|
| 20 |
.size noit_atomic_cas32,(.-noit_atomic_cas32) |
|---|
| 21 |
#endif |
|---|
| 22 |
#if defined(__sparcv9) |
|---|
| 23 |
.section ".text" |
|---|
| 24 |
.align 8 |
|---|
| 25 |
.skip 24 |
|---|
| 26 |
.align 4 |
|---|
| 27 |
|
|---|
| 28 |
.global noit_atomic_cas64 |
|---|
| 29 |
noit_atomic_cas64: |
|---|
| 30 |
casx [%o0],%o2,%o1 |
|---|
| 31 |
mov %o1,%o0 |
|---|
| 32 |
retl |
|---|
| 33 |
nop |
|---|
| 34 |
.type noit_atomic_cas64,2 |
|---|
| 35 |
.size noit_atomic_cas64,(.-noit_atomic_cas64) |
|---|
| 36 |
|
|---|
| 37 |
.section ".text" |
|---|
| 38 |
.align 8 |
|---|
| 39 |
.skip 24 |
|---|
| 40 |
.align 4 |
|---|
| 41 |
|
|---|
| 42 |
.global noit_atomic_casptr |
|---|
| 43 |
noit_atomic_casptr: |
|---|
| 44 |
casx [%o0],%o2,%o1 |
|---|
| 45 |
mov %o1,%o0 |
|---|
| 46 |
retl |
|---|
| 47 |
nop |
|---|
| 48 |
.type noit_atomic_casptr,2 |
|---|
| 49 |
.size noit_atomic_casptr,(.-noit_atomic_casptr) |
|---|
| 50 |
|
|---|
| 51 |
#elif defined(__sparc) |
|---|
| 52 |
.section ".text" |
|---|
| 53 |
.align 8 |
|---|
| 54 |
.skip 24 |
|---|
| 55 |
.align 4 |
|---|
| 56 |
|
|---|
| 57 |
.global noit_atomic_cas64 |
|---|
| 58 |
noit_atomic_cas64: |
|---|
| 59 |
cas [%o0],%o2,%o1 |
|---|
| 60 |
mov %o1,%o0 |
|---|
| 61 |
retl |
|---|
| 62 |
nop |
|---|
| 63 |
.type noit_atomic_cas64,2 |
|---|
| 64 |
.size noit_atomic_cas64,(.-noit_atomic_cas64) |
|---|
| 65 |
|
|---|
| 66 |
.section ".text" |
|---|
| 67 |
.align 8 |
|---|
| 68 |
.skip 24 |
|---|
| 69 |
.align 4 |
|---|
| 70 |
|
|---|
| 71 |
.global noit_atomic_casptr |
|---|
| 72 |
noit_atomic_casptr: |
|---|
| 73 |
cas [%o0],%o2,%o1 |
|---|
| 74 |
mov %o1,%o0 |
|---|
| 75 |
retl |
|---|
| 76 |
nop |
|---|
| 77 |
.type noit_atomic_casptr,2 |
|---|
| 78 |
.size noit_atomic_casptr,(.-noit_atomic_casptr) |
|---|
| 79 |
|
|---|
| 80 |
#elif defined(__amd64) || defined(__i386) |
|---|
| 81 |
|
|---|
| 82 |
#if defined(__amd64) |
|---|
| 83 |
.code64 |
|---|
| 84 |
#endif |
|---|
| 85 |
.globl noit_atomic_cas32 |
|---|
| 86 |
.type noit_atomic_cas32, @function |
|---|
| 87 |
.globl noit_atomic_casptr |
|---|
| 88 |
.type noit_atomic_casptr, @function |
|---|
| 89 |
.globl noit_atomic_cas64 |
|---|
| 90 |
.type noit_atomic_cas64, @function |
|---|
| 91 |
|
|---|
| 92 |
.section .text,"ax" |
|---|
| 93 |
.align 16 |
|---|
| 94 |
noit_atomic_cas64: |
|---|
| 95 |
#if defined(__amd64) |
|---|
| 96 |
movq %rdx,%rax |
|---|
| 97 |
lock |
|---|
| 98 |
cmpxchgq %rsi,(%rdi) |
|---|
| 99 |
#else |
|---|
| 100 |
pushl %ebx |
|---|
| 101 |
pushl %esi |
|---|
| 102 |
movl 0xc(%esp),%esi |
|---|
| 103 |
movl 0x18(%esp),%eax |
|---|
| 104 |
movl 0x1c(%esp),%edx |
|---|
| 105 |
movl 0x10(%esp),%ebx |
|---|
| 106 |
movl 0x14(%esp),%ecx |
|---|
| 107 |
lock |
|---|
| 108 |
cmpxchg8b (%esi) |
|---|
| 109 |
popl %esi |
|---|
| 110 |
popl %ebx |
|---|
| 111 |
#endif |
|---|
| 112 |
ret |
|---|
| 113 |
.size noit_atomic_cas64, . - noit_atomic_cas64 |
|---|
| 114 |
|
|---|
| 115 |
.align 16 |
|---|
| 116 |
noit_atomic_cas32: |
|---|
| 117 |
#if defined(__amd64) |
|---|
| 118 |
movl %edx,%eax |
|---|
| 119 |
lock |
|---|
| 120 |
cmpxchgl %esi,(%rdi) |
|---|
| 121 |
#else |
|---|
| 122 |
movl 4(%esp), %edx |
|---|
| 123 |
movl 8(%esp), %ecx |
|---|
| 124 |
movl 12(%esp), %eax |
|---|
| 125 |
lock |
|---|
| 126 |
cmpxchgl %ecx, (%edx) |
|---|
| 127 |
#endif |
|---|
| 128 |
ret |
|---|
| 129 |
.size noit_atomic_cas32, . - noit_atomic_cas32 |
|---|
| 130 |
.align 16 |
|---|
| 131 |
noit_atomic_casptr: |
|---|
| 132 |
#if defined(__amd64) |
|---|
| 133 |
movq %rdx,%rax |
|---|
| 134 |
lock |
|---|
| 135 |
cmpxchgq %rsi,(%rdi) |
|---|
| 136 |
#else |
|---|
| 137 |
movl 4(%esp), %edx |
|---|
| 138 |
movl 8(%esp), %ecx |
|---|
| 139 |
movl 12(%esp), %eax |
|---|
| 140 |
lock |
|---|
| 141 |
cmpxchgl %ecx, (%edx) |
|---|
| 142 |
#endif |
|---|
| 143 |
ret |
|---|
| 144 |
.size noit_atomic_casptr, . - noit_atomic_casptr |
|---|
| 145 |
|
|---|
| 146 |
#else |
|---|
| 147 |
#error "No atomics for this architecture?!" |
|---|
| 148 |
#endif |
|---|