]>
Commit | Line | Data |
---|---|---|
b0d623f7 A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
25 | * | |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
27 | */ | |
28 | ||
29 | #;*************************************************************************** | |
30 | #;* Boolean OSCompareAndSwap(SInt32 oldValue, SInt32 newValue, SInt32 *ptr) * | |
31 | #;*************************************************************************** | |
32 | ||
33 | .globl _OSCompareAndSwap | |
b0d623f7 A |
34 | _OSCompareAndSwap: #;oldValue, newValue, ptr |
35 | movl %edi, %eax | |
36 | lock | |
6d2010ae A |
37 | cmpxchgl %esi, (%rdx) #; CAS (eax is an implicit operand) |
38 | sete %al #; did CAS succeed? (TZ=1) | |
b0d623f7 A |
39 | movzbq %al, %rax #; clear out the high bytes |
40 | ret | |
41 | ||
42 | #;***************************************************************************** | |
43 | #;* Boolean OSCompareAndSwap64(SInt64 oldValue, SInt64 newValue, SInt64 *ptr) * | |
44 | #;***************************************************************************** | |
45 | ||
46 | .globl _OSCompareAndSwap64 | |
47 | .globl _OSCompareAndSwapPtr | |
48 | ||
49 | _OSCompareAndSwap64: | |
50 | _OSCompareAndSwapPtr: #;oldValue, newValue, ptr | |
6d2010ae | 51 | movq %rdi, %rax |
b0d623f7 | 52 | lock |
6d2010ae A |
53 | cmpxchgq %rsi, (%rdx) #; CAS (rax is an implicit operand) |
54 | sete %al #; did CAS succeed? (TZ=1) | |
b0d623f7 A |
55 | movzbq %al, %rax #; clear out the high bytes |
56 | ret | |
57 | ||
58 | #;******************************************************* | |
59 | #;* SInt64 OSAddAtomic64(SInt64 theAmount, SInt64 *ptr) * | |
60 | #;******************************************************* | |
61 | ||
62 | .globl _OSAddAtomicLong | |
63 | .globl _OSAddAtomic64 | |
64 | _OSAddAtomic64: | |
65 | _OSAddAtomicLong: | |
66 | lock | |
6d2010ae | 67 | xaddq %rdi, (%rsi) #; Atomic exchange and add |
b0d623f7 A |
68 | movq %rdi, %rax; |
69 | ret | |
70 | ||
71 | ||
72 | #;******************************************************* | |
73 | #; SInt32 OSAddAtomic(SInt32 delta, SInt32 *address) | |
74 | #;******************************************************* | |
75 | ||
76 | .globl _OSAddAtomic | |
77 | _OSAddAtomic: | |
78 | lock | |
6d2010ae | 79 | xaddl %edi, (%rsi) #; Atomic exchange and add |
b0d623f7 A |
80 | movl %edi, %eax; |
81 | ret |