17c478bd9Sstevel@tonic-gate/* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5dfb96a4fSab196087 * Common Development and Distribution License (the "License"). 6dfb96a4fSab196087 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21*7257d1b4Sraf 227c478bd9Sstevel@tonic-gate/* 23*7257d1b4Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 27*7257d1b4Sraf#pragma ident "%Z%%M% %I% %E% SMI" 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate .file "%M%" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate#include <sys/asm_linkage.h> 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate#if defined(_KERNEL) 347c478bd9Sstevel@tonic-gate /* 357c478bd9Sstevel@tonic-gate * Legacy kernel interfaces; they will go away (eventually). 367c478bd9Sstevel@tonic-gate */ 377c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(cas8,atomic_cas_8,function) 387c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(cas32,atomic_cas_32,function) 397c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(cas64,atomic_cas_64,function) 407c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(caslong,atomic_cas_ulong,function) 417c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(casptr,atomic_cas_ptr,function) 427c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(atomic_and_long,atomic_and_ulong,function) 437c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(atomic_or_long,atomic_or_ulong,function) 447c478bd9Sstevel@tonic-gate#endif 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_8) 477c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_uchar) 487c478bd9Sstevel@tonic-gate lock 497c478bd9Sstevel@tonic-gate incb (%rdi) 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 lock 577c478bd9Sstevel@tonic-gate incw (%rdi) 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 lock 657c478bd9Sstevel@tonic-gate incl (%rdi) 667c478bd9Sstevel@tonic-gate ret 677c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_uint) 687c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_32) 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_64) 717c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_ulong) 727c478bd9Sstevel@tonic-gate lock 737c478bd9Sstevel@tonic-gate incq (%rdi) 747c478bd9Sstevel@tonic-gate ret 757c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_ulong) 767c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_64) 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_8_nv) 797c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_uchar_nv) 807c478bd9Sstevel@tonic-gate movb (%rdi), %al / %al = old value 817c478bd9Sstevel@tonic-gate1: 827c478bd9Sstevel@tonic-gate leaq 1(%rax), %rcx / %cl = new value 837c478bd9Sstevel@tonic-gate lock 847c478bd9Sstevel@tonic-gate cmpxchgb %cl, (%rdi) / try to stick it in 857c478bd9Sstevel@tonic-gate jne 1b 867c478bd9Sstevel@tonic-gate movzbl %cl, %eax / return new value 877c478bd9Sstevel@tonic-gate ret 887c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_uchar_nv) 897c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_8_nv) 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_16_nv) 927c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_ushort_nv) 937c478bd9Sstevel@tonic-gate movw (%rdi), %ax / %ax = old value 947c478bd9Sstevel@tonic-gate1: 957c478bd9Sstevel@tonic-gate leaq 1(%rax), %rcx / %cx = new value 967c478bd9Sstevel@tonic-gate lock 977c478bd9Sstevel@tonic-gate cmpxchgw %cx, (%rdi) / try to stick it in 987c478bd9Sstevel@tonic-gate jne 1b 997c478bd9Sstevel@tonic-gate movzwl %cx, %eax / return new value 1007c478bd9Sstevel@tonic-gate ret 1017c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_ushort_nv) 1027c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_16_nv) 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_32_nv) 1057c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_uint_nv) 1067c478bd9Sstevel@tonic-gate movl (%rdi), %eax / %eax = old value 1077c478bd9Sstevel@tonic-gate1: 1087c478bd9Sstevel@tonic-gate leaq 1(%rax), %rcx / %ecx = new value 1097c478bd9Sstevel@tonic-gate lock 1107c478bd9Sstevel@tonic-gate cmpxchgl %ecx, (%rdi) / try to stick it in 1117c478bd9Sstevel@tonic-gate jne 1b 1127c478bd9Sstevel@tonic-gate movl %ecx, %eax / return new value 1137c478bd9Sstevel@tonic-gate ret 1147c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_uint_nv) 1157c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_32_nv) 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_64_nv) 1187c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_ulong_nv) 1197c478bd9Sstevel@tonic-gate movq (%rdi), %rax / %rax = old value 1207c478bd9Sstevel@tonic-gate1: 1217c478bd9Sstevel@tonic-gate leaq 1(%rax), %rcx / %rcx = new value 1227c478bd9Sstevel@tonic-gate lock 1237c478bd9Sstevel@tonic-gate cmpxchgq %rcx, (%rdi) / try to stick it in 1247c478bd9Sstevel@tonic-gate jne 1b 1257c478bd9Sstevel@tonic-gate movq %rcx, %rax / return new value 1267c478bd9Sstevel@tonic-gate ret 1277c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_ulong_nv) 1287c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_64_nv) 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_8) 1317c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_uchar) 1327c478bd9Sstevel@tonic-gate lock 1337c478bd9Sstevel@tonic-gate decb (%rdi) 1347c478bd9Sstevel@tonic-gate ret 1357c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_uchar) 1367c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_8) 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_16) 1397c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_ushort) 1407c478bd9Sstevel@tonic-gate lock 1417c478bd9Sstevel@tonic-gate decw (%rdi) 1427c478bd9Sstevel@tonic-gate ret 1437c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_ushort) 1447c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_16) 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_32) 1477c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_uint) 1487c478bd9Sstevel@tonic-gate lock 1497c478bd9Sstevel@tonic-gate decl (%rdi) 1507c478bd9Sstevel@tonic-gate ret 1517c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_uint) 1527c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_32) 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_64) 1557c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_ulong) 1567c478bd9Sstevel@tonic-gate lock 1577c478bd9Sstevel@tonic-gate decq (%rdi) 1587c478bd9Sstevel@tonic-gate ret 1597c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_ulong) 1607c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_64) 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_8_nv) 1637c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_uchar_nv) 1647c478bd9Sstevel@tonic-gate movb (%rdi), %al / %al = old value 1657c478bd9Sstevel@tonic-gate1: 1667c478bd9Sstevel@tonic-gate leaq -1(%rax), %rcx / %cl = new value 1677c478bd9Sstevel@tonic-gate lock 1687c478bd9Sstevel@tonic-gate cmpxchgb %cl, (%rdi) / try to stick it in 1697c478bd9Sstevel@tonic-gate jne 1b 1707c478bd9Sstevel@tonic-gate movzbl %cl, %eax / return new value 1717c478bd9Sstevel@tonic-gate ret 1727c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_uchar_nv) 1737c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_8_nv) 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_16_nv) 1767c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_ushort_nv) 1777c478bd9Sstevel@tonic-gate movw (%rdi), %ax / %ax = old value 1787c478bd9Sstevel@tonic-gate1: 1797c478bd9Sstevel@tonic-gate leaq -1(%rax), %rcx / %cx = new value 1807c478bd9Sstevel@tonic-gate lock 1817c478bd9Sstevel@tonic-gate cmpxchgw %cx, (%rdi) / try to stick it in 1827c478bd9Sstevel@tonic-gate jne 1b 1837c478bd9Sstevel@tonic-gate movzwl %cx, %eax / return new value 1847c478bd9Sstevel@tonic-gate ret 1857c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_ushort_nv) 1867c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_16_nv) 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_32_nv) 1897c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_uint_nv) 1907c478bd9Sstevel@tonic-gate movl (%rdi), %eax / %eax = old value 1917c478bd9Sstevel@tonic-gate1: 1927c478bd9Sstevel@tonic-gate leaq -1(%rax), %rcx / %ecx = new value 1937c478bd9Sstevel@tonic-gate lock 1947c478bd9Sstevel@tonic-gate cmpxchgl %ecx, (%rdi) / try to stick it in 1957c478bd9Sstevel@tonic-gate jne 1b 1967c478bd9Sstevel@tonic-gate movl %ecx, %eax / return new value 1977c478bd9Sstevel@tonic-gate ret 1987c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_uint_nv) 1997c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_32_nv) 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_64_nv) 2027c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_ulong_nv) 2037c478bd9Sstevel@tonic-gate movq (%rdi), %rax / %rax = old value 2047c478bd9Sstevel@tonic-gate1: 2057c478bd9Sstevel@tonic-gate leaq -1(%rax), %rcx / %rcx = new value 2067c478bd9Sstevel@tonic-gate lock 2077c478bd9Sstevel@tonic-gate cmpxchgq %rcx, (%rdi) / try to stick it in 2087c478bd9Sstevel@tonic-gate jne 1b 2097c478bd9Sstevel@tonic-gate movq %rcx, %rax / return new value 2107c478bd9Sstevel@tonic-gate ret 2117c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_ulong_nv) 2127c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_64_nv) 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate ENTRY(atomic_add_8) 2157c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_char) 2167c478bd9Sstevel@tonic-gate lock 2177c478bd9Sstevel@tonic-gate addb %sil, (%rdi) 2187c478bd9Sstevel@tonic-gate ret 2197c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_char) 2207c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_8) 2217c478bd9Sstevel@tonic-gate 2227c478bd9Sstevel@tonic-gate ENTRY(atomic_add_16) 2237c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_short) 2247c478bd9Sstevel@tonic-gate lock 2257c478bd9Sstevel@tonic-gate addw %si, (%rdi) 2267c478bd9Sstevel@tonic-gate ret 2277c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_short) 2287c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_16) 2297c478bd9Sstevel@tonic-gate 2307c478bd9Sstevel@tonic-gate ENTRY(atomic_add_32) 2317c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_int) 2327c478bd9Sstevel@tonic-gate lock 2337c478bd9Sstevel@tonic-gate addl %esi, (%rdi) 2347c478bd9Sstevel@tonic-gate ret 2357c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_int) 2367c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_32) 2377c478bd9Sstevel@tonic-gate 2387c478bd9Sstevel@tonic-gate ENTRY(atomic_add_64) 2397c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_ptr) 2407c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_long) 2417c478bd9Sstevel@tonic-gate lock 2427c478bd9Sstevel@tonic-gate addq %rsi, (%rdi) 2437c478bd9Sstevel@tonic-gate ret 2447c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_long) 2457c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_ptr) 2467c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_64) 2477c478bd9Sstevel@tonic-gate 2487c478bd9Sstevel@tonic-gate ENTRY(atomic_or_8) 2497c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_uchar) 2507c478bd9Sstevel@tonic-gate lock 2517c478bd9Sstevel@tonic-gate orb %sil, (%rdi) 2527c478bd9Sstevel@tonic-gate ret 2537c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_uchar) 2547c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_8) 2557c478bd9Sstevel@tonic-gate 2567c478bd9Sstevel@tonic-gate ENTRY(atomic_or_16) 2577c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_ushort) 2587c478bd9Sstevel@tonic-gate lock 2597c478bd9Sstevel@tonic-gate orw %si, (%rdi) 2607c478bd9Sstevel@tonic-gate ret 2617c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_ushort) 2627c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_16) 2637c478bd9Sstevel@tonic-gate 2647c478bd9Sstevel@tonic-gate ENTRY(atomic_or_32) 2657c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_uint) 2667c478bd9Sstevel@tonic-gate lock 2677c478bd9Sstevel@tonic-gate orl %esi, (%rdi) 2687c478bd9Sstevel@tonic-gate ret 2697c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_uint) 2707c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_32) 2717c478bd9Sstevel@tonic-gate 2727c478bd9Sstevel@tonic-gate ENTRY(atomic_or_64) 2737c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_ulong) 2747c478bd9Sstevel@tonic-gate lock 2757c478bd9Sstevel@tonic-gate orq %rsi, (%rdi) 2767c478bd9Sstevel@tonic-gate ret 2777c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_ulong) 2787c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_64) 2797c478bd9Sstevel@tonic-gate 2807c478bd9Sstevel@tonic-gate ENTRY(atomic_and_8) 2817c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_uchar) 2827c478bd9Sstevel@tonic-gate lock 2837c478bd9Sstevel@tonic-gate andb %sil, (%rdi) 2847c478bd9Sstevel@tonic-gate ret 2857c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_uchar) 2867c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_8) 2877c478bd9Sstevel@tonic-gate 2887c478bd9Sstevel@tonic-gate ENTRY(atomic_and_16) 2897c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_ushort) 2907c478bd9Sstevel@tonic-gate lock 2917c478bd9Sstevel@tonic-gate andw %si, (%rdi) 2927c478bd9Sstevel@tonic-gate ret 2937c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_ushort) 2947c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_16) 2957c478bd9Sstevel@tonic-gate 2967c478bd9Sstevel@tonic-gate ENTRY(atomic_and_32) 2977c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_uint) 2987c478bd9Sstevel@tonic-gate lock 2997c478bd9Sstevel@tonic-gate andl %esi, (%rdi) 3007c478bd9Sstevel@tonic-gate ret 3017c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_uint) 3027c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_32) 3037c478bd9Sstevel@tonic-gate 3047c478bd9Sstevel@tonic-gate ENTRY(atomic_and_64) 3057c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_ulong) 3067c478bd9Sstevel@tonic-gate lock 3077c478bd9Sstevel@tonic-gate andq %rsi, (%rdi) 3087c478bd9Sstevel@tonic-gate ret 3097c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_ulong) 3107c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_64) 3117c478bd9Sstevel@tonic-gate 3127c478bd9Sstevel@tonic-gate ENTRY(atomic_add_8_nv) 3137c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_char_nv) 3147c478bd9Sstevel@tonic-gate movb (%rdi), %al / %al = old value 3157c478bd9Sstevel@tonic-gate1: 3167c478bd9Sstevel@tonic-gate movb %sil, %cl 3177c478bd9Sstevel@tonic-gate addb %al, %cl / %cl = new value 3187c478bd9Sstevel@tonic-gate lock 3197c478bd9Sstevel@tonic-gate cmpxchgb %cl, (%rdi) / try to stick it in 3207c478bd9Sstevel@tonic-gate jne 1b 3217c478bd9Sstevel@tonic-gate movzbl %cl, %eax / return new value 3227c478bd9Sstevel@tonic-gate ret 3237c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_char_nv) 3247c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_8_nv) 3257c478bd9Sstevel@tonic-gate 3267c478bd9Sstevel@tonic-gate ENTRY(atomic_add_16_nv) 3277c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_short_nv) 3287c478bd9Sstevel@tonic-gate movw (%rdi), %ax / %ax = old value 3297c478bd9Sstevel@tonic-gate1: 3307c478bd9Sstevel@tonic-gate movw %si, %cx 3317c478bd9Sstevel@tonic-gate addw %ax, %cx / %cx = new value 3327c478bd9Sstevel@tonic-gate lock 3337c478bd9Sstevel@tonic-gate cmpxchgw %cx, (%rdi) / try to stick it in 3347c478bd9Sstevel@tonic-gate jne 1b 3357c478bd9Sstevel@tonic-gate movzwl %cx, %eax / return new value 3367c478bd9Sstevel@tonic-gate ret 3377c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_short_nv) 3387c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_16_nv) 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gate ENTRY(atomic_add_32_nv) 3417c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_int_nv) 3427c478bd9Sstevel@tonic-gate movl (%rdi), %eax 3437c478bd9Sstevel@tonic-gate1: 3447c478bd9Sstevel@tonic-gate movl %esi, %ecx 3457c478bd9Sstevel@tonic-gate addl %eax, %ecx 3467c478bd9Sstevel@tonic-gate lock 3477c478bd9Sstevel@tonic-gate cmpxchgl %ecx, (%rdi) 3487c478bd9Sstevel@tonic-gate jne 1b 3497c478bd9Sstevel@tonic-gate movl %ecx, %eax 3507c478bd9Sstevel@tonic-gate ret 3517c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_int_nv) 3527c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_32_nv) 3537c478bd9Sstevel@tonic-gate 3547c478bd9Sstevel@tonic-gate ENTRY(atomic_add_64_nv) 3557c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_ptr_nv) 3567c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_long_nv) 3577c478bd9Sstevel@tonic-gate movq (%rdi), %rax 3587c478bd9Sstevel@tonic-gate1: 3597c478bd9Sstevel@tonic-gate movq %rsi, %rcx 3607c478bd9Sstevel@tonic-gate addq %rax, %rcx 3617c478bd9Sstevel@tonic-gate lock 3627c478bd9Sstevel@tonic-gate cmpxchgq %rcx, (%rdi) 3637c478bd9Sstevel@tonic-gate jne 1b 3647c478bd9Sstevel@tonic-gate movq %rcx, %rax 3657c478bd9Sstevel@tonic-gate ret 3667c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_long_nv) 3677c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_ptr_nv) 3687c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_64_nv) 3697c478bd9Sstevel@tonic-gate 3707c478bd9Sstevel@tonic-gate ENTRY(atomic_and_8_nv) 3717c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_uchar_nv) 3727c478bd9Sstevel@tonic-gate movb (%rdi), %al / %al = old value 3737c478bd9Sstevel@tonic-gate1: 3747c478bd9Sstevel@tonic-gate movb %sil, %cl 3757c478bd9Sstevel@tonic-gate andb %al, %cl / %cl = new value 3767c478bd9Sstevel@tonic-gate lock 3777c478bd9Sstevel@tonic-gate cmpxchgb %cl, (%rdi) / try to stick it in 3787c478bd9Sstevel@tonic-gate jne 1b 3797c478bd9Sstevel@tonic-gate movzbl %cl, %eax / return new value 3807c478bd9Sstevel@tonic-gate ret 3817c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_uchar_nv) 3827c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_8_nv) 3837c478bd9Sstevel@tonic-gate 3847c478bd9Sstevel@tonic-gate ENTRY(atomic_and_16_nv) 3857c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_ushort_nv) 3867c478bd9Sstevel@tonic-gate movw (%rdi), %ax / %ax = old value 3877c478bd9Sstevel@tonic-gate1: 3887c478bd9Sstevel@tonic-gate movw %si, %cx 3897c478bd9Sstevel@tonic-gate andw %ax, %cx / %cx = new value 3907c478bd9Sstevel@tonic-gate lock 3917c478bd9Sstevel@tonic-gate cmpxchgw %cx, (%rdi) / try to stick it in 3927c478bd9Sstevel@tonic-gate jne 1b 3937c478bd9Sstevel@tonic-gate movzwl %cx, %eax / return new value 3947c478bd9Sstevel@tonic-gate ret 3957c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_ushort_nv) 3967c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_16_nv) 3977c478bd9Sstevel@tonic-gate 3987c478bd9Sstevel@tonic-gate ENTRY(atomic_and_32_nv) 3997c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_uint_nv) 4007c478bd9Sstevel@tonic-gate movl (%rdi), %eax 4017c478bd9Sstevel@tonic-gate1: 4027c478bd9Sstevel@tonic-gate movl %esi, %ecx 4037c478bd9Sstevel@tonic-gate andl %eax, %ecx 4047c478bd9Sstevel@tonic-gate lock 4057c478bd9Sstevel@tonic-gate cmpxchgl %ecx, (%rdi) 4067c478bd9Sstevel@tonic-gate jne 1b 4077c478bd9Sstevel@tonic-gate movl %ecx, %eax 4087c478bd9Sstevel@tonic-gate ret 4097c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_uint_nv) 4107c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_32_nv) 4117c478bd9Sstevel@tonic-gate 4127c478bd9Sstevel@tonic-gate ENTRY(atomic_and_64_nv) 4137c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_ulong_nv) 4147c478bd9Sstevel@tonic-gate movq (%rdi), %rax 4157c478bd9Sstevel@tonic-gate1: 4167c478bd9Sstevel@tonic-gate movq %rsi, %rcx 4177c478bd9Sstevel@tonic-gate andq %rax, %rcx 4187c478bd9Sstevel@tonic-gate lock 4197c478bd9Sstevel@tonic-gate cmpxchgq %rcx, (%rdi) 4207c478bd9Sstevel@tonic-gate jne 1b 4217c478bd9Sstevel@tonic-gate movq %rcx, %rax 4227c478bd9Sstevel@tonic-gate ret 4237c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_ulong_nv) 4247c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_64_nv) 4257c478bd9Sstevel@tonic-gate 4267c478bd9Sstevel@tonic-gate ENTRY(atomic_or_8_nv) 4277c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_uchar_nv) 4287c478bd9Sstevel@tonic-gate movb (%rdi), %al / %al = old value 4297c478bd9Sstevel@tonic-gate1: 4307c478bd9Sstevel@tonic-gate movb %sil, %cl 4317c478bd9Sstevel@tonic-gate orb %al, %cl / %cl = new value 4327c478bd9Sstevel@tonic-gate lock 4337c478bd9Sstevel@tonic-gate cmpxchgb %cl, (%rdi) / try to stick it in 4347c478bd9Sstevel@tonic-gate jne 1b 4357c478bd9Sstevel@tonic-gate movzbl %cl, %eax / return new value 4367c478bd9Sstevel@tonic-gate ret 4377c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_uchar_nv) 4387c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_8_nv) 4397c478bd9Sstevel@tonic-gate 4407c478bd9Sstevel@tonic-gate ENTRY(atomic_or_16_nv) 4417c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_ushort_nv) 4427c478bd9Sstevel@tonic-gate movw (%rdi), %ax / %ax = old value 4437c478bd9Sstevel@tonic-gate1: 4447c478bd9Sstevel@tonic-gate movw %si, %cx 4457c478bd9Sstevel@tonic-gate orw %ax, %cx / %cx = new value 4467c478bd9Sstevel@tonic-gate lock 4477c478bd9Sstevel@tonic-gate cmpxchgw %cx, (%rdi) / try to stick it in 4487c478bd9Sstevel@tonic-gate jne 1b 4497c478bd9Sstevel@tonic-gate movzwl %cx, %eax / return new value 4507c478bd9Sstevel@tonic-gate ret 4517c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_ushort_nv) 4527c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_16_nv) 4537c478bd9Sstevel@tonic-gate 4547c478bd9Sstevel@tonic-gate ENTRY(atomic_or_32_nv) 4557c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_uint_nv) 4567c478bd9Sstevel@tonic-gate movl (%rdi), %eax 4577c478bd9Sstevel@tonic-gate1: 4587c478bd9Sstevel@tonic-gate movl %esi, %ecx 4597c478bd9Sstevel@tonic-gate orl %eax, %ecx 4607c478bd9Sstevel@tonic-gate lock 4617c478bd9Sstevel@tonic-gate cmpxchgl %ecx, (%rdi) 4627c478bd9Sstevel@tonic-gate jne 1b 4637c478bd9Sstevel@tonic-gate movl %ecx, %eax 4647c478bd9Sstevel@tonic-gate ret 4657c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_uint_nv) 4667c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_32_nv) 4677c478bd9Sstevel@tonic-gate 4687c478bd9Sstevel@tonic-gate ENTRY(atomic_or_64_nv) 4697c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_ulong_nv) 4707c478bd9Sstevel@tonic-gate movq (%rdi), %rax 4717c478bd9Sstevel@tonic-gate1: 4727c478bd9Sstevel@tonic-gate movq %rsi, %rcx 4737c478bd9Sstevel@tonic-gate orq %rax, %rcx 4747c478bd9Sstevel@tonic-gate lock 4757c478bd9Sstevel@tonic-gate cmpxchgq %rcx, (%rdi) 4767c478bd9Sstevel@tonic-gate jne 1b 4777c478bd9Sstevel@tonic-gate movq %rcx, %rax 4787c478bd9Sstevel@tonic-gate ret 4797c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_ulong_nv) 4807c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_64_nv) 4817c478bd9Sstevel@tonic-gate 4827c478bd9Sstevel@tonic-gate ENTRY(atomic_cas_8) 4837c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_uchar) 4847c478bd9Sstevel@tonic-gate movzbl %sil, %eax 4857c478bd9Sstevel@tonic-gate lock 4867c478bd9Sstevel@tonic-gate cmpxchgb %dl, (%rdi) 4877c478bd9Sstevel@tonic-gate ret 4887c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_uchar) 4897c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_8) 4907c478bd9Sstevel@tonic-gate 4917c478bd9Sstevel@tonic-gate ENTRY(atomic_cas_16) 4927c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_ushort) 4937c478bd9Sstevel@tonic-gate movzwl %si, %eax 4947c478bd9Sstevel@tonic-gate lock 4957c478bd9Sstevel@tonic-gate cmpxchgw %dx, (%rdi) 4967c478bd9Sstevel@tonic-gate ret 4977c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_ushort) 4987c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_16) 4997c478bd9Sstevel@tonic-gate 5007c478bd9Sstevel@tonic-gate ENTRY(atomic_cas_32) 5017c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_uint) 5027c478bd9Sstevel@tonic-gate movl %esi, %eax 5037c478bd9Sstevel@tonic-gate lock 5047c478bd9Sstevel@tonic-gate cmpxchgl %edx, (%rdi) 5057c478bd9Sstevel@tonic-gate ret 5067c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_uint) 5077c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_32) 5087c478bd9Sstevel@tonic-gate 5097c478bd9Sstevel@tonic-gate ENTRY(atomic_cas_64) 5107c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_ulong) 5117c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_ptr) 5127c478bd9Sstevel@tonic-gate movq %rsi, %rax 5137c478bd9Sstevel@tonic-gate lock 5147c478bd9Sstevel@tonic-gate cmpxchgq %rdx, (%rdi) 5157c478bd9Sstevel@tonic-gate ret 5167c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_ptr) 5177c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_ulong) 5187c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_64) 5197c478bd9Sstevel@tonic-gate 5207c478bd9Sstevel@tonic-gate ENTRY(atomic_swap_8) 5217c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_uchar) 5227c478bd9Sstevel@tonic-gate movzbl %sil, %eax 5237c478bd9Sstevel@tonic-gate lock 5247c478bd9Sstevel@tonic-gate xchgb %al, (%rdi) 5257c478bd9Sstevel@tonic-gate ret 5267c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_uchar) 5277c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_8) 5287c478bd9Sstevel@tonic-gate 5297c478bd9Sstevel@tonic-gate ENTRY(atomic_swap_16) 5307c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_ushort) 5317c478bd9Sstevel@tonic-gate movzwl %si, %eax 5327c478bd9Sstevel@tonic-gate lock 5337c478bd9Sstevel@tonic-gate xchgw %ax, (%rdi) 5347c478bd9Sstevel@tonic-gate ret 5357c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_ushort) 5367c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_16) 5377c478bd9Sstevel@tonic-gate 5387c478bd9Sstevel@tonic-gate ENTRY(atomic_swap_32) 5397c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_uint) 5407c478bd9Sstevel@tonic-gate movl %esi, %eax 5417c478bd9Sstevel@tonic-gate lock 5427c478bd9Sstevel@tonic-gate xchgl %eax, (%rdi) 5437c478bd9Sstevel@tonic-gate ret 5447c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_uint) 5457c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_32) 5467c478bd9Sstevel@tonic-gate 5477c478bd9Sstevel@tonic-gate ENTRY(atomic_swap_64) 5487c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_ulong) 5497c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_ptr) 5507c478bd9Sstevel@tonic-gate movq %rsi, %rax 5517c478bd9Sstevel@tonic-gate lock 5527c478bd9Sstevel@tonic-gate xchgq %rax, (%rdi) 5537c478bd9Sstevel@tonic-gate ret 5547c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_ptr) 5557c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_ulong) 5567c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_64) 5577c478bd9Sstevel@tonic-gate 5587c478bd9Sstevel@tonic-gate ENTRY(atomic_set_long_excl) 5597c478bd9Sstevel@tonic-gate xorl %eax, %eax 5607c478bd9Sstevel@tonic-gate lock 5617c478bd9Sstevel@tonic-gate btsq %rsi, (%rdi) 5627c478bd9Sstevel@tonic-gate jnc 1f 5637c478bd9Sstevel@tonic-gate decl %eax / return -1 5647c478bd9Sstevel@tonic-gate1: 5657c478bd9Sstevel@tonic-gate ret 5667c478bd9Sstevel@tonic-gate SET_SIZE(atomic_set_long_excl) 5677c478bd9Sstevel@tonic-gate 5687c478bd9Sstevel@tonic-gate ENTRY(atomic_clear_long_excl) 5697c478bd9Sstevel@tonic-gate xorl %eax, %eax 5707c478bd9Sstevel@tonic-gate lock 5717c478bd9Sstevel@tonic-gate btrq %rsi, (%rdi) 5727c478bd9Sstevel@tonic-gate jc 1f 5737c478bd9Sstevel@tonic-gate decl %eax / return -1 5747c478bd9Sstevel@tonic-gate1: 5757c478bd9Sstevel@tonic-gate ret 5767c478bd9Sstevel@tonic-gate SET_SIZE(atomic_clear_long_excl) 5777c478bd9Sstevel@tonic-gate 5787c478bd9Sstevel@tonic-gate#if !defined(_KERNEL) 5797c478bd9Sstevel@tonic-gate 580dfb96a4fSab196087 /* 581dfb96a4fSab196087 * NOTE: membar_enter, and membar_exit are identical routines. 582dfb96a4fSab196087 * We define them separately, instead of using an ALTENTRY 583dfb96a4fSab196087 * definitions to alias them together, so that DTrace and 584dfb96a4fSab196087 * debuggers will see a unique address for them, allowing 585dfb96a4fSab196087 * more accurate tracing. 586dfb96a4fSab196087 */ 587dfb96a4fSab196087 5887c478bd9Sstevel@tonic-gate ENTRY(membar_enter) 589dfb96a4fSab196087 mfence 590dfb96a4fSab196087 ret 591dfb96a4fSab196087 SET_SIZE(membar_enter) 592dfb96a4fSab196087 593dfb96a4fSab196087 ENTRY(membar_exit) 5947c478bd9Sstevel@tonic-gate mfence 5957c478bd9Sstevel@tonic-gate ret 5967c478bd9Sstevel@tonic-gate SET_SIZE(membar_exit) 5977c478bd9Sstevel@tonic-gate 5987c478bd9Sstevel@tonic-gate ENTRY(membar_producer) 5997c478bd9Sstevel@tonic-gate sfence 6007c478bd9Sstevel@tonic-gate ret 6017c478bd9Sstevel@tonic-gate SET_SIZE(membar_producer) 6027c478bd9Sstevel@tonic-gate 6037c478bd9Sstevel@tonic-gate ENTRY(membar_consumer) 6047c478bd9Sstevel@tonic-gate lfence 6057c478bd9Sstevel@tonic-gate ret 6067c478bd9Sstevel@tonic-gate SET_SIZE(membar_consumer) 6077c478bd9Sstevel@tonic-gate 6087c478bd9Sstevel@tonic-gate#endif /* !_KERNEL */ 609