1*7c478bd9Sstevel@tonic-gate/* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate/* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate .ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate .file "%M%" 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate#include <sys/asm_linkage.h> 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate#if defined(_KERNEL) 34*7c478bd9Sstevel@tonic-gate /* 35*7c478bd9Sstevel@tonic-gate * Legacy kernel interfaces; they will go away (eventually). 36*7c478bd9Sstevel@tonic-gate */ 37*7c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(cas8,atomic_cas_8,function) 38*7c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(cas32,atomic_cas_32,function) 39*7c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(cas64,atomic_cas_64,function) 40*7c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(caslong,atomic_cas_ulong,function) 41*7c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(casptr,atomic_cas_ptr,function) 42*7c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(atomic_and_long,atomic_and_ulong,function) 43*7c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(atomic_or_long,atomic_or_ulong,function) 44*7c478bd9Sstevel@tonic-gate#else 45*7c478bd9Sstevel@tonic-gate /* 46*7c478bd9Sstevel@tonic-gate * Include the definitions for the libc weak aliases. 47*7c478bd9Sstevel@tonic-gate */ 48*7c478bd9Sstevel@tonic-gate#include "../atomic_asm_weak.h" 49*7c478bd9Sstevel@tonic-gate#endif 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_8) 52*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_uchar) 53*7c478bd9Sstevel@tonic-gate lock 54*7c478bd9Sstevel@tonic-gate incb (%rdi) 55*7c478bd9Sstevel@tonic-gate ret 56*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_uchar) 57*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_8) 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_16) 60*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_ushort) 61*7c478bd9Sstevel@tonic-gate lock 62*7c478bd9Sstevel@tonic-gate incw (%rdi) 63*7c478bd9Sstevel@tonic-gate ret 64*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_ushort) 65*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_16) 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_32) 68*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_uint) 69*7c478bd9Sstevel@tonic-gate lock 70*7c478bd9Sstevel@tonic-gate incl (%rdi) 71*7c478bd9Sstevel@tonic-gate ret 72*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_uint) 73*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_32) 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_64) 76*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_ulong) 77*7c478bd9Sstevel@tonic-gate lock 78*7c478bd9Sstevel@tonic-gate incq (%rdi) 79*7c478bd9Sstevel@tonic-gate ret 80*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_ulong) 81*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_64) 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_8_nv) 84*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_uchar_nv) 85*7c478bd9Sstevel@tonic-gate movb (%rdi), %al / %al = old value 86*7c478bd9Sstevel@tonic-gate1: 87*7c478bd9Sstevel@tonic-gate leaq 1(%rax), %rcx / %cl = new value 88*7c478bd9Sstevel@tonic-gate lock 89*7c478bd9Sstevel@tonic-gate cmpxchgb %cl, (%rdi) / try to stick it in 90*7c478bd9Sstevel@tonic-gate jne 1b 91*7c478bd9Sstevel@tonic-gate movzbl %cl, %eax / return new value 92*7c478bd9Sstevel@tonic-gate ret 93*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_uchar_nv) 94*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_8_nv) 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_16_nv) 97*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_ushort_nv) 98*7c478bd9Sstevel@tonic-gate movw (%rdi), %ax / %ax = old value 99*7c478bd9Sstevel@tonic-gate1: 100*7c478bd9Sstevel@tonic-gate leaq 1(%rax), %rcx / %cx = new value 101*7c478bd9Sstevel@tonic-gate lock 102*7c478bd9Sstevel@tonic-gate cmpxchgw %cx, (%rdi) / try to stick it in 103*7c478bd9Sstevel@tonic-gate jne 1b 104*7c478bd9Sstevel@tonic-gate movzwl %cx, %eax / return new value 105*7c478bd9Sstevel@tonic-gate ret 106*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_ushort_nv) 107*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_16_nv) 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_32_nv) 110*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_uint_nv) 111*7c478bd9Sstevel@tonic-gate movl (%rdi), %eax / %eax = old value 112*7c478bd9Sstevel@tonic-gate1: 113*7c478bd9Sstevel@tonic-gate leaq 1(%rax), %rcx / %ecx = new value 114*7c478bd9Sstevel@tonic-gate lock 115*7c478bd9Sstevel@tonic-gate cmpxchgl %ecx, (%rdi) / try to stick it in 116*7c478bd9Sstevel@tonic-gate jne 1b 117*7c478bd9Sstevel@tonic-gate movl %ecx, %eax / return new value 118*7c478bd9Sstevel@tonic-gate ret 119*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_uint_nv) 120*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_32_nv) 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_64_nv) 123*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_ulong_nv) 124*7c478bd9Sstevel@tonic-gate movq (%rdi), %rax / %rax = old value 125*7c478bd9Sstevel@tonic-gate1: 126*7c478bd9Sstevel@tonic-gate leaq 1(%rax), %rcx / %rcx = new value 127*7c478bd9Sstevel@tonic-gate lock 128*7c478bd9Sstevel@tonic-gate cmpxchgq %rcx, (%rdi) / try to stick it in 129*7c478bd9Sstevel@tonic-gate jne 1b 130*7c478bd9Sstevel@tonic-gate movq %rcx, %rax / return new value 131*7c478bd9Sstevel@tonic-gate ret 132*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_ulong_nv) 133*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_64_nv) 134*7c478bd9Sstevel@tonic-gate 135*7c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_8) 136*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_uchar) 137*7c478bd9Sstevel@tonic-gate lock 138*7c478bd9Sstevel@tonic-gate decb (%rdi) 139*7c478bd9Sstevel@tonic-gate ret 140*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_uchar) 141*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_8) 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_16) 144*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_ushort) 145*7c478bd9Sstevel@tonic-gate lock 146*7c478bd9Sstevel@tonic-gate decw (%rdi) 147*7c478bd9Sstevel@tonic-gate ret 148*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_ushort) 149*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_16) 150*7c478bd9Sstevel@tonic-gate 151*7c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_32) 152*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_uint) 153*7c478bd9Sstevel@tonic-gate lock 154*7c478bd9Sstevel@tonic-gate decl (%rdi) 155*7c478bd9Sstevel@tonic-gate ret 156*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_uint) 157*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_32) 158*7c478bd9Sstevel@tonic-gate 159*7c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_64) 160*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_ulong) 161*7c478bd9Sstevel@tonic-gate lock 162*7c478bd9Sstevel@tonic-gate decq (%rdi) 163*7c478bd9Sstevel@tonic-gate ret 164*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_ulong) 165*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_64) 166*7c478bd9Sstevel@tonic-gate 167*7c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_8_nv) 168*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_uchar_nv) 169*7c478bd9Sstevel@tonic-gate movb (%rdi), %al / %al = old value 170*7c478bd9Sstevel@tonic-gate1: 171*7c478bd9Sstevel@tonic-gate leaq -1(%rax), %rcx / %cl = new value 172*7c478bd9Sstevel@tonic-gate lock 173*7c478bd9Sstevel@tonic-gate cmpxchgb %cl, (%rdi) / try to stick it in 174*7c478bd9Sstevel@tonic-gate jne 1b 175*7c478bd9Sstevel@tonic-gate movzbl %cl, %eax / return new value 176*7c478bd9Sstevel@tonic-gate ret 177*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_uchar_nv) 178*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_8_nv) 179*7c478bd9Sstevel@tonic-gate 180*7c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_16_nv) 181*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_ushort_nv) 182*7c478bd9Sstevel@tonic-gate movw (%rdi), %ax / %ax = old value 183*7c478bd9Sstevel@tonic-gate1: 184*7c478bd9Sstevel@tonic-gate leaq -1(%rax), %rcx / %cx = new value 185*7c478bd9Sstevel@tonic-gate lock 186*7c478bd9Sstevel@tonic-gate cmpxchgw %cx, (%rdi) / try to stick it in 187*7c478bd9Sstevel@tonic-gate jne 1b 188*7c478bd9Sstevel@tonic-gate movzwl %cx, %eax / return new value 189*7c478bd9Sstevel@tonic-gate ret 190*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_ushort_nv) 191*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_16_nv) 192*7c478bd9Sstevel@tonic-gate 193*7c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_32_nv) 194*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_uint_nv) 195*7c478bd9Sstevel@tonic-gate movl (%rdi), %eax / %eax = old value 196*7c478bd9Sstevel@tonic-gate1: 197*7c478bd9Sstevel@tonic-gate leaq -1(%rax), %rcx / %ecx = new value 198*7c478bd9Sstevel@tonic-gate lock 199*7c478bd9Sstevel@tonic-gate cmpxchgl %ecx, (%rdi) / try to stick it in 200*7c478bd9Sstevel@tonic-gate jne 1b 201*7c478bd9Sstevel@tonic-gate movl %ecx, %eax / return new value 202*7c478bd9Sstevel@tonic-gate ret 203*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_uint_nv) 204*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_32_nv) 205*7c478bd9Sstevel@tonic-gate 206*7c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_64_nv) 207*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_ulong_nv) 208*7c478bd9Sstevel@tonic-gate movq (%rdi), %rax / %rax = old value 209*7c478bd9Sstevel@tonic-gate1: 210*7c478bd9Sstevel@tonic-gate leaq -1(%rax), %rcx / %rcx = new value 211*7c478bd9Sstevel@tonic-gate lock 212*7c478bd9Sstevel@tonic-gate cmpxchgq %rcx, (%rdi) / try to stick it in 213*7c478bd9Sstevel@tonic-gate jne 1b 214*7c478bd9Sstevel@tonic-gate movq %rcx, %rax / return new value 215*7c478bd9Sstevel@tonic-gate ret 216*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_ulong_nv) 217*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_64_nv) 218*7c478bd9Sstevel@tonic-gate 219*7c478bd9Sstevel@tonic-gate ENTRY(atomic_add_8) 220*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_char) 221*7c478bd9Sstevel@tonic-gate lock 222*7c478bd9Sstevel@tonic-gate addb %sil, (%rdi) 223*7c478bd9Sstevel@tonic-gate ret 224*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_char) 225*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_8) 226*7c478bd9Sstevel@tonic-gate 227*7c478bd9Sstevel@tonic-gate ENTRY(atomic_add_16) 228*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_short) 229*7c478bd9Sstevel@tonic-gate lock 230*7c478bd9Sstevel@tonic-gate addw %si, (%rdi) 231*7c478bd9Sstevel@tonic-gate ret 232*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_short) 233*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_16) 234*7c478bd9Sstevel@tonic-gate 235*7c478bd9Sstevel@tonic-gate ENTRY(atomic_add_32) 236*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_int) 237*7c478bd9Sstevel@tonic-gate lock 238*7c478bd9Sstevel@tonic-gate addl %esi, (%rdi) 239*7c478bd9Sstevel@tonic-gate ret 240*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_int) 241*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_32) 242*7c478bd9Sstevel@tonic-gate 243*7c478bd9Sstevel@tonic-gate ENTRY(atomic_add_64) 244*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_ptr) 245*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_long) 246*7c478bd9Sstevel@tonic-gate lock 247*7c478bd9Sstevel@tonic-gate addq %rsi, (%rdi) 248*7c478bd9Sstevel@tonic-gate ret 249*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_long) 250*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_ptr) 251*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_64) 252*7c478bd9Sstevel@tonic-gate 253*7c478bd9Sstevel@tonic-gate ENTRY(atomic_or_8) 254*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_uchar) 255*7c478bd9Sstevel@tonic-gate lock 256*7c478bd9Sstevel@tonic-gate orb %sil, (%rdi) 257*7c478bd9Sstevel@tonic-gate ret 258*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_uchar) 259*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_8) 260*7c478bd9Sstevel@tonic-gate 261*7c478bd9Sstevel@tonic-gate ENTRY(atomic_or_16) 262*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_ushort) 263*7c478bd9Sstevel@tonic-gate lock 264*7c478bd9Sstevel@tonic-gate orw %si, (%rdi) 265*7c478bd9Sstevel@tonic-gate ret 266*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_ushort) 267*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_16) 268*7c478bd9Sstevel@tonic-gate 269*7c478bd9Sstevel@tonic-gate ENTRY(atomic_or_32) 270*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_uint) 271*7c478bd9Sstevel@tonic-gate lock 272*7c478bd9Sstevel@tonic-gate orl %esi, (%rdi) 273*7c478bd9Sstevel@tonic-gate ret 274*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_uint) 275*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_32) 276*7c478bd9Sstevel@tonic-gate 277*7c478bd9Sstevel@tonic-gate ENTRY(atomic_or_64) 278*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_ulong) 279*7c478bd9Sstevel@tonic-gate lock 280*7c478bd9Sstevel@tonic-gate orq %rsi, (%rdi) 281*7c478bd9Sstevel@tonic-gate ret 282*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_ulong) 283*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_64) 284*7c478bd9Sstevel@tonic-gate 285*7c478bd9Sstevel@tonic-gate ENTRY(atomic_and_8) 286*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_uchar) 287*7c478bd9Sstevel@tonic-gate lock 288*7c478bd9Sstevel@tonic-gate andb %sil, (%rdi) 289*7c478bd9Sstevel@tonic-gate ret 290*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_uchar) 291*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_8) 292*7c478bd9Sstevel@tonic-gate 293*7c478bd9Sstevel@tonic-gate ENTRY(atomic_and_16) 294*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_ushort) 295*7c478bd9Sstevel@tonic-gate lock 296*7c478bd9Sstevel@tonic-gate andw %si, (%rdi) 297*7c478bd9Sstevel@tonic-gate ret 298*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_ushort) 299*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_16) 300*7c478bd9Sstevel@tonic-gate 301*7c478bd9Sstevel@tonic-gate ENTRY(atomic_and_32) 302*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_uint) 303*7c478bd9Sstevel@tonic-gate lock 304*7c478bd9Sstevel@tonic-gate andl %esi, (%rdi) 305*7c478bd9Sstevel@tonic-gate ret 306*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_uint) 307*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_32) 308*7c478bd9Sstevel@tonic-gate 309*7c478bd9Sstevel@tonic-gate ENTRY(atomic_and_64) 310*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_ulong) 311*7c478bd9Sstevel@tonic-gate lock 312*7c478bd9Sstevel@tonic-gate andq %rsi, (%rdi) 313*7c478bd9Sstevel@tonic-gate ret 314*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_ulong) 315*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_64) 316*7c478bd9Sstevel@tonic-gate 317*7c478bd9Sstevel@tonic-gate ENTRY(atomic_add_8_nv) 318*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_char_nv) 319*7c478bd9Sstevel@tonic-gate movb (%rdi), %al / %al = old value 320*7c478bd9Sstevel@tonic-gate1: 321*7c478bd9Sstevel@tonic-gate movb %sil, %cl 322*7c478bd9Sstevel@tonic-gate addb %al, %cl / %cl = new value 323*7c478bd9Sstevel@tonic-gate lock 324*7c478bd9Sstevel@tonic-gate cmpxchgb %cl, (%rdi) / try to stick it in 325*7c478bd9Sstevel@tonic-gate jne 1b 326*7c478bd9Sstevel@tonic-gate movzbl %cl, %eax / return new value 327*7c478bd9Sstevel@tonic-gate ret 328*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_char_nv) 329*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_8_nv) 330*7c478bd9Sstevel@tonic-gate 331*7c478bd9Sstevel@tonic-gate ENTRY(atomic_add_16_nv) 332*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_short_nv) 333*7c478bd9Sstevel@tonic-gate movw (%rdi), %ax / %ax = old value 334*7c478bd9Sstevel@tonic-gate1: 335*7c478bd9Sstevel@tonic-gate movw %si, %cx 336*7c478bd9Sstevel@tonic-gate addw %ax, %cx / %cx = new value 337*7c478bd9Sstevel@tonic-gate lock 338*7c478bd9Sstevel@tonic-gate cmpxchgw %cx, (%rdi) / try to stick it in 339*7c478bd9Sstevel@tonic-gate jne 1b 340*7c478bd9Sstevel@tonic-gate movzwl %cx, %eax / return new value 341*7c478bd9Sstevel@tonic-gate ret 342*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_short_nv) 343*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_16_nv) 344*7c478bd9Sstevel@tonic-gate 345*7c478bd9Sstevel@tonic-gate ENTRY(atomic_add_32_nv) 346*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_int_nv) 347*7c478bd9Sstevel@tonic-gate movl (%rdi), %eax 348*7c478bd9Sstevel@tonic-gate1: 349*7c478bd9Sstevel@tonic-gate movl %esi, %ecx 350*7c478bd9Sstevel@tonic-gate addl %eax, %ecx 351*7c478bd9Sstevel@tonic-gate lock 352*7c478bd9Sstevel@tonic-gate cmpxchgl %ecx, (%rdi) 353*7c478bd9Sstevel@tonic-gate jne 1b 354*7c478bd9Sstevel@tonic-gate movl %ecx, %eax 355*7c478bd9Sstevel@tonic-gate ret 356*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_int_nv) 357*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_32_nv) 358*7c478bd9Sstevel@tonic-gate 359*7c478bd9Sstevel@tonic-gate ENTRY(atomic_add_64_nv) 360*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_ptr_nv) 361*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_long_nv) 362*7c478bd9Sstevel@tonic-gate movq (%rdi), %rax 363*7c478bd9Sstevel@tonic-gate1: 364*7c478bd9Sstevel@tonic-gate movq %rsi, %rcx 365*7c478bd9Sstevel@tonic-gate addq %rax, %rcx 366*7c478bd9Sstevel@tonic-gate lock 367*7c478bd9Sstevel@tonic-gate cmpxchgq %rcx, (%rdi) 368*7c478bd9Sstevel@tonic-gate jne 1b 369*7c478bd9Sstevel@tonic-gate movq %rcx, %rax 370*7c478bd9Sstevel@tonic-gate ret 371*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_long_nv) 372*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_ptr_nv) 373*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_64_nv) 374*7c478bd9Sstevel@tonic-gate 375*7c478bd9Sstevel@tonic-gate ENTRY(atomic_and_8_nv) 376*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_uchar_nv) 377*7c478bd9Sstevel@tonic-gate movb (%rdi), %al / %al = old value 378*7c478bd9Sstevel@tonic-gate1: 379*7c478bd9Sstevel@tonic-gate movb %sil, %cl 380*7c478bd9Sstevel@tonic-gate andb %al, %cl / %cl = new value 381*7c478bd9Sstevel@tonic-gate lock 382*7c478bd9Sstevel@tonic-gate cmpxchgb %cl, (%rdi) / try to stick it in 383*7c478bd9Sstevel@tonic-gate jne 1b 384*7c478bd9Sstevel@tonic-gate movzbl %cl, %eax / return new value 385*7c478bd9Sstevel@tonic-gate ret 386*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_uchar_nv) 387*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_8_nv) 388*7c478bd9Sstevel@tonic-gate 389*7c478bd9Sstevel@tonic-gate ENTRY(atomic_and_16_nv) 390*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_ushort_nv) 391*7c478bd9Sstevel@tonic-gate movw (%rdi), %ax / %ax = old value 392*7c478bd9Sstevel@tonic-gate1: 393*7c478bd9Sstevel@tonic-gate movw %si, %cx 394*7c478bd9Sstevel@tonic-gate andw %ax, %cx / %cx = new value 395*7c478bd9Sstevel@tonic-gate lock 396*7c478bd9Sstevel@tonic-gate cmpxchgw %cx, (%rdi) / try to stick it in 397*7c478bd9Sstevel@tonic-gate jne 1b 398*7c478bd9Sstevel@tonic-gate movzwl %cx, %eax / return new value 399*7c478bd9Sstevel@tonic-gate ret 400*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_ushort_nv) 401*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_16_nv) 402*7c478bd9Sstevel@tonic-gate 403*7c478bd9Sstevel@tonic-gate ENTRY(atomic_and_32_nv) 404*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_uint_nv) 405*7c478bd9Sstevel@tonic-gate movl (%rdi), %eax 406*7c478bd9Sstevel@tonic-gate1: 407*7c478bd9Sstevel@tonic-gate movl %esi, %ecx 408*7c478bd9Sstevel@tonic-gate andl %eax, %ecx 409*7c478bd9Sstevel@tonic-gate lock 410*7c478bd9Sstevel@tonic-gate cmpxchgl %ecx, (%rdi) 411*7c478bd9Sstevel@tonic-gate jne 1b 412*7c478bd9Sstevel@tonic-gate movl %ecx, %eax 413*7c478bd9Sstevel@tonic-gate ret 414*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_uint_nv) 415*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_32_nv) 416*7c478bd9Sstevel@tonic-gate 417*7c478bd9Sstevel@tonic-gate ENTRY(atomic_and_64_nv) 418*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_ulong_nv) 419*7c478bd9Sstevel@tonic-gate movq (%rdi), %rax 420*7c478bd9Sstevel@tonic-gate1: 421*7c478bd9Sstevel@tonic-gate movq %rsi, %rcx 422*7c478bd9Sstevel@tonic-gate andq %rax, %rcx 423*7c478bd9Sstevel@tonic-gate lock 424*7c478bd9Sstevel@tonic-gate cmpxchgq %rcx, (%rdi) 425*7c478bd9Sstevel@tonic-gate jne 1b 426*7c478bd9Sstevel@tonic-gate movq %rcx, %rax 427*7c478bd9Sstevel@tonic-gate ret 428*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_ulong_nv) 429*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_64_nv) 430*7c478bd9Sstevel@tonic-gate 431*7c478bd9Sstevel@tonic-gate ENTRY(atomic_or_8_nv) 432*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_uchar_nv) 433*7c478bd9Sstevel@tonic-gate movb (%rdi), %al / %al = old value 434*7c478bd9Sstevel@tonic-gate1: 435*7c478bd9Sstevel@tonic-gate movb %sil, %cl 436*7c478bd9Sstevel@tonic-gate orb %al, %cl / %cl = new value 437*7c478bd9Sstevel@tonic-gate lock 438*7c478bd9Sstevel@tonic-gate cmpxchgb %cl, (%rdi) / try to stick it in 439*7c478bd9Sstevel@tonic-gate jne 1b 440*7c478bd9Sstevel@tonic-gate movzbl %cl, %eax / return new value 441*7c478bd9Sstevel@tonic-gate ret 442*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_uchar_nv) 443*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_8_nv) 444*7c478bd9Sstevel@tonic-gate 445*7c478bd9Sstevel@tonic-gate ENTRY(atomic_or_16_nv) 446*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_ushort_nv) 447*7c478bd9Sstevel@tonic-gate movw (%rdi), %ax / %ax = old value 448*7c478bd9Sstevel@tonic-gate1: 449*7c478bd9Sstevel@tonic-gate movw %si, %cx 450*7c478bd9Sstevel@tonic-gate orw %ax, %cx / %cx = new value 451*7c478bd9Sstevel@tonic-gate lock 452*7c478bd9Sstevel@tonic-gate cmpxchgw %cx, (%rdi) / try to stick it in 453*7c478bd9Sstevel@tonic-gate jne 1b 454*7c478bd9Sstevel@tonic-gate movzwl %cx, %eax / return new value 455*7c478bd9Sstevel@tonic-gate ret 456*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_ushort_nv) 457*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_16_nv) 458*7c478bd9Sstevel@tonic-gate 459*7c478bd9Sstevel@tonic-gate ENTRY(atomic_or_32_nv) 460*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_uint_nv) 461*7c478bd9Sstevel@tonic-gate movl (%rdi), %eax 462*7c478bd9Sstevel@tonic-gate1: 463*7c478bd9Sstevel@tonic-gate movl %esi, %ecx 464*7c478bd9Sstevel@tonic-gate orl %eax, %ecx 465*7c478bd9Sstevel@tonic-gate lock 466*7c478bd9Sstevel@tonic-gate cmpxchgl %ecx, (%rdi) 467*7c478bd9Sstevel@tonic-gate jne 1b 468*7c478bd9Sstevel@tonic-gate movl %ecx, %eax 469*7c478bd9Sstevel@tonic-gate ret 470*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_uint_nv) 471*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_32_nv) 472*7c478bd9Sstevel@tonic-gate 473*7c478bd9Sstevel@tonic-gate ENTRY(atomic_or_64_nv) 474*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_ulong_nv) 475*7c478bd9Sstevel@tonic-gate movq (%rdi), %rax 476*7c478bd9Sstevel@tonic-gate1: 477*7c478bd9Sstevel@tonic-gate movq %rsi, %rcx 478*7c478bd9Sstevel@tonic-gate orq %rax, %rcx 479*7c478bd9Sstevel@tonic-gate lock 480*7c478bd9Sstevel@tonic-gate cmpxchgq %rcx, (%rdi) 481*7c478bd9Sstevel@tonic-gate jne 1b 482*7c478bd9Sstevel@tonic-gate movq %rcx, %rax 483*7c478bd9Sstevel@tonic-gate ret 484*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_ulong_nv) 485*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_64_nv) 486*7c478bd9Sstevel@tonic-gate 487*7c478bd9Sstevel@tonic-gate ENTRY(atomic_cas_8) 488*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_uchar) 489*7c478bd9Sstevel@tonic-gate movzbl %sil, %eax 490*7c478bd9Sstevel@tonic-gate lock 491*7c478bd9Sstevel@tonic-gate cmpxchgb %dl, (%rdi) 492*7c478bd9Sstevel@tonic-gate ret 493*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_uchar) 494*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_8) 495*7c478bd9Sstevel@tonic-gate 496*7c478bd9Sstevel@tonic-gate ENTRY(atomic_cas_16) 497*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_ushort) 498*7c478bd9Sstevel@tonic-gate movzwl %si, %eax 499*7c478bd9Sstevel@tonic-gate lock 500*7c478bd9Sstevel@tonic-gate cmpxchgw %dx, (%rdi) 501*7c478bd9Sstevel@tonic-gate ret 502*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_ushort) 503*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_16) 504*7c478bd9Sstevel@tonic-gate 505*7c478bd9Sstevel@tonic-gate ENTRY(atomic_cas_32) 506*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_uint) 507*7c478bd9Sstevel@tonic-gate movl %esi, %eax 508*7c478bd9Sstevel@tonic-gate lock 509*7c478bd9Sstevel@tonic-gate cmpxchgl %edx, (%rdi) 510*7c478bd9Sstevel@tonic-gate ret 511*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_uint) 512*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_32) 513*7c478bd9Sstevel@tonic-gate 514*7c478bd9Sstevel@tonic-gate ENTRY(atomic_cas_64) 515*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_ulong) 516*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_ptr) 517*7c478bd9Sstevel@tonic-gate movq %rsi, %rax 518*7c478bd9Sstevel@tonic-gate lock 519*7c478bd9Sstevel@tonic-gate cmpxchgq %rdx, (%rdi) 520*7c478bd9Sstevel@tonic-gate ret 521*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_ptr) 522*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_ulong) 523*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_64) 524*7c478bd9Sstevel@tonic-gate 525*7c478bd9Sstevel@tonic-gate ENTRY(atomic_swap_8) 526*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_uchar) 527*7c478bd9Sstevel@tonic-gate movzbl %sil, %eax 528*7c478bd9Sstevel@tonic-gate lock 529*7c478bd9Sstevel@tonic-gate xchgb %al, (%rdi) 530*7c478bd9Sstevel@tonic-gate ret 531*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_uchar) 532*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_8) 533*7c478bd9Sstevel@tonic-gate 534*7c478bd9Sstevel@tonic-gate ENTRY(atomic_swap_16) 535*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_ushort) 536*7c478bd9Sstevel@tonic-gate movzwl %si, %eax 537*7c478bd9Sstevel@tonic-gate lock 538*7c478bd9Sstevel@tonic-gate xchgw %ax, (%rdi) 539*7c478bd9Sstevel@tonic-gate ret 540*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_ushort) 541*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_16) 542*7c478bd9Sstevel@tonic-gate 543*7c478bd9Sstevel@tonic-gate ENTRY(atomic_swap_32) 544*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_uint) 545*7c478bd9Sstevel@tonic-gate movl %esi, %eax 546*7c478bd9Sstevel@tonic-gate lock 547*7c478bd9Sstevel@tonic-gate xchgl %eax, (%rdi) 548*7c478bd9Sstevel@tonic-gate ret 549*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_uint) 550*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_32) 551*7c478bd9Sstevel@tonic-gate 552*7c478bd9Sstevel@tonic-gate ENTRY(atomic_swap_64) 553*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_ulong) 554*7c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_ptr) 555*7c478bd9Sstevel@tonic-gate movq %rsi, %rax 556*7c478bd9Sstevel@tonic-gate lock 557*7c478bd9Sstevel@tonic-gate xchgq %rax, (%rdi) 558*7c478bd9Sstevel@tonic-gate ret 559*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_ptr) 560*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_ulong) 561*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_64) 562*7c478bd9Sstevel@tonic-gate 563*7c478bd9Sstevel@tonic-gate ENTRY(atomic_set_long_excl) 564*7c478bd9Sstevel@tonic-gate xorl %eax, %eax 565*7c478bd9Sstevel@tonic-gate lock 566*7c478bd9Sstevel@tonic-gate btsq %rsi, (%rdi) 567*7c478bd9Sstevel@tonic-gate jnc 1f 568*7c478bd9Sstevel@tonic-gate decl %eax / return -1 569*7c478bd9Sstevel@tonic-gate1: 570*7c478bd9Sstevel@tonic-gate ret 571*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_set_long_excl) 572*7c478bd9Sstevel@tonic-gate 573*7c478bd9Sstevel@tonic-gate ENTRY(atomic_clear_long_excl) 574*7c478bd9Sstevel@tonic-gate xorl %eax, %eax 575*7c478bd9Sstevel@tonic-gate lock 576*7c478bd9Sstevel@tonic-gate btrq %rsi, (%rdi) 577*7c478bd9Sstevel@tonic-gate jc 1f 578*7c478bd9Sstevel@tonic-gate decl %eax / return -1 579*7c478bd9Sstevel@tonic-gate1: 580*7c478bd9Sstevel@tonic-gate ret 581*7c478bd9Sstevel@tonic-gate SET_SIZE(atomic_clear_long_excl) 582*7c478bd9Sstevel@tonic-gate 583*7c478bd9Sstevel@tonic-gate#if !defined(_KERNEL) 584*7c478bd9Sstevel@tonic-gate 585*7c478bd9Sstevel@tonic-gate ENTRY(membar_enter) 586*7c478bd9Sstevel@tonic-gate ALTENTRY(membar_exit) 587*7c478bd9Sstevel@tonic-gate mfence 588*7c478bd9Sstevel@tonic-gate ret 589*7c478bd9Sstevel@tonic-gate SET_SIZE(membar_exit) 590*7c478bd9Sstevel@tonic-gate SET_SIZE(membar_enter) 591*7c478bd9Sstevel@tonic-gate 592*7c478bd9Sstevel@tonic-gate ENTRY(membar_producer) 593*7c478bd9Sstevel@tonic-gate sfence 594*7c478bd9Sstevel@tonic-gate ret 595*7c478bd9Sstevel@tonic-gate SET_SIZE(membar_producer) 596*7c478bd9Sstevel@tonic-gate 597*7c478bd9Sstevel@tonic-gate ENTRY(membar_consumer) 598*7c478bd9Sstevel@tonic-gate lfence 599*7c478bd9Sstevel@tonic-gate ret 600*7c478bd9Sstevel@tonic-gate SET_SIZE(membar_consumer) 601*7c478bd9Sstevel@tonic-gate 602*7c478bd9Sstevel@tonic-gate#endif /* !_KERNEL */ 603