4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 #include <sys/asm_linkage.h>
33 * NOTE: If atomic_dec_64 and atomic_dec_64_nv are ever
34 * separated, it is important to edit the libc i386 platform
35 * specific mapfile and remove the NODYNSORT attribute
36 * from atomic_dec_64_nv.
39 ALTENTRY(atomic_dec_64_nv)
42 movl 12(%esp), %edi // %edi = target address
44 movl 4(%edi), %edx // %edx:%eax = old value
49 not %ebx // %ecx:%ebx = -1
51 adcl %edx, %ecx // add in the carry from inc
53 cmpxchg8b (%edi) // try to stick it in
56 movl %ecx, %edx // return new value
60 SET_SIZE(atomic_dec_64_nv)
61 SET_SIZE(atomic_dec_64)
64 * NOTE: If atomic_add_64 and atomic_add_64_nv are ever
65 * separated, it is important to edit the libc i386 platform
66 * specific mapfile and remove the NODYNSORT attribute
67 * from atomic_add_64_nv.
70 ALTENTRY(atomic_add_64_nv)
73 movl 12(%esp), %edi // %edi = target address
75 movl 4(%edi), %edx // %edx:%eax = old value
78 movl 20(%esp), %ecx // %ecx:%ebx = delta
80 adcl %edx, %ecx // %ecx:%ebx = new value
82 cmpxchg8b (%edi) // try to stick it in
85 movl %ecx, %edx // return new value
89 SET_SIZE(atomic_add_64_nv)
90 SET_SIZE(atomic_add_64)
93 movl 4(%esp), %edx // %edx = target address
94 movb (%edx), %al // %al = old value
96 movl 8(%esp), %ecx // %ecx = delta
97 orb %al, %cl // %cl = new value
99 cmpxchgb %cl, (%edx) // try to stick it in
101 movzbl %cl, %eax // return new value
103 SET_SIZE(atomic_or_8_nv)
110 cmpxchgl %ecx, (%edx)
112 SET_SIZE(atomic_cas_32)
127 SET_SIZE(atomic_cas_64)
129 ENTRY(membar_producer)
133 SET_SIZE(membar_producer)