xref: /titanic_44/usr/src/common/atomic/i386/atomic.s (revision 7257d1b4d25bfac0c802847390e98a464fd787ac)
17c478bd9Sstevel@tonic-gate/*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5dfb96a4fSab196087 * Common Development and Distribution License (the "License").
6dfb96a4fSab196087 * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
21*7257d1b4Sraf
227c478bd9Sstevel@tonic-gate/*
23*7257d1b4Sraf * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
27*7257d1b4Sraf#pragma ident	"%Z%%M%	%I%	%E% SMI"
287c478bd9Sstevel@tonic-gate
297c478bd9Sstevel@tonic-gate	.file	"%M%"
307c478bd9Sstevel@tonic-gate
317c478bd9Sstevel@tonic-gate#include <sys/asm_linkage.h>
327c478bd9Sstevel@tonic-gate
337c478bd9Sstevel@tonic-gate#if defined(_KERNEL)
347c478bd9Sstevel@tonic-gate	/*
357c478bd9Sstevel@tonic-gate	 * Legacy kernel interfaces; they will go away (eventually).
367c478bd9Sstevel@tonic-gate	 */
377c478bd9Sstevel@tonic-gate	ANSI_PRAGMA_WEAK2(cas8,atomic_cas_8,function)
387c478bd9Sstevel@tonic-gate	ANSI_PRAGMA_WEAK2(cas32,atomic_cas_32,function)
397c478bd9Sstevel@tonic-gate	ANSI_PRAGMA_WEAK2(cas64,atomic_cas_64,function)
407c478bd9Sstevel@tonic-gate	ANSI_PRAGMA_WEAK2(caslong,atomic_cas_ulong,function)
417c478bd9Sstevel@tonic-gate	ANSI_PRAGMA_WEAK2(casptr,atomic_cas_ptr,function)
427c478bd9Sstevel@tonic-gate	ANSI_PRAGMA_WEAK2(atomic_and_long,atomic_and_ulong,function)
437c478bd9Sstevel@tonic-gate	ANSI_PRAGMA_WEAK2(atomic_or_long,atomic_or_ulong,function)
447c478bd9Sstevel@tonic-gate#endif
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gate	ENTRY(atomic_inc_8)
477c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_inc_uchar)
487c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
497c478bd9Sstevel@tonic-gate	lock
507c478bd9Sstevel@tonic-gate	incb	(%eax)
517c478bd9Sstevel@tonic-gate	ret
527c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_uchar)
537c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_8)
547c478bd9Sstevel@tonic-gate
557c478bd9Sstevel@tonic-gate	ENTRY(atomic_inc_16)
567c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_inc_ushort)
577c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
587c478bd9Sstevel@tonic-gate	lock
597c478bd9Sstevel@tonic-gate	incw	(%eax)
607c478bd9Sstevel@tonic-gate	ret
617c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_ushort)
627c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_16)
637c478bd9Sstevel@tonic-gate
647c478bd9Sstevel@tonic-gate	ENTRY(atomic_inc_32)
657c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_inc_uint)
667c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_inc_ulong)
677c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
687c478bd9Sstevel@tonic-gate	lock
697c478bd9Sstevel@tonic-gate	incl	(%eax)
707c478bd9Sstevel@tonic-gate	ret
717c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_ulong)
727c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_uint)
737c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_32)
747c478bd9Sstevel@tonic-gate
757c478bd9Sstevel@tonic-gate	ENTRY(atomic_inc_8_nv)
767c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_inc_uchar_nv)
777c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
787c478bd9Sstevel@tonic-gate	movb	(%edx), %al	/ %al = old value
797c478bd9Sstevel@tonic-gate1:
807c478bd9Sstevel@tonic-gate	leal	1(%eax), %ecx	/ %cl = new value
817c478bd9Sstevel@tonic-gate	lock
827c478bd9Sstevel@tonic-gate	cmpxchgb %cl, (%edx)	/ try to stick it in
837c478bd9Sstevel@tonic-gate	jne	1b
847c478bd9Sstevel@tonic-gate	movzbl	%cl, %eax	/ return new value
857c478bd9Sstevel@tonic-gate	ret
867c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_uchar_nv)
877c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_8_nv)
887c478bd9Sstevel@tonic-gate
897c478bd9Sstevel@tonic-gate	ENTRY(atomic_inc_16_nv)
907c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_inc_ushort_nv)
917c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
927c478bd9Sstevel@tonic-gate	movw	(%edx), %ax	/ %ax = old value
937c478bd9Sstevel@tonic-gate1:
947c478bd9Sstevel@tonic-gate	leal	1(%eax), %ecx	/ %cx = new value
957c478bd9Sstevel@tonic-gate	lock
967c478bd9Sstevel@tonic-gate	cmpxchgw %cx, (%edx)	/ try to stick it in
977c478bd9Sstevel@tonic-gate	jne	1b
987c478bd9Sstevel@tonic-gate	movzwl	%cx, %eax	/ return new value
997c478bd9Sstevel@tonic-gate	ret
1007c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_ushort_nv)
1017c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_16_nv)
1027c478bd9Sstevel@tonic-gate
1037c478bd9Sstevel@tonic-gate	ENTRY(atomic_inc_32_nv)
1047c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_inc_uint_nv)
1057c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_inc_ulong_nv)
1067c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
1077c478bd9Sstevel@tonic-gate	movl	(%edx), %eax	/ %eax = old value
1087c478bd9Sstevel@tonic-gate1:
1097c478bd9Sstevel@tonic-gate	leal	1(%eax), %ecx	/ %ecx = new value
1107c478bd9Sstevel@tonic-gate	lock
1117c478bd9Sstevel@tonic-gate	cmpxchgl %ecx, (%edx)	/ try to stick it in
1127c478bd9Sstevel@tonic-gate	jne	1b
1137c478bd9Sstevel@tonic-gate	movl	%ecx, %eax	/ return new value
1147c478bd9Sstevel@tonic-gate	ret
1157c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_ulong_nv)
1167c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_uint_nv)
1177c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_32_nv)
1187c478bd9Sstevel@tonic-gate
119dfb96a4fSab196087	/*
120dfb96a4fSab196087	 * NOTE: If atomic_inc_64 and atomic_inc_64_nv are ever
121dfb96a4fSab196087	 * separated, you need to also edit the libc i386 platform
122dfb96a4fSab196087	 * specific mapfile and remove the NODYNSORT attribute
123dfb96a4fSab196087	 * from atomic_inc_64_nv.
124dfb96a4fSab196087	 */
1257c478bd9Sstevel@tonic-gate	ENTRY(atomic_inc_64)
1267c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_inc_64_nv)
1277c478bd9Sstevel@tonic-gate	pushl	%edi
1287c478bd9Sstevel@tonic-gate	pushl	%ebx
1297c478bd9Sstevel@tonic-gate	movl	12(%esp), %edi	/ %edi = target address
1307c478bd9Sstevel@tonic-gate	movl	(%edi), %eax
1317c478bd9Sstevel@tonic-gate	movl	4(%edi), %edx	/ %edx:%eax = old value
1327c478bd9Sstevel@tonic-gate1:
1337c478bd9Sstevel@tonic-gate	xorl	%ebx, %ebx
1347c478bd9Sstevel@tonic-gate	xorl	%ecx, %ecx
1357c478bd9Sstevel@tonic-gate	incl	%ebx		/ %ecx:%ebx = 1
1367c478bd9Sstevel@tonic-gate	addl	%eax, %ebx
1377c478bd9Sstevel@tonic-gate	adcl	%edx, %ecx	/ add in the carry from inc
1387c478bd9Sstevel@tonic-gate	lock
1397c478bd9Sstevel@tonic-gate	cmpxchg8b (%edi)	/ try to stick it in
1407c478bd9Sstevel@tonic-gate	jne	1b
1417c478bd9Sstevel@tonic-gate	movl	%ebx, %eax
1427c478bd9Sstevel@tonic-gate	movl	%ecx, %edx	/ return new value
1437c478bd9Sstevel@tonic-gate	popl	%ebx
1447c478bd9Sstevel@tonic-gate	popl	%edi
1457c478bd9Sstevel@tonic-gate	ret
1467c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_64_nv)
1477c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_64)
1487c478bd9Sstevel@tonic-gate
1497c478bd9Sstevel@tonic-gate	ENTRY(atomic_dec_8)
1507c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_dec_uchar)
1517c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
1527c478bd9Sstevel@tonic-gate	lock
1537c478bd9Sstevel@tonic-gate	decb	(%eax)
1547c478bd9Sstevel@tonic-gate	ret
1557c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_uchar)
1567c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_8)
1577c478bd9Sstevel@tonic-gate
1587c478bd9Sstevel@tonic-gate	ENTRY(atomic_dec_16)
1597c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_dec_ushort)
1607c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
1617c478bd9Sstevel@tonic-gate	lock
1627c478bd9Sstevel@tonic-gate	decw	(%eax)
1637c478bd9Sstevel@tonic-gate	ret
1647c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_ushort)
1657c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_16)
1667c478bd9Sstevel@tonic-gate
1677c478bd9Sstevel@tonic-gate	ENTRY(atomic_dec_32)
1687c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_dec_uint)
1697c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_dec_ulong)
1707c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
1717c478bd9Sstevel@tonic-gate	lock
1727c478bd9Sstevel@tonic-gate	decl	(%eax)
1737c478bd9Sstevel@tonic-gate	ret
1747c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_ulong)
1757c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_uint)
1767c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_32)
1777c478bd9Sstevel@tonic-gate
1787c478bd9Sstevel@tonic-gate	ENTRY(atomic_dec_8_nv)
1797c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_dec_uchar_nv)
1807c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
1817c478bd9Sstevel@tonic-gate	movb	(%edx), %al	/ %al = old value
1827c478bd9Sstevel@tonic-gate1:
1837c478bd9Sstevel@tonic-gate	leal	-1(%eax), %ecx	/ %cl = new value
1847c478bd9Sstevel@tonic-gate	lock
1857c478bd9Sstevel@tonic-gate	cmpxchgb %cl, (%edx)	/ try to stick it in
1867c478bd9Sstevel@tonic-gate	jne	1b
1877c478bd9Sstevel@tonic-gate	movzbl	%cl, %eax	/ return new value
1887c478bd9Sstevel@tonic-gate	ret
1897c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_uchar_nv)
1907c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_8_nv)
1917c478bd9Sstevel@tonic-gate
1927c478bd9Sstevel@tonic-gate	ENTRY(atomic_dec_16_nv)
1937c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_dec_ushort_nv)
1947c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
1957c478bd9Sstevel@tonic-gate	movw	(%edx), %ax	/ %ax = old value
1967c478bd9Sstevel@tonic-gate1:
1977c478bd9Sstevel@tonic-gate	leal	-1(%eax), %ecx	/ %cx = new value
1987c478bd9Sstevel@tonic-gate	lock
1997c478bd9Sstevel@tonic-gate	cmpxchgw %cx, (%edx)	/ try to stick it in
2007c478bd9Sstevel@tonic-gate	jne	1b
2017c478bd9Sstevel@tonic-gate	movzwl	%cx, %eax	/ return new value
2027c478bd9Sstevel@tonic-gate	ret
2037c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_ushort_nv)
2047c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_16_nv)
2057c478bd9Sstevel@tonic-gate
2067c478bd9Sstevel@tonic-gate	ENTRY(atomic_dec_32_nv)
2077c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_dec_uint_nv)
2087c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_dec_ulong_nv)
2097c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
2107c478bd9Sstevel@tonic-gate	movl	(%edx), %eax	/ %eax = old value
2117c478bd9Sstevel@tonic-gate1:
2127c478bd9Sstevel@tonic-gate	leal	-1(%eax), %ecx	/ %ecx = new value
2137c478bd9Sstevel@tonic-gate	lock
2147c478bd9Sstevel@tonic-gate	cmpxchgl %ecx, (%edx)	/ try to stick it in
2157c478bd9Sstevel@tonic-gate	jne	1b
2167c478bd9Sstevel@tonic-gate	movl	%ecx, %eax	/ return new value
2177c478bd9Sstevel@tonic-gate	ret
2187c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_ulong_nv)
2197c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_uint_nv)
2207c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_32_nv)
2217c478bd9Sstevel@tonic-gate
222dfb96a4fSab196087	/*
223dfb96a4fSab196087	 * NOTE: If atomic_dec_64 and atomic_dec_64_nv are ever
224dfb96a4fSab196087	 * separated, it is important to edit the libc i386 platform
225dfb96a4fSab196087	 * specific mapfile and remove the NODYNSORT attribute
226dfb96a4fSab196087	 * from atomic_dec_64_nv.
227dfb96a4fSab196087	 */
2287c478bd9Sstevel@tonic-gate	ENTRY(atomic_dec_64)
2297c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_dec_64_nv)
2307c478bd9Sstevel@tonic-gate	pushl	%edi
2317c478bd9Sstevel@tonic-gate	pushl	%ebx
2327c478bd9Sstevel@tonic-gate	movl	12(%esp), %edi	/ %edi = target address
2337c478bd9Sstevel@tonic-gate	movl	(%edi), %eax
2347c478bd9Sstevel@tonic-gate	movl	4(%edi), %edx	/ %edx:%eax = old value
2357c478bd9Sstevel@tonic-gate1:
2367c478bd9Sstevel@tonic-gate	xorl	%ebx, %ebx
2377c478bd9Sstevel@tonic-gate	xorl	%ecx, %ecx
2387c478bd9Sstevel@tonic-gate	not	%ecx
2397c478bd9Sstevel@tonic-gate	not	%ebx		/ %ecx:%ebx = -1
2407c478bd9Sstevel@tonic-gate	addl	%eax, %ebx
2417c478bd9Sstevel@tonic-gate	adcl	%edx, %ecx	/ add in the carry from inc
2427c478bd9Sstevel@tonic-gate	lock
2437c478bd9Sstevel@tonic-gate	cmpxchg8b (%edi)	/ try to stick it in
2447c478bd9Sstevel@tonic-gate	jne	1b
2457c478bd9Sstevel@tonic-gate	movl	%ebx, %eax
2467c478bd9Sstevel@tonic-gate	movl	%ecx, %edx	/ return new value
2477c478bd9Sstevel@tonic-gate	popl	%ebx
2487c478bd9Sstevel@tonic-gate	popl	%edi
2497c478bd9Sstevel@tonic-gate	ret
2507c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_64_nv)
2517c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_64)
2527c478bd9Sstevel@tonic-gate
2537c478bd9Sstevel@tonic-gate	ENTRY(atomic_add_8)
2547c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_char)
2557c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
2567c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx
2577c478bd9Sstevel@tonic-gate	lock
2587c478bd9Sstevel@tonic-gate	addb	%cl, (%eax)
2597c478bd9Sstevel@tonic-gate	ret
2607c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_char)
2617c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_8)
2627c478bd9Sstevel@tonic-gate
2637c478bd9Sstevel@tonic-gate	ENTRY(atomic_add_16)
2647c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_short)
2657c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
2667c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx
2677c478bd9Sstevel@tonic-gate	lock
2687c478bd9Sstevel@tonic-gate	addw	%cx, (%eax)
2697c478bd9Sstevel@tonic-gate	ret
2707c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_short)
2717c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_16)
2727c478bd9Sstevel@tonic-gate
2737c478bd9Sstevel@tonic-gate	ENTRY(atomic_add_32)
2747c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_int)
2757c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_ptr)
2767c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_long)
2777c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
2787c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx
2797c478bd9Sstevel@tonic-gate	lock
2807c478bd9Sstevel@tonic-gate	addl	%ecx, (%eax)
2817c478bd9Sstevel@tonic-gate	ret
2827c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_long)
2837c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_ptr)
2847c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_int)
2857c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_32)
2867c478bd9Sstevel@tonic-gate
2877c478bd9Sstevel@tonic-gate	ENTRY(atomic_or_8)
2887c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_or_uchar)
2897c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
2907c478bd9Sstevel@tonic-gate	movb	8(%esp), %cl
2917c478bd9Sstevel@tonic-gate	lock
2927c478bd9Sstevel@tonic-gate	orb	%cl, (%eax)
2937c478bd9Sstevel@tonic-gate	ret
2947c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_uchar)
2957c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_8)
2967c478bd9Sstevel@tonic-gate
2977c478bd9Sstevel@tonic-gate	ENTRY(atomic_or_16)
2987c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_or_ushort)
2997c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
3007c478bd9Sstevel@tonic-gate	movw	8(%esp), %cx
3017c478bd9Sstevel@tonic-gate	lock
3027c478bd9Sstevel@tonic-gate	orw	%cx, (%eax)
3037c478bd9Sstevel@tonic-gate	ret
3047c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_ushort)
3057c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_16)
3067c478bd9Sstevel@tonic-gate
3077c478bd9Sstevel@tonic-gate	ENTRY(atomic_or_32)
3087c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_or_uint)
3097c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_or_ulong)
3107c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
3117c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx
3127c478bd9Sstevel@tonic-gate	lock
3137c478bd9Sstevel@tonic-gate	orl	%ecx, (%eax)
3147c478bd9Sstevel@tonic-gate	ret
3157c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_ulong)
3167c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_uint)
3177c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_32)
3187c478bd9Sstevel@tonic-gate
3197c478bd9Sstevel@tonic-gate	ENTRY(atomic_and_8)
3207c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_and_uchar)
3217c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
3227c478bd9Sstevel@tonic-gate	movb	8(%esp), %cl
3237c478bd9Sstevel@tonic-gate	lock
3247c478bd9Sstevel@tonic-gate	andb	%cl, (%eax)
3257c478bd9Sstevel@tonic-gate	ret
3267c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_uchar)
3277c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_8)
3287c478bd9Sstevel@tonic-gate
3297c478bd9Sstevel@tonic-gate	ENTRY(atomic_and_16)
3307c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_and_ushort)
3317c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
3327c478bd9Sstevel@tonic-gate	movw	8(%esp), %cx
3337c478bd9Sstevel@tonic-gate	lock
3347c478bd9Sstevel@tonic-gate	andw	%cx, (%eax)
3357c478bd9Sstevel@tonic-gate	ret
3367c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_ushort)
3377c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_16)
3387c478bd9Sstevel@tonic-gate
3397c478bd9Sstevel@tonic-gate	ENTRY(atomic_and_32)
3407c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_and_uint)
3417c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_and_ulong)
3427c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
3437c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx
3447c478bd9Sstevel@tonic-gate	lock
3457c478bd9Sstevel@tonic-gate	andl	%ecx, (%eax)
3467c478bd9Sstevel@tonic-gate	ret
3477c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_ulong)
3487c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_uint)
3497c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_32)
3507c478bd9Sstevel@tonic-gate
3517c478bd9Sstevel@tonic-gate	ENTRY(atomic_add_8_nv)
3527c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_char_nv)
3537c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
3547c478bd9Sstevel@tonic-gate	movb	(%edx), %al	/ %al = old value
3557c478bd9Sstevel@tonic-gate1:
3567c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = delta
3577c478bd9Sstevel@tonic-gate	addb	%al, %cl	/ %cl = new value
3587c478bd9Sstevel@tonic-gate	lock
3597c478bd9Sstevel@tonic-gate	cmpxchgb %cl, (%edx)	/ try to stick it in
3607c478bd9Sstevel@tonic-gate	jne	1b
3617c478bd9Sstevel@tonic-gate	movzbl	%cl, %eax	/ return new value
3627c478bd9Sstevel@tonic-gate	ret
3637c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_char_nv)
3647c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_8_nv)
3657c478bd9Sstevel@tonic-gate
3667c478bd9Sstevel@tonic-gate	ENTRY(atomic_add_16_nv)
3677c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_short_nv)
3687c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
3697c478bd9Sstevel@tonic-gate	movw	(%edx), %ax	/ %ax = old value
3707c478bd9Sstevel@tonic-gate1:
3717c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = delta
3727c478bd9Sstevel@tonic-gate	addw	%ax, %cx	/ %cx = new value
3737c478bd9Sstevel@tonic-gate	lock
3747c478bd9Sstevel@tonic-gate	cmpxchgw %cx, (%edx)	/ try to stick it in
3757c478bd9Sstevel@tonic-gate	jne	1b
3767c478bd9Sstevel@tonic-gate	movzwl	%cx, %eax	/ return new value
3777c478bd9Sstevel@tonic-gate	ret
3787c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_short_nv)
3797c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_16_nv)
3807c478bd9Sstevel@tonic-gate
3817c478bd9Sstevel@tonic-gate	ENTRY(atomic_add_32_nv)
3827c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_int_nv)
3837c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_ptr_nv)
3847c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_long_nv)
3857c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
3867c478bd9Sstevel@tonic-gate	movl	(%edx), %eax	/ %eax = old value
3877c478bd9Sstevel@tonic-gate1:
3887c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = delta
3897c478bd9Sstevel@tonic-gate	addl	%eax, %ecx	/ %ecx = new value
3907c478bd9Sstevel@tonic-gate	lock
3917c478bd9Sstevel@tonic-gate	cmpxchgl %ecx, (%edx)	/ try to stick it in
3927c478bd9Sstevel@tonic-gate	jne	1b
3937c478bd9Sstevel@tonic-gate	movl	%ecx, %eax	/ return new value
3947c478bd9Sstevel@tonic-gate	ret
3957c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_long_nv)
3967c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_ptr_nv)
3977c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_int_nv)
3987c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_32_nv)
3997c478bd9Sstevel@tonic-gate
400dfb96a4fSab196087	/*
401dfb96a4fSab196087	 * NOTE: If atomic_add_64 and atomic_add_64_nv are ever
402dfb96a4fSab196087	 * separated, it is important to edit the libc i386 platform
403dfb96a4fSab196087	 * specific mapfile and remove the NODYNSORT attribute
404dfb96a4fSab196087	 * from atomic_add_64_nv.
405dfb96a4fSab196087	 */
4067c478bd9Sstevel@tonic-gate	ENTRY(atomic_add_64)
4077c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_64_nv)
4087c478bd9Sstevel@tonic-gate	pushl	%edi
4097c478bd9Sstevel@tonic-gate	pushl	%ebx
4107c478bd9Sstevel@tonic-gate	movl	12(%esp), %edi	/ %edi = target address
4117c478bd9Sstevel@tonic-gate	movl	(%edi), %eax
4127c478bd9Sstevel@tonic-gate	movl	4(%edi), %edx	/ %edx:%eax = old value
4137c478bd9Sstevel@tonic-gate1:
4147c478bd9Sstevel@tonic-gate	movl	16(%esp), %ebx
4157c478bd9Sstevel@tonic-gate	movl	20(%esp), %ecx	/ %ecx:%ebx = delta
4167c478bd9Sstevel@tonic-gate	addl	%eax, %ebx
4177c478bd9Sstevel@tonic-gate	adcl	%edx, %ecx	/ %ecx:%ebx = new value
4187c478bd9Sstevel@tonic-gate	lock
4197c478bd9Sstevel@tonic-gate	cmpxchg8b (%edi)	/ try to stick it in
4207c478bd9Sstevel@tonic-gate	jne	1b
4217c478bd9Sstevel@tonic-gate	movl	%ebx, %eax
4227c478bd9Sstevel@tonic-gate	movl	%ecx, %edx	/ return new value
4237c478bd9Sstevel@tonic-gate	popl	%ebx
4247c478bd9Sstevel@tonic-gate	popl	%edi
4257c478bd9Sstevel@tonic-gate	ret
4267c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_64_nv)
4277c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_64)
4287c478bd9Sstevel@tonic-gate
4297c478bd9Sstevel@tonic-gate	ENTRY(atomic_or_8_nv)
4307c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_or_uchar_nv)
4317c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
4327c478bd9Sstevel@tonic-gate	movb	(%edx), %al	/ %al = old value
4337c478bd9Sstevel@tonic-gate1:
4347c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = delta
4357c478bd9Sstevel@tonic-gate	orb	%al, %cl	/ %cl = new value
4367c478bd9Sstevel@tonic-gate	lock
4377c478bd9Sstevel@tonic-gate	cmpxchgb %cl, (%edx)	/ try to stick it in
4387c478bd9Sstevel@tonic-gate	jne	1b
4397c478bd9Sstevel@tonic-gate	movzbl	%cl, %eax	/ return new value
4407c478bd9Sstevel@tonic-gate	ret
4417c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_uchar_nv)
4427c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_8_nv)
4437c478bd9Sstevel@tonic-gate
4447c478bd9Sstevel@tonic-gate	ENTRY(atomic_or_16_nv)
4457c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_or_ushort_nv)
4467c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
4477c478bd9Sstevel@tonic-gate	movw	(%edx), %ax	/ %ax = old value
4487c478bd9Sstevel@tonic-gate1:
4497c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = delta
4507c478bd9Sstevel@tonic-gate	orw	%ax, %cx	/ %cx = new value
4517c478bd9Sstevel@tonic-gate	lock
4527c478bd9Sstevel@tonic-gate	cmpxchgw %cx, (%edx)	/ try to stick it in
4537c478bd9Sstevel@tonic-gate	jne	1b
4547c478bd9Sstevel@tonic-gate	movzwl	%cx, %eax	/ return new value
4557c478bd9Sstevel@tonic-gate	ret
4567c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_ushort_nv)
4577c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_16_nv)
4587c478bd9Sstevel@tonic-gate
4597c478bd9Sstevel@tonic-gate	ENTRY(atomic_or_32_nv)
4607c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_or_uint_nv)
4617c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_or_ulong_nv)
4627c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
4637c478bd9Sstevel@tonic-gate	movl	(%edx), %eax	/ %eax = old value
4647c478bd9Sstevel@tonic-gate1:
4657c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = delta
4667c478bd9Sstevel@tonic-gate	orl	%eax, %ecx	/ %ecx = new value
4677c478bd9Sstevel@tonic-gate	lock
4687c478bd9Sstevel@tonic-gate	cmpxchgl %ecx, (%edx)	/ try to stick it in
4697c478bd9Sstevel@tonic-gate	jne	1b
4707c478bd9Sstevel@tonic-gate	movl	%ecx, %eax	/ return new value
4717c478bd9Sstevel@tonic-gate	ret
4727c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_ulong_nv)
4737c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_uint_nv)
4747c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_32_nv)
4757c478bd9Sstevel@tonic-gate
476dfb96a4fSab196087	/*
477dfb96a4fSab196087	 * NOTE: If atomic_or_64 and atomic_or_64_nv are ever
478dfb96a4fSab196087	 * separated, it is important to edit the libc i386 platform
479dfb96a4fSab196087	 * specific mapfile and remove the NODYNSORT attribute
480dfb96a4fSab196087	 * from atomic_or_64_nv.
481dfb96a4fSab196087	 */
4827c478bd9Sstevel@tonic-gate	ENTRY(atomic_or_64)
4837c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_or_64_nv)
4847c478bd9Sstevel@tonic-gate	pushl	%edi
4857c478bd9Sstevel@tonic-gate	pushl	%ebx
4867c478bd9Sstevel@tonic-gate	movl	12(%esp), %edi	/ %edi = target address
4877c478bd9Sstevel@tonic-gate	movl	(%edi), %eax
4887c478bd9Sstevel@tonic-gate	movl	4(%edi), %edx	/ %edx:%eax = old value
4897c478bd9Sstevel@tonic-gate1:
4907c478bd9Sstevel@tonic-gate	movl	16(%esp), %ebx
4917c478bd9Sstevel@tonic-gate	movl	20(%esp), %ecx	/ %ecx:%ebx = delta
4927c478bd9Sstevel@tonic-gate	orl	%eax, %ebx
4937c478bd9Sstevel@tonic-gate	orl	%edx, %ecx	/ %ecx:%ebx = new value
4947c478bd9Sstevel@tonic-gate	lock
4957c478bd9Sstevel@tonic-gate	cmpxchg8b (%edi)	/ try to stick it in
4967c478bd9Sstevel@tonic-gate	jne	1b
4977c478bd9Sstevel@tonic-gate	movl	%ebx, %eax
4987c478bd9Sstevel@tonic-gate	movl	%ecx, %edx	/ return new value
4997c478bd9Sstevel@tonic-gate	popl	%ebx
5007c478bd9Sstevel@tonic-gate	popl	%edi
5017c478bd9Sstevel@tonic-gate	ret
5027c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_64_nv)
5037c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_64)
5047c478bd9Sstevel@tonic-gate
5057c478bd9Sstevel@tonic-gate	ENTRY(atomic_and_8_nv)
5067c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_and_uchar_nv)
5077c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
5087c478bd9Sstevel@tonic-gate	movb	(%edx), %al	/ %al = old value
5097c478bd9Sstevel@tonic-gate1:
5107c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = delta
5117c478bd9Sstevel@tonic-gate	andb	%al, %cl	/ %cl = new value
5127c478bd9Sstevel@tonic-gate	lock
5137c478bd9Sstevel@tonic-gate	cmpxchgb %cl, (%edx)	/ try to stick it in
5147c478bd9Sstevel@tonic-gate	jne	1b
5157c478bd9Sstevel@tonic-gate	movzbl	%cl, %eax	/ return new value
5167c478bd9Sstevel@tonic-gate	ret
5177c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_uchar_nv)
5187c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_8_nv)
5197c478bd9Sstevel@tonic-gate
5207c478bd9Sstevel@tonic-gate	ENTRY(atomic_and_16_nv)
5217c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_and_ushort_nv)
5227c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
5237c478bd9Sstevel@tonic-gate	movw	(%edx), %ax	/ %ax = old value
5247c478bd9Sstevel@tonic-gate1:
5257c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = delta
5267c478bd9Sstevel@tonic-gate	andw	%ax, %cx	/ %cx = new value
5277c478bd9Sstevel@tonic-gate	lock
5287c478bd9Sstevel@tonic-gate	cmpxchgw %cx, (%edx)	/ try to stick it in
5297c478bd9Sstevel@tonic-gate	jne	1b
5307c478bd9Sstevel@tonic-gate	movzwl	%cx, %eax	/ return new value
5317c478bd9Sstevel@tonic-gate	ret
5327c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_ushort_nv)
5337c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_16_nv)
5347c478bd9Sstevel@tonic-gate
5357c478bd9Sstevel@tonic-gate	ENTRY(atomic_and_32_nv)
5367c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_and_uint_nv)
5377c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_and_ulong_nv)
5387c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
5397c478bd9Sstevel@tonic-gate	movl	(%edx), %eax	/ %eax = old value
5407c478bd9Sstevel@tonic-gate1:
5417c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = delta
5427c478bd9Sstevel@tonic-gate	andl	%eax, %ecx	/ %ecx = new value
5437c478bd9Sstevel@tonic-gate	lock
5447c478bd9Sstevel@tonic-gate	cmpxchgl %ecx, (%edx)	/ try to stick it in
5457c478bd9Sstevel@tonic-gate	jne	1b
5467c478bd9Sstevel@tonic-gate	movl	%ecx, %eax	/ return new value
5477c478bd9Sstevel@tonic-gate	ret
5487c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_ulong_nv)
5497c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_uint_nv)
5507c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_32_nv)
5517c478bd9Sstevel@tonic-gate
552dfb96a4fSab196087	/*
553dfb96a4fSab196087	 * NOTE: If atomic_and_64 and atomic_and_64_nv are ever
554dfb96a4fSab196087	 * separated, it is important to edit the libc i386 platform
555dfb96a4fSab196087	 * specific mapfile and remove the NODYNSORT attribute
556dfb96a4fSab196087	 * from atomic_and_64_nv.
557dfb96a4fSab196087	 */
5587c478bd9Sstevel@tonic-gate	ENTRY(atomic_and_64)
5597c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_and_64_nv)
5607c478bd9Sstevel@tonic-gate	pushl	%edi
5617c478bd9Sstevel@tonic-gate	pushl	%ebx
5627c478bd9Sstevel@tonic-gate	movl	12(%esp), %edi	/ %edi = target address
5637c478bd9Sstevel@tonic-gate	movl	(%edi), %eax
5647c478bd9Sstevel@tonic-gate	movl	4(%edi), %edx	/ %edx:%eax = old value
5657c478bd9Sstevel@tonic-gate1:
5667c478bd9Sstevel@tonic-gate	movl	16(%esp), %ebx
5677c478bd9Sstevel@tonic-gate	movl	20(%esp), %ecx	/ %ecx:%ebx = delta
5687c478bd9Sstevel@tonic-gate	andl	%eax, %ebx
5697c478bd9Sstevel@tonic-gate	andl	%edx, %ecx	/ %ecx:%ebx = new value
5707c478bd9Sstevel@tonic-gate	lock
5717c478bd9Sstevel@tonic-gate	cmpxchg8b (%edi)	/ try to stick it in
5727c478bd9Sstevel@tonic-gate	jne	1b
5737c478bd9Sstevel@tonic-gate	movl	%ebx, %eax
5747c478bd9Sstevel@tonic-gate	movl	%ecx, %edx	/ return new value
5757c478bd9Sstevel@tonic-gate	popl	%ebx
5767c478bd9Sstevel@tonic-gate	popl	%edi
5777c478bd9Sstevel@tonic-gate	ret
5787c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_64_nv)
5797c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_64)
5807c478bd9Sstevel@tonic-gate
5817c478bd9Sstevel@tonic-gate	ENTRY(atomic_cas_8)
5827c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_cas_uchar)
5837c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx
5847c478bd9Sstevel@tonic-gate	movzbl	8(%esp), %eax
5857c478bd9Sstevel@tonic-gate	movb	12(%esp), %cl
5867c478bd9Sstevel@tonic-gate	lock
5877c478bd9Sstevel@tonic-gate	cmpxchgb %cl, (%edx)
5887c478bd9Sstevel@tonic-gate	ret
5897c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_cas_uchar)
5907c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_cas_8)
5917c478bd9Sstevel@tonic-gate
5927c478bd9Sstevel@tonic-gate	ENTRY(atomic_cas_16)
5937c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_cas_ushort)
5947c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx
5957c478bd9Sstevel@tonic-gate	movzwl	8(%esp), %eax
5967c478bd9Sstevel@tonic-gate	movw	12(%esp), %cx
5977c478bd9Sstevel@tonic-gate	lock
5987c478bd9Sstevel@tonic-gate	cmpxchgw %cx, (%edx)
5997c478bd9Sstevel@tonic-gate	ret
6007c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_cas_ushort)
6017c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_cas_16)
6027c478bd9Sstevel@tonic-gate
6037c478bd9Sstevel@tonic-gate	ENTRY(atomic_cas_32)
6047c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_cas_uint)
6057c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_cas_ulong)
6067c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_cas_ptr)
6077c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx
6087c478bd9Sstevel@tonic-gate	movl	8(%esp), %eax
6097c478bd9Sstevel@tonic-gate	movl	12(%esp), %ecx
6107c478bd9Sstevel@tonic-gate	lock
6117c478bd9Sstevel@tonic-gate	cmpxchgl %ecx, (%edx)
6127c478bd9Sstevel@tonic-gate	ret
6137c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_cas_ptr)
6147c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_cas_ulong)
6157c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_cas_uint)
6167c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_cas_32)
6177c478bd9Sstevel@tonic-gate
6187c478bd9Sstevel@tonic-gate	ENTRY(atomic_cas_64)
6197c478bd9Sstevel@tonic-gate	pushl	%ebx
6207c478bd9Sstevel@tonic-gate	pushl	%esi
6217c478bd9Sstevel@tonic-gate	movl	12(%esp), %esi
6227c478bd9Sstevel@tonic-gate	movl	16(%esp), %eax
6237c478bd9Sstevel@tonic-gate	movl	20(%esp), %edx
6247c478bd9Sstevel@tonic-gate	movl	24(%esp), %ebx
6257c478bd9Sstevel@tonic-gate	movl	28(%esp), %ecx
6267c478bd9Sstevel@tonic-gate	lock
6277c478bd9Sstevel@tonic-gate	cmpxchg8b (%esi)
6287c478bd9Sstevel@tonic-gate	popl	%esi
6297c478bd9Sstevel@tonic-gate	popl	%ebx
6307c478bd9Sstevel@tonic-gate	ret
6317c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_cas_64)
6327c478bd9Sstevel@tonic-gate
6337c478bd9Sstevel@tonic-gate	ENTRY(atomic_swap_8)
6347c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_swap_uchar)
6357c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx
6367c478bd9Sstevel@tonic-gate	movzbl	8(%esp), %eax
6377c478bd9Sstevel@tonic-gate	lock
6387c478bd9Sstevel@tonic-gate	xchgb	%al, (%edx)
6397c478bd9Sstevel@tonic-gate	ret
6407c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_swap_uchar)
6417c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_swap_8)
6427c478bd9Sstevel@tonic-gate
6437c478bd9Sstevel@tonic-gate	ENTRY(atomic_swap_16)
6447c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_swap_ushort)
6457c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx
6467c478bd9Sstevel@tonic-gate	movzwl	8(%esp), %eax
6477c478bd9Sstevel@tonic-gate	lock
6487c478bd9Sstevel@tonic-gate	xchgw	%ax, (%edx)
6497c478bd9Sstevel@tonic-gate	ret
6507c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_swap_ushort)
6517c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_swap_16)
6527c478bd9Sstevel@tonic-gate
6537c478bd9Sstevel@tonic-gate	ENTRY(atomic_swap_32)
6547c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_swap_uint)
6557c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_swap_ptr)
6567c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_swap_ulong)
6577c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx
6587c478bd9Sstevel@tonic-gate	movl	8(%esp), %eax
6597c478bd9Sstevel@tonic-gate	lock
6607c478bd9Sstevel@tonic-gate	xchgl	%eax, (%edx)
6617c478bd9Sstevel@tonic-gate	ret
6627c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_swap_ulong)
6637c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_swap_ptr)
6647c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_swap_uint)
6657c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_swap_32)
6667c478bd9Sstevel@tonic-gate
6677c478bd9Sstevel@tonic-gate	ENTRY(atomic_swap_64)
6687c478bd9Sstevel@tonic-gate	pushl	%esi
6697c478bd9Sstevel@tonic-gate	pushl	%ebx
6707c478bd9Sstevel@tonic-gate	movl	12(%esp), %esi
6717c478bd9Sstevel@tonic-gate	movl	16(%esp), %ebx
6727c478bd9Sstevel@tonic-gate	movl	20(%esp), %ecx
6737c478bd9Sstevel@tonic-gate	movl	(%esi), %eax
6747c478bd9Sstevel@tonic-gate	movl	4(%esi), %edx	/ %edx:%eax = old value
6757c478bd9Sstevel@tonic-gate1:
6767c478bd9Sstevel@tonic-gate	lock
6777c478bd9Sstevel@tonic-gate	cmpxchg8b (%esi)
6787c478bd9Sstevel@tonic-gate	jne	1b
6797c478bd9Sstevel@tonic-gate	popl	%ebx
6807c478bd9Sstevel@tonic-gate	popl	%esi
6817c478bd9Sstevel@tonic-gate	ret
6827c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_swap_64)
6837c478bd9Sstevel@tonic-gate
6847c478bd9Sstevel@tonic-gate	ENTRY(atomic_set_long_excl)
6857c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
6867c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = bit id
6877c478bd9Sstevel@tonic-gate	xorl	%eax, %eax
6887c478bd9Sstevel@tonic-gate	lock
6897c478bd9Sstevel@tonic-gate	btsl	%ecx, (%edx)
6907c478bd9Sstevel@tonic-gate	jnc	1f
6917c478bd9Sstevel@tonic-gate	decl	%eax		/ return -1
6927c478bd9Sstevel@tonic-gate1:
6937c478bd9Sstevel@tonic-gate	ret
6947c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_set_long_excl)
6957c478bd9Sstevel@tonic-gate
6967c478bd9Sstevel@tonic-gate	ENTRY(atomic_clear_long_excl)
6977c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
6987c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = bit id
6997c478bd9Sstevel@tonic-gate	xorl	%eax, %eax
7007c478bd9Sstevel@tonic-gate	lock
7017c478bd9Sstevel@tonic-gate	btrl	%ecx, (%edx)
7027c478bd9Sstevel@tonic-gate	jc	1f
7037c478bd9Sstevel@tonic-gate	decl	%eax		/ return -1
7047c478bd9Sstevel@tonic-gate1:
7057c478bd9Sstevel@tonic-gate	ret
7067c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_clear_long_excl)
7077c478bd9Sstevel@tonic-gate
7087c478bd9Sstevel@tonic-gate#if !defined(_KERNEL)
7097c478bd9Sstevel@tonic-gate
710dfb96a4fSab196087	/*
711dfb96a4fSab196087	 * NOTE: membar_enter, membar_exit, membar_producer, and
712dfb96a4fSab196087	 * membar_consumer are all identical routines. We define them
713dfb96a4fSab196087	 * separately, instead of using ALTENTRY definitions to alias them
714dfb96a4fSab196087	 * together, so that DTrace and debuggers will see a unique address
715dfb96a4fSab196087	 * for them, allowing more accurate tracing.
716dfb96a4fSab196087	*/
717dfb96a4fSab196087
718dfb96a4fSab196087
7197c478bd9Sstevel@tonic-gate	ENTRY(membar_enter)
720dfb96a4fSab196087	lock
721dfb96a4fSab196087	xorl	$0, (%esp)
722dfb96a4fSab196087	ret
723dfb96a4fSab196087	SET_SIZE(membar_enter)
724dfb96a4fSab196087
725dfb96a4fSab196087	ENTRY(membar_exit)
726dfb96a4fSab196087	lock
727dfb96a4fSab196087	xorl	$0, (%esp)
728dfb96a4fSab196087	ret
729dfb96a4fSab196087	SET_SIZE(membar_exit)
730dfb96a4fSab196087
731dfb96a4fSab196087	ENTRY(membar_producer)
732dfb96a4fSab196087	lock
733dfb96a4fSab196087	xorl	$0, (%esp)
734dfb96a4fSab196087	ret
735dfb96a4fSab196087	SET_SIZE(membar_producer)
736dfb96a4fSab196087
737dfb96a4fSab196087	ENTRY(membar_consumer)
7387c478bd9Sstevel@tonic-gate	lock
7397c478bd9Sstevel@tonic-gate	xorl	$0, (%esp)
7407c478bd9Sstevel@tonic-gate	ret
7417c478bd9Sstevel@tonic-gate	SET_SIZE(membar_consumer)
7427c478bd9Sstevel@tonic-gate
7437c478bd9Sstevel@tonic-gate#endif	/* !_KERNEL */
744