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