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 #pragma ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate #include <sys/atomic.h> 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate /* 32*7c478bd9Sstevel@tonic-gate * This file exists only for the purpose of running lint. 33*7c478bd9Sstevel@tonic-gate */ 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate #if defined(__lint) 36*7c478bd9Sstevel@tonic-gate 37*7c478bd9Sstevel@tonic-gate void 38*7c478bd9Sstevel@tonic-gate atomic_inc_8(volatile uint8_t *target) 39*7c478bd9Sstevel@tonic-gate { (*target)++; } 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate void 42*7c478bd9Sstevel@tonic-gate atomic_inc_uchar(volatile uchar_t *target) 43*7c478bd9Sstevel@tonic-gate { (*target)++; } 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate void 46*7c478bd9Sstevel@tonic-gate atomic_inc_16(volatile uint16_t *target) 47*7c478bd9Sstevel@tonic-gate { (*target)++; } 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate void 50*7c478bd9Sstevel@tonic-gate atomic_inc_ushort(volatile ushort_t *target) 51*7c478bd9Sstevel@tonic-gate { (*target)++; } 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate void 54*7c478bd9Sstevel@tonic-gate atomic_inc_32(volatile uint32_t *target) 55*7c478bd9Sstevel@tonic-gate { (*target)++; } 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate void 58*7c478bd9Sstevel@tonic-gate atomic_inc_uint(volatile uint_t *target) 59*7c478bd9Sstevel@tonic-gate { (*target)++; } 60*7c478bd9Sstevel@tonic-gate 61*7c478bd9Sstevel@tonic-gate void 62*7c478bd9Sstevel@tonic-gate atomic_inc_ulong(volatile ulong_t *target) 63*7c478bd9Sstevel@tonic-gate { (*target)++; } 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate void 66*7c478bd9Sstevel@tonic-gate atomic_inc_64(volatile uint64_t *target) 67*7c478bd9Sstevel@tonic-gate { (*target)++; } 68*7c478bd9Sstevel@tonic-gate 69*7c478bd9Sstevel@tonic-gate void 70*7c478bd9Sstevel@tonic-gate atomic_dec_8(volatile uint8_t *target) 71*7c478bd9Sstevel@tonic-gate { (*target)--; } 72*7c478bd9Sstevel@tonic-gate 73*7c478bd9Sstevel@tonic-gate void 74*7c478bd9Sstevel@tonic-gate atomic_dec_uchar(volatile uchar_t *target) 75*7c478bd9Sstevel@tonic-gate { (*target)--; } 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate void 78*7c478bd9Sstevel@tonic-gate atomic_dec_16(volatile uint16_t *target) 79*7c478bd9Sstevel@tonic-gate { (*target)--; } 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate void 82*7c478bd9Sstevel@tonic-gate atomic_dec_ushort(volatile ushort_t *target) 83*7c478bd9Sstevel@tonic-gate { (*target)--; } 84*7c478bd9Sstevel@tonic-gate 85*7c478bd9Sstevel@tonic-gate void 86*7c478bd9Sstevel@tonic-gate atomic_dec_32(volatile uint32_t *target) 87*7c478bd9Sstevel@tonic-gate { (*target)--; } 88*7c478bd9Sstevel@tonic-gate 89*7c478bd9Sstevel@tonic-gate void 90*7c478bd9Sstevel@tonic-gate atomic_dec_uint(volatile uint_t *target) 91*7c478bd9Sstevel@tonic-gate { (*target)--; } 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate void 94*7c478bd9Sstevel@tonic-gate atomic_dec_ulong(volatile ulong_t *target) 95*7c478bd9Sstevel@tonic-gate { (*target)--; } 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate void 98*7c478bd9Sstevel@tonic-gate atomic_dec_64(volatile uint64_t *target) 99*7c478bd9Sstevel@tonic-gate { (*target)--; } 100*7c478bd9Sstevel@tonic-gate 101*7c478bd9Sstevel@tonic-gate void 102*7c478bd9Sstevel@tonic-gate atomic_add_8(volatile uint8_t *target, int8_t value) 103*7c478bd9Sstevel@tonic-gate { *target += value; } 104*7c478bd9Sstevel@tonic-gate 105*7c478bd9Sstevel@tonic-gate void 106*7c478bd9Sstevel@tonic-gate atomic_add_char(volatile uchar_t *target, signed char value) 107*7c478bd9Sstevel@tonic-gate { *target += value; } 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate void 110*7c478bd9Sstevel@tonic-gate atomic_add_16(volatile uint16_t *target, int16_t delta) 111*7c478bd9Sstevel@tonic-gate { *target += delta; } 112*7c478bd9Sstevel@tonic-gate 113*7c478bd9Sstevel@tonic-gate void 114*7c478bd9Sstevel@tonic-gate atomic_add_ushort(volatile ushort_t *target, short value) 115*7c478bd9Sstevel@tonic-gate { *target += value; } 116*7c478bd9Sstevel@tonic-gate 117*7c478bd9Sstevel@tonic-gate void 118*7c478bd9Sstevel@tonic-gate atomic_add_32(volatile uint32_t *target, int32_t delta) 119*7c478bd9Sstevel@tonic-gate { *target += delta; } 120*7c478bd9Sstevel@tonic-gate 121*7c478bd9Sstevel@tonic-gate void 122*7c478bd9Sstevel@tonic-gate atomic_add_ptr(volatile void *target, ssize_t value) 123*7c478bd9Sstevel@tonic-gate { *(caddr_t *)target += value; } 124*7c478bd9Sstevel@tonic-gate 125*7c478bd9Sstevel@tonic-gate void 126*7c478bd9Sstevel@tonic-gate atomic_add_long(volatile ulong_t *target, long delta) 127*7c478bd9Sstevel@tonic-gate { *target += delta; } 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate void 130*7c478bd9Sstevel@tonic-gate atomic_add_64(volatile uint64_t *target, int64_t delta) 131*7c478bd9Sstevel@tonic-gate { *target += delta; } 132*7c478bd9Sstevel@tonic-gate 133*7c478bd9Sstevel@tonic-gate void 134*7c478bd9Sstevel@tonic-gate atomic_or_8(volatile uint8_t *target, uint8_t bits) 135*7c478bd9Sstevel@tonic-gate { *target |= bits; } 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate void 138*7c478bd9Sstevel@tonic-gate atomic_or_uchar(volatile uchar_t *target, uchar_t bits) 139*7c478bd9Sstevel@tonic-gate { *target |= bits; } 140*7c478bd9Sstevel@tonic-gate 141*7c478bd9Sstevel@tonic-gate void 142*7c478bd9Sstevel@tonic-gate atomic_or_16(volatile uint16_t *target, uint16_t bits) 143*7c478bd9Sstevel@tonic-gate { *target |= bits; } 144*7c478bd9Sstevel@tonic-gate 145*7c478bd9Sstevel@tonic-gate void 146*7c478bd9Sstevel@tonic-gate atomic_or_ushort(volatile ushort_t *target, ushort_t bits) 147*7c478bd9Sstevel@tonic-gate { *target |= bits; } 148*7c478bd9Sstevel@tonic-gate 149*7c478bd9Sstevel@tonic-gate void 150*7c478bd9Sstevel@tonic-gate atomic_or_32(volatile uint32_t *target, uint32_t bits) 151*7c478bd9Sstevel@tonic-gate { *target |= bits; } 152*7c478bd9Sstevel@tonic-gate 153*7c478bd9Sstevel@tonic-gate void 154*7c478bd9Sstevel@tonic-gate atomic_or_uint(volatile uint_t *target, uint_t bits) 155*7c478bd9Sstevel@tonic-gate { *target |= bits; } 156*7c478bd9Sstevel@tonic-gate 157*7c478bd9Sstevel@tonic-gate void 158*7c478bd9Sstevel@tonic-gate atomic_or_ulong(volatile ulong_t *target, ulong_t bits) 159*7c478bd9Sstevel@tonic-gate { *target |= bits; } 160*7c478bd9Sstevel@tonic-gate 161*7c478bd9Sstevel@tonic-gate void 162*7c478bd9Sstevel@tonic-gate atomic_or_64(volatile uint64_t *target, uint64_t bits) 163*7c478bd9Sstevel@tonic-gate { *target |= bits; } 164*7c478bd9Sstevel@tonic-gate 165*7c478bd9Sstevel@tonic-gate void 166*7c478bd9Sstevel@tonic-gate atomic_and_8(volatile uint8_t *target, uint8_t bits) 167*7c478bd9Sstevel@tonic-gate { *target &= bits; } 168*7c478bd9Sstevel@tonic-gate 169*7c478bd9Sstevel@tonic-gate void 170*7c478bd9Sstevel@tonic-gate atomic_and_uchar(volatile uchar_t *target, uchar_t bits) 171*7c478bd9Sstevel@tonic-gate { *target &= bits; } 172*7c478bd9Sstevel@tonic-gate 173*7c478bd9Sstevel@tonic-gate void 174*7c478bd9Sstevel@tonic-gate atomic_and_16(volatile uint16_t *target, uint16_t bits) 175*7c478bd9Sstevel@tonic-gate { *target &= bits; } 176*7c478bd9Sstevel@tonic-gate 177*7c478bd9Sstevel@tonic-gate void 178*7c478bd9Sstevel@tonic-gate atomic_and_ushort(volatile ushort_t *target, ushort_t bits) 179*7c478bd9Sstevel@tonic-gate { *target &= bits; } 180*7c478bd9Sstevel@tonic-gate 181*7c478bd9Sstevel@tonic-gate void 182*7c478bd9Sstevel@tonic-gate atomic_and_32(volatile uint32_t *target, uint32_t bits) 183*7c478bd9Sstevel@tonic-gate { *target &= bits; } 184*7c478bd9Sstevel@tonic-gate 185*7c478bd9Sstevel@tonic-gate void 186*7c478bd9Sstevel@tonic-gate atomic_and_uint(volatile uint_t *target, uint_t bits) 187*7c478bd9Sstevel@tonic-gate { *target &= bits; } 188*7c478bd9Sstevel@tonic-gate 189*7c478bd9Sstevel@tonic-gate void 190*7c478bd9Sstevel@tonic-gate atomic_and_ulong(volatile ulong_t *target, ulong_t bits) 191*7c478bd9Sstevel@tonic-gate { *target &= bits; } 192*7c478bd9Sstevel@tonic-gate 193*7c478bd9Sstevel@tonic-gate void 194*7c478bd9Sstevel@tonic-gate atomic_and_64(volatile uint64_t *target, uint64_t bits) 195*7c478bd9Sstevel@tonic-gate { *target &= bits; } 196*7c478bd9Sstevel@tonic-gate 197*7c478bd9Sstevel@tonic-gate uint8_t 198*7c478bd9Sstevel@tonic-gate atomic_inc_8_nv(volatile uint8_t *target) 199*7c478bd9Sstevel@tonic-gate { return (++(*target)); } 200*7c478bd9Sstevel@tonic-gate 201*7c478bd9Sstevel@tonic-gate uchar_t 202*7c478bd9Sstevel@tonic-gate atomic_inc_uchar_nv(volatile uchar_t *target) 203*7c478bd9Sstevel@tonic-gate { return (++(*target)); } 204*7c478bd9Sstevel@tonic-gate 205*7c478bd9Sstevel@tonic-gate uint16_t 206*7c478bd9Sstevel@tonic-gate atomic_inc_16_nv(volatile uint16_t *target) 207*7c478bd9Sstevel@tonic-gate { return (++(*target)); } 208*7c478bd9Sstevel@tonic-gate 209*7c478bd9Sstevel@tonic-gate ushort_t 210*7c478bd9Sstevel@tonic-gate atomic_inc_ushort_nv(volatile ushort_t *target) 211*7c478bd9Sstevel@tonic-gate { return (++(*target)); } 212*7c478bd9Sstevel@tonic-gate 213*7c478bd9Sstevel@tonic-gate uint32_t 214*7c478bd9Sstevel@tonic-gate atomic_inc_32_nv(volatile uint32_t *target) 215*7c478bd9Sstevel@tonic-gate { return (++(*target)); } 216*7c478bd9Sstevel@tonic-gate 217*7c478bd9Sstevel@tonic-gate uint_t 218*7c478bd9Sstevel@tonic-gate atomic_inc_uint_nv(volatile uint_t *target) 219*7c478bd9Sstevel@tonic-gate { return (++(*target)); } 220*7c478bd9Sstevel@tonic-gate 221*7c478bd9Sstevel@tonic-gate ulong_t 222*7c478bd9Sstevel@tonic-gate atomic_inc_ulong_nv(volatile ulong_t *target) 223*7c478bd9Sstevel@tonic-gate { return (++(*target)); } 224*7c478bd9Sstevel@tonic-gate 225*7c478bd9Sstevel@tonic-gate uint64_t 226*7c478bd9Sstevel@tonic-gate atomic_inc_64_nv(volatile uint64_t *target) 227*7c478bd9Sstevel@tonic-gate { return (++(*target)); } 228*7c478bd9Sstevel@tonic-gate 229*7c478bd9Sstevel@tonic-gate uint8_t 230*7c478bd9Sstevel@tonic-gate atomic_dec_8_nv(volatile uint8_t *target) 231*7c478bd9Sstevel@tonic-gate { return (--(*target)); } 232*7c478bd9Sstevel@tonic-gate 233*7c478bd9Sstevel@tonic-gate uchar_t 234*7c478bd9Sstevel@tonic-gate atomic_dec_uchar_nv(volatile uchar_t *target) 235*7c478bd9Sstevel@tonic-gate { return (--(*target)); } 236*7c478bd9Sstevel@tonic-gate 237*7c478bd9Sstevel@tonic-gate uint16_t 238*7c478bd9Sstevel@tonic-gate atomic_dec_16_nv(volatile uint16_t *target) 239*7c478bd9Sstevel@tonic-gate { return (--(*target)); } 240*7c478bd9Sstevel@tonic-gate 241*7c478bd9Sstevel@tonic-gate ushort_t 242*7c478bd9Sstevel@tonic-gate atomic_dec_ushort_nv(volatile ushort_t *target) 243*7c478bd9Sstevel@tonic-gate { return (--(*target)); } 244*7c478bd9Sstevel@tonic-gate 245*7c478bd9Sstevel@tonic-gate uint32_t 246*7c478bd9Sstevel@tonic-gate atomic_dec_32_nv(volatile uint32_t *target) 247*7c478bd9Sstevel@tonic-gate { return (--(*target)); } 248*7c478bd9Sstevel@tonic-gate 249*7c478bd9Sstevel@tonic-gate uint_t 250*7c478bd9Sstevel@tonic-gate atomic_dec_uint_nv(volatile uint_t *target) 251*7c478bd9Sstevel@tonic-gate { return (--(*target)); } 252*7c478bd9Sstevel@tonic-gate 253*7c478bd9Sstevel@tonic-gate ulong_t 254*7c478bd9Sstevel@tonic-gate atomic_dec_ulong_nv(volatile ulong_t *target) 255*7c478bd9Sstevel@tonic-gate { return (--(*target)); } 256*7c478bd9Sstevel@tonic-gate 257*7c478bd9Sstevel@tonic-gate uint64_t 258*7c478bd9Sstevel@tonic-gate atomic_dec_64_nv(volatile uint64_t *target) 259*7c478bd9Sstevel@tonic-gate { return (--(*target)); } 260*7c478bd9Sstevel@tonic-gate 261*7c478bd9Sstevel@tonic-gate uint8_t 262*7c478bd9Sstevel@tonic-gate atomic_add_8_nv(volatile uint8_t *target, int8_t value) 263*7c478bd9Sstevel@tonic-gate { return (*target += value); } 264*7c478bd9Sstevel@tonic-gate 265*7c478bd9Sstevel@tonic-gate uchar_t 266*7c478bd9Sstevel@tonic-gate atomic_add_char_nv(volatile uchar_t *target, signed char value) 267*7c478bd9Sstevel@tonic-gate { return (*target += value); } 268*7c478bd9Sstevel@tonic-gate 269*7c478bd9Sstevel@tonic-gate uint16_t 270*7c478bd9Sstevel@tonic-gate atomic_add_16_nv(volatile uint16_t *target, int16_t delta) 271*7c478bd9Sstevel@tonic-gate { return (*target += delta); } 272*7c478bd9Sstevel@tonic-gate 273*7c478bd9Sstevel@tonic-gate ushort_t 274*7c478bd9Sstevel@tonic-gate atomic_add_short_nv(volatile ushort_t *target, short value) 275*7c478bd9Sstevel@tonic-gate { return (*target += value); } 276*7c478bd9Sstevel@tonic-gate 277*7c478bd9Sstevel@tonic-gate uint32_t 278*7c478bd9Sstevel@tonic-gate atomic_add_32_nv(volatile uint32_t *target, int32_t delta) 279*7c478bd9Sstevel@tonic-gate { return (*target += delta); } 280*7c478bd9Sstevel@tonic-gate 281*7c478bd9Sstevel@tonic-gate uint_t 282*7c478bd9Sstevel@tonic-gate atomic_add_int_nv(volatile uint_t *target, int delta) 283*7c478bd9Sstevel@tonic-gate { return (*target += delta); } 284*7c478bd9Sstevel@tonic-gate 285*7c478bd9Sstevel@tonic-gate void * 286*7c478bd9Sstevel@tonic-gate atomic_add_ptr_nv(volatile void *target, ssize_t value) 287*7c478bd9Sstevel@tonic-gate { return (*(caddr_t *)target += value); } 288*7c478bd9Sstevel@tonic-gate 289*7c478bd9Sstevel@tonic-gate ulong_t 290*7c478bd9Sstevel@tonic-gate atomic_add_long_nv(volatile ulong_t *target, long delta) 291*7c478bd9Sstevel@tonic-gate { return (*target += delta); } 292*7c478bd9Sstevel@tonic-gate 293*7c478bd9Sstevel@tonic-gate uint64_t 294*7c478bd9Sstevel@tonic-gate atomic_add_64_nv(volatile uint64_t *target, int64_t delta) 295*7c478bd9Sstevel@tonic-gate { return (*target += delta); } 296*7c478bd9Sstevel@tonic-gate 297*7c478bd9Sstevel@tonic-gate uint8_t 298*7c478bd9Sstevel@tonic-gate atomic_or_8_nv(volatile uint8_t *target, uint8_t value) 299*7c478bd9Sstevel@tonic-gate { return (*target |= value); } 300*7c478bd9Sstevel@tonic-gate 301*7c478bd9Sstevel@tonic-gate uchar_t 302*7c478bd9Sstevel@tonic-gate atomic_or_uchar_nv(volatile uchar_t *target, uchar_t value) 303*7c478bd9Sstevel@tonic-gate { return (*target |= value); } 304*7c478bd9Sstevel@tonic-gate 305*7c478bd9Sstevel@tonic-gate uint16_t 306*7c478bd9Sstevel@tonic-gate atomic_or_16_nv(volatile uint16_t *target, uint16_t value) 307*7c478bd9Sstevel@tonic-gate { return (*target |= value); } 308*7c478bd9Sstevel@tonic-gate 309*7c478bd9Sstevel@tonic-gate ushort_t 310*7c478bd9Sstevel@tonic-gate atomic_or_ushort_nv(volatile ushort_t *target, ushort_t value) 311*7c478bd9Sstevel@tonic-gate { return (*target |= value); } 312*7c478bd9Sstevel@tonic-gate 313*7c478bd9Sstevel@tonic-gate uint32_t 314*7c478bd9Sstevel@tonic-gate atomic_or_32_nv(volatile uint32_t *target, uint32_t value) 315*7c478bd9Sstevel@tonic-gate { return (*target |= value); } 316*7c478bd9Sstevel@tonic-gate 317*7c478bd9Sstevel@tonic-gate uint_t 318*7c478bd9Sstevel@tonic-gate atomic_or_uint_nv(volatile uint_t *target, uint_t value) 319*7c478bd9Sstevel@tonic-gate { return (*target |= value); } 320*7c478bd9Sstevel@tonic-gate 321*7c478bd9Sstevel@tonic-gate ulong_t 322*7c478bd9Sstevel@tonic-gate atomic_or_ulong_nv(volatile ulong_t *target, ulong_t value) 323*7c478bd9Sstevel@tonic-gate { return (*target |= value); } 324*7c478bd9Sstevel@tonic-gate 325*7c478bd9Sstevel@tonic-gate uint64_t 326*7c478bd9Sstevel@tonic-gate atomic_or_64_nv(volatile uint64_t *target, uint64_t value) 327*7c478bd9Sstevel@tonic-gate { return (*target |= value); } 328*7c478bd9Sstevel@tonic-gate 329*7c478bd9Sstevel@tonic-gate uint8_t 330*7c478bd9Sstevel@tonic-gate atomic_and_8_nv(volatile uint8_t *target, uint8_t value) 331*7c478bd9Sstevel@tonic-gate { return (*target &= value); } 332*7c478bd9Sstevel@tonic-gate 333*7c478bd9Sstevel@tonic-gate uchar_t 334*7c478bd9Sstevel@tonic-gate atomic_and_uchar_nv(volatile uchar_t *target, uchar_t value) 335*7c478bd9Sstevel@tonic-gate { return (*target &= value); } 336*7c478bd9Sstevel@tonic-gate 337*7c478bd9Sstevel@tonic-gate uint16_t 338*7c478bd9Sstevel@tonic-gate atomic_and_16_nv(volatile uint16_t *target, uint16_t value) 339*7c478bd9Sstevel@tonic-gate { return (*target &= value); } 340*7c478bd9Sstevel@tonic-gate 341*7c478bd9Sstevel@tonic-gate ushort_t 342*7c478bd9Sstevel@tonic-gate atomic_and_ushort_nv(volatile ushort_t *target, ushort_t value) 343*7c478bd9Sstevel@tonic-gate { return (*target &= value); } 344*7c478bd9Sstevel@tonic-gate 345*7c478bd9Sstevel@tonic-gate uint32_t 346*7c478bd9Sstevel@tonic-gate atomic_and_32_nv(volatile uint32_t *target, uint32_t value) 347*7c478bd9Sstevel@tonic-gate { return (*target &= value); } 348*7c478bd9Sstevel@tonic-gate 349*7c478bd9Sstevel@tonic-gate uint_t 350*7c478bd9Sstevel@tonic-gate atomic_and_uint_nv(volatile uint_t *target, uint_t value) 351*7c478bd9Sstevel@tonic-gate { return (*target &= value); } 352*7c478bd9Sstevel@tonic-gate 353*7c478bd9Sstevel@tonic-gate ulong_t 354*7c478bd9Sstevel@tonic-gate atomic_and_ulong_nv(volatile ulong_t *target, ulong_t value) 355*7c478bd9Sstevel@tonic-gate { return (*target &= value); } 356*7c478bd9Sstevel@tonic-gate 357*7c478bd9Sstevel@tonic-gate uint64_t 358*7c478bd9Sstevel@tonic-gate atomic_and_64_nv(volatile uint64_t *target, uint64_t value) 359*7c478bd9Sstevel@tonic-gate { return (*target &= value); } 360*7c478bd9Sstevel@tonic-gate 361*7c478bd9Sstevel@tonic-gate uint8_t 362*7c478bd9Sstevel@tonic-gate atomic_cas_8(volatile uint8_t *target, uint8_t cmp, uint8_t new) 363*7c478bd9Sstevel@tonic-gate { 364*7c478bd9Sstevel@tonic-gate uint8_t old = *target; 365*7c478bd9Sstevel@tonic-gate if (old == cmp) 366*7c478bd9Sstevel@tonic-gate *target = new; 367*7c478bd9Sstevel@tonic-gate return (old); 368*7c478bd9Sstevel@tonic-gate } 369*7c478bd9Sstevel@tonic-gate 370*7c478bd9Sstevel@tonic-gate uchar_t 371*7c478bd9Sstevel@tonic-gate atomic_cas_uchar(volatile uchar_t *target, uchar_t cmp, uchar_t new) 372*7c478bd9Sstevel@tonic-gate { 373*7c478bd9Sstevel@tonic-gate uchar_t old = *target; 374*7c478bd9Sstevel@tonic-gate if (old == cmp) 375*7c478bd9Sstevel@tonic-gate *target = new; 376*7c478bd9Sstevel@tonic-gate return (old); 377*7c478bd9Sstevel@tonic-gate } 378*7c478bd9Sstevel@tonic-gate 379*7c478bd9Sstevel@tonic-gate uint16_t 380*7c478bd9Sstevel@tonic-gate atomic_cas_16(volatile uint16_t *target, uint16_t cmp, uint16_t new) 381*7c478bd9Sstevel@tonic-gate { 382*7c478bd9Sstevel@tonic-gate uint16_t old = *target; 383*7c478bd9Sstevel@tonic-gate if (old == cmp) 384*7c478bd9Sstevel@tonic-gate *target = new; 385*7c478bd9Sstevel@tonic-gate return (old); 386*7c478bd9Sstevel@tonic-gate } 387*7c478bd9Sstevel@tonic-gate 388*7c478bd9Sstevel@tonic-gate ushort_t 389*7c478bd9Sstevel@tonic-gate atomic_cas_ushort(volatile ushort_t *target, ushort_t cmp, ushort_t new) 390*7c478bd9Sstevel@tonic-gate { 391*7c478bd9Sstevel@tonic-gate ushort_t old = *target; 392*7c478bd9Sstevel@tonic-gate if (old == cmp) 393*7c478bd9Sstevel@tonic-gate *target = new; 394*7c478bd9Sstevel@tonic-gate return (old); 395*7c478bd9Sstevel@tonic-gate } 396*7c478bd9Sstevel@tonic-gate 397*7c478bd9Sstevel@tonic-gate uint32_t 398*7c478bd9Sstevel@tonic-gate atomic_cas_32(volatile uint32_t *target, uint32_t cmp, uint32_t new) 399*7c478bd9Sstevel@tonic-gate { 400*7c478bd9Sstevel@tonic-gate uint32_t old = *target; 401*7c478bd9Sstevel@tonic-gate if (old == cmp) 402*7c478bd9Sstevel@tonic-gate *target = new; 403*7c478bd9Sstevel@tonic-gate return (old); 404*7c478bd9Sstevel@tonic-gate } 405*7c478bd9Sstevel@tonic-gate 406*7c478bd9Sstevel@tonic-gate uint_t 407*7c478bd9Sstevel@tonic-gate atomic_cas_uint(volatile uint_t *target, uint_t cmp, uint_t new) 408*7c478bd9Sstevel@tonic-gate { 409*7c478bd9Sstevel@tonic-gate uint_t old = *target; 410*7c478bd9Sstevel@tonic-gate if (old == cmp) 411*7c478bd9Sstevel@tonic-gate *target = new; 412*7c478bd9Sstevel@tonic-gate return (old); 413*7c478bd9Sstevel@tonic-gate } 414*7c478bd9Sstevel@tonic-gate 415*7c478bd9Sstevel@tonic-gate ulong_t 416*7c478bd9Sstevel@tonic-gate atomic_cas_ulong(volatile ulong_t *target, ulong_t cmp, ulong_t new) 417*7c478bd9Sstevel@tonic-gate { 418*7c478bd9Sstevel@tonic-gate ulong_t old = *target; 419*7c478bd9Sstevel@tonic-gate if (old == cmp) 420*7c478bd9Sstevel@tonic-gate *target = new; 421*7c478bd9Sstevel@tonic-gate return (old); 422*7c478bd9Sstevel@tonic-gate } 423*7c478bd9Sstevel@tonic-gate 424*7c478bd9Sstevel@tonic-gate uint64_t 425*7c478bd9Sstevel@tonic-gate atomic_cas_uint64(volatile uint64_t *target, ulong_t cmp, uint64_t new) 426*7c478bd9Sstevel@tonic-gate { 427*7c478bd9Sstevel@tonic-gate uint64_t old = *target; 428*7c478bd9Sstevel@tonic-gate if (old == cmp) 429*7c478bd9Sstevel@tonic-gate *target = new; 430*7c478bd9Sstevel@tonic-gate return (old); 431*7c478bd9Sstevel@tonic-gate } 432*7c478bd9Sstevel@tonic-gate 433*7c478bd9Sstevel@tonic-gate void * 434*7c478bd9Sstevel@tonic-gate atomic_cas_ptr(volatile void *target, void *cmp, void *new) 435*7c478bd9Sstevel@tonic-gate { 436*7c478bd9Sstevel@tonic-gate void *old = *(void **)target; 437*7c478bd9Sstevel@tonic-gate if (old == cmp) 438*7c478bd9Sstevel@tonic-gate *(void **)target = new; 439*7c478bd9Sstevel@tonic-gate return (old); 440*7c478bd9Sstevel@tonic-gate } 441*7c478bd9Sstevel@tonic-gate 442*7c478bd9Sstevel@tonic-gate uint8_t 443*7c478bd9Sstevel@tonic-gate atomic_swap_8(volatile uint8_t *target, uint8_t new) 444*7c478bd9Sstevel@tonic-gate { 445*7c478bd9Sstevel@tonic-gate uint8_t old = *target; 446*7c478bd9Sstevel@tonic-gate *target = new; 447*7c478bd9Sstevel@tonic-gate return (old); 448*7c478bd9Sstevel@tonic-gate } 449*7c478bd9Sstevel@tonic-gate 450*7c478bd9Sstevel@tonic-gate uchar_t 451*7c478bd9Sstevel@tonic-gate atomic_swap_char(volatile uchar_t *target, uchar_t new) 452*7c478bd9Sstevel@tonic-gate { 453*7c478bd9Sstevel@tonic-gate uchar_t old = *target; 454*7c478bd9Sstevel@tonic-gate *target = new; 455*7c478bd9Sstevel@tonic-gate return (old); 456*7c478bd9Sstevel@tonic-gate } 457*7c478bd9Sstevel@tonic-gate 458*7c478bd9Sstevel@tonic-gate uint16_t 459*7c478bd9Sstevel@tonic-gate atomic_swap_16(volatile uint16_t *target, uint16_t new) 460*7c478bd9Sstevel@tonic-gate { 461*7c478bd9Sstevel@tonic-gate uint16_t old = *target; 462*7c478bd9Sstevel@tonic-gate *target = new; 463*7c478bd9Sstevel@tonic-gate return (old); 464*7c478bd9Sstevel@tonic-gate } 465*7c478bd9Sstevel@tonic-gate 466*7c478bd9Sstevel@tonic-gate ushort_t 467*7c478bd9Sstevel@tonic-gate atomic_swap_ushort(volatile ushort_t *target, ushort_t new) 468*7c478bd9Sstevel@tonic-gate { 469*7c478bd9Sstevel@tonic-gate ushort_t old = *target; 470*7c478bd9Sstevel@tonic-gate *target = new; 471*7c478bd9Sstevel@tonic-gate return (old); 472*7c478bd9Sstevel@tonic-gate } 473*7c478bd9Sstevel@tonic-gate 474*7c478bd9Sstevel@tonic-gate uint32_t 475*7c478bd9Sstevel@tonic-gate atomic_swap_32(volatile uint32_t *target, uint32_t new) 476*7c478bd9Sstevel@tonic-gate { 477*7c478bd9Sstevel@tonic-gate uint32_t old = *target; 478*7c478bd9Sstevel@tonic-gate *target = new; 479*7c478bd9Sstevel@tonic-gate return (old); 480*7c478bd9Sstevel@tonic-gate } 481*7c478bd9Sstevel@tonic-gate 482*7c478bd9Sstevel@tonic-gate uint_t 483*7c478bd9Sstevel@tonic-gate atomic_swap_uint(volatile uint_t *target, uint_t new) 484*7c478bd9Sstevel@tonic-gate { 485*7c478bd9Sstevel@tonic-gate ulong_t old = *target; 486*7c478bd9Sstevel@tonic-gate *target = new; 487*7c478bd9Sstevel@tonic-gate return (old); 488*7c478bd9Sstevel@tonic-gate } 489*7c478bd9Sstevel@tonic-gate 490*7c478bd9Sstevel@tonic-gate uint64_t 491*7c478bd9Sstevel@tonic-gate atomic_swap_64(volatile uint64_t *target, uint64_t new) 492*7c478bd9Sstevel@tonic-gate { 493*7c478bd9Sstevel@tonic-gate uint64_t old = *target; 494*7c478bd9Sstevel@tonic-gate *target = new; 495*7c478bd9Sstevel@tonic-gate return (old); 496*7c478bd9Sstevel@tonic-gate } 497*7c478bd9Sstevel@tonic-gate 498*7c478bd9Sstevel@tonic-gate void * 499*7c478bd9Sstevel@tonic-gate atomic_swap_ptr(volatile void *target, void *new) 500*7c478bd9Sstevel@tonic-gate { 501*7c478bd9Sstevel@tonic-gate void *old = *(void **)target; 502*7c478bd9Sstevel@tonic-gate *(void **)target = new; 503*7c478bd9Sstevel@tonic-gate return (old); 504*7c478bd9Sstevel@tonic-gate } 505*7c478bd9Sstevel@tonic-gate 506*7c478bd9Sstevel@tonic-gate ulong_t 507*7c478bd9Sstevel@tonic-gate atomic_swap_ulong(volatile ulong_t *target, ulong_t new) 508*7c478bd9Sstevel@tonic-gate { 509*7c478bd9Sstevel@tonic-gate ulong_t old = *target; 510*7c478bd9Sstevel@tonic-gate *target = new; 511*7c478bd9Sstevel@tonic-gate return (old); 512*7c478bd9Sstevel@tonic-gate } 513*7c478bd9Sstevel@tonic-gate 514*7c478bd9Sstevel@tonic-gate int 515*7c478bd9Sstevel@tonic-gate atomic_set_long_excl(volatile ulong_t *target, uint_t value) 516*7c478bd9Sstevel@tonic-gate { 517*7c478bd9Sstevel@tonic-gate ulong_t bit = (1UL << value); 518*7c478bd9Sstevel@tonic-gate if ((*target & bit) != 0) 519*7c478bd9Sstevel@tonic-gate return (-1); 520*7c478bd9Sstevel@tonic-gate *target |= bit; 521*7c478bd9Sstevel@tonic-gate return (0); 522*7c478bd9Sstevel@tonic-gate } 523*7c478bd9Sstevel@tonic-gate 524*7c478bd9Sstevel@tonic-gate int 525*7c478bd9Sstevel@tonic-gate atomic_clear_long_excl(volatile ulong_t *target, uint_t value) 526*7c478bd9Sstevel@tonic-gate { 527*7c478bd9Sstevel@tonic-gate ulong_t bit = (1UL << value); 528*7c478bd9Sstevel@tonic-gate if ((*target & bit) == 0) 529*7c478bd9Sstevel@tonic-gate return (-1); 530*7c478bd9Sstevel@tonic-gate *target &= ~bit; 531*7c478bd9Sstevel@tonic-gate return (0); 532*7c478bd9Sstevel@tonic-gate } 533*7c478bd9Sstevel@tonic-gate 534*7c478bd9Sstevel@tonic-gate #if !defined(_KERNEL) 535*7c478bd9Sstevel@tonic-gate 536*7c478bd9Sstevel@tonic-gate void 537*7c478bd9Sstevel@tonic-gate membar_enter(void) 538*7c478bd9Sstevel@tonic-gate {} 539*7c478bd9Sstevel@tonic-gate 540*7c478bd9Sstevel@tonic-gate void 541*7c478bd9Sstevel@tonic-gate membar_exit(void) 542*7c478bd9Sstevel@tonic-gate {} 543*7c478bd9Sstevel@tonic-gate 544*7c478bd9Sstevel@tonic-gate void 545*7c478bd9Sstevel@tonic-gate membar_producer(void) 546*7c478bd9Sstevel@tonic-gate {} 547*7c478bd9Sstevel@tonic-gate 548*7c478bd9Sstevel@tonic-gate void 549*7c478bd9Sstevel@tonic-gate membar_consumer(void) 550*7c478bd9Sstevel@tonic-gate {} 551*7c478bd9Sstevel@tonic-gate 552*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 553*7c478bd9Sstevel@tonic-gate 554*7c478bd9Sstevel@tonic-gate #endif /* __lint */ 555