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