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/* 23c38855f9SShesha Sreenivasamurthy * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 279a70fc3bSMark J. Nelson .file "atomic.s" 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate#include <sys/asm_linkage.h> 307c478bd9Sstevel@tonic-gate 31895ca178Sae112802/* 32895ca178Sae112802 * ATOMIC_BO_ENABLE_SHIFT can be selectively defined by processors 33895ca178Sae112802 * to enable exponential backoff. No definition means backoff is 34895ca178Sae112802 * not desired i.e. backoff should be disabled. 35895ca178Sae112802 * By default, the shift value is used to generate a power of 2 36895ca178Sae112802 * value for backoff limit. In the kernel, processors scale this 37895ca178Sae112802 * shift value with the number of online cpus. 38895ca178Sae112802 */ 39895ca178Sae112802 407c478bd9Sstevel@tonic-gate#if defined(_KERNEL) 417c478bd9Sstevel@tonic-gate /* 42*e521049dSJosef 'Jeff' Sipek * Legacy kernel interfaces; they will go away the moment our closed 43*e521049dSJosef 'Jeff' Sipek * bins no longer require them. 447c478bd9Sstevel@tonic-gate */ 457c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(cas8,atomic_cas_8,function) 467c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(cas32,atomic_cas_32,function) 477c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(cas64,atomic_cas_64,function) 487c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(caslong,atomic_cas_ulong,function) 497c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(casptr,atomic_cas_ptr,function) 507c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(atomic_and_long,atomic_and_ulong,function) 517c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(atomic_or_long,atomic_or_ulong,function) 527c478bd9Sstevel@tonic-gate ANSI_PRAGMA_WEAK2(swapl,atomic_swap_32,function) 53895ca178Sae112802 54895ca178Sae112802#ifdef ATOMIC_BO_ENABLE_SHIFT 55895ca178Sae112802 56895ca178Sae112802#if !defined(lint) 57895ca178Sae112802 .weak cpu_atomic_delay 58895ca178Sae112802 .type cpu_atomic_delay, #function 59895ca178Sae112802#endif /* lint */ 60895ca178Sae112802 61895ca178Sae112802/* 62895ca178Sae112802 * For the kernel, invoke processor specific delay routine to perform 63895ca178Sae112802 * low-impact spin delay. The value of ATOMIC_BO_ENABLE_SHIFT is tuned 64895ca178Sae112802 * with respect to the specific spin delay implementation. 65895ca178Sae112802 */ 66895ca178Sae112802#define DELAY_SPIN(label, tmp1, tmp2) \ 67895ca178Sae112802 /* ; \ 68895ca178Sae112802 * Define a pragma weak reference to a cpu specific ; \ 69895ca178Sae112802 * delay routine for atomic backoff. For CPUs that ; \ 70895ca178Sae112802 * have no such delay routine defined, the delay becomes ; \ 71895ca178Sae112802 * just a simple tight loop. ; \ 72895ca178Sae112802 * ; \ 73895ca178Sae112802 * tmp1 = holds CPU specific delay routine ; \ 74895ca178Sae112802 * tmp2 = holds atomic routine's callee return address ; \ 75895ca178Sae112802 */ ; \ 76895ca178Sae112802 sethi %hi(cpu_atomic_delay), tmp1 ; \ 77895ca178Sae112802 or tmp1, %lo(cpu_atomic_delay), tmp1 ; \ 78895ca178Sae112802label/**/0: ; \ 79895ca178Sae112802 brz,pn tmp1, label/**/1 ; \ 80895ca178Sae112802 mov %o7, tmp2 ; \ 81895ca178Sae112802 jmpl tmp1, %o7 /* call CPU specific delay routine */ ; \ 82895ca178Sae112802 nop /* delay slot : do nothing */ ; \ 83895ca178Sae112802 mov tmp2, %o7 /* restore callee's return address */ ; \ 84895ca178Sae112802label/**/1: 85895ca178Sae112802 86895ca178Sae112802/* 87895ca178Sae112802 * For the kernel, we take into consideration of cas failures 88895ca178Sae112802 * and also scale the backoff limit w.r.t. the number of cpus. 89895ca178Sae112802 * For cas failures, we reset the backoff value to 1 if the cas 90895ca178Sae112802 * failures exceed or equal to the number of online cpus. This 91895ca178Sae112802 * will enforce some degree of fairness and prevent starvation. 92895ca178Sae112802 * We also scale/normalize the processor provided specific 93895ca178Sae112802 * ATOMIC_BO_ENABLE_SHIFT w.r.t. the number of online cpus to 94895ca178Sae112802 * obtain the actual final limit to use. 95895ca178Sae112802 */ 96895ca178Sae112802#define ATOMIC_BACKOFF_CPU(val, limit, ncpu, cas_cnt, label) \ 97895ca178Sae112802 brnz,pt ncpu, label/**/0 ; \ 98895ca178Sae112802 inc cas_cnt ; \ 99895ca178Sae112802 sethi %hi(ncpus_online), ncpu ; \ 100895ca178Sae112802 ld [ncpu + %lo(ncpus_online)], ncpu ; \ 101895ca178Sae112802label/**/0: ; \ 102895ca178Sae112802 cmp cas_cnt, ncpu ; \ 103895ca178Sae112802 blu,pt %xcc, label/**/1 ; \ 104895ca178Sae112802 sllx ncpu, ATOMIC_BO_ENABLE_SHIFT, limit ; \ 105895ca178Sae112802 mov %g0, cas_cnt ; \ 106895ca178Sae112802 mov 1, val ; \ 107895ca178Sae112802label/**/1: 108895ca178Sae112802#endif /* ATOMIC_BO_ENABLE_SHIFT */ 109895ca178Sae112802 110895ca178Sae112802#else /* _KERNEL */ 111895ca178Sae112802 112895ca178Sae112802/* 113895ca178Sae112802 * ATOMIC_BO_ENABLE_SHIFT may be enabled/defined here for generic 114895ca178Sae112802 * libc atomics. None for now. 115895ca178Sae112802 */ 116895ca178Sae112802#ifdef ATOMIC_BO_ENABLE_SHIFT 117895ca178Sae112802#define DELAY_SPIN(label, tmp1, tmp2) \ 118895ca178Sae112802label/**/0: 119895ca178Sae112802 120895ca178Sae112802#define ATOMIC_BACKOFF_CPU(val, limit, ncpu, cas_cnt, label) \ 121895ca178Sae112802 set 1 << ATOMIC_BO_ENABLE_SHIFT, limit 122895ca178Sae112802#endif /* ATOMIC_BO_ENABLE_SHIFT */ 123895ca178Sae112802#endif /* _KERNEL */ 124895ca178Sae112802 125895ca178Sae112802#ifdef ATOMIC_BO_ENABLE_SHIFT 126895ca178Sae112802/* 127895ca178Sae112802 * ATOMIC_BACKOFF_INIT macro for initialization. 128895ca178Sae112802 * backoff val is initialized to 1. 129895ca178Sae112802 * ncpu is initialized to 0 130895ca178Sae112802 * The cas_cnt counts the cas instruction failure and is 131895ca178Sae112802 * initialized to 0. 132895ca178Sae112802 */ 133895ca178Sae112802#define ATOMIC_BACKOFF_INIT(val, ncpu, cas_cnt) \ 134895ca178Sae112802 mov 1, val ; \ 135895ca178Sae112802 mov %g0, ncpu ; \ 136895ca178Sae112802 mov %g0, cas_cnt 137895ca178Sae112802 138895ca178Sae112802#define ATOMIC_BACKOFF_BRANCH(cr, backoff, loop) \ 139895ca178Sae112802 bne,a,pn cr, backoff 140895ca178Sae112802 141895ca178Sae112802/* 142895ca178Sae112802 * Main ATOMIC_BACKOFF_BACKOFF macro for backoff. 143895ca178Sae112802 */ 144895ca178Sae112802#define ATOMIC_BACKOFF_BACKOFF(val, limit, ncpu, cas_cnt, label, retlabel) \ 145895ca178Sae112802 ATOMIC_BACKOFF_CPU(val, limit, ncpu, cas_cnt, label/**/_0) ; \ 146895ca178Sae112802 cmp val, limit ; \ 147895ca178Sae112802 blu,a,pt %xcc, label/**/_1 ; \ 148895ca178Sae112802 mov val, limit ; \ 149895ca178Sae112802label/**/_1: ; \ 150895ca178Sae112802 mov limit, val ; \ 151895ca178Sae112802 DELAY_SPIN(label/**/_2, %g2, %g3) ; \ 152895ca178Sae112802 deccc limit ; \ 153895ca178Sae112802 bgu,pn %xcc, label/**/_20 /* branch to middle of DELAY_SPIN */ ; \ 154895ca178Sae112802 nop ; \ 155895ca178Sae112802 ba retlabel ; \ 156895ca178Sae112802 sllx val, 1, val 157c38855f9SShesha Sreenivasamurthy 158895ca178Sae112802#else /* ATOMIC_BO_ENABLE_SHIFT */ 159895ca178Sae112802#define ATOMIC_BACKOFF_INIT(val, ncpu, cas_cnt) 160895ca178Sae112802 161895ca178Sae112802#define ATOMIC_BACKOFF_BRANCH(cr, backoff, loop) \ 162895ca178Sae112802 bne,a,pn cr, loop 163895ca178Sae112802 164895ca178Sae112802#define ATOMIC_BACKOFF_BACKOFF(val, limit, ncpu, cas_cnt, label, retlabel) 165895ca178Sae112802#endif /* ATOMIC_BO_ENABLE_SHIFT */ 1667c478bd9Sstevel@tonic-gate 167dfb96a4fSab196087 /* 168dfb96a4fSab196087 * NOTE: If atomic_inc_8 and atomic_inc_8_nv are ever 169dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 170dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 171dfb96a4fSab196087 * from atomic_inc_8_nv. 172dfb96a4fSab196087 */ 1737c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_8) 1747c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_8_nv) 1757c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_uchar) 1767c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_uchar_nv) 1777c478bd9Sstevel@tonic-gate ba add_8 1787c478bd9Sstevel@tonic-gate add %g0, 1, %o1 1797c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_uchar_nv) 1807c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_uchar) 1817c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_8_nv) 1827c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_8) 1837c478bd9Sstevel@tonic-gate 184dfb96a4fSab196087 /* 185dfb96a4fSab196087 * NOTE: If atomic_dec_8 and atomic_dec_8_nv are ever 186dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 187dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 188dfb96a4fSab196087 * from atomic_dec_8_nv. 189dfb96a4fSab196087 */ 1907c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_8) 1917c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_8_nv) 1927c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_uchar) 1937c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_uchar_nv) 1947c478bd9Sstevel@tonic-gate ba add_8 1957c478bd9Sstevel@tonic-gate sub %g0, 1, %o1 1967c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_uchar_nv) 1977c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_uchar) 1987c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_8_nv) 1997c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_8) 2007c478bd9Sstevel@tonic-gate 201dfb96a4fSab196087 /* 202dfb96a4fSab196087 * NOTE: If atomic_add_8 and atomic_add_8_nv are ever 203dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 204dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 205dfb96a4fSab196087 * from atomic_add_8_nv. 206dfb96a4fSab196087 */ 2077c478bd9Sstevel@tonic-gate ENTRY(atomic_add_8) 2087c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_8_nv) 2097c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_char) 2107c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_char_nv) 2117c478bd9Sstevel@tonic-gateadd_8: 2127c478bd9Sstevel@tonic-gate and %o0, 0x3, %o4 ! %o4 = byte offset, left-to-right 2137c478bd9Sstevel@tonic-gate xor %o4, 0x3, %g1 ! %g1 = byte offset, right-to-left 2147c478bd9Sstevel@tonic-gate sll %g1, 3, %g1 ! %g1 = bit offset, right-to-left 2157c478bd9Sstevel@tonic-gate set 0xff, %o3 ! %o3 = mask 2167c478bd9Sstevel@tonic-gate sll %o3, %g1, %o3 ! %o3 = shifted to bit offset 2177c478bd9Sstevel@tonic-gate sll %o1, %g1, %o1 ! %o1 = shifted to bit offset 2187c478bd9Sstevel@tonic-gate and %o1, %o3, %o1 ! %o1 = single byte value 2197c478bd9Sstevel@tonic-gate andn %o0, 0x3, %o0 ! %o0 = word address 2207c478bd9Sstevel@tonic-gate ld [%o0], %o2 ! read old value 2217c478bd9Sstevel@tonic-gate1: 2227c478bd9Sstevel@tonic-gate add %o2, %o1, %o5 ! add value to the old value 2237c478bd9Sstevel@tonic-gate and %o5, %o3, %o5 ! clear other bits 2247c478bd9Sstevel@tonic-gate andn %o2, %o3, %o4 ! clear target bits 2257c478bd9Sstevel@tonic-gate or %o4, %o5, %o5 ! insert the new value 2267c478bd9Sstevel@tonic-gate cas [%o0], %o2, %o5 2277c478bd9Sstevel@tonic-gate cmp %o2, %o5 2287c478bd9Sstevel@tonic-gate bne,a,pn %icc, 1b 2297c478bd9Sstevel@tonic-gate mov %o5, %o2 ! %o2 = old value 2307c478bd9Sstevel@tonic-gate add %o2, %o1, %o5 2317c478bd9Sstevel@tonic-gate and %o5, %o3, %o5 2327c478bd9Sstevel@tonic-gate retl 2337c478bd9Sstevel@tonic-gate srl %o5, %g1, %o0 ! %o0 = new value 2347c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_char_nv) 2357c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_char) 2367c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_8_nv) 2377c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_8) 2387c478bd9Sstevel@tonic-gate 239dfb96a4fSab196087 /* 240dfb96a4fSab196087 * NOTE: If atomic_inc_16 and atomic_inc_16_nv are ever 241dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 242dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 243dfb96a4fSab196087 * from atomic_inc_16_nv. 244dfb96a4fSab196087 */ 2457c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_16) 2467c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_16_nv) 2477c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_ushort) 2487c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_ushort_nv) 2497c478bd9Sstevel@tonic-gate ba add_16 2507c478bd9Sstevel@tonic-gate add %g0, 1, %o1 2517c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_ushort_nv) 2527c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_ushort) 2537c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_16_nv) 2547c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_16) 2557c478bd9Sstevel@tonic-gate 256dfb96a4fSab196087 /* 257dfb96a4fSab196087 * NOTE: If atomic_dec_16 and atomic_dec_16_nv are ever 258dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 259dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 260dfb96a4fSab196087 * from atomic_dec_16_nv. 261dfb96a4fSab196087 */ 2627c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_16) 2637c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_16_nv) 2647c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_ushort) 2657c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_ushort_nv) 2667c478bd9Sstevel@tonic-gate ba add_16 2677c478bd9Sstevel@tonic-gate sub %g0, 1, %o1 2687c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_ushort_nv) 2697c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_ushort) 2707c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_16_nv) 2717c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_16) 2727c478bd9Sstevel@tonic-gate 273dfb96a4fSab196087 /* 274dfb96a4fSab196087 * NOTE: If atomic_add_16 and atomic_add_16_nv are ever 275dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 276dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 277dfb96a4fSab196087 * from atomic_add_16_nv. 278dfb96a4fSab196087 */ 2797c478bd9Sstevel@tonic-gate ENTRY(atomic_add_16) 2807c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_16_nv) 2817c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_short) 2827c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_short_nv) 2837c478bd9Sstevel@tonic-gateadd_16: 2847c478bd9Sstevel@tonic-gate and %o0, 0x2, %o4 ! %o4 = byte offset, left-to-right 2857c478bd9Sstevel@tonic-gate xor %o4, 0x2, %g1 ! %g1 = byte offset, right-to-left 2867c478bd9Sstevel@tonic-gate sll %o4, 3, %o4 ! %o4 = bit offset, left-to-right 2877c478bd9Sstevel@tonic-gate sll %g1, 3, %g1 ! %g1 = bit offset, right-to-left 2887c478bd9Sstevel@tonic-gate sethi %hi(0xffff0000), %o3 ! %o3 = mask 2897c478bd9Sstevel@tonic-gate srl %o3, %o4, %o3 ! %o3 = shifted to bit offset 2907c478bd9Sstevel@tonic-gate sll %o1, %g1, %o1 ! %o1 = shifted to bit offset 2917c478bd9Sstevel@tonic-gate and %o1, %o3, %o1 ! %o1 = single short value 2927c478bd9Sstevel@tonic-gate andn %o0, 0x2, %o0 ! %o0 = word address 2937c478bd9Sstevel@tonic-gate ! if low-order bit is 1, we will properly get an alignment fault here 2947c478bd9Sstevel@tonic-gate ld [%o0], %o2 ! read old value 2957c478bd9Sstevel@tonic-gate1: 2967c478bd9Sstevel@tonic-gate add %o1, %o2, %o5 ! add value to the old value 2977c478bd9Sstevel@tonic-gate and %o5, %o3, %o5 ! clear other bits 2987c478bd9Sstevel@tonic-gate andn %o2, %o3, %o4 ! clear target bits 2997c478bd9Sstevel@tonic-gate or %o4, %o5, %o5 ! insert the new value 3007c478bd9Sstevel@tonic-gate cas [%o0], %o2, %o5 3017c478bd9Sstevel@tonic-gate cmp %o2, %o5 3027c478bd9Sstevel@tonic-gate bne,a,pn %icc, 1b 3037c478bd9Sstevel@tonic-gate mov %o5, %o2 ! %o2 = old value 3047c478bd9Sstevel@tonic-gate add %o1, %o2, %o5 3057c478bd9Sstevel@tonic-gate and %o5, %o3, %o5 3067c478bd9Sstevel@tonic-gate retl 3077c478bd9Sstevel@tonic-gate srl %o5, %g1, %o0 ! %o0 = new value 3087c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_short_nv) 3097c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_short) 3107c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_16_nv) 3117c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_16) 3127c478bd9Sstevel@tonic-gate 313dfb96a4fSab196087 /* 314dfb96a4fSab196087 * NOTE: If atomic_inc_32 and atomic_inc_32_nv are ever 315dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 316dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 317dfb96a4fSab196087 * from atomic_inc_32_nv. 318dfb96a4fSab196087 */ 3197c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_32) 3207c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_32_nv) 3217c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_uint) 3227c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_uint_nv) 3237c478bd9Sstevel@tonic-gate ba add_32 3247c478bd9Sstevel@tonic-gate add %g0, 1, %o1 3257c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_uint_nv) 3267c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_uint) 3277c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_32_nv) 3287c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_32) 3297c478bd9Sstevel@tonic-gate 330dfb96a4fSab196087 /* 331dfb96a4fSab196087 * NOTE: If atomic_dec_32 and atomic_dec_32_nv are ever 332dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 333dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 334dfb96a4fSab196087 * from atomic_dec_32_nv. 335dfb96a4fSab196087 */ 3367c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_32) 3377c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_32_nv) 3387c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_uint) 3397c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_uint_nv) 3407c478bd9Sstevel@tonic-gate ba add_32 3417c478bd9Sstevel@tonic-gate sub %g0, 1, %o1 3427c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_uint_nv) 3437c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_uint) 3447c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_32_nv) 3457c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_32) 3467c478bd9Sstevel@tonic-gate 347dfb96a4fSab196087 /* 348dfb96a4fSab196087 * NOTE: If atomic_add_32 and atomic_add_32_nv are ever 349dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 350dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 351dfb96a4fSab196087 * from atomic_add_32_nv. 352dfb96a4fSab196087 */ 3537c478bd9Sstevel@tonic-gate ENTRY(atomic_add_32) 3547c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_32_nv) 3557c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_int) 3567c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_int_nv) 3577c478bd9Sstevel@tonic-gateadd_32: 358895ca178Sae112802 ATOMIC_BACKOFF_INIT(%o4, %g4, %g5) 359895ca178Sae1128020: 3607c478bd9Sstevel@tonic-gate ld [%o0], %o2 3617c478bd9Sstevel@tonic-gate1: 3627c478bd9Sstevel@tonic-gate add %o2, %o1, %o3 3637c478bd9Sstevel@tonic-gate cas [%o0], %o2, %o3 3647c478bd9Sstevel@tonic-gate cmp %o2, %o3 365895ca178Sae112802 ATOMIC_BACKOFF_BRANCH(%icc, 2f, 1b) 3667c478bd9Sstevel@tonic-gate mov %o3, %o2 3677c478bd9Sstevel@tonic-gate retl 3687c478bd9Sstevel@tonic-gate add %o2, %o1, %o0 ! return new value 369895ca178Sae1128022: 370895ca178Sae112802 ATOMIC_BACKOFF_BACKOFF(%o4, %o5, %g4, %g5, add32, 0b) 3717c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_int_nv) 3727c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_int) 3737c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_32_nv) 3747c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_32) 3757c478bd9Sstevel@tonic-gate 376dfb96a4fSab196087 /* 377dfb96a4fSab196087 * NOTE: If atomic_inc_64 and atomic_inc_64_nv are ever 378dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 379dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 380dfb96a4fSab196087 * from atomic_inc_64_nv. 381dfb96a4fSab196087 */ 3827c478bd9Sstevel@tonic-gate ENTRY(atomic_inc_64) 3837c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_64_nv) 3847c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_ulong) 3857c478bd9Sstevel@tonic-gate ALTENTRY(atomic_inc_ulong_nv) 3867c478bd9Sstevel@tonic-gate ba add_64 3877c478bd9Sstevel@tonic-gate add %g0, 1, %o1 3887c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_ulong_nv) 3897c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_ulong) 3907c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_64_nv) 3917c478bd9Sstevel@tonic-gate SET_SIZE(atomic_inc_64) 3927c478bd9Sstevel@tonic-gate 393dfb96a4fSab196087 /* 394dfb96a4fSab196087 * NOTE: If atomic_dec_64 and atomic_dec_64_nv are ever 395dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 396dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 397dfb96a4fSab196087 * from atomic_dec_64_nv. 398dfb96a4fSab196087 */ 3997c478bd9Sstevel@tonic-gate ENTRY(atomic_dec_64) 4007c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_64_nv) 4017c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_ulong) 4027c478bd9Sstevel@tonic-gate ALTENTRY(atomic_dec_ulong_nv) 4037c478bd9Sstevel@tonic-gate ba add_64 4047c478bd9Sstevel@tonic-gate sub %g0, 1, %o1 4057c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_ulong_nv) 4067c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_ulong) 4077c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_64_nv) 4087c478bd9Sstevel@tonic-gate SET_SIZE(atomic_dec_64) 4097c478bd9Sstevel@tonic-gate 410dfb96a4fSab196087 /* 411dfb96a4fSab196087 * NOTE: If atomic_add_64 and atomic_add_64_nv are ever 412dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 413dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 414dfb96a4fSab196087 * from atomic_add_64_nv. 415dfb96a4fSab196087 */ 4167c478bd9Sstevel@tonic-gate ENTRY(atomic_add_64) 4177c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_64_nv) 4187c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_ptr) 4197c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_ptr_nv) 4207c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_long) 4217c478bd9Sstevel@tonic-gate ALTENTRY(atomic_add_long_nv) 4227c478bd9Sstevel@tonic-gateadd_64: 423895ca178Sae112802 ATOMIC_BACKOFF_INIT(%o4, %g4, %g5) 424895ca178Sae1128020: 4257c478bd9Sstevel@tonic-gate ldx [%o0], %o2 4267c478bd9Sstevel@tonic-gate1: 4277c478bd9Sstevel@tonic-gate add %o2, %o1, %o3 4287c478bd9Sstevel@tonic-gate casx [%o0], %o2, %o3 4297c478bd9Sstevel@tonic-gate cmp %o2, %o3 430895ca178Sae112802 ATOMIC_BACKOFF_BRANCH(%xcc, 2f, 1b) 4317c478bd9Sstevel@tonic-gate mov %o3, %o2 4327c478bd9Sstevel@tonic-gate retl 4337c478bd9Sstevel@tonic-gate add %o2, %o1, %o0 ! return new value 434895ca178Sae1128022: 435895ca178Sae112802 ATOMIC_BACKOFF_BACKOFF(%o4, %o5, %g4, %g5, add64, 0b) 4367c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_long_nv) 4377c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_long) 4387c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_ptr_nv) 4397c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_ptr) 4407c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_64_nv) 4417c478bd9Sstevel@tonic-gate SET_SIZE(atomic_add_64) 4427c478bd9Sstevel@tonic-gate 443dfb96a4fSab196087 /* 444dfb96a4fSab196087 * NOTE: If atomic_or_8 and atomic_or_8_nv are ever 445dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 446dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 447dfb96a4fSab196087 * from atomic_or_8_nv. 448dfb96a4fSab196087 */ 4497c478bd9Sstevel@tonic-gate ENTRY(atomic_or_8) 4507c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_8_nv) 4517c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_uchar) 4527c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_uchar_nv) 4537c478bd9Sstevel@tonic-gate and %o0, 0x3, %o4 ! %o4 = byte offset, left-to-right 4547c478bd9Sstevel@tonic-gate xor %o4, 0x3, %g1 ! %g1 = byte offset, right-to-left 4557c478bd9Sstevel@tonic-gate sll %g1, 3, %g1 ! %g1 = bit offset, right-to-left 4567c478bd9Sstevel@tonic-gate set 0xff, %o3 ! %o3 = mask 4577c478bd9Sstevel@tonic-gate sll %o3, %g1, %o3 ! %o3 = shifted to bit offset 4587c478bd9Sstevel@tonic-gate sll %o1, %g1, %o1 ! %o1 = shifted to bit offset 4597c478bd9Sstevel@tonic-gate and %o1, %o3, %o1 ! %o1 = single byte value 4607c478bd9Sstevel@tonic-gate andn %o0, 0x3, %o0 ! %o0 = word address 4617c478bd9Sstevel@tonic-gate ld [%o0], %o2 ! read old value 4627c478bd9Sstevel@tonic-gate1: 4637c478bd9Sstevel@tonic-gate or %o2, %o1, %o5 ! or in the new value 4647c478bd9Sstevel@tonic-gate cas [%o0], %o2, %o5 4657c478bd9Sstevel@tonic-gate cmp %o2, %o5 4667c478bd9Sstevel@tonic-gate bne,a,pn %icc, 1b 4677c478bd9Sstevel@tonic-gate mov %o5, %o2 ! %o2 = old value 4687c478bd9Sstevel@tonic-gate or %o2, %o1, %o5 4697c478bd9Sstevel@tonic-gate and %o5, %o3, %o5 4707c478bd9Sstevel@tonic-gate retl 4717c478bd9Sstevel@tonic-gate srl %o5, %g1, %o0 ! %o0 = new value 4727c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_uchar_nv) 4737c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_uchar) 4747c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_8_nv) 4757c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_8) 4767c478bd9Sstevel@tonic-gate 477dfb96a4fSab196087 /* 478dfb96a4fSab196087 * NOTE: If atomic_or_16 and atomic_or_16_nv are ever 479dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 480dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 481dfb96a4fSab196087 * from atomic_or_16_nv. 482dfb96a4fSab196087 */ 4837c478bd9Sstevel@tonic-gate ENTRY(atomic_or_16) 4847c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_16_nv) 4857c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_ushort) 4867c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_ushort_nv) 4877c478bd9Sstevel@tonic-gate and %o0, 0x2, %o4 ! %o4 = byte offset, left-to-right 4887c478bd9Sstevel@tonic-gate xor %o4, 0x2, %g1 ! %g1 = byte offset, right-to-left 4897c478bd9Sstevel@tonic-gate sll %o4, 3, %o4 ! %o4 = bit offset, left-to-right 4907c478bd9Sstevel@tonic-gate sll %g1, 3, %g1 ! %g1 = bit offset, right-to-left 4917c478bd9Sstevel@tonic-gate sethi %hi(0xffff0000), %o3 ! %o3 = mask 4927c478bd9Sstevel@tonic-gate srl %o3, %o4, %o3 ! %o3 = shifted to bit offset 4937c478bd9Sstevel@tonic-gate sll %o1, %g1, %o1 ! %o1 = shifted to bit offset 4947c478bd9Sstevel@tonic-gate and %o1, %o3, %o1 ! %o1 = single short value 4957c478bd9Sstevel@tonic-gate andn %o0, 0x2, %o0 ! %o0 = word address 4967c478bd9Sstevel@tonic-gate ! if low-order bit is 1, we will properly get an alignment fault here 4977c478bd9Sstevel@tonic-gate ld [%o0], %o2 ! read old value 4987c478bd9Sstevel@tonic-gate1: 4997c478bd9Sstevel@tonic-gate or %o2, %o1, %o5 ! or in the new value 5007c478bd9Sstevel@tonic-gate cas [%o0], %o2, %o5 5017c478bd9Sstevel@tonic-gate cmp %o2, %o5 5027c478bd9Sstevel@tonic-gate bne,a,pn %icc, 1b 5037c478bd9Sstevel@tonic-gate mov %o5, %o2 ! %o2 = old value 5047c478bd9Sstevel@tonic-gate or %o2, %o1, %o5 ! or in the new value 5057c478bd9Sstevel@tonic-gate and %o5, %o3, %o5 5067c478bd9Sstevel@tonic-gate retl 5077c478bd9Sstevel@tonic-gate srl %o5, %g1, %o0 ! %o0 = new value 5087c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_ushort_nv) 5097c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_ushort) 5107c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_16_nv) 5117c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_16) 5127c478bd9Sstevel@tonic-gate 513dfb96a4fSab196087 /* 514dfb96a4fSab196087 * NOTE: If atomic_or_32 and atomic_or_32_nv are ever 515dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 516dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 517dfb96a4fSab196087 * from atomic_or_32_nv. 518dfb96a4fSab196087 */ 5197c478bd9Sstevel@tonic-gate ENTRY(atomic_or_32) 5207c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_32_nv) 5217c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_uint) 5227c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_uint_nv) 523895ca178Sae112802 ATOMIC_BACKOFF_INIT(%o4, %g4, %g5) 524895ca178Sae1128020: 5257c478bd9Sstevel@tonic-gate ld [%o0], %o2 5267c478bd9Sstevel@tonic-gate1: 5277c478bd9Sstevel@tonic-gate or %o2, %o1, %o3 5287c478bd9Sstevel@tonic-gate cas [%o0], %o2, %o3 5297c478bd9Sstevel@tonic-gate cmp %o2, %o3 530895ca178Sae112802 ATOMIC_BACKOFF_BRANCH(%icc, 2f, 1b) 5317c478bd9Sstevel@tonic-gate mov %o3, %o2 5327c478bd9Sstevel@tonic-gate retl 5337c478bd9Sstevel@tonic-gate or %o2, %o1, %o0 ! return new value 534895ca178Sae1128022: 535895ca178Sae112802 ATOMIC_BACKOFF_BACKOFF(%o4, %o5, %g4, %g5, or32, 0b) 5367c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_uint_nv) 5377c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_uint) 5387c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_32_nv) 5397c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_32) 5407c478bd9Sstevel@tonic-gate 541dfb96a4fSab196087 /* 542dfb96a4fSab196087 * NOTE: If atomic_or_64 and atomic_or_64_nv are ever 543dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 544dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 545dfb96a4fSab196087 * from atomic_or_64_nv. 546dfb96a4fSab196087 */ 5477c478bd9Sstevel@tonic-gate ENTRY(atomic_or_64) 5487c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_64_nv) 5497c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_ulong) 5507c478bd9Sstevel@tonic-gate ALTENTRY(atomic_or_ulong_nv) 551895ca178Sae112802 ATOMIC_BACKOFF_INIT(%o4, %g4, %g5) 552895ca178Sae1128020: 5537c478bd9Sstevel@tonic-gate ldx [%o0], %o2 5547c478bd9Sstevel@tonic-gate1: 5557c478bd9Sstevel@tonic-gate or %o2, %o1, %o3 5567c478bd9Sstevel@tonic-gate casx [%o0], %o2, %o3 5577c478bd9Sstevel@tonic-gate cmp %o2, %o3 558895ca178Sae112802 ATOMIC_BACKOFF_BRANCH(%xcc, 2f, 1b) 5597c478bd9Sstevel@tonic-gate mov %o3, %o2 5607c478bd9Sstevel@tonic-gate retl 5617c478bd9Sstevel@tonic-gate or %o2, %o1, %o0 ! return new value 562895ca178Sae1128022: 563895ca178Sae112802 ATOMIC_BACKOFF_BACKOFF(%o4, %o5, %g4, %g5, or64, 0b) 5647c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_ulong_nv) 5657c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_ulong) 5667c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_64_nv) 5677c478bd9Sstevel@tonic-gate SET_SIZE(atomic_or_64) 5687c478bd9Sstevel@tonic-gate 569dfb96a4fSab196087 /* 570dfb96a4fSab196087 * NOTE: If atomic_and_8 and atomic_and_8_nv are ever 571dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 572dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 573dfb96a4fSab196087 * from atomic_and_8_nv. 574dfb96a4fSab196087 */ 5757c478bd9Sstevel@tonic-gate ENTRY(atomic_and_8) 5767c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_8_nv) 5777c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_uchar) 5787c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_uchar_nv) 5797c478bd9Sstevel@tonic-gate and %o0, 0x3, %o4 ! %o4 = byte offset, left-to-right 5807c478bd9Sstevel@tonic-gate xor %o4, 0x3, %g1 ! %g1 = byte offset, right-to-left 5817c478bd9Sstevel@tonic-gate sll %g1, 3, %g1 ! %g1 = bit offset, right-to-left 5827c478bd9Sstevel@tonic-gate set 0xff, %o3 ! %o3 = mask 5837c478bd9Sstevel@tonic-gate sll %o3, %g1, %o3 ! %o3 = shifted to bit offset 5847c478bd9Sstevel@tonic-gate sll %o1, %g1, %o1 ! %o1 = shifted to bit offset 5857c478bd9Sstevel@tonic-gate orn %o1, %o3, %o1 ! all ones in other bytes 5867c478bd9Sstevel@tonic-gate andn %o0, 0x3, %o0 ! %o0 = word address 5877c478bd9Sstevel@tonic-gate ld [%o0], %o2 ! read old value 5887c478bd9Sstevel@tonic-gate1: 5897c478bd9Sstevel@tonic-gate and %o2, %o1, %o5 ! and in the new value 5907c478bd9Sstevel@tonic-gate cas [%o0], %o2, %o5 5917c478bd9Sstevel@tonic-gate cmp %o2, %o5 5927c478bd9Sstevel@tonic-gate bne,a,pn %icc, 1b 5937c478bd9Sstevel@tonic-gate mov %o5, %o2 ! %o2 = old value 5947c478bd9Sstevel@tonic-gate and %o2, %o1, %o5 5957c478bd9Sstevel@tonic-gate and %o5, %o3, %o5 5967c478bd9Sstevel@tonic-gate retl 5977c478bd9Sstevel@tonic-gate srl %o5, %g1, %o0 ! %o0 = new value 5987c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_uchar_nv) 5997c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_uchar) 6007c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_8_nv) 6017c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_8) 6027c478bd9Sstevel@tonic-gate 603dfb96a4fSab196087 /* 604dfb96a4fSab196087 * NOTE: If atomic_and_16 and atomic_and_16_nv are ever 605dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 606dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 607dfb96a4fSab196087 * from atomic_and_16_nv. 608dfb96a4fSab196087 */ 6097c478bd9Sstevel@tonic-gate ENTRY(atomic_and_16) 6107c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_16_nv) 6117c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_ushort) 6127c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_ushort_nv) 6137c478bd9Sstevel@tonic-gate and %o0, 0x2, %o4 ! %o4 = byte offset, left-to-right 6147c478bd9Sstevel@tonic-gate xor %o4, 0x2, %g1 ! %g1 = byte offset, right-to-left 6157c478bd9Sstevel@tonic-gate sll %o4, 3, %o4 ! %o4 = bit offset, left-to-right 6167c478bd9Sstevel@tonic-gate sll %g1, 3, %g1 ! %g1 = bit offset, right-to-left 6177c478bd9Sstevel@tonic-gate sethi %hi(0xffff0000), %o3 ! %o3 = mask 6187c478bd9Sstevel@tonic-gate srl %o3, %o4, %o3 ! %o3 = shifted to bit offset 6197c478bd9Sstevel@tonic-gate sll %o1, %g1, %o1 ! %o1 = shifted to bit offset 6207c478bd9Sstevel@tonic-gate orn %o1, %o3, %o1 ! all ones in the other half 6217c478bd9Sstevel@tonic-gate andn %o0, 0x2, %o0 ! %o0 = word address 6227c478bd9Sstevel@tonic-gate ! if low-order bit is 1, we will properly get an alignment fault here 6237c478bd9Sstevel@tonic-gate ld [%o0], %o2 ! read old value 6247c478bd9Sstevel@tonic-gate1: 6257c478bd9Sstevel@tonic-gate and %o2, %o1, %o5 ! and in the new value 6267c478bd9Sstevel@tonic-gate cas [%o0], %o2, %o5 6277c478bd9Sstevel@tonic-gate cmp %o2, %o5 6287c478bd9Sstevel@tonic-gate bne,a,pn %icc, 1b 6297c478bd9Sstevel@tonic-gate mov %o5, %o2 ! %o2 = old value 6307c478bd9Sstevel@tonic-gate and %o2, %o1, %o5 6317c478bd9Sstevel@tonic-gate and %o5, %o3, %o5 6327c478bd9Sstevel@tonic-gate retl 6337c478bd9Sstevel@tonic-gate srl %o5, %g1, %o0 ! %o0 = new value 6347c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_ushort_nv) 6357c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_ushort) 6367c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_16_nv) 6377c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_16) 6387c478bd9Sstevel@tonic-gate 639dfb96a4fSab196087 /* 640dfb96a4fSab196087 * NOTE: If atomic_and_32 and atomic_and_32_nv are ever 641dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 642dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 643dfb96a4fSab196087 * from atomic_and_32_nv. 644dfb96a4fSab196087 */ 6457c478bd9Sstevel@tonic-gate ENTRY(atomic_and_32) 6467c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_32_nv) 6477c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_uint) 6487c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_uint_nv) 649895ca178Sae112802 ATOMIC_BACKOFF_INIT(%o4, %g4, %g5) 650895ca178Sae1128020: 6517c478bd9Sstevel@tonic-gate ld [%o0], %o2 6527c478bd9Sstevel@tonic-gate1: 6537c478bd9Sstevel@tonic-gate and %o2, %o1, %o3 6547c478bd9Sstevel@tonic-gate cas [%o0], %o2, %o3 6557c478bd9Sstevel@tonic-gate cmp %o2, %o3 656895ca178Sae112802 ATOMIC_BACKOFF_BRANCH(%icc, 2f, 1b) 6577c478bd9Sstevel@tonic-gate mov %o3, %o2 6587c478bd9Sstevel@tonic-gate retl 6597c478bd9Sstevel@tonic-gate and %o2, %o1, %o0 ! return new value 660895ca178Sae1128022: 661895ca178Sae112802 ATOMIC_BACKOFF_BACKOFF(%o4, %o5, %g4, %g5, and32, 0b) 6627c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_uint_nv) 6637c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_uint) 6647c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_32_nv) 6657c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_32) 6667c478bd9Sstevel@tonic-gate 667dfb96a4fSab196087 /* 668dfb96a4fSab196087 * NOTE: If atomic_and_64 and atomic_and_64_nv are ever 669dfb96a4fSab196087 * separated, you need to also edit the libc sparcv9 platform 670dfb96a4fSab196087 * specific mapfile and remove the NODYNSORT attribute 671dfb96a4fSab196087 * from atomic_and_64_nv. 672dfb96a4fSab196087 */ 6737c478bd9Sstevel@tonic-gate ENTRY(atomic_and_64) 6747c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_64_nv) 6757c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_ulong) 6767c478bd9Sstevel@tonic-gate ALTENTRY(atomic_and_ulong_nv) 677895ca178Sae112802 ATOMIC_BACKOFF_INIT(%o4, %g4, %g5) 678895ca178Sae1128020: 6797c478bd9Sstevel@tonic-gate ldx [%o0], %o2 6807c478bd9Sstevel@tonic-gate1: 6817c478bd9Sstevel@tonic-gate and %o2, %o1, %o3 6827c478bd9Sstevel@tonic-gate casx [%o0], %o2, %o3 6837c478bd9Sstevel@tonic-gate cmp %o2, %o3 684895ca178Sae112802 ATOMIC_BACKOFF_BRANCH(%xcc, 2f, 1b) 6857c478bd9Sstevel@tonic-gate mov %o3, %o2 6867c478bd9Sstevel@tonic-gate retl 6877c478bd9Sstevel@tonic-gate and %o2, %o1, %o0 ! return new value 688895ca178Sae1128022: 689895ca178Sae112802 ATOMIC_BACKOFF_BACKOFF(%o4, %o5, %g4, %g5, and64, 0b) 6907c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_ulong_nv) 6917c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_ulong) 6927c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_64_nv) 6937c478bd9Sstevel@tonic-gate SET_SIZE(atomic_and_64) 6947c478bd9Sstevel@tonic-gate 6957c478bd9Sstevel@tonic-gate ENTRY(atomic_cas_8) 6967c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_uchar) 6977c478bd9Sstevel@tonic-gate and %o0, 0x3, %o4 ! %o4 = byte offset, left-to-right 6987c478bd9Sstevel@tonic-gate xor %o4, 0x3, %g1 ! %g1 = byte offset, right-to-left 6997c478bd9Sstevel@tonic-gate sll %g1, 3, %g1 ! %g1 = bit offset, right-to-left 7007c478bd9Sstevel@tonic-gate set 0xff, %o3 ! %o3 = mask 7017c478bd9Sstevel@tonic-gate sll %o3, %g1, %o3 ! %o3 = shifted to bit offset 7027c478bd9Sstevel@tonic-gate sll %o1, %g1, %o1 ! %o1 = shifted to bit offset 7037c478bd9Sstevel@tonic-gate and %o1, %o3, %o1 ! %o1 = single byte value 7047c478bd9Sstevel@tonic-gate sll %o2, %g1, %o2 ! %o2 = shifted to bit offset 7057c478bd9Sstevel@tonic-gate and %o2, %o3, %o2 ! %o2 = single byte value 7067c478bd9Sstevel@tonic-gate andn %o0, 0x3, %o0 ! %o0 = word address 7077c478bd9Sstevel@tonic-gate ld [%o0], %o4 ! read old value 7087c478bd9Sstevel@tonic-gate1: 7097c478bd9Sstevel@tonic-gate andn %o4, %o3, %o4 ! clear target bits 7107c478bd9Sstevel@tonic-gate or %o4, %o2, %o5 ! insert the new value 7117c478bd9Sstevel@tonic-gate or %o4, %o1, %o4 ! insert the comparison value 7127c478bd9Sstevel@tonic-gate cas [%o0], %o4, %o5 7137c478bd9Sstevel@tonic-gate cmp %o4, %o5 ! did we succeed? 7147c478bd9Sstevel@tonic-gate be,pt %icc, 2f 7157c478bd9Sstevel@tonic-gate and %o5, %o3, %o4 ! isolate the old value 7167c478bd9Sstevel@tonic-gate cmp %o1, %o4 ! should we have succeeded? 7177c478bd9Sstevel@tonic-gate be,a,pt %icc, 1b ! yes, try again 7187c478bd9Sstevel@tonic-gate mov %o5, %o4 ! %o4 = old value 7197c478bd9Sstevel@tonic-gate2: 7207c478bd9Sstevel@tonic-gate retl 7217c478bd9Sstevel@tonic-gate srl %o4, %g1, %o0 ! %o0 = old value 7227c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_uchar) 7237c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_8) 7247c478bd9Sstevel@tonic-gate 7257c478bd9Sstevel@tonic-gate ENTRY(atomic_cas_16) 7267c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_ushort) 7277c478bd9Sstevel@tonic-gate and %o0, 0x2, %o4 ! %o4 = byte offset, left-to-right 7287c478bd9Sstevel@tonic-gate xor %o4, 0x2, %g1 ! %g1 = byte offset, right-to-left 7297c478bd9Sstevel@tonic-gate sll %o4, 3, %o4 ! %o4 = bit offset, left-to-right 7307c478bd9Sstevel@tonic-gate sll %g1, 3, %g1 ! %g1 = bit offset, right-to-left 7317c478bd9Sstevel@tonic-gate sethi %hi(0xffff0000), %o3 ! %o3 = mask 7327c478bd9Sstevel@tonic-gate srl %o3, %o4, %o3 ! %o3 = shifted to bit offset 7337c478bd9Sstevel@tonic-gate sll %o1, %g1, %o1 ! %o1 = shifted to bit offset 7347c478bd9Sstevel@tonic-gate and %o1, %o3, %o1 ! %o1 = single short value 7357c478bd9Sstevel@tonic-gate sll %o2, %g1, %o2 ! %o2 = shifted to bit offset 7367c478bd9Sstevel@tonic-gate and %o2, %o3, %o2 ! %o2 = single short value 7377c478bd9Sstevel@tonic-gate andn %o0, 0x2, %o0 ! %o0 = word address 7387c478bd9Sstevel@tonic-gate ! if low-order bit is 1, we will properly get an alignment fault here 7397c478bd9Sstevel@tonic-gate ld [%o0], %o4 ! read old value 7407c478bd9Sstevel@tonic-gate1: 7417c478bd9Sstevel@tonic-gate andn %o4, %o3, %o4 ! clear target bits 7427c478bd9Sstevel@tonic-gate or %o4, %o2, %o5 ! insert the new value 7437c478bd9Sstevel@tonic-gate or %o4, %o1, %o4 ! insert the comparison value 7447c478bd9Sstevel@tonic-gate cas [%o0], %o4, %o5 7457c478bd9Sstevel@tonic-gate cmp %o4, %o5 ! did we succeed? 7467c478bd9Sstevel@tonic-gate be,pt %icc, 2f 7477c478bd9Sstevel@tonic-gate and %o5, %o3, %o4 ! isolate the old value 7487c478bd9Sstevel@tonic-gate cmp %o1, %o4 ! should we have succeeded? 7497c478bd9Sstevel@tonic-gate be,a,pt %icc, 1b ! yes, try again 7507c478bd9Sstevel@tonic-gate mov %o5, %o4 ! %o4 = old value 7517c478bd9Sstevel@tonic-gate2: 7527c478bd9Sstevel@tonic-gate retl 7537c478bd9Sstevel@tonic-gate srl %o4, %g1, %o0 ! %o0 = old value 7547c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_ushort) 7557c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_16) 7567c478bd9Sstevel@tonic-gate 7577c478bd9Sstevel@tonic-gate ENTRY(atomic_cas_32) 7587c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_uint) 7597c478bd9Sstevel@tonic-gate cas [%o0], %o1, %o2 7607c478bd9Sstevel@tonic-gate retl 7617c478bd9Sstevel@tonic-gate mov %o2, %o0 7627c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_uint) 7637c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_32) 7647c478bd9Sstevel@tonic-gate 7657c478bd9Sstevel@tonic-gate ENTRY(atomic_cas_64) 7667c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_ptr) 7677c478bd9Sstevel@tonic-gate ALTENTRY(atomic_cas_ulong) 7687c478bd9Sstevel@tonic-gate casx [%o0], %o1, %o2 7697c478bd9Sstevel@tonic-gate retl 7707c478bd9Sstevel@tonic-gate mov %o2, %o0 7717c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_ulong) 7727c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_ptr) 7737c478bd9Sstevel@tonic-gate SET_SIZE(atomic_cas_64) 7747c478bd9Sstevel@tonic-gate 7757c478bd9Sstevel@tonic-gate ENTRY(atomic_swap_8) 7767c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_uchar) 7777c478bd9Sstevel@tonic-gate and %o0, 0x3, %o4 ! %o4 = byte offset, left-to-right 7787c478bd9Sstevel@tonic-gate xor %o4, 0x3, %g1 ! %g1 = byte offset, right-to-left 7797c478bd9Sstevel@tonic-gate sll %g1, 3, %g1 ! %g1 = bit offset, right-to-left 7807c478bd9Sstevel@tonic-gate set 0xff, %o3 ! %o3 = mask 7817c478bd9Sstevel@tonic-gate sll %o3, %g1, %o3 ! %o3 = shifted to bit offset 7827c478bd9Sstevel@tonic-gate sll %o1, %g1, %o1 ! %o1 = shifted to bit offset 7837c478bd9Sstevel@tonic-gate and %o1, %o3, %o1 ! %o1 = single byte value 7847c478bd9Sstevel@tonic-gate andn %o0, 0x3, %o0 ! %o0 = word address 7857c478bd9Sstevel@tonic-gate ld [%o0], %o2 ! read old value 7867c478bd9Sstevel@tonic-gate1: 7877c478bd9Sstevel@tonic-gate andn %o2, %o3, %o5 ! clear target bits 7887c478bd9Sstevel@tonic-gate or %o5, %o1, %o5 ! insert the new value 7897c478bd9Sstevel@tonic-gate cas [%o0], %o2, %o5 7907c478bd9Sstevel@tonic-gate cmp %o2, %o5 7917c478bd9Sstevel@tonic-gate bne,a,pn %icc, 1b 7927c478bd9Sstevel@tonic-gate mov %o5, %o2 ! %o2 = old value 7937c478bd9Sstevel@tonic-gate and %o5, %o3, %o5 7947c478bd9Sstevel@tonic-gate retl 7957c478bd9Sstevel@tonic-gate srl %o5, %g1, %o0 ! %o0 = old value 7967c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_uchar) 7977c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_8) 7987c478bd9Sstevel@tonic-gate 7997c478bd9Sstevel@tonic-gate ENTRY(atomic_swap_16) 8007c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_ushort) 8017c478bd9Sstevel@tonic-gate and %o0, 0x2, %o4 ! %o4 = byte offset, left-to-right 8027c478bd9Sstevel@tonic-gate xor %o4, 0x2, %g1 ! %g1 = byte offset, right-to-left 8037c478bd9Sstevel@tonic-gate sll %o4, 3, %o4 ! %o4 = bit offset, left-to-right 8047c478bd9Sstevel@tonic-gate sll %g1, 3, %g1 ! %g1 = bit offset, right-to-left 8057c478bd9Sstevel@tonic-gate sethi %hi(0xffff0000), %o3 ! %o3 = mask 8067c478bd9Sstevel@tonic-gate srl %o3, %o4, %o3 ! %o3 = shifted to bit offset 8077c478bd9Sstevel@tonic-gate sll %o1, %g1, %o1 ! %o1 = shifted to bit offset 8087c478bd9Sstevel@tonic-gate and %o1, %o3, %o1 ! %o1 = single short value 8097c478bd9Sstevel@tonic-gate andn %o0, 0x2, %o0 ! %o0 = word address 8107c478bd9Sstevel@tonic-gate ! if low-order bit is 1, we will properly get an alignment fault here 8117c478bd9Sstevel@tonic-gate ld [%o0], %o2 ! read old value 8127c478bd9Sstevel@tonic-gate1: 8137c478bd9Sstevel@tonic-gate andn %o2, %o3, %o5 ! clear target bits 8147c478bd9Sstevel@tonic-gate or %o5, %o1, %o5 ! insert the new value 8157c478bd9Sstevel@tonic-gate cas [%o0], %o2, %o5 8167c478bd9Sstevel@tonic-gate cmp %o2, %o5 8177c478bd9Sstevel@tonic-gate bne,a,pn %icc, 1b 8187c478bd9Sstevel@tonic-gate mov %o5, %o2 ! %o2 = old value 8197c478bd9Sstevel@tonic-gate and %o5, %o3, %o5 8207c478bd9Sstevel@tonic-gate retl 8217c478bd9Sstevel@tonic-gate srl %o5, %g1, %o0 ! %o0 = old value 8227c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_ushort) 8237c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_16) 8247c478bd9Sstevel@tonic-gate 8257c478bd9Sstevel@tonic-gate ENTRY(atomic_swap_32) 8267c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_uint) 827895ca178Sae112802 ATOMIC_BACKOFF_INIT(%o4, %g4, %g5) 828895ca178Sae1128020: 8297c478bd9Sstevel@tonic-gate ld [%o0], %o2 8307c478bd9Sstevel@tonic-gate1: 8317c478bd9Sstevel@tonic-gate mov %o1, %o3 8327c478bd9Sstevel@tonic-gate cas [%o0], %o2, %o3 8337c478bd9Sstevel@tonic-gate cmp %o2, %o3 834895ca178Sae112802 ATOMIC_BACKOFF_BRANCH(%icc, 2f, 1b) 8357c478bd9Sstevel@tonic-gate mov %o3, %o2 8367c478bd9Sstevel@tonic-gate retl 8377c478bd9Sstevel@tonic-gate mov %o3, %o0 838895ca178Sae1128022: 839895ca178Sae112802 ATOMIC_BACKOFF_BACKOFF(%o4, %o5, %g4, %g5, swap32, 0b) 8407c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_uint) 8417c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_32) 8427c478bd9Sstevel@tonic-gate 8437c478bd9Sstevel@tonic-gate ENTRY(atomic_swap_64) 8447c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_ptr) 8457c478bd9Sstevel@tonic-gate ALTENTRY(atomic_swap_ulong) 846895ca178Sae112802 ATOMIC_BACKOFF_INIT(%o4, %g4, %g5) 847895ca178Sae1128020: 8487c478bd9Sstevel@tonic-gate ldx [%o0], %o2 8497c478bd9Sstevel@tonic-gate1: 8507c478bd9Sstevel@tonic-gate mov %o1, %o3 8517c478bd9Sstevel@tonic-gate casx [%o0], %o2, %o3 8527c478bd9Sstevel@tonic-gate cmp %o2, %o3 853895ca178Sae112802 ATOMIC_BACKOFF_BRANCH(%xcc, 2f, 1b) 8547c478bd9Sstevel@tonic-gate mov %o3, %o2 8557c478bd9Sstevel@tonic-gate retl 8567c478bd9Sstevel@tonic-gate mov %o3, %o0 857895ca178Sae1128022: 858895ca178Sae112802 ATOMIC_BACKOFF_BACKOFF(%o4, %o5, %g4, %g5, swap64, 0b) 8597c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_ulong) 8607c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_ptr) 8617c478bd9Sstevel@tonic-gate SET_SIZE(atomic_swap_64) 8627c478bd9Sstevel@tonic-gate 8637c478bd9Sstevel@tonic-gate ENTRY(atomic_set_long_excl) 864895ca178Sae112802 ATOMIC_BACKOFF_INIT(%o5, %g4, %g5) 8657c478bd9Sstevel@tonic-gate mov 1, %o3 8667c478bd9Sstevel@tonic-gate slln %o3, %o1, %o3 867895ca178Sae1128020: 8687c478bd9Sstevel@tonic-gate ldn [%o0], %o2 8697c478bd9Sstevel@tonic-gate1: 8707c478bd9Sstevel@tonic-gate andcc %o2, %o3, %g0 ! test if the bit is set 8717c478bd9Sstevel@tonic-gate bnz,a,pn %ncc, 2f ! if so, then fail out 8727c478bd9Sstevel@tonic-gate mov -1, %o0 8737c478bd9Sstevel@tonic-gate or %o2, %o3, %o4 ! set the bit, and try to commit it 8747c478bd9Sstevel@tonic-gate casn [%o0], %o2, %o4 8757c478bd9Sstevel@tonic-gate cmp %o2, %o4 876895ca178Sae112802 ATOMIC_BACKOFF_BRANCH(%ncc, 5f, 1b) 8777c478bd9Sstevel@tonic-gate mov %o4, %o2 8787c478bd9Sstevel@tonic-gate mov %g0, %o0 8797c478bd9Sstevel@tonic-gate2: 8807c478bd9Sstevel@tonic-gate retl 8817c478bd9Sstevel@tonic-gate nop 882895ca178Sae1128025: 883895ca178Sae112802 ATOMIC_BACKOFF_BACKOFF(%o5, %g1, %g4, %g5, setlongexcl, 0b) 8847c478bd9Sstevel@tonic-gate SET_SIZE(atomic_set_long_excl) 8857c478bd9Sstevel@tonic-gate 8867c478bd9Sstevel@tonic-gate ENTRY(atomic_clear_long_excl) 887895ca178Sae112802 ATOMIC_BACKOFF_INIT(%o5, %g4, %g5) 8887c478bd9Sstevel@tonic-gate mov 1, %o3 8897c478bd9Sstevel@tonic-gate slln %o3, %o1, %o3 890895ca178Sae1128020: 8917c478bd9Sstevel@tonic-gate ldn [%o0], %o2 8927c478bd9Sstevel@tonic-gate1: 8937c478bd9Sstevel@tonic-gate andncc %o3, %o2, %g0 ! test if the bit is clear 8947c478bd9Sstevel@tonic-gate bnz,a,pn %ncc, 2f ! if so, then fail out 8957c478bd9Sstevel@tonic-gate mov -1, %o0 8967c478bd9Sstevel@tonic-gate andn %o2, %o3, %o4 ! clear the bit, and try to commit it 8977c478bd9Sstevel@tonic-gate casn [%o0], %o2, %o4 8987c478bd9Sstevel@tonic-gate cmp %o2, %o4 899895ca178Sae112802 ATOMIC_BACKOFF_BRANCH(%ncc, 5f, 1b) 9007c478bd9Sstevel@tonic-gate mov %o4, %o2 9017c478bd9Sstevel@tonic-gate mov %g0, %o0 9027c478bd9Sstevel@tonic-gate2: 9037c478bd9Sstevel@tonic-gate retl 9047c478bd9Sstevel@tonic-gate nop 905895ca178Sae1128025: 906895ca178Sae112802 ATOMIC_BACKOFF_BACKOFF(%o5, %g1, %g4, %g5, clrlongexcl, 0b) 9077c478bd9Sstevel@tonic-gate SET_SIZE(atomic_clear_long_excl) 9087c478bd9Sstevel@tonic-gate 9097c478bd9Sstevel@tonic-gate#if !defined(_KERNEL) 9107c478bd9Sstevel@tonic-gate 9117c478bd9Sstevel@tonic-gate /* 9127c478bd9Sstevel@tonic-gate * Spitfires and Blackbirds have a problem with membars in the 9137c478bd9Sstevel@tonic-gate * delay slot (SF_ERRATA_51). For safety's sake, we assume 9147c478bd9Sstevel@tonic-gate * that the whole world needs the workaround. 9157c478bd9Sstevel@tonic-gate */ 9167c478bd9Sstevel@tonic-gate ENTRY(membar_enter) 9177c478bd9Sstevel@tonic-gate membar #StoreLoad|#StoreStore 9187c478bd9Sstevel@tonic-gate retl 9197c478bd9Sstevel@tonic-gate nop 9207c478bd9Sstevel@tonic-gate SET_SIZE(membar_enter) 9217c478bd9Sstevel@tonic-gate 9227c478bd9Sstevel@tonic-gate ENTRY(membar_exit) 9237c478bd9Sstevel@tonic-gate membar #LoadStore|#StoreStore 9247c478bd9Sstevel@tonic-gate retl 9257c478bd9Sstevel@tonic-gate nop 9267c478bd9Sstevel@tonic-gate SET_SIZE(membar_exit) 9277c478bd9Sstevel@tonic-gate 9287c478bd9Sstevel@tonic-gate ENTRY(membar_producer) 9297c478bd9Sstevel@tonic-gate membar #StoreStore 9307c478bd9Sstevel@tonic-gate retl 9317c478bd9Sstevel@tonic-gate nop 9327c478bd9Sstevel@tonic-gate SET_SIZE(membar_producer) 9337c478bd9Sstevel@tonic-gate 9347c478bd9Sstevel@tonic-gate ENTRY(membar_consumer) 9357c478bd9Sstevel@tonic-gate membar #LoadLoad 9367c478bd9Sstevel@tonic-gate retl 9377c478bd9Sstevel@tonic-gate nop 9387c478bd9Sstevel@tonic-gate SET_SIZE(membar_consumer) 9397c478bd9Sstevel@tonic-gate 9407c478bd9Sstevel@tonic-gate#endif /* !_KERNEL */ 941