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/* 237257d1b4Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 27*9a70fc3bSMark 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 767c478bd9Sstevel@tonic-gate movb (%edx), %al / %al = old value 777c478bd9Sstevel@tonic-gate1: 787c478bd9Sstevel@tonic-gate leal 1(%eax), %ecx / %cl = new value 797c478bd9Sstevel@tonic-gate lock 807c478bd9Sstevel@tonic-gate cmpxchgb %cl, (%edx) / try to stick it in 817c478bd9Sstevel@tonic-gate jne 1b 827c478bd9Sstevel@tonic-gate movzbl %cl, %eax / return new value 837c478bd9Sstevel@tonic-gate ret 847c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_uchar_nv) 857c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_8_nv) 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_16_nv) 887c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_ushort_nv) 897c478bd9Sstevel@tonic-gate movl 4(%esp), %edx / %edx = target address 907c478bd9Sstevel@tonic-gate movw (%edx), %ax / %ax = old value 917c478bd9Sstevel@tonic-gate1: 927c478bd9Sstevel@tonic-gate leal 1(%eax), %ecx / %cx = new value 937c478bd9Sstevel@tonic-gate lock 947c478bd9Sstevel@tonic-gate cmpxchgw %cx, (%edx) / try to stick it in 957c478bd9Sstevel@tonic-gate jne 1b 967c478bd9Sstevel@tonic-gate movzwl %cx, %eax / return new value 977c478bd9Sstevel@tonic-gate ret 987c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_ushort_nv) 997c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_16_nv) 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_32_nv) 1027c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_uint_nv) 1037c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_ulong_nv) 1047c478bd9Sstevel@tonic-gate movl 4(%esp), %edx / %edx = target address 1057c478bd9Sstevel@tonic-gate movl (%edx), %eax / %eax = old value 1067c478bd9Sstevel@tonic-gate1: 1077c478bd9Sstevel@tonic-gate leal 1(%eax), %ecx / %ecx = new value 1087c478bd9Sstevel@tonic-gate lock 1097c478bd9Sstevel@tonic-gate cmpxchgl %ecx, (%edx) / try to stick it in 1107c478bd9Sstevel@tonic-gate jne 1b 1117c478bd9Sstevel@tonic-gate movl %ecx, %eax / return new value 1127c478bd9Sstevel@tonic-gate ret 1137c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_ulong_nv) 1147c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_uint_nv) 1157c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_32_nv) 1167c478bd9Sstevel@tonic-gate 117dfb96a4fSab196087 /* 118dfb96a4fSab196087 * NOTE: If atomic_inc_64 and atomic_inc_64_nv are ever 119dfb96a4fSab196087 * separated, you need to also edit the libc i386 platform 120dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 121dfb96a4fSab196087 * from atomic_inc_64_nv. 122dfb96a4fSab196087 */ 1237c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_64) 1247c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_64_nv) 1257c478bd9Sstevel@tonic-gate pushl %edi 1267c478bd9Sstevel@tonic-gate pushl %ebx 1277c478bd9Sstevel@tonic-gate movl 12(%esp), %edi / %edi = target address 1287c478bd9Sstevel@tonic-gate movl (%edi), %eax 1297c478bd9Sstevel@tonic-gate movl 4(%edi), %edx / %edx:%eax = old value 1307c478bd9Sstevel@tonic-gate1: 1317c478bd9Sstevel@tonic-gate xorl %ebx, %ebx 1327c478bd9Sstevel@tonic-gate xorl %ecx, %ecx 1337c478bd9Sstevel@tonic-gate incl %ebx / %ecx:%ebx = 1 1347c478bd9Sstevel@tonic-gate addl %eax, %ebx 1357c478bd9Sstevel@tonic-gate adcl %edx, %ecx / add in the carry from inc 1367c478bd9Sstevel@tonic-gate lock 1377c478bd9Sstevel@tonic-gate cmpxchg8b (%edi) / try to stick it in 1387c478bd9Sstevel@tonic-gate jne 1b 1397c478bd9Sstevel@tonic-gate movl %ebx, %eax 1407c478bd9Sstevel@tonic-gate movl %ecx, %edx / return new value 1417c478bd9Sstevel@tonic-gate popl %ebx 1427c478bd9Sstevel@tonic-gate popl %edi 1437c478bd9Sstevel@tonic-gate ret 1447c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_64_nv) 1457c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_64) 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_8) 1487c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_uchar) 1497c478bd9Sstevel@tonic-gate movl 4(%esp), %eax 1507c478bd9Sstevel@tonic-gate lock 1517c478bd9Sstevel@tonic-gate decb (%eax) 1527c478bd9Sstevel@tonic-gate ret 1537c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_uchar) 1547c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_8) 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_16) 1577c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_ushort) 1587c478bd9Sstevel@tonic-gate movl 4(%esp), %eax 1597c478bd9Sstevel@tonic-gate lock 1607c478bd9Sstevel@tonic-gate decw (%eax) 1617c478bd9Sstevel@tonic-gate ret 1627c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_ushort) 1637c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_16) 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_32) 1667c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_uint) 1677c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_ulong) 1687c478bd9Sstevel@tonic-gate movl 4(%esp), %eax 1697c478bd9Sstevel@tonic-gate lock 1707c478bd9Sstevel@tonic-gate decl (%eax) 1717c478bd9Sstevel@tonic-gate ret 1727c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_ulong) 1737c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_uint) 1747c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_32) 1757c478bd9Sstevel@tonic-gate 1767c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_8_nv) 1777c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_uchar_nv) 1787c478bd9Sstevel@tonic-gate movl 4(%esp), %edx / %edx = target address 1797c478bd9Sstevel@tonic-gate movb (%edx), %al / %al = old value 1807c478bd9Sstevel@tonic-gate1: 1817c478bd9Sstevel@tonic-gate leal -1(%eax), %ecx / %cl = new value 1827c478bd9Sstevel@tonic-gate lock 1837c478bd9Sstevel@tonic-gate cmpxchgb %cl, (%edx) / try to stick it in 1847c478bd9Sstevel@tonic-gate jne 1b 1857c478bd9Sstevel@tonic-gate movzbl %cl, %eax / return new value 1867c478bd9Sstevel@tonic-gate ret 1877c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_uchar_nv) 1887c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_8_nv) 1897c478bd9Sstevel@tonic-gate 1907c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_16_nv) 1917c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_ushort_nv) 1927c478bd9Sstevel@tonic-gate movl 4(%esp), %edx / %edx = target address 1937c478bd9Sstevel@tonic-gate movw (%edx), %ax / %ax = old value 1947c478bd9Sstevel@tonic-gate1: 1957c478bd9Sstevel@tonic-gate leal -1(%eax), %ecx / %cx = new value 1967c478bd9Sstevel@tonic-gate lock 1977c478bd9Sstevel@tonic-gate cmpxchgw %cx, (%edx) / try to stick it in 1987c478bd9Sstevel@tonic-gate jne 1b 1997c478bd9Sstevel@tonic-gate movzwl %cx, %eax / return new value 2007c478bd9Sstevel@tonic-gate ret 2017c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_ushort_nv) 2027c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_16_nv) 2037c478bd9Sstevel@tonic-gate 2047c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_32_nv) 2057c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_uint_nv) 2067c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_ulong_nv) 2077c478bd9Sstevel@tonic-gate movl 4(%esp), %edx / %edx = target address 2087c478bd9Sstevel@tonic-gate movl (%edx), %eax / %eax = old value 2097c478bd9Sstevel@tonic-gate1: 2107c478bd9Sstevel@tonic-gate leal -1(%eax), %ecx / %ecx = new value 2117c478bd9Sstevel@tonic-gate lock 2127c478bd9Sstevel@tonic-gate cmpxchgl %ecx, (%edx) / try to stick it in 2137c478bd9Sstevel@tonic-gate jne 1b 2147c478bd9Sstevel@tonic-gate movl %ecx, %eax / return new value 2157c478bd9Sstevel@tonic-gate ret 2167c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_ulong_nv) 2177c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_uint_nv) 2187c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_32_nv) 2197c478bd9Sstevel@tonic-gate 220dfb96a4fSab196087 /* 221dfb96a4fSab196087 * NOTE: If atomic_dec_64 and atomic_dec_64_nv are ever 222dfb96a4fSab196087 * separated, it is important to edit the libc i386 platform 223dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 224dfb96a4fSab196087 * from atomic_dec_64_nv. 225dfb96a4fSab196087 */ 2267c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_64) 2277c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_64_nv) 2287c478bd9Sstevel@tonic-gate pushl %edi 2297c478bd9Sstevel@tonic-gate pushl %ebx 2307c478bd9Sstevel@tonic-gate movl 12(%esp), %edi / %edi = target address 2317c478bd9Sstevel@tonic-gate movl (%edi), %eax 2327c478bd9Sstevel@tonic-gate movl 4(%edi), %edx / %edx:%eax = old value 2337c478bd9Sstevel@tonic-gate1: 2347c478bd9Sstevel@tonic-gate xorl %ebx, %ebx 2357c478bd9Sstevel@tonic-gate xorl %ecx, %ecx 2367c478bd9Sstevel@tonic-gate not %ecx 2377c478bd9Sstevel@tonic-gate not %ebx / %ecx:%ebx = -1 2387c478bd9Sstevel@tonic-gate addl %eax, %ebx 2397c478bd9Sstevel@tonic-gate adcl %edx, %ecx / add in the carry from inc 2407c478bd9Sstevel@tonic-gate lock 2417c478bd9Sstevel@tonic-gate cmpxchg8b (%edi) / try to stick it in 2427c478bd9Sstevel@tonic-gate jne 1b 2437c478bd9Sstevel@tonic-gate movl %ebx, %eax 2447c478bd9Sstevel@tonic-gate movl %ecx, %edx / return new value 2457c478bd9Sstevel@tonic-gate popl %ebx 2467c478bd9Sstevel@tonic-gate popl %edi 2477c478bd9Sstevel@tonic-gate ret 2487c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_64_nv) 2497c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_64) 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate ENTRY(atomic_add_8) 2527c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_char) 2537c478bd9Sstevel@tonic-gate movl 4(%esp), %eax 2547c478bd9Sstevel@tonic-gate movl 8(%esp), %ecx 2557c478bd9Sstevel@tonic-gate lock 2567c478bd9Sstevel@tonic-gate addb %cl, (%eax) 2577c478bd9Sstevel@tonic-gate ret 2587c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_char) 2597c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_8) 2607c478bd9Sstevel@tonic-gate 2617c478bd9Sstevel@tonic-gate ENTRY(atomic_add_16) 2627c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_short) 2637c478bd9Sstevel@tonic-gate movl 4(%esp), %eax 2647c478bd9Sstevel@tonic-gate movl 8(%esp), %ecx 2657c478bd9Sstevel@tonic-gate lock 2667c478bd9Sstevel@tonic-gate addw %cx, (%eax) 2677c478bd9Sstevel@tonic-gate ret 2687c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_short) 2697c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_16) 2707c478bd9Sstevel@tonic-gate 2717c478bd9Sstevel@tonic-gate ENTRY(atomic_add_32) 2727c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_int) 2737c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_ptr) 2747c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_long) 2757c478bd9Sstevel@tonic-gate movl 4(%esp), %eax 2767c478bd9Sstevel@tonic-gate movl 8(%esp), %ecx 2777c478bd9Sstevel@tonic-gate lock 2787c478bd9Sstevel@tonic-gate addl %ecx, (%eax) 2797c478bd9Sstevel@tonic-gate ret 2807c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_long) 2817c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_ptr) 2827c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_int) 2837c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_32) 2847c478bd9Sstevel@tonic-gate 2857c478bd9Sstevel@tonic-gate ENTRY(atomic_or_8) 2867c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_uchar) 2877c478bd9Sstevel@tonic-gate movl 4(%esp), %eax 2887c478bd9Sstevel@tonic-gate movb 8(%esp), %cl 2897c478bd9Sstevel@tonic-gate lock 2907c478bd9Sstevel@tonic-gate orb %cl, (%eax) 2917c478bd9Sstevel@tonic-gate ret 2927c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_uchar) 2937c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_8) 2947c478bd9Sstevel@tonic-gate 2957c478bd9Sstevel@tonic-gate ENTRY(atomic_or_16) 2967c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_ushort) 2977c478bd9Sstevel@tonic-gate movl 4(%esp), %eax 2987c478bd9Sstevel@tonic-gate movw 8(%esp), %cx 2997c478bd9Sstevel@tonic-gate lock 3007c478bd9Sstevel@tonic-gate orw %cx, (%eax) 3017c478bd9Sstevel@tonic-gate ret 3027c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_ushort) 3037c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_16) 3047c478bd9Sstevel@tonic-gate 3057c478bd9Sstevel@tonic-gate ENTRY(atomic_or_32) 3067c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_uint) 3077c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_ulong) 3087c478bd9Sstevel@tonic-gate movl 4(%esp), %eax 3097c478bd9Sstevel@tonic-gate movl 8(%esp), %ecx 3107c478bd9Sstevel@tonic-gate lock 3117c478bd9Sstevel@tonic-gate orl %ecx, (%eax) 3127c478bd9Sstevel@tonic-gate ret 3137c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_ulong) 3147c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_uint) 3157c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_32) 3167c478bd9Sstevel@tonic-gate 3177c478bd9Sstevel@tonic-gate ENTRY(atomic_and_8) 3187c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_uchar) 3197c478bd9Sstevel@tonic-gate movl 4(%esp), %eax 3207c478bd9Sstevel@tonic-gate movb 8(%esp), %cl 3217c478bd9Sstevel@tonic-gate lock 3227c478bd9Sstevel@tonic-gate andb %cl, (%eax) 3237c478bd9Sstevel@tonic-gate ret 3247c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_uchar) 3257c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_8) 3267c478bd9Sstevel@tonic-gate 3277c478bd9Sstevel@tonic-gate ENTRY(atomic_and_16) 3287c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_ushort) 3297c478bd9Sstevel@tonic-gate movl 4(%esp), %eax 3307c478bd9Sstevel@tonic-gate movw 8(%esp), %cx 3317c478bd9Sstevel@tonic-gate lock 3327c478bd9Sstevel@tonic-gate andw %cx, (%eax) 3337c478bd9Sstevel@tonic-gate ret 3347c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_ushort) 3357c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_16) 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate ENTRY(atomic_and_32) 3387c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_uint) 3397c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_ulong) 3407c478bd9Sstevel@tonic-gate movl 4(%esp), %eax 3417c478bd9Sstevel@tonic-gate movl 8(%esp), %ecx 3427c478bd9Sstevel@tonic-gate lock 3437c478bd9Sstevel@tonic-gate andl %ecx, (%eax) 3447c478bd9Sstevel@tonic-gate ret 3457c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_ulong) 3467c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_uint) 3477c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_32) 3487c478bd9Sstevel@tonic-gate 3497c478bd9Sstevel@tonic-gate ENTRY(atomic_add_8_nv) 3507c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_char_nv) 3517c478bd9Sstevel@tonic-gate movl 4(%esp), %edx / %edx = target address 3527c478bd9Sstevel@tonic-gate movb (%edx), %al / %al = old value 3537c478bd9Sstevel@tonic-gate1: 3547c478bd9Sstevel@tonic-gate movl 8(%esp), %ecx / %ecx = delta 3557c478bd9Sstevel@tonic-gate addb %al, %cl / %cl = new value 3567c478bd9Sstevel@tonic-gate lock 3577c478bd9Sstevel@tonic-gate cmpxchgb %cl, (%edx) / try to stick it in 3587c478bd9Sstevel@tonic-gate jne 1b 3597c478bd9Sstevel@tonic-gate movzbl %cl, %eax / return new value 3607c478bd9Sstevel@tonic-gate ret 3617c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_char_nv) 3627c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_8_nv) 3637c478bd9Sstevel@tonic-gate 3647c478bd9Sstevel@tonic-gate ENTRY(atomic_add_16_nv) 3657c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_short_nv) 3667c478bd9Sstevel@tonic-gate movl 4(%esp), %edx / %edx = target address 3677c478bd9Sstevel@tonic-gate movw (%edx), %ax / %ax = old value 3687c478bd9Sstevel@tonic-gate1: 3697c478bd9Sstevel@tonic-gate movl 8(%esp), %ecx / %ecx = delta 3707c478bd9Sstevel@tonic-gate addw %ax, %cx / %cx = new value 3717c478bd9Sstevel@tonic-gate lock 3727c478bd9Sstevel@tonic-gate cmpxchgw %cx, (%edx) / try to stick it in 3737c478bd9Sstevel@tonic-gate jne 1b 3747c478bd9Sstevel@tonic-gate movzwl %cx, %eax / return new value 3757c478bd9Sstevel@tonic-gate ret 3767c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_short_nv) 3777c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_16_nv) 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate ENTRY(atomic_add_32_nv) 3807c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_int_nv) 3817c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_ptr_nv) 3827c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_long_nv) 3837c478bd9Sstevel@tonic-gate movl 4(%esp), %edx / %edx = target address 3847c478bd9Sstevel@tonic-gate movl (%edx), %eax / %eax = old value 3857c478bd9Sstevel@tonic-gate1: 3867c478bd9Sstevel@tonic-gate movl 8(%esp), %ecx / %ecx = delta 3877c478bd9Sstevel@tonic-gate addl %eax, %ecx / %ecx = new value 3887c478bd9Sstevel@tonic-gate lock 3897c478bd9Sstevel@tonic-gate cmpxchgl %ecx, (%edx) / try to stick it in 3907c478bd9Sstevel@tonic-gate jne 1b 3917c478bd9Sstevel@tonic-gate movl %ecx, %eax / return new value 3927c478bd9Sstevel@tonic-gate ret 3937c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_long_nv) 3947c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_ptr_nv) 3957c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_int_nv) 3967c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_32_nv) 3977c478bd9Sstevel@tonic-gate 398dfb96a4fSab196087 /* 399dfb96a4fSab196087 * NOTE: If atomic_add_64 and atomic_add_64_nv are ever 400dfb96a4fSab196087 * separated, it is important to edit the libc i386 platform 401dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 402dfb96a4fSab196087 * from atomic_add_64_nv. 403dfb96a4fSab196087 */ 4047c478bd9Sstevel@tonic-gate ENTRY(atomic_add_64) 4057c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_64_nv) 4067c478bd9Sstevel@tonic-gate pushl %edi 4077c478bd9Sstevel@tonic-gate pushl %ebx 4087c478bd9Sstevel@tonic-gate movl 12(%esp), %edi / %edi = target address 4097c478bd9Sstevel@tonic-gate movl (%edi), %eax 4107c478bd9Sstevel@tonic-gate movl 4(%edi), %edx / %edx:%eax = old value 4117c478bd9Sstevel@tonic-gate1: 4127c478bd9Sstevel@tonic-gate movl 16(%esp), %ebx 4137c478bd9Sstevel@tonic-gate movl 20(%esp), %ecx / %ecx:%ebx = delta 4147c478bd9Sstevel@tonic-gate addl %eax, %ebx 4157c478bd9Sstevel@tonic-gate adcl %edx, %ecx / %ecx:%ebx = new value 4167c478bd9Sstevel@tonic-gate lock 4177c478bd9Sstevel@tonic-gate cmpxchg8b (%edi) / try to stick it in 4187c478bd9Sstevel@tonic-gate jne 1b 4197c478bd9Sstevel@tonic-gate movl %ebx, %eax 4207c478bd9Sstevel@tonic-gate movl %ecx, %edx / return new value 4217c478bd9Sstevel@tonic-gate popl %ebx 4227c478bd9Sstevel@tonic-gate popl %edi 4237c478bd9Sstevel@tonic-gate ret 4247c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_64_nv) 4257c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_64) 4267c478bd9Sstevel@tonic-gate 4277c478bd9Sstevel@tonic-gate ENTRY(atomic_or_8_nv) 4287c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_uchar_nv) 4297c478bd9Sstevel@tonic-gate movl 4(%esp), %edx / %edx = target address 4307c478bd9Sstevel@tonic-gate movb (%edx), %al / %al = old value 4317c478bd9Sstevel@tonic-gate1: 4327c478bd9Sstevel@tonic-gate movl 8(%esp), %ecx / %ecx = delta 4337c478bd9Sstevel@tonic-gate orb %al, %cl / %cl = new value 4347c478bd9Sstevel@tonic-gate lock 4357c478bd9Sstevel@tonic-gate cmpxchgb %cl, (%edx) / try to stick it in 4367c478bd9Sstevel@tonic-gate jne 1b 4377c478bd9Sstevel@tonic-gate movzbl %cl, %eax / return new value 4387c478bd9Sstevel@tonic-gate ret 4397c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_uchar_nv) 4407c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_8_nv) 4417c478bd9Sstevel@tonic-gate 4427c478bd9Sstevel@tonic-gate ENTRY(atomic_or_16_nv) 4437c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_ushort_nv) 4447c478bd9Sstevel@tonic-gate movl 4(%esp), %edx / %edx = target address 4457c478bd9Sstevel@tonic-gate movw (%edx), %ax / %ax = old value 4467c478bd9Sstevel@tonic-gate1: 4477c478bd9Sstevel@tonic-gate movl 8(%esp), %ecx / %ecx = delta 4487c478bd9Sstevel@tonic-gate orw %ax, %cx / %cx = new value 4497c478bd9Sstevel@tonic-gate lock 4507c478bd9Sstevel@tonic-gate cmpxchgw %cx, (%edx) / try to stick it in 4517c478bd9Sstevel@tonic-gate jne 1b 4527c478bd9Sstevel@tonic-gate movzwl %cx, %eax / return new value 4537c478bd9Sstevel@tonic-gate ret 4547c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_ushort_nv) 4557c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_16_nv) 4567c478bd9Sstevel@tonic-gate 4577c478bd9Sstevel@tonic-gate ENTRY(atomic_or_32_nv) 4587c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_uint_nv) 4597c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_ulong_nv) 4607c478bd9Sstevel@tonic-gate movl 4(%esp), %edx / %edx = target address 4617c478bd9Sstevel@tonic-gate movl (%edx), %eax / %eax = old value 4627c478bd9Sstevel@tonic-gate1: 4637c478bd9Sstevel@tonic-gate movl 8(%esp), %ecx / %ecx = delta 4647c478bd9Sstevel@tonic-gate orl %eax, %ecx / %ecx = new value 4657c478bd9Sstevel@tonic-gate lock 4667c478bd9Sstevel@tonic-gate cmpxchgl %ecx, (%edx) / try to stick it in 4677c478bd9Sstevel@tonic-gate jne 1b 4687c478bd9Sstevel@tonic-gate movl %ecx, %eax / return new value 4697c478bd9Sstevel@tonic-gate ret 4707c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_ulong_nv) 4717c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_uint_nv) 4727c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_32_nv) 4737c478bd9Sstevel@tonic-gate 474dfb96a4fSab196087 /* 475dfb96a4fSab196087 * NOTE: If atomic_or_64 and atomic_or_64_nv are ever 476dfb96a4fSab196087 * separated, it is important to edit the libc i386 platform 477dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 478dfb96a4fSab196087 * from atomic_or_64_nv. 479dfb96a4fSab196087 */ 4807c478bd9Sstevel@tonic-gate ENTRY(atomic_or_64) 4817c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_64_nv) 4827c478bd9Sstevel@tonic-gate pushl %edi 4837c478bd9Sstevel@tonic-gate pushl %ebx 4847c478bd9Sstevel@tonic-gate movl 12(%esp), %edi / %edi = target address 4857c478bd9Sstevel@tonic-gate movl (%edi), %eax 4867c478bd9Sstevel@tonic-gate movl 4(%edi), %edx / %edx:%eax = old value 4877c478bd9Sstevel@tonic-gate1: 4887c478bd9Sstevel@tonic-gate movl 16(%esp), %ebx 4897c478bd9Sstevel@tonic-gate movl 20(%esp), %ecx / %ecx:%ebx = delta 4907c478bd9Sstevel@tonic-gate orl %eax, %ebx 4917c478bd9Sstevel@tonic-gate orl %edx, %ecx / %ecx:%ebx = new value 4927c478bd9Sstevel@tonic-gate lock 4937c478bd9Sstevel@tonic-gate cmpxchg8b (%edi) / try to stick it in 4947c478bd9Sstevel@tonic-gate jne 1b 4957c478bd9Sstevel@tonic-gate movl %ebx, %eax 4967c478bd9Sstevel@tonic-gate movl %ecx, %edx / return new value 4977c478bd9Sstevel@tonic-gate popl %ebx 4987c478bd9Sstevel@tonic-gate popl %edi 4997c478bd9Sstevel@tonic-gate ret 5007c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_64_nv) 5017c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_64) 5027c478bd9Sstevel@tonic-gate 5037c478bd9Sstevel@tonic-gate ENTRY(atomic_and_8_nv) 5047c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_uchar_nv) 5057c478bd9Sstevel@tonic-gate movl 4(%esp), %edx / %edx = target address 5067c478bd9Sstevel@tonic-gate movb (%edx), %al / %al = old value 5077c478bd9Sstevel@tonic-gate1: 5087c478bd9Sstevel@tonic-gate movl 8(%esp), %ecx / %ecx = delta 5097c478bd9Sstevel@tonic-gate andb %al, %cl / %cl = new value 5107c478bd9Sstevel@tonic-gate lock 5117c478bd9Sstevel@tonic-gate cmpxchgb %cl, (%edx) / try to stick it in 5127c478bd9Sstevel@tonic-gate jne 1b 5137c478bd9Sstevel@tonic-gate movzbl %cl, %eax / return new value 5147c478bd9Sstevel@tonic-gate ret 5157c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_uchar_nv) 5167c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_8_nv) 5177c478bd9Sstevel@tonic-gate 5187c478bd9Sstevel@tonic-gate ENTRY(atomic_and_16_nv) 5197c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_ushort_nv) 5207c478bd9Sstevel@tonic-gate movl 4(%esp), %edx / %edx = target address 5217c478bd9Sstevel@tonic-gate movw (%edx), %ax / %ax = old value 5227c478bd9Sstevel@tonic-gate1: 5237c478bd9Sstevel@tonic-gate movl 8(%esp), %ecx / %ecx = delta 5247c478bd9Sstevel@tonic-gate andw %ax, %cx / %cx = new value 5257c478bd9Sstevel@tonic-gate lock 5267c478bd9Sstevel@tonic-gate cmpxchgw %cx, (%edx) / try to stick it in 5277c478bd9Sstevel@tonic-gate jne 1b 5287c478bd9Sstevel@tonic-gate movzwl %cx, %eax / return new value 5297c478bd9Sstevel@tonic-gate ret 5307c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_ushort_nv) 5317c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_16_nv) 5327c478bd9Sstevel@tonic-gate 5337c478bd9Sstevel@tonic-gate ENTRY(atomic_and_32_nv) 5347c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_uint_nv) 5357c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_ulong_nv) 5367c478bd9Sstevel@tonic-gate movl 4(%esp), %edx / %edx = target address 5377c478bd9Sstevel@tonic-gate movl (%edx), %eax / %eax = old value 5387c478bd9Sstevel@tonic-gate1: 5397c478bd9Sstevel@tonic-gate movl 8(%esp), %ecx / %ecx = delta 5407c478bd9Sstevel@tonic-gate andl %eax, %ecx / %ecx = new value 5417c478bd9Sstevel@tonic-gate lock 5427c478bd9Sstevel@tonic-gate cmpxchgl %ecx, (%edx) / try to stick it in 5437c478bd9Sstevel@tonic-gate jne 1b 5447c478bd9Sstevel@tonic-gate movl %ecx, %eax / return new value 5457c478bd9Sstevel@tonic-gate ret 5467c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_ulong_nv) 5477c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_uint_nv) 5487c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_32_nv) 5497c478bd9Sstevel@tonic-gate 550dfb96a4fSab196087 /* 551dfb96a4fSab196087 * NOTE: If atomic_and_64 and atomic_and_64_nv are ever 552dfb96a4fSab196087 * separated, it is important to edit the libc i386 platform 553dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 554dfb96a4fSab196087 * from atomic_and_64_nv. 555dfb96a4fSab196087 */ 5567c478bd9Sstevel@tonic-gate ENTRY(atomic_and_64) 5577c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_64_nv) 5587c478bd9Sstevel@tonic-gate pushl %edi 5597c478bd9Sstevel@tonic-gate pushl %ebx 5607c478bd9Sstevel@tonic-gate movl 12(%esp), %edi / %edi = target address 5617c478bd9Sstevel@tonic-gate movl (%edi), %eax 5627c478bd9Sstevel@tonic-gate movl 4(%edi), %edx / %edx:%eax = old value 5637c478bd9Sstevel@tonic-gate1: 5647c478bd9Sstevel@tonic-gate movl 16(%esp), %ebx 5657c478bd9Sstevel@tonic-gate movl 20(%esp), %ecx / %ecx:%ebx = delta 5667c478bd9Sstevel@tonic-gate andl %eax, %ebx 5677c478bd9Sstevel@tonic-gate andl %edx, %ecx / %ecx:%ebx = new value 5687c478bd9Sstevel@tonic-gate lock 5697c478bd9Sstevel@tonic-gate cmpxchg8b (%edi) / try to stick it in 5707c478bd9Sstevel@tonic-gate jne 1b 5717c478bd9Sstevel@tonic-gate movl %ebx, %eax 5727c478bd9Sstevel@tonic-gate movl %ecx, %edx / return new value 5737c478bd9Sstevel@tonic-gate popl %ebx 5747c478bd9Sstevel@tonic-gate popl %edi 5757c478bd9Sstevel@tonic-gate ret 5767c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_64_nv) 5777c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_64) 5787c478bd9Sstevel@tonic-gate 5797c478bd9Sstevel@tonic-gate ENTRY(atomic_cas_8) 5807c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_uchar) 5817c478bd9Sstevel@tonic-gate movl 4(%esp), %edx 5827c478bd9Sstevel@tonic-gate movzbl 8(%esp), %eax 5837c478bd9Sstevel@tonic-gate movb 12(%esp), %cl 5847c478bd9Sstevel@tonic-gate lock 5857c478bd9Sstevel@tonic-gate cmpxchgb %cl, (%edx) 5867c478bd9Sstevel@tonic-gate ret 5877c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_uchar) 5887c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_8) 5897c478bd9Sstevel@tonic-gate 5907c478bd9Sstevel@tonic-gate ENTRY(atomic_cas_16) 5917c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_ushort) 5927c478bd9Sstevel@tonic-gate movl 4(%esp), %edx 5937c478bd9Sstevel@tonic-gate movzwl 8(%esp), %eax 5947c478bd9Sstevel@tonic-gate movw 12(%esp), %cx 5957c478bd9Sstevel@tonic-gate lock 5967c478bd9Sstevel@tonic-gate cmpxchgw %cx, (%edx) 5977c478bd9Sstevel@tonic-gate ret 5987c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_ushort) 5997c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_16) 6007c478bd9Sstevel@tonic-gate 6017c478bd9Sstevel@tonic-gate ENTRY(atomic_cas_32) 6027c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_uint) 6037c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_ulong) 6047c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_ptr) 6057c478bd9Sstevel@tonic-gate movl 4(%esp), %edx 6067c478bd9Sstevel@tonic-gate movl 8(%esp), %eax 6077c478bd9Sstevel@tonic-gate movl 12(%esp), %ecx 6087c478bd9Sstevel@tonic-gate lock 6097c478bd9Sstevel@tonic-gate cmpxchgl %ecx, (%edx) 6107c478bd9Sstevel@tonic-gate ret 6117c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_ptr) 6127c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_ulong) 6137c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_uint) 6147c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_32) 6157c478bd9Sstevel@tonic-gate 6167c478bd9Sstevel@tonic-gate ENTRY(atomic_cas_64) 6177c478bd9Sstevel@tonic-gate pushl %ebx 6187c478bd9Sstevel@tonic-gate pushl %esi 6197c478bd9Sstevel@tonic-gate movl 12(%esp), %esi 6207c478bd9Sstevel@tonic-gate movl 16(%esp), %eax 6217c478bd9Sstevel@tonic-gate movl 20(%esp), %edx 6227c478bd9Sstevel@tonic-gate movl 24(%esp), %ebx 6237c478bd9Sstevel@tonic-gate movl 28(%esp), %ecx 6247c478bd9Sstevel@tonic-gate lock 6257c478bd9Sstevel@tonic-gate cmpxchg8b (%esi) 6267c478bd9Sstevel@tonic-gate popl %esi 6277c478bd9Sstevel@tonic-gate popl %ebx 6287c478bd9Sstevel@tonic-gate ret 6297c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_64) 6307c478bd9Sstevel@tonic-gate 6317c478bd9Sstevel@tonic-gate ENTRY(atomic_swap_8) 6327c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_uchar) 6337c478bd9Sstevel@tonic-gate movl 4(%esp), %edx 6347c478bd9Sstevel@tonic-gate movzbl 8(%esp), %eax 6357c478bd9Sstevel@tonic-gate lock 6367c478bd9Sstevel@tonic-gate xchgb %al, (%edx) 6377c478bd9Sstevel@tonic-gate ret 6387c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_uchar) 6397c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_8) 6407c478bd9Sstevel@tonic-gate 6417c478bd9Sstevel@tonic-gate ENTRY(atomic_swap_16) 6427c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_ushort) 6437c478bd9Sstevel@tonic-gate movl 4(%esp), %edx 6447c478bd9Sstevel@tonic-gate movzwl 8(%esp), %eax 6457c478bd9Sstevel@tonic-gate lock 6467c478bd9Sstevel@tonic-gate xchgw %ax, (%edx) 6477c478bd9Sstevel@tonic-gate ret 6487c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_ushort) 6497c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_16) 6507c478bd9Sstevel@tonic-gate 6517c478bd9Sstevel@tonic-gate ENTRY(atomic_swap_32) 6527c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_uint) 6537c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_ptr) 6547c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_ulong) 6557c478bd9Sstevel@tonic-gate movl 4(%esp), %edx 6567c478bd9Sstevel@tonic-gate movl 8(%esp), %eax 6577c478bd9Sstevel@tonic-gate lock 6587c478bd9Sstevel@tonic-gate xchgl %eax, (%edx) 6597c478bd9Sstevel@tonic-gate ret 6607c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_ulong) 6617c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_ptr) 6627c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_uint) 6637c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_32) 6647c478bd9Sstevel@tonic-gate 6657c478bd9Sstevel@tonic-gate ENTRY(atomic_swap_64) 6667c478bd9Sstevel@tonic-gate pushl %esi 6677c478bd9Sstevel@tonic-gate pushl %ebx 6687c478bd9Sstevel@tonic-gate movl 12(%esp), %esi 6697c478bd9Sstevel@tonic-gate movl 16(%esp), %ebx 6707c478bd9Sstevel@tonic-gate movl 20(%esp), %ecx 6717c478bd9Sstevel@tonic-gate movl (%esi), %eax 6727c478bd9Sstevel@tonic-gate movl 4(%esi), %edx / %edx:%eax = old value 6737c478bd9Sstevel@tonic-gate1: 6747c478bd9Sstevel@tonic-gate lock 6757c478bd9Sstevel@tonic-gate cmpxchg8b (%esi) 6767c478bd9Sstevel@tonic-gate jne 1b 6777c478bd9Sstevel@tonic-gate popl %ebx 6787c478bd9Sstevel@tonic-gate popl %esi 6797c478bd9Sstevel@tonic-gate ret 6807c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_64) 6817c478bd9Sstevel@tonic-gate 6827c478bd9Sstevel@tonic-gate ENTRY(atomic_set_long_excl) 6837c478bd9Sstevel@tonic-gate movl 4(%esp), %edx / %edx = target address 6847c478bd9Sstevel@tonic-gate movl 8(%esp), %ecx / %ecx = bit id 6857c478bd9Sstevel@tonic-gate xorl %eax, %eax 6867c478bd9Sstevel@tonic-gate lock 6877c478bd9Sstevel@tonic-gate btsl %ecx, (%edx) 6887c478bd9Sstevel@tonic-gate jnc 1f 6897c478bd9Sstevel@tonic-gate decl %eax / return -1 6907c478bd9Sstevel@tonic-gate1: 6917c478bd9Sstevel@tonic-gate ret 6927c478bd9Sstevel@tonic-gate SET_SIZE(atomic_set_long_excl) 6937c478bd9Sstevel@tonic-gate 6947c478bd9Sstevel@tonic-gate ENTRY(atomic_clear_long_excl) 6957c478bd9Sstevel@tonic-gate movl 4(%esp), %edx / %edx = target address 6967c478bd9Sstevel@tonic-gate movl 8(%esp), %ecx / %ecx = bit id 6977c478bd9Sstevel@tonic-gate xorl %eax, %eax 6987c478bd9Sstevel@tonic-gate lock 6997c478bd9Sstevel@tonic-gate btrl %ecx, (%edx) 7007c478bd9Sstevel@tonic-gate jc 1f 7017c478bd9Sstevel@tonic-gate decl %eax / return -1 7027c478bd9Sstevel@tonic-gate1: 7037c478bd9Sstevel@tonic-gate ret 7047c478bd9Sstevel@tonic-gate SET_SIZE(atomic_clear_long_excl) 7057c478bd9Sstevel@tonic-gate 7067c478bd9Sstevel@tonic-gate#if !defined(_KERNEL) 7077c478bd9Sstevel@tonic-gate 708dfb96a4fSab196087 /* 709dfb96a4fSab196087 * NOTE: membar_enter, membar_exit, membar_producer, and 710dfb96a4fSab196087 * membar_consumer are all identical routines. We define them 711dfb96a4fSab196087 * separately, instead of using ALTENTRY definitions to alias them 712dfb96a4fSab196087 * together, so that DTrace and debuggers will see a unique address 713dfb96a4fSab196087 * for them, allowing more accurate tracing. 714dfb96a4fSab196087 */ 715dfb96a4fSab196087 716dfb96a4fSab196087 7177c478bd9Sstevel@tonic-gate ENTRY(membar_enter) 718dfb96a4fSab196087 lock 719dfb96a4fSab196087 xorl $0, (%esp) 720dfb96a4fSab196087 ret 721dfb96a4fSab196087 SET_SIZE(membar_enter) 722dfb96a4fSab196087 723dfb96a4fSab196087 ENTRY(membar_exit) 724dfb96a4fSab196087 lock 725dfb96a4fSab196087 xorl $0, (%esp) 726dfb96a4fSab196087 ret 727dfb96a4fSab196087 SET_SIZE(membar_exit) 728dfb96a4fSab196087 729dfb96a4fSab196087 ENTRY(membar_producer) 730dfb96a4fSab196087 lock 731dfb96a4fSab196087 xorl $0, (%esp) 732dfb96a4fSab196087 ret 733dfb96a4fSab196087 SET_SIZE(membar_producer) 734dfb96a4fSab196087 735dfb96a4fSab196087 ENTRY(membar_consumer) 7367c478bd9Sstevel@tonic-gate lock 7377c478bd9Sstevel@tonic-gate xorl $0, (%esp) 7387c478bd9Sstevel@tonic-gate ret 7397c478bd9Sstevel@tonic-gate SET_SIZE(membar_consumer) 7407c478bd9Sstevel@tonic-gate 7417c478bd9Sstevel@tonic-gate#endif /* !_KERNEL */ 742