xref: /titanic_51/usr/src/common/atomic/i386/atomic.s (revision 96d9f183facd90dbbc2268c9a51689be0b6a0b46)
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 */
217257d1b4Sraf
227c478bd9Sstevel@tonic-gate/*
23*96d9f183SBill Holler * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
279a70fc3bSMark J. Nelson	.file	"atomic.s"
287c478bd9Sstevel@tonic-gate
297c478bd9Sstevel@tonic-gate#include <sys/asm_linkage.h>
307c478bd9Sstevel@tonic-gate
317c478bd9Sstevel@tonic-gate#if defined(_KERNEL)
327c478bd9Sstevel@tonic-gate	/*
337c478bd9Sstevel@tonic-gate	 * Legacy kernel interfaces; they will go away (eventually).
347c478bd9Sstevel@tonic-gate	 */
357c478bd9Sstevel@tonic-gate	ANSI_PRAGMA_WEAK2(cas8,atomic_cas_8,function)
367c478bd9Sstevel@tonic-gate	ANSI_PRAGMA_WEAK2(cas32,atomic_cas_32,function)
377c478bd9Sstevel@tonic-gate	ANSI_PRAGMA_WEAK2(cas64,atomic_cas_64,function)
387c478bd9Sstevel@tonic-gate	ANSI_PRAGMA_WEAK2(caslong,atomic_cas_ulong,function)
397c478bd9Sstevel@tonic-gate	ANSI_PRAGMA_WEAK2(casptr,atomic_cas_ptr,function)
407c478bd9Sstevel@tonic-gate	ANSI_PRAGMA_WEAK2(atomic_and_long,atomic_and_ulong,function)
417c478bd9Sstevel@tonic-gate	ANSI_PRAGMA_WEAK2(atomic_or_long,atomic_or_ulong,function)
427c478bd9Sstevel@tonic-gate#endif
437c478bd9Sstevel@tonic-gate
447c478bd9Sstevel@tonic-gate	ENTRY(atomic_inc_8)
457c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_inc_uchar)
467c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
477c478bd9Sstevel@tonic-gate	lock
487c478bd9Sstevel@tonic-gate	incb	(%eax)
497c478bd9Sstevel@tonic-gate	ret
507c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_uchar)
517c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_8)
527c478bd9Sstevel@tonic-gate
537c478bd9Sstevel@tonic-gate	ENTRY(atomic_inc_16)
547c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_inc_ushort)
557c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
567c478bd9Sstevel@tonic-gate	lock
577c478bd9Sstevel@tonic-gate	incw	(%eax)
587c478bd9Sstevel@tonic-gate	ret
597c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_ushort)
607c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_16)
617c478bd9Sstevel@tonic-gate
627c478bd9Sstevel@tonic-gate	ENTRY(atomic_inc_32)
637c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_inc_uint)
647c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_inc_ulong)
657c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
667c478bd9Sstevel@tonic-gate	lock
677c478bd9Sstevel@tonic-gate	incl	(%eax)
687c478bd9Sstevel@tonic-gate	ret
697c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_ulong)
707c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_uint)
717c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_32)
727c478bd9Sstevel@tonic-gate
737c478bd9Sstevel@tonic-gate	ENTRY(atomic_inc_8_nv)
747c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_inc_uchar_nv)
757c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
76*96d9f183SBill Holler	xorl	%eax, %eax	/ clear upper bits of %eax
77*96d9f183SBill Holler	incb	%al		/ %al = 1
787c478bd9Sstevel@tonic-gate	lock
79*96d9f183SBill Holler	  xaddb	%al, (%edx)	/ %al = old value, inc (%edx)
80*96d9f183SBill Holler	incb	%al	/ return new value
817c478bd9Sstevel@tonic-gate	ret
827c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_uchar_nv)
837c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_8_nv)
847c478bd9Sstevel@tonic-gate
857c478bd9Sstevel@tonic-gate	ENTRY(atomic_inc_16_nv)
867c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_inc_ushort_nv)
877c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
88*96d9f183SBill Holler	xorl	%eax, %eax	/ clear upper bits of %eax
89*96d9f183SBill Holler	incw	%ax		/ %ax = 1
907c478bd9Sstevel@tonic-gate	lock
91*96d9f183SBill Holler	  xaddw	%ax, (%edx)	/ %ax = old value, inc (%edx)
92*96d9f183SBill Holler	incw	%ax		/ return new value
937c478bd9Sstevel@tonic-gate	ret
947c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_ushort_nv)
957c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_16_nv)
967c478bd9Sstevel@tonic-gate
977c478bd9Sstevel@tonic-gate	ENTRY(atomic_inc_32_nv)
987c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_inc_uint_nv)
997c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_inc_ulong_nv)
1007c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
101*96d9f183SBill Holler	xorl	%eax, %eax	/ %eax = 0
102*96d9f183SBill Holler	incl	%eax		/ %eax = 1
1037c478bd9Sstevel@tonic-gate	lock
104*96d9f183SBill Holler	  xaddl	%eax, (%edx)	/ %eax = old value, inc (%edx)
105*96d9f183SBill Holler	incl	%eax		/ return new value
1067c478bd9Sstevel@tonic-gate	ret
1077c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_ulong_nv)
1087c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_uint_nv)
1097c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_32_nv)
1107c478bd9Sstevel@tonic-gate
111dfb96a4fSab196087	/*
112dfb96a4fSab196087	 * NOTE: If atomic_inc_64 and atomic_inc_64_nv are ever
113dfb96a4fSab196087	 * separated, you need to also edit the libc i386 platform
114dfb96a4fSab196087	 * specific mapfile and remove the NODYNSORT attribute
115dfb96a4fSab196087	 * from atomic_inc_64_nv.
116dfb96a4fSab196087	 */
1177c478bd9Sstevel@tonic-gate	ENTRY(atomic_inc_64)
1187c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_inc_64_nv)
1197c478bd9Sstevel@tonic-gate	pushl	%edi
1207c478bd9Sstevel@tonic-gate	pushl	%ebx
1217c478bd9Sstevel@tonic-gate	movl	12(%esp), %edi	/ %edi = target address
1227c478bd9Sstevel@tonic-gate	movl	(%edi), %eax
1237c478bd9Sstevel@tonic-gate	movl	4(%edi), %edx	/ %edx:%eax = old value
1247c478bd9Sstevel@tonic-gate1:
1257c478bd9Sstevel@tonic-gate	xorl	%ebx, %ebx
1267c478bd9Sstevel@tonic-gate	xorl	%ecx, %ecx
1277c478bd9Sstevel@tonic-gate	incl	%ebx		/ %ecx:%ebx = 1
1287c478bd9Sstevel@tonic-gate	addl	%eax, %ebx
1297c478bd9Sstevel@tonic-gate	adcl	%edx, %ecx	/ add in the carry from inc
1307c478bd9Sstevel@tonic-gate	lock
1317c478bd9Sstevel@tonic-gate	cmpxchg8b (%edi)	/ try to stick it in
1327c478bd9Sstevel@tonic-gate	jne	1b
1337c478bd9Sstevel@tonic-gate	movl	%ebx, %eax
1347c478bd9Sstevel@tonic-gate	movl	%ecx, %edx	/ return new value
1357c478bd9Sstevel@tonic-gate	popl	%ebx
1367c478bd9Sstevel@tonic-gate	popl	%edi
1377c478bd9Sstevel@tonic-gate	ret
1387c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_64_nv)
1397c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_inc_64)
1407c478bd9Sstevel@tonic-gate
1417c478bd9Sstevel@tonic-gate	ENTRY(atomic_dec_8)
1427c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_dec_uchar)
1437c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
1447c478bd9Sstevel@tonic-gate	lock
1457c478bd9Sstevel@tonic-gate	decb	(%eax)
1467c478bd9Sstevel@tonic-gate	ret
1477c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_uchar)
1487c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_8)
1497c478bd9Sstevel@tonic-gate
1507c478bd9Sstevel@tonic-gate	ENTRY(atomic_dec_16)
1517c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_dec_ushort)
1527c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
1537c478bd9Sstevel@tonic-gate	lock
1547c478bd9Sstevel@tonic-gate	decw	(%eax)
1557c478bd9Sstevel@tonic-gate	ret
1567c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_ushort)
1577c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_16)
1587c478bd9Sstevel@tonic-gate
1597c478bd9Sstevel@tonic-gate	ENTRY(atomic_dec_32)
1607c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_dec_uint)
1617c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_dec_ulong)
1627c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
1637c478bd9Sstevel@tonic-gate	lock
1647c478bd9Sstevel@tonic-gate	decl	(%eax)
1657c478bd9Sstevel@tonic-gate	ret
1667c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_ulong)
1677c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_uint)
1687c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_32)
1697c478bd9Sstevel@tonic-gate
1707c478bd9Sstevel@tonic-gate	ENTRY(atomic_dec_8_nv)
1717c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_dec_uchar_nv)
1727c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
173*96d9f183SBill Holler	xorl	%eax, %eax	/ zero upper bits of %eax
174*96d9f183SBill Holler	decb	%al		/ %al = -1
1757c478bd9Sstevel@tonic-gate	lock
176*96d9f183SBill Holler	  xaddb	%al, (%edx)	/ %al = old value, dec (%edx)
177*96d9f183SBill Holler	decb	%al		/ return new value
1787c478bd9Sstevel@tonic-gate	ret
1797c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_uchar_nv)
1807c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_8_nv)
1817c478bd9Sstevel@tonic-gate
1827c478bd9Sstevel@tonic-gate	ENTRY(atomic_dec_16_nv)
1837c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_dec_ushort_nv)
1847c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
185*96d9f183SBill Holler	xorl	%eax, %eax	/ zero upper bits of %eax
186*96d9f183SBill Holler	decw	%ax		/ %ax = -1
1877c478bd9Sstevel@tonic-gate	lock
188*96d9f183SBill Holler	  xaddw	%ax, (%edx)	/ %ax = old value, dec (%edx)
189*96d9f183SBill Holler	decw	%ax		/ return new value
1907c478bd9Sstevel@tonic-gate	ret
1917c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_ushort_nv)
1927c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_16_nv)
1937c478bd9Sstevel@tonic-gate
1947c478bd9Sstevel@tonic-gate	ENTRY(atomic_dec_32_nv)
1957c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_dec_uint_nv)
1967c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_dec_ulong_nv)
1977c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
198*96d9f183SBill Holler	xorl	%eax, %eax	/ %eax = 0
199*96d9f183SBill Holler	decl	%eax		/ %eax = -1
2007c478bd9Sstevel@tonic-gate	lock
201*96d9f183SBill Holler	  xaddl	%eax, (%edx)	/ %eax = old value, dec (%edx)
202*96d9f183SBill Holler	decl	%eax		/ return new value
2037c478bd9Sstevel@tonic-gate	ret
2047c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_ulong_nv)
2057c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_uint_nv)
2067c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_32_nv)
2077c478bd9Sstevel@tonic-gate
208dfb96a4fSab196087	/*
209dfb96a4fSab196087	 * NOTE: If atomic_dec_64 and atomic_dec_64_nv are ever
210dfb96a4fSab196087	 * separated, it is important to edit the libc i386 platform
211dfb96a4fSab196087	 * specific mapfile and remove the NODYNSORT attribute
212dfb96a4fSab196087	 * from atomic_dec_64_nv.
213dfb96a4fSab196087	 */
2147c478bd9Sstevel@tonic-gate	ENTRY(atomic_dec_64)
2157c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_dec_64_nv)
2167c478bd9Sstevel@tonic-gate	pushl	%edi
2177c478bd9Sstevel@tonic-gate	pushl	%ebx
2187c478bd9Sstevel@tonic-gate	movl	12(%esp), %edi	/ %edi = target address
2197c478bd9Sstevel@tonic-gate	movl	(%edi), %eax
2207c478bd9Sstevel@tonic-gate	movl	4(%edi), %edx	/ %edx:%eax = old value
2217c478bd9Sstevel@tonic-gate1:
2227c478bd9Sstevel@tonic-gate	xorl	%ebx, %ebx
2237c478bd9Sstevel@tonic-gate	xorl	%ecx, %ecx
2247c478bd9Sstevel@tonic-gate	not	%ecx
2257c478bd9Sstevel@tonic-gate	not	%ebx		/ %ecx:%ebx = -1
2267c478bd9Sstevel@tonic-gate	addl	%eax, %ebx
2277c478bd9Sstevel@tonic-gate	adcl	%edx, %ecx	/ add in the carry from inc
2287c478bd9Sstevel@tonic-gate	lock
2297c478bd9Sstevel@tonic-gate	cmpxchg8b (%edi)	/ try to stick it in
2307c478bd9Sstevel@tonic-gate	jne	1b
2317c478bd9Sstevel@tonic-gate	movl	%ebx, %eax
2327c478bd9Sstevel@tonic-gate	movl	%ecx, %edx	/ return new value
2337c478bd9Sstevel@tonic-gate	popl	%ebx
2347c478bd9Sstevel@tonic-gate	popl	%edi
2357c478bd9Sstevel@tonic-gate	ret
2367c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_64_nv)
2377c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_dec_64)
2387c478bd9Sstevel@tonic-gate
2397c478bd9Sstevel@tonic-gate	ENTRY(atomic_add_8)
2407c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_char)
2417c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
2427c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx
2437c478bd9Sstevel@tonic-gate	lock
2447c478bd9Sstevel@tonic-gate	addb	%cl, (%eax)
2457c478bd9Sstevel@tonic-gate	ret
2467c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_char)
2477c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_8)
2487c478bd9Sstevel@tonic-gate
2497c478bd9Sstevel@tonic-gate	ENTRY(atomic_add_16)
2507c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_short)
2517c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
2527c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx
2537c478bd9Sstevel@tonic-gate	lock
2547c478bd9Sstevel@tonic-gate	addw	%cx, (%eax)
2557c478bd9Sstevel@tonic-gate	ret
2567c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_short)
2577c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_16)
2587c478bd9Sstevel@tonic-gate
2597c478bd9Sstevel@tonic-gate	ENTRY(atomic_add_32)
2607c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_int)
2617c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_ptr)
2627c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_long)
2637c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
2647c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx
2657c478bd9Sstevel@tonic-gate	lock
2667c478bd9Sstevel@tonic-gate	addl	%ecx, (%eax)
2677c478bd9Sstevel@tonic-gate	ret
2687c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_long)
2697c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_ptr)
2707c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_int)
2717c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_32)
2727c478bd9Sstevel@tonic-gate
2737c478bd9Sstevel@tonic-gate	ENTRY(atomic_or_8)
2747c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_or_uchar)
2757c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
2767c478bd9Sstevel@tonic-gate	movb	8(%esp), %cl
2777c478bd9Sstevel@tonic-gate	lock
2787c478bd9Sstevel@tonic-gate	orb	%cl, (%eax)
2797c478bd9Sstevel@tonic-gate	ret
2807c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_uchar)
2817c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_8)
2827c478bd9Sstevel@tonic-gate
2837c478bd9Sstevel@tonic-gate	ENTRY(atomic_or_16)
2847c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_or_ushort)
2857c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
2867c478bd9Sstevel@tonic-gate	movw	8(%esp), %cx
2877c478bd9Sstevel@tonic-gate	lock
2887c478bd9Sstevel@tonic-gate	orw	%cx, (%eax)
2897c478bd9Sstevel@tonic-gate	ret
2907c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_ushort)
2917c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_16)
2927c478bd9Sstevel@tonic-gate
2937c478bd9Sstevel@tonic-gate	ENTRY(atomic_or_32)
2947c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_or_uint)
2957c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_or_ulong)
2967c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
2977c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx
2987c478bd9Sstevel@tonic-gate	lock
2997c478bd9Sstevel@tonic-gate	orl	%ecx, (%eax)
3007c478bd9Sstevel@tonic-gate	ret
3017c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_ulong)
3027c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_uint)
3037c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_32)
3047c478bd9Sstevel@tonic-gate
3057c478bd9Sstevel@tonic-gate	ENTRY(atomic_and_8)
3067c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_and_uchar)
3077c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
3087c478bd9Sstevel@tonic-gate	movb	8(%esp), %cl
3097c478bd9Sstevel@tonic-gate	lock
3107c478bd9Sstevel@tonic-gate	andb	%cl, (%eax)
3117c478bd9Sstevel@tonic-gate	ret
3127c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_uchar)
3137c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_8)
3147c478bd9Sstevel@tonic-gate
3157c478bd9Sstevel@tonic-gate	ENTRY(atomic_and_16)
3167c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_and_ushort)
3177c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
3187c478bd9Sstevel@tonic-gate	movw	8(%esp), %cx
3197c478bd9Sstevel@tonic-gate	lock
3207c478bd9Sstevel@tonic-gate	andw	%cx, (%eax)
3217c478bd9Sstevel@tonic-gate	ret
3227c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_ushort)
3237c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_16)
3247c478bd9Sstevel@tonic-gate
3257c478bd9Sstevel@tonic-gate	ENTRY(atomic_and_32)
3267c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_and_uint)
3277c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_and_ulong)
3287c478bd9Sstevel@tonic-gate	movl	4(%esp), %eax
3297c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx
3307c478bd9Sstevel@tonic-gate	lock
3317c478bd9Sstevel@tonic-gate	andl	%ecx, (%eax)
3327c478bd9Sstevel@tonic-gate	ret
3337c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_ulong)
3347c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_uint)
3357c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_32)
3367c478bd9Sstevel@tonic-gate
3377c478bd9Sstevel@tonic-gate	ENTRY(atomic_add_8_nv)
3387c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_char_nv)
3397c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
340*96d9f183SBill Holler	movb	8(%esp), %cl	/ %cl = delta
341*96d9f183SBill Holler	movzbl	%cl, %eax	/ %al = delta, zero extended
3427c478bd9Sstevel@tonic-gate	lock
343*96d9f183SBill Holler	  xaddb	%cl, (%edx)	/ %cl = old value, (%edx) = sum
344*96d9f183SBill Holler	addb	%cl, %al	/ return old value plus delta
3457c478bd9Sstevel@tonic-gate	ret
3467c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_char_nv)
3477c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_8_nv)
3487c478bd9Sstevel@tonic-gate
3497c478bd9Sstevel@tonic-gate	ENTRY(atomic_add_16_nv)
3507c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_short_nv)
3517c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
352*96d9f183SBill Holler	movw	8(%esp), %cx	/ %cx = delta
353*96d9f183SBill Holler	movzwl	%cx, %eax	/ %ax = delta, zero extended
3547c478bd9Sstevel@tonic-gate	lock
355*96d9f183SBill Holler	  xaddw	%cx, (%edx)	/ %cx = old value, (%edx) = sum
356*96d9f183SBill Holler	addw	%cx, %ax	/ return old value plus delta
3577c478bd9Sstevel@tonic-gate	ret
3587c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_short_nv)
3597c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_16_nv)
3607c478bd9Sstevel@tonic-gate
3617c478bd9Sstevel@tonic-gate	ENTRY(atomic_add_32_nv)
3627c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_int_nv)
3637c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_ptr_nv)
3647c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_long_nv)
3657c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
366*96d9f183SBill Holler	movl	8(%esp), %eax	/ %eax = delta
367*96d9f183SBill Holler	movl	%eax, %ecx	/ %ecx = delta
3687c478bd9Sstevel@tonic-gate	lock
369*96d9f183SBill Holler	  xaddl	%eax, (%edx)	/ %eax = old value, (%edx) = sum
370*96d9f183SBill Holler	addl	%ecx, %eax	/ return old value plus delta
3717c478bd9Sstevel@tonic-gate	ret
3727c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_long_nv)
3737c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_ptr_nv)
3747c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_int_nv)
3757c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_32_nv)
3767c478bd9Sstevel@tonic-gate
377dfb96a4fSab196087	/*
378dfb96a4fSab196087	 * NOTE: If atomic_add_64 and atomic_add_64_nv are ever
379dfb96a4fSab196087	 * separated, it is important to edit the libc i386 platform
380dfb96a4fSab196087	 * specific mapfile and remove the NODYNSORT attribute
381dfb96a4fSab196087	 * from atomic_add_64_nv.
382dfb96a4fSab196087	 */
3837c478bd9Sstevel@tonic-gate	ENTRY(atomic_add_64)
3847c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_add_64_nv)
3857c478bd9Sstevel@tonic-gate	pushl	%edi
3867c478bd9Sstevel@tonic-gate	pushl	%ebx
3877c478bd9Sstevel@tonic-gate	movl	12(%esp), %edi	/ %edi = target address
3887c478bd9Sstevel@tonic-gate	movl	(%edi), %eax
3897c478bd9Sstevel@tonic-gate	movl	4(%edi), %edx	/ %edx:%eax = old value
3907c478bd9Sstevel@tonic-gate1:
3917c478bd9Sstevel@tonic-gate	movl	16(%esp), %ebx
3927c478bd9Sstevel@tonic-gate	movl	20(%esp), %ecx	/ %ecx:%ebx = delta
3937c478bd9Sstevel@tonic-gate	addl	%eax, %ebx
3947c478bd9Sstevel@tonic-gate	adcl	%edx, %ecx	/ %ecx:%ebx = new value
3957c478bd9Sstevel@tonic-gate	lock
3967c478bd9Sstevel@tonic-gate	cmpxchg8b (%edi)	/ try to stick it in
3977c478bd9Sstevel@tonic-gate	jne	1b
3987c478bd9Sstevel@tonic-gate	movl	%ebx, %eax
3997c478bd9Sstevel@tonic-gate	movl	%ecx, %edx	/ return new value
4007c478bd9Sstevel@tonic-gate	popl	%ebx
4017c478bd9Sstevel@tonic-gate	popl	%edi
4027c478bd9Sstevel@tonic-gate	ret
4037c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_64_nv)
4047c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_add_64)
4057c478bd9Sstevel@tonic-gate
4067c478bd9Sstevel@tonic-gate	ENTRY(atomic_or_8_nv)
4077c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_or_uchar_nv)
4087c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
4097c478bd9Sstevel@tonic-gate	movb	(%edx), %al	/ %al = old value
4107c478bd9Sstevel@tonic-gate1:
4117c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = delta
4127c478bd9Sstevel@tonic-gate	orb	%al, %cl	/ %cl = new value
4137c478bd9Sstevel@tonic-gate	lock
4147c478bd9Sstevel@tonic-gate	cmpxchgb %cl, (%edx)	/ try to stick it in
4157c478bd9Sstevel@tonic-gate	jne	1b
4167c478bd9Sstevel@tonic-gate	movzbl	%cl, %eax	/ return new value
4177c478bd9Sstevel@tonic-gate	ret
4187c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_uchar_nv)
4197c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_8_nv)
4207c478bd9Sstevel@tonic-gate
4217c478bd9Sstevel@tonic-gate	ENTRY(atomic_or_16_nv)
4227c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_or_ushort_nv)
4237c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
4247c478bd9Sstevel@tonic-gate	movw	(%edx), %ax	/ %ax = old value
4257c478bd9Sstevel@tonic-gate1:
4267c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = delta
4277c478bd9Sstevel@tonic-gate	orw	%ax, %cx	/ %cx = new value
4287c478bd9Sstevel@tonic-gate	lock
4297c478bd9Sstevel@tonic-gate	cmpxchgw %cx, (%edx)	/ try to stick it in
4307c478bd9Sstevel@tonic-gate	jne	1b
4317c478bd9Sstevel@tonic-gate	movzwl	%cx, %eax	/ return new value
4327c478bd9Sstevel@tonic-gate	ret
4337c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_ushort_nv)
4347c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_16_nv)
4357c478bd9Sstevel@tonic-gate
4367c478bd9Sstevel@tonic-gate	ENTRY(atomic_or_32_nv)
4377c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_or_uint_nv)
4387c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_or_ulong_nv)
4397c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
4407c478bd9Sstevel@tonic-gate	movl	(%edx), %eax	/ %eax = old value
4417c478bd9Sstevel@tonic-gate1:
4427c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = delta
4437c478bd9Sstevel@tonic-gate	orl	%eax, %ecx	/ %ecx = new value
4447c478bd9Sstevel@tonic-gate	lock
4457c478bd9Sstevel@tonic-gate	cmpxchgl %ecx, (%edx)	/ try to stick it in
4467c478bd9Sstevel@tonic-gate	jne	1b
4477c478bd9Sstevel@tonic-gate	movl	%ecx, %eax	/ return new value
4487c478bd9Sstevel@tonic-gate	ret
4497c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_ulong_nv)
4507c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_uint_nv)
4517c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_32_nv)
4527c478bd9Sstevel@tonic-gate
453dfb96a4fSab196087	/*
454dfb96a4fSab196087	 * NOTE: If atomic_or_64 and atomic_or_64_nv are ever
455dfb96a4fSab196087	 * separated, it is important to edit the libc i386 platform
456dfb96a4fSab196087	 * specific mapfile and remove the NODYNSORT attribute
457dfb96a4fSab196087	 * from atomic_or_64_nv.
458dfb96a4fSab196087	 */
4597c478bd9Sstevel@tonic-gate	ENTRY(atomic_or_64)
4607c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_or_64_nv)
4617c478bd9Sstevel@tonic-gate	pushl	%edi
4627c478bd9Sstevel@tonic-gate	pushl	%ebx
4637c478bd9Sstevel@tonic-gate	movl	12(%esp), %edi	/ %edi = target address
4647c478bd9Sstevel@tonic-gate	movl	(%edi), %eax
4657c478bd9Sstevel@tonic-gate	movl	4(%edi), %edx	/ %edx:%eax = old value
4667c478bd9Sstevel@tonic-gate1:
4677c478bd9Sstevel@tonic-gate	movl	16(%esp), %ebx
4687c478bd9Sstevel@tonic-gate	movl	20(%esp), %ecx	/ %ecx:%ebx = delta
4697c478bd9Sstevel@tonic-gate	orl	%eax, %ebx
4707c478bd9Sstevel@tonic-gate	orl	%edx, %ecx	/ %ecx:%ebx = new value
4717c478bd9Sstevel@tonic-gate	lock
4727c478bd9Sstevel@tonic-gate	cmpxchg8b (%edi)	/ try to stick it in
4737c478bd9Sstevel@tonic-gate	jne	1b
4747c478bd9Sstevel@tonic-gate	movl	%ebx, %eax
4757c478bd9Sstevel@tonic-gate	movl	%ecx, %edx	/ return new value
4767c478bd9Sstevel@tonic-gate	popl	%ebx
4777c478bd9Sstevel@tonic-gate	popl	%edi
4787c478bd9Sstevel@tonic-gate	ret
4797c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_64_nv)
4807c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_or_64)
4817c478bd9Sstevel@tonic-gate
4827c478bd9Sstevel@tonic-gate	ENTRY(atomic_and_8_nv)
4837c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_and_uchar_nv)
4847c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
4857c478bd9Sstevel@tonic-gate	movb	(%edx), %al	/ %al = old value
4867c478bd9Sstevel@tonic-gate1:
4877c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = delta
4887c478bd9Sstevel@tonic-gate	andb	%al, %cl	/ %cl = new value
4897c478bd9Sstevel@tonic-gate	lock
4907c478bd9Sstevel@tonic-gate	cmpxchgb %cl, (%edx)	/ try to stick it in
4917c478bd9Sstevel@tonic-gate	jne	1b
4927c478bd9Sstevel@tonic-gate	movzbl	%cl, %eax	/ return new value
4937c478bd9Sstevel@tonic-gate	ret
4947c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_uchar_nv)
4957c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_8_nv)
4967c478bd9Sstevel@tonic-gate
4977c478bd9Sstevel@tonic-gate	ENTRY(atomic_and_16_nv)
4987c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_and_ushort_nv)
4997c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
5007c478bd9Sstevel@tonic-gate	movw	(%edx), %ax	/ %ax = old value
5017c478bd9Sstevel@tonic-gate1:
5027c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = delta
5037c478bd9Sstevel@tonic-gate	andw	%ax, %cx	/ %cx = new value
5047c478bd9Sstevel@tonic-gate	lock
5057c478bd9Sstevel@tonic-gate	cmpxchgw %cx, (%edx)	/ try to stick it in
5067c478bd9Sstevel@tonic-gate	jne	1b
5077c478bd9Sstevel@tonic-gate	movzwl	%cx, %eax	/ return new value
5087c478bd9Sstevel@tonic-gate	ret
5097c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_ushort_nv)
5107c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_16_nv)
5117c478bd9Sstevel@tonic-gate
5127c478bd9Sstevel@tonic-gate	ENTRY(atomic_and_32_nv)
5137c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_and_uint_nv)
5147c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_and_ulong_nv)
5157c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
5167c478bd9Sstevel@tonic-gate	movl	(%edx), %eax	/ %eax = old value
5177c478bd9Sstevel@tonic-gate1:
5187c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = delta
5197c478bd9Sstevel@tonic-gate	andl	%eax, %ecx	/ %ecx = new value
5207c478bd9Sstevel@tonic-gate	lock
5217c478bd9Sstevel@tonic-gate	cmpxchgl %ecx, (%edx)	/ try to stick it in
5227c478bd9Sstevel@tonic-gate	jne	1b
5237c478bd9Sstevel@tonic-gate	movl	%ecx, %eax	/ return new value
5247c478bd9Sstevel@tonic-gate	ret
5257c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_ulong_nv)
5267c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_uint_nv)
5277c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_32_nv)
5287c478bd9Sstevel@tonic-gate
529dfb96a4fSab196087	/*
530dfb96a4fSab196087	 * NOTE: If atomic_and_64 and atomic_and_64_nv are ever
531dfb96a4fSab196087	 * separated, it is important to edit the libc i386 platform
532dfb96a4fSab196087	 * specific mapfile and remove the NODYNSORT attribute
533dfb96a4fSab196087	 * from atomic_and_64_nv.
534dfb96a4fSab196087	 */
5357c478bd9Sstevel@tonic-gate	ENTRY(atomic_and_64)
5367c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_and_64_nv)
5377c478bd9Sstevel@tonic-gate	pushl	%edi
5387c478bd9Sstevel@tonic-gate	pushl	%ebx
5397c478bd9Sstevel@tonic-gate	movl	12(%esp), %edi	/ %edi = target address
5407c478bd9Sstevel@tonic-gate	movl	(%edi), %eax
5417c478bd9Sstevel@tonic-gate	movl	4(%edi), %edx	/ %edx:%eax = old value
5427c478bd9Sstevel@tonic-gate1:
5437c478bd9Sstevel@tonic-gate	movl	16(%esp), %ebx
5447c478bd9Sstevel@tonic-gate	movl	20(%esp), %ecx	/ %ecx:%ebx = delta
5457c478bd9Sstevel@tonic-gate	andl	%eax, %ebx
5467c478bd9Sstevel@tonic-gate	andl	%edx, %ecx	/ %ecx:%ebx = new value
5477c478bd9Sstevel@tonic-gate	lock
5487c478bd9Sstevel@tonic-gate	cmpxchg8b (%edi)	/ try to stick it in
5497c478bd9Sstevel@tonic-gate	jne	1b
5507c478bd9Sstevel@tonic-gate	movl	%ebx, %eax
5517c478bd9Sstevel@tonic-gate	movl	%ecx, %edx	/ return new value
5527c478bd9Sstevel@tonic-gate	popl	%ebx
5537c478bd9Sstevel@tonic-gate	popl	%edi
5547c478bd9Sstevel@tonic-gate	ret
5557c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_64_nv)
5567c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_and_64)
5577c478bd9Sstevel@tonic-gate
5587c478bd9Sstevel@tonic-gate	ENTRY(atomic_cas_8)
5597c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_cas_uchar)
5607c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx
5617c478bd9Sstevel@tonic-gate	movzbl	8(%esp), %eax
5627c478bd9Sstevel@tonic-gate	movb	12(%esp), %cl
5637c478bd9Sstevel@tonic-gate	lock
5647c478bd9Sstevel@tonic-gate	cmpxchgb %cl, (%edx)
5657c478bd9Sstevel@tonic-gate	ret
5667c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_cas_uchar)
5677c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_cas_8)
5687c478bd9Sstevel@tonic-gate
5697c478bd9Sstevel@tonic-gate	ENTRY(atomic_cas_16)
5707c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_cas_ushort)
5717c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx
5727c478bd9Sstevel@tonic-gate	movzwl	8(%esp), %eax
5737c478bd9Sstevel@tonic-gate	movw	12(%esp), %cx
5747c478bd9Sstevel@tonic-gate	lock
5757c478bd9Sstevel@tonic-gate	cmpxchgw %cx, (%edx)
5767c478bd9Sstevel@tonic-gate	ret
5777c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_cas_ushort)
5787c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_cas_16)
5797c478bd9Sstevel@tonic-gate
5807c478bd9Sstevel@tonic-gate	ENTRY(atomic_cas_32)
5817c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_cas_uint)
5827c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_cas_ulong)
5837c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_cas_ptr)
5847c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx
5857c478bd9Sstevel@tonic-gate	movl	8(%esp), %eax
5867c478bd9Sstevel@tonic-gate	movl	12(%esp), %ecx
5877c478bd9Sstevel@tonic-gate	lock
5887c478bd9Sstevel@tonic-gate	cmpxchgl %ecx, (%edx)
5897c478bd9Sstevel@tonic-gate	ret
5907c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_cas_ptr)
5917c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_cas_ulong)
5927c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_cas_uint)
5937c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_cas_32)
5947c478bd9Sstevel@tonic-gate
5957c478bd9Sstevel@tonic-gate	ENTRY(atomic_cas_64)
5967c478bd9Sstevel@tonic-gate	pushl	%ebx
5977c478bd9Sstevel@tonic-gate	pushl	%esi
5987c478bd9Sstevel@tonic-gate	movl	12(%esp), %esi
5997c478bd9Sstevel@tonic-gate	movl	16(%esp), %eax
6007c478bd9Sstevel@tonic-gate	movl	20(%esp), %edx
6017c478bd9Sstevel@tonic-gate	movl	24(%esp), %ebx
6027c478bd9Sstevel@tonic-gate	movl	28(%esp), %ecx
6037c478bd9Sstevel@tonic-gate	lock
6047c478bd9Sstevel@tonic-gate	cmpxchg8b (%esi)
6057c478bd9Sstevel@tonic-gate	popl	%esi
6067c478bd9Sstevel@tonic-gate	popl	%ebx
6077c478bd9Sstevel@tonic-gate	ret
6087c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_cas_64)
6097c478bd9Sstevel@tonic-gate
6107c478bd9Sstevel@tonic-gate	ENTRY(atomic_swap_8)
6117c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_swap_uchar)
6127c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx
6137c478bd9Sstevel@tonic-gate	movzbl	8(%esp), %eax
6147c478bd9Sstevel@tonic-gate	lock
6157c478bd9Sstevel@tonic-gate	xchgb	%al, (%edx)
6167c478bd9Sstevel@tonic-gate	ret
6177c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_swap_uchar)
6187c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_swap_8)
6197c478bd9Sstevel@tonic-gate
6207c478bd9Sstevel@tonic-gate	ENTRY(atomic_swap_16)
6217c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_swap_ushort)
6227c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx
6237c478bd9Sstevel@tonic-gate	movzwl	8(%esp), %eax
6247c478bd9Sstevel@tonic-gate	lock
6257c478bd9Sstevel@tonic-gate	xchgw	%ax, (%edx)
6267c478bd9Sstevel@tonic-gate	ret
6277c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_swap_ushort)
6287c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_swap_16)
6297c478bd9Sstevel@tonic-gate
6307c478bd9Sstevel@tonic-gate	ENTRY(atomic_swap_32)
6317c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_swap_uint)
6327c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_swap_ptr)
6337c478bd9Sstevel@tonic-gate	ALTENTRY(atomic_swap_ulong)
6347c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx
6357c478bd9Sstevel@tonic-gate	movl	8(%esp), %eax
6367c478bd9Sstevel@tonic-gate	lock
6377c478bd9Sstevel@tonic-gate	xchgl	%eax, (%edx)
6387c478bd9Sstevel@tonic-gate	ret
6397c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_swap_ulong)
6407c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_swap_ptr)
6417c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_swap_uint)
6427c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_swap_32)
6437c478bd9Sstevel@tonic-gate
6447c478bd9Sstevel@tonic-gate	ENTRY(atomic_swap_64)
6457c478bd9Sstevel@tonic-gate	pushl	%esi
6467c478bd9Sstevel@tonic-gate	pushl	%ebx
6477c478bd9Sstevel@tonic-gate	movl	12(%esp), %esi
6487c478bd9Sstevel@tonic-gate	movl	16(%esp), %ebx
6497c478bd9Sstevel@tonic-gate	movl	20(%esp), %ecx
6507c478bd9Sstevel@tonic-gate	movl	(%esi), %eax
6517c478bd9Sstevel@tonic-gate	movl	4(%esi), %edx	/ %edx:%eax = old value
6527c478bd9Sstevel@tonic-gate1:
6537c478bd9Sstevel@tonic-gate	lock
6547c478bd9Sstevel@tonic-gate	cmpxchg8b (%esi)
6557c478bd9Sstevel@tonic-gate	jne	1b
6567c478bd9Sstevel@tonic-gate	popl	%ebx
6577c478bd9Sstevel@tonic-gate	popl	%esi
6587c478bd9Sstevel@tonic-gate	ret
6597c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_swap_64)
6607c478bd9Sstevel@tonic-gate
6617c478bd9Sstevel@tonic-gate	ENTRY(atomic_set_long_excl)
6627c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
6637c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = bit id
6647c478bd9Sstevel@tonic-gate	xorl	%eax, %eax
6657c478bd9Sstevel@tonic-gate	lock
6667c478bd9Sstevel@tonic-gate	btsl	%ecx, (%edx)
6677c478bd9Sstevel@tonic-gate	jnc	1f
6687c478bd9Sstevel@tonic-gate	decl	%eax		/ return -1
6697c478bd9Sstevel@tonic-gate1:
6707c478bd9Sstevel@tonic-gate	ret
6717c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_set_long_excl)
6727c478bd9Sstevel@tonic-gate
6737c478bd9Sstevel@tonic-gate	ENTRY(atomic_clear_long_excl)
6747c478bd9Sstevel@tonic-gate	movl	4(%esp), %edx	/ %edx = target address
6757c478bd9Sstevel@tonic-gate	movl	8(%esp), %ecx	/ %ecx = bit id
6767c478bd9Sstevel@tonic-gate	xorl	%eax, %eax
6777c478bd9Sstevel@tonic-gate	lock
6787c478bd9Sstevel@tonic-gate	btrl	%ecx, (%edx)
6797c478bd9Sstevel@tonic-gate	jc	1f
6807c478bd9Sstevel@tonic-gate	decl	%eax		/ return -1
6817c478bd9Sstevel@tonic-gate1:
6827c478bd9Sstevel@tonic-gate	ret
6837c478bd9Sstevel@tonic-gate	SET_SIZE(atomic_clear_long_excl)
6847c478bd9Sstevel@tonic-gate
6857c478bd9Sstevel@tonic-gate#if !defined(_KERNEL)
6867c478bd9Sstevel@tonic-gate
687dfb96a4fSab196087	/*
688dfb96a4fSab196087	 * NOTE: membar_enter, membar_exit, membar_producer, and
689dfb96a4fSab196087	 * membar_consumer are all identical routines. We define them
690dfb96a4fSab196087	 * separately, instead of using ALTENTRY definitions to alias them
691dfb96a4fSab196087	 * together, so that DTrace and debuggers will see a unique address
692dfb96a4fSab196087	 * for them, allowing more accurate tracing.
693dfb96a4fSab196087	*/
694dfb96a4fSab196087
695dfb96a4fSab196087
6967c478bd9Sstevel@tonic-gate	ENTRY(membar_enter)
697dfb96a4fSab196087	lock
698dfb96a4fSab196087	xorl	$0, (%esp)
699dfb96a4fSab196087	ret
700dfb96a4fSab196087	SET_SIZE(membar_enter)
701dfb96a4fSab196087
702dfb96a4fSab196087	ENTRY(membar_exit)
703dfb96a4fSab196087	lock
704dfb96a4fSab196087	xorl	$0, (%esp)
705dfb96a4fSab196087	ret
706dfb96a4fSab196087	SET_SIZE(membar_exit)
707dfb96a4fSab196087
708dfb96a4fSab196087	ENTRY(membar_producer)
709dfb96a4fSab196087	lock
710dfb96a4fSab196087	xorl	$0, (%esp)
711dfb96a4fSab196087	ret
712dfb96a4fSab196087	SET_SIZE(membar_producer)
713dfb96a4fSab196087
714dfb96a4fSab196087	ENTRY(membar_consumer)
7157c478bd9Sstevel@tonic-gate	lock
7167c478bd9Sstevel@tonic-gate	xorl	$0, (%esp)
7177c478bd9Sstevel@tonic-gate	ret
7187c478bd9Sstevel@tonic-gate	SET_SIZE(membar_consumer)
7197c478bd9Sstevel@tonic-gate
7207c478bd9Sstevel@tonic-gate#endif	/* !_KERNEL */
721