10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*5352Ssvemuri * Common Development and Distribution License (the "License"). 6*5352Ssvemuri * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*5352Ssvemuri * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate #include <sys/atomic.h> 290Sstevel@tonic-gate 300Sstevel@tonic-gate /* 310Sstevel@tonic-gate * This file exists only for the purpose of running lint. 320Sstevel@tonic-gate */ 330Sstevel@tonic-gate 340Sstevel@tonic-gate #if defined(__lint) 350Sstevel@tonic-gate 360Sstevel@tonic-gate void 370Sstevel@tonic-gate atomic_inc_8(volatile uint8_t *target) 380Sstevel@tonic-gate { (*target)++; } 390Sstevel@tonic-gate 400Sstevel@tonic-gate void 410Sstevel@tonic-gate atomic_inc_uchar(volatile uchar_t *target) 420Sstevel@tonic-gate { (*target)++; } 430Sstevel@tonic-gate 440Sstevel@tonic-gate void 450Sstevel@tonic-gate atomic_inc_16(volatile uint16_t *target) 460Sstevel@tonic-gate { (*target)++; } 470Sstevel@tonic-gate 480Sstevel@tonic-gate void 490Sstevel@tonic-gate atomic_inc_ushort(volatile ushort_t *target) 500Sstevel@tonic-gate { (*target)++; } 510Sstevel@tonic-gate 520Sstevel@tonic-gate void 530Sstevel@tonic-gate atomic_inc_32(volatile uint32_t *target) 540Sstevel@tonic-gate { (*target)++; } 550Sstevel@tonic-gate 560Sstevel@tonic-gate void 570Sstevel@tonic-gate atomic_inc_uint(volatile uint_t *target) 580Sstevel@tonic-gate { (*target)++; } 590Sstevel@tonic-gate 600Sstevel@tonic-gate void 610Sstevel@tonic-gate atomic_inc_ulong(volatile ulong_t *target) 620Sstevel@tonic-gate { (*target)++; } 630Sstevel@tonic-gate 640Sstevel@tonic-gate void 650Sstevel@tonic-gate atomic_inc_64(volatile uint64_t *target) 660Sstevel@tonic-gate { (*target)++; } 670Sstevel@tonic-gate 680Sstevel@tonic-gate void 690Sstevel@tonic-gate atomic_dec_8(volatile uint8_t *target) 700Sstevel@tonic-gate { (*target)--; } 710Sstevel@tonic-gate 720Sstevel@tonic-gate void 730Sstevel@tonic-gate atomic_dec_uchar(volatile uchar_t *target) 740Sstevel@tonic-gate { (*target)--; } 750Sstevel@tonic-gate 760Sstevel@tonic-gate void 770Sstevel@tonic-gate atomic_dec_16(volatile uint16_t *target) 780Sstevel@tonic-gate { (*target)--; } 790Sstevel@tonic-gate 800Sstevel@tonic-gate void 810Sstevel@tonic-gate atomic_dec_ushort(volatile ushort_t *target) 820Sstevel@tonic-gate { (*target)--; } 830Sstevel@tonic-gate 840Sstevel@tonic-gate void 850Sstevel@tonic-gate atomic_dec_32(volatile uint32_t *target) 860Sstevel@tonic-gate { (*target)--; } 870Sstevel@tonic-gate 880Sstevel@tonic-gate void 890Sstevel@tonic-gate atomic_dec_uint(volatile uint_t *target) 900Sstevel@tonic-gate { (*target)--; } 910Sstevel@tonic-gate 920Sstevel@tonic-gate void 930Sstevel@tonic-gate atomic_dec_ulong(volatile ulong_t *target) 940Sstevel@tonic-gate { (*target)--; } 950Sstevel@tonic-gate 960Sstevel@tonic-gate void 970Sstevel@tonic-gate atomic_dec_64(volatile uint64_t *target) 980Sstevel@tonic-gate { (*target)--; } 990Sstevel@tonic-gate 1000Sstevel@tonic-gate void 1010Sstevel@tonic-gate atomic_add_8(volatile uint8_t *target, int8_t value) 1020Sstevel@tonic-gate { *target += value; } 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate void 1050Sstevel@tonic-gate atomic_add_char(volatile uchar_t *target, signed char value) 1060Sstevel@tonic-gate { *target += value; } 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate void 1090Sstevel@tonic-gate atomic_add_16(volatile uint16_t *target, int16_t delta) 1100Sstevel@tonic-gate { *target += delta; } 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate void 1130Sstevel@tonic-gate atomic_add_ushort(volatile ushort_t *target, short value) 1140Sstevel@tonic-gate { *target += value; } 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate void 1170Sstevel@tonic-gate atomic_add_32(volatile uint32_t *target, int32_t delta) 1180Sstevel@tonic-gate { *target += delta; } 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate void 1210Sstevel@tonic-gate atomic_add_ptr(volatile void *target, ssize_t value) 1220Sstevel@tonic-gate { *(caddr_t *)target += value; } 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate void 1250Sstevel@tonic-gate atomic_add_long(volatile ulong_t *target, long delta) 1260Sstevel@tonic-gate { *target += delta; } 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate void 1290Sstevel@tonic-gate atomic_add_64(volatile uint64_t *target, int64_t delta) 1300Sstevel@tonic-gate { *target += delta; } 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate void 1330Sstevel@tonic-gate atomic_or_8(volatile uint8_t *target, uint8_t bits) 1340Sstevel@tonic-gate { *target |= bits; } 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate void 1370Sstevel@tonic-gate atomic_or_uchar(volatile uchar_t *target, uchar_t bits) 1380Sstevel@tonic-gate { *target |= bits; } 1390Sstevel@tonic-gate 1400Sstevel@tonic-gate void 1410Sstevel@tonic-gate atomic_or_16(volatile uint16_t *target, uint16_t bits) 1420Sstevel@tonic-gate { *target |= bits; } 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate void 1450Sstevel@tonic-gate atomic_or_ushort(volatile ushort_t *target, ushort_t bits) 1460Sstevel@tonic-gate { *target |= bits; } 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate void 1490Sstevel@tonic-gate atomic_or_32(volatile uint32_t *target, uint32_t bits) 1500Sstevel@tonic-gate { *target |= bits; } 1510Sstevel@tonic-gate 1520Sstevel@tonic-gate void 1530Sstevel@tonic-gate atomic_or_uint(volatile uint_t *target, uint_t bits) 1540Sstevel@tonic-gate { *target |= bits; } 1550Sstevel@tonic-gate 1560Sstevel@tonic-gate void 1570Sstevel@tonic-gate atomic_or_ulong(volatile ulong_t *target, ulong_t bits) 1580Sstevel@tonic-gate { *target |= bits; } 1590Sstevel@tonic-gate 1600Sstevel@tonic-gate void 1610Sstevel@tonic-gate atomic_or_64(volatile uint64_t *target, uint64_t bits) 1620Sstevel@tonic-gate { *target |= bits; } 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate void 1650Sstevel@tonic-gate atomic_and_8(volatile uint8_t *target, uint8_t bits) 1660Sstevel@tonic-gate { *target &= bits; } 1670Sstevel@tonic-gate 1680Sstevel@tonic-gate void 1690Sstevel@tonic-gate atomic_and_uchar(volatile uchar_t *target, uchar_t bits) 1700Sstevel@tonic-gate { *target &= bits; } 1710Sstevel@tonic-gate 1720Sstevel@tonic-gate void 1730Sstevel@tonic-gate atomic_and_16(volatile uint16_t *target, uint16_t bits) 1740Sstevel@tonic-gate { *target &= bits; } 1750Sstevel@tonic-gate 1760Sstevel@tonic-gate void 1770Sstevel@tonic-gate atomic_and_ushort(volatile ushort_t *target, ushort_t bits) 1780Sstevel@tonic-gate { *target &= bits; } 1790Sstevel@tonic-gate 1800Sstevel@tonic-gate void 1810Sstevel@tonic-gate atomic_and_32(volatile uint32_t *target, uint32_t bits) 1820Sstevel@tonic-gate { *target &= bits; } 1830Sstevel@tonic-gate 1840Sstevel@tonic-gate void 1850Sstevel@tonic-gate atomic_and_uint(volatile uint_t *target, uint_t bits) 1860Sstevel@tonic-gate { *target &= bits; } 1870Sstevel@tonic-gate 1880Sstevel@tonic-gate void 1890Sstevel@tonic-gate atomic_and_ulong(volatile ulong_t *target, ulong_t bits) 1900Sstevel@tonic-gate { *target &= bits; } 1910Sstevel@tonic-gate 1920Sstevel@tonic-gate void 1930Sstevel@tonic-gate atomic_and_64(volatile uint64_t *target, uint64_t bits) 1940Sstevel@tonic-gate { *target &= bits; } 1950Sstevel@tonic-gate 1960Sstevel@tonic-gate uint8_t 1970Sstevel@tonic-gate atomic_inc_8_nv(volatile uint8_t *target) 1980Sstevel@tonic-gate { return (++(*target)); } 1990Sstevel@tonic-gate 2000Sstevel@tonic-gate uchar_t 2010Sstevel@tonic-gate atomic_inc_uchar_nv(volatile uchar_t *target) 2020Sstevel@tonic-gate { return (++(*target)); } 2030Sstevel@tonic-gate 2040Sstevel@tonic-gate uint16_t 2050Sstevel@tonic-gate atomic_inc_16_nv(volatile uint16_t *target) 2060Sstevel@tonic-gate { return (++(*target)); } 2070Sstevel@tonic-gate 2080Sstevel@tonic-gate ushort_t 2090Sstevel@tonic-gate atomic_inc_ushort_nv(volatile ushort_t *target) 2100Sstevel@tonic-gate { return (++(*target)); } 2110Sstevel@tonic-gate 2120Sstevel@tonic-gate uint32_t 2130Sstevel@tonic-gate atomic_inc_32_nv(volatile uint32_t *target) 2140Sstevel@tonic-gate { return (++(*target)); } 2150Sstevel@tonic-gate 2160Sstevel@tonic-gate uint_t 2170Sstevel@tonic-gate atomic_inc_uint_nv(volatile uint_t *target) 2180Sstevel@tonic-gate { return (++(*target)); } 2190Sstevel@tonic-gate 2200Sstevel@tonic-gate ulong_t 2210Sstevel@tonic-gate atomic_inc_ulong_nv(volatile ulong_t *target) 2220Sstevel@tonic-gate { return (++(*target)); } 2230Sstevel@tonic-gate 2240Sstevel@tonic-gate uint64_t 2250Sstevel@tonic-gate atomic_inc_64_nv(volatile uint64_t *target) 2260Sstevel@tonic-gate { return (++(*target)); } 2270Sstevel@tonic-gate 2280Sstevel@tonic-gate uint8_t 2290Sstevel@tonic-gate atomic_dec_8_nv(volatile uint8_t *target) 2300Sstevel@tonic-gate { return (--(*target)); } 2310Sstevel@tonic-gate 2320Sstevel@tonic-gate uchar_t 2330Sstevel@tonic-gate atomic_dec_uchar_nv(volatile uchar_t *target) 2340Sstevel@tonic-gate { return (--(*target)); } 2350Sstevel@tonic-gate 2360Sstevel@tonic-gate uint16_t 2370Sstevel@tonic-gate atomic_dec_16_nv(volatile uint16_t *target) 2380Sstevel@tonic-gate { return (--(*target)); } 2390Sstevel@tonic-gate 2400Sstevel@tonic-gate ushort_t 2410Sstevel@tonic-gate atomic_dec_ushort_nv(volatile ushort_t *target) 2420Sstevel@tonic-gate { return (--(*target)); } 2430Sstevel@tonic-gate 2440Sstevel@tonic-gate uint32_t 2450Sstevel@tonic-gate atomic_dec_32_nv(volatile uint32_t *target) 2460Sstevel@tonic-gate { return (--(*target)); } 2470Sstevel@tonic-gate 2480Sstevel@tonic-gate uint_t 2490Sstevel@tonic-gate atomic_dec_uint_nv(volatile uint_t *target) 2500Sstevel@tonic-gate { return (--(*target)); } 2510Sstevel@tonic-gate 2520Sstevel@tonic-gate ulong_t 2530Sstevel@tonic-gate atomic_dec_ulong_nv(volatile ulong_t *target) 2540Sstevel@tonic-gate { return (--(*target)); } 2550Sstevel@tonic-gate 2560Sstevel@tonic-gate uint64_t 2570Sstevel@tonic-gate atomic_dec_64_nv(volatile uint64_t *target) 2580Sstevel@tonic-gate { return (--(*target)); } 2590Sstevel@tonic-gate 2600Sstevel@tonic-gate uint8_t 2610Sstevel@tonic-gate atomic_add_8_nv(volatile uint8_t *target, int8_t value) 2620Sstevel@tonic-gate { return (*target += value); } 2630Sstevel@tonic-gate 2640Sstevel@tonic-gate uchar_t 2650Sstevel@tonic-gate atomic_add_char_nv(volatile uchar_t *target, signed char value) 2660Sstevel@tonic-gate { return (*target += value); } 2670Sstevel@tonic-gate 2680Sstevel@tonic-gate uint16_t 2690Sstevel@tonic-gate atomic_add_16_nv(volatile uint16_t *target, int16_t delta) 2700Sstevel@tonic-gate { return (*target += delta); } 2710Sstevel@tonic-gate 2720Sstevel@tonic-gate ushort_t 2730Sstevel@tonic-gate atomic_add_short_nv(volatile ushort_t *target, short value) 2740Sstevel@tonic-gate { return (*target += value); } 2750Sstevel@tonic-gate 2760Sstevel@tonic-gate uint32_t 2770Sstevel@tonic-gate atomic_add_32_nv(volatile uint32_t *target, int32_t delta) 2780Sstevel@tonic-gate { return (*target += delta); } 2790Sstevel@tonic-gate 2800Sstevel@tonic-gate uint_t 2810Sstevel@tonic-gate atomic_add_int_nv(volatile uint_t *target, int delta) 2820Sstevel@tonic-gate { return (*target += delta); } 2830Sstevel@tonic-gate 2840Sstevel@tonic-gate void * 2850Sstevel@tonic-gate atomic_add_ptr_nv(volatile void *target, ssize_t value) 2860Sstevel@tonic-gate { return (*(caddr_t *)target += value); } 2870Sstevel@tonic-gate 2880Sstevel@tonic-gate ulong_t 2890Sstevel@tonic-gate atomic_add_long_nv(volatile ulong_t *target, long delta) 2900Sstevel@tonic-gate { return (*target += delta); } 2910Sstevel@tonic-gate 2920Sstevel@tonic-gate uint64_t 2930Sstevel@tonic-gate atomic_add_64_nv(volatile uint64_t *target, int64_t delta) 2940Sstevel@tonic-gate { return (*target += delta); } 2950Sstevel@tonic-gate 2960Sstevel@tonic-gate uint8_t 2970Sstevel@tonic-gate atomic_or_8_nv(volatile uint8_t *target, uint8_t value) 2980Sstevel@tonic-gate { return (*target |= value); } 2990Sstevel@tonic-gate 3000Sstevel@tonic-gate uchar_t 3010Sstevel@tonic-gate atomic_or_uchar_nv(volatile uchar_t *target, uchar_t value) 3020Sstevel@tonic-gate { return (*target |= value); } 3030Sstevel@tonic-gate 3040Sstevel@tonic-gate uint16_t 3050Sstevel@tonic-gate atomic_or_16_nv(volatile uint16_t *target, uint16_t value) 3060Sstevel@tonic-gate { return (*target |= value); } 3070Sstevel@tonic-gate 3080Sstevel@tonic-gate ushort_t 3090Sstevel@tonic-gate atomic_or_ushort_nv(volatile ushort_t *target, ushort_t value) 3100Sstevel@tonic-gate { return (*target |= value); } 3110Sstevel@tonic-gate 3120Sstevel@tonic-gate uint32_t 3130Sstevel@tonic-gate atomic_or_32_nv(volatile uint32_t *target, uint32_t value) 3140Sstevel@tonic-gate { return (*target |= value); } 3150Sstevel@tonic-gate 3160Sstevel@tonic-gate uint_t 3170Sstevel@tonic-gate atomic_or_uint_nv(volatile uint_t *target, uint_t value) 3180Sstevel@tonic-gate { return (*target |= value); } 3190Sstevel@tonic-gate 3200Sstevel@tonic-gate ulong_t 3210Sstevel@tonic-gate atomic_or_ulong_nv(volatile ulong_t *target, ulong_t value) 3220Sstevel@tonic-gate { return (*target |= value); } 3230Sstevel@tonic-gate 3240Sstevel@tonic-gate uint64_t 3250Sstevel@tonic-gate atomic_or_64_nv(volatile uint64_t *target, uint64_t value) 3260Sstevel@tonic-gate { return (*target |= value); } 3270Sstevel@tonic-gate 3280Sstevel@tonic-gate uint8_t 3290Sstevel@tonic-gate atomic_and_8_nv(volatile uint8_t *target, uint8_t value) 3300Sstevel@tonic-gate { return (*target &= value); } 3310Sstevel@tonic-gate 3320Sstevel@tonic-gate uchar_t 3330Sstevel@tonic-gate atomic_and_uchar_nv(volatile uchar_t *target, uchar_t value) 3340Sstevel@tonic-gate { return (*target &= value); } 3350Sstevel@tonic-gate 3360Sstevel@tonic-gate uint16_t 3370Sstevel@tonic-gate atomic_and_16_nv(volatile uint16_t *target, uint16_t value) 3380Sstevel@tonic-gate { return (*target &= value); } 3390Sstevel@tonic-gate 3400Sstevel@tonic-gate ushort_t 3410Sstevel@tonic-gate atomic_and_ushort_nv(volatile ushort_t *target, ushort_t value) 3420Sstevel@tonic-gate { return (*target &= value); } 3430Sstevel@tonic-gate 3440Sstevel@tonic-gate uint32_t 3450Sstevel@tonic-gate atomic_and_32_nv(volatile uint32_t *target, uint32_t value) 3460Sstevel@tonic-gate { return (*target &= value); } 3470Sstevel@tonic-gate 3480Sstevel@tonic-gate uint_t 3490Sstevel@tonic-gate atomic_and_uint_nv(volatile uint_t *target, uint_t value) 3500Sstevel@tonic-gate { return (*target &= value); } 3510Sstevel@tonic-gate 3520Sstevel@tonic-gate ulong_t 3530Sstevel@tonic-gate atomic_and_ulong_nv(volatile ulong_t *target, ulong_t value) 3540Sstevel@tonic-gate { return (*target &= value); } 3550Sstevel@tonic-gate 3560Sstevel@tonic-gate uint64_t 3570Sstevel@tonic-gate atomic_and_64_nv(volatile uint64_t *target, uint64_t value) 3580Sstevel@tonic-gate { return (*target &= value); } 3590Sstevel@tonic-gate 3600Sstevel@tonic-gate uint8_t 3610Sstevel@tonic-gate atomic_cas_8(volatile uint8_t *target, uint8_t cmp, uint8_t new) 3620Sstevel@tonic-gate { 3630Sstevel@tonic-gate uint8_t old = *target; 3640Sstevel@tonic-gate if (old == cmp) 3650Sstevel@tonic-gate *target = new; 3660Sstevel@tonic-gate return (old); 3670Sstevel@tonic-gate } 3680Sstevel@tonic-gate 3690Sstevel@tonic-gate uchar_t 3700Sstevel@tonic-gate atomic_cas_uchar(volatile uchar_t *target, uchar_t cmp, uchar_t new) 3710Sstevel@tonic-gate { 3720Sstevel@tonic-gate uchar_t old = *target; 3730Sstevel@tonic-gate if (old == cmp) 3740Sstevel@tonic-gate *target = new; 3750Sstevel@tonic-gate return (old); 3760Sstevel@tonic-gate } 3770Sstevel@tonic-gate 3780Sstevel@tonic-gate uint16_t 3790Sstevel@tonic-gate atomic_cas_16(volatile uint16_t *target, uint16_t cmp, uint16_t new) 3800Sstevel@tonic-gate { 3810Sstevel@tonic-gate uint16_t old = *target; 3820Sstevel@tonic-gate if (old == cmp) 3830Sstevel@tonic-gate *target = new; 3840Sstevel@tonic-gate return (old); 3850Sstevel@tonic-gate } 3860Sstevel@tonic-gate 3870Sstevel@tonic-gate ushort_t 3880Sstevel@tonic-gate atomic_cas_ushort(volatile ushort_t *target, ushort_t cmp, ushort_t new) 3890Sstevel@tonic-gate { 3900Sstevel@tonic-gate ushort_t old = *target; 3910Sstevel@tonic-gate if (old == cmp) 3920Sstevel@tonic-gate *target = new; 3930Sstevel@tonic-gate return (old); 3940Sstevel@tonic-gate } 3950Sstevel@tonic-gate 3960Sstevel@tonic-gate uint32_t 3970Sstevel@tonic-gate atomic_cas_32(volatile uint32_t *target, uint32_t cmp, uint32_t new) 3980Sstevel@tonic-gate { 3990Sstevel@tonic-gate uint32_t old = *target; 4000Sstevel@tonic-gate if (old == cmp) 4010Sstevel@tonic-gate *target = new; 4020Sstevel@tonic-gate return (old); 4030Sstevel@tonic-gate } 4040Sstevel@tonic-gate 4050Sstevel@tonic-gate uint_t 4060Sstevel@tonic-gate atomic_cas_uint(volatile uint_t *target, uint_t cmp, uint_t new) 4070Sstevel@tonic-gate { 4080Sstevel@tonic-gate uint_t old = *target; 4090Sstevel@tonic-gate if (old == cmp) 4100Sstevel@tonic-gate *target = new; 4110Sstevel@tonic-gate return (old); 4120Sstevel@tonic-gate } 4130Sstevel@tonic-gate 4140Sstevel@tonic-gate ulong_t 4150Sstevel@tonic-gate atomic_cas_ulong(volatile ulong_t *target, ulong_t cmp, ulong_t new) 4160Sstevel@tonic-gate { 4170Sstevel@tonic-gate ulong_t old = *target; 4180Sstevel@tonic-gate if (old == cmp) 4190Sstevel@tonic-gate *target = new; 4200Sstevel@tonic-gate return (old); 4210Sstevel@tonic-gate } 4220Sstevel@tonic-gate 4230Sstevel@tonic-gate uint64_t 4240Sstevel@tonic-gate atomic_cas_uint64(volatile uint64_t *target, ulong_t cmp, uint64_t new) 4250Sstevel@tonic-gate { 4260Sstevel@tonic-gate uint64_t old = *target; 4270Sstevel@tonic-gate if (old == cmp) 4280Sstevel@tonic-gate *target = new; 4290Sstevel@tonic-gate return (old); 4300Sstevel@tonic-gate } 4310Sstevel@tonic-gate 4320Sstevel@tonic-gate void * 4330Sstevel@tonic-gate atomic_cas_ptr(volatile void *target, void *cmp, void *new) 4340Sstevel@tonic-gate { 4350Sstevel@tonic-gate void *old = *(void **)target; 4360Sstevel@tonic-gate if (old == cmp) 4370Sstevel@tonic-gate *(void **)target = new; 4380Sstevel@tonic-gate return (old); 4390Sstevel@tonic-gate } 4400Sstevel@tonic-gate 4410Sstevel@tonic-gate uint8_t 4420Sstevel@tonic-gate atomic_swap_8(volatile uint8_t *target, uint8_t new) 4430Sstevel@tonic-gate { 4440Sstevel@tonic-gate uint8_t old = *target; 4450Sstevel@tonic-gate *target = new; 4460Sstevel@tonic-gate return (old); 4470Sstevel@tonic-gate } 4480Sstevel@tonic-gate 4490Sstevel@tonic-gate uchar_t 4500Sstevel@tonic-gate atomic_swap_char(volatile uchar_t *target, uchar_t new) 4510Sstevel@tonic-gate { 4520Sstevel@tonic-gate uchar_t old = *target; 4530Sstevel@tonic-gate *target = new; 4540Sstevel@tonic-gate return (old); 4550Sstevel@tonic-gate } 4560Sstevel@tonic-gate 4570Sstevel@tonic-gate uint16_t 4580Sstevel@tonic-gate atomic_swap_16(volatile uint16_t *target, uint16_t new) 4590Sstevel@tonic-gate { 4600Sstevel@tonic-gate uint16_t old = *target; 4610Sstevel@tonic-gate *target = new; 4620Sstevel@tonic-gate return (old); 4630Sstevel@tonic-gate } 4640Sstevel@tonic-gate 4650Sstevel@tonic-gate ushort_t 4660Sstevel@tonic-gate atomic_swap_ushort(volatile ushort_t *target, ushort_t new) 4670Sstevel@tonic-gate { 4680Sstevel@tonic-gate ushort_t old = *target; 4690Sstevel@tonic-gate *target = new; 4700Sstevel@tonic-gate return (old); 4710Sstevel@tonic-gate } 4720Sstevel@tonic-gate 4730Sstevel@tonic-gate uint32_t 4740Sstevel@tonic-gate atomic_swap_32(volatile uint32_t *target, uint32_t new) 4750Sstevel@tonic-gate { 4760Sstevel@tonic-gate uint32_t old = *target; 4770Sstevel@tonic-gate *target = new; 4780Sstevel@tonic-gate return (old); 4790Sstevel@tonic-gate } 4800Sstevel@tonic-gate 4810Sstevel@tonic-gate uint_t 4820Sstevel@tonic-gate atomic_swap_uint(volatile uint_t *target, uint_t new) 4830Sstevel@tonic-gate { 484*5352Ssvemuri uint_t old = *target; 4850Sstevel@tonic-gate *target = new; 4860Sstevel@tonic-gate return (old); 4870Sstevel@tonic-gate } 4880Sstevel@tonic-gate 4890Sstevel@tonic-gate uint64_t 4900Sstevel@tonic-gate atomic_swap_64(volatile uint64_t *target, uint64_t new) 4910Sstevel@tonic-gate { 4920Sstevel@tonic-gate uint64_t old = *target; 4930Sstevel@tonic-gate *target = new; 4940Sstevel@tonic-gate return (old); 4950Sstevel@tonic-gate } 4960Sstevel@tonic-gate 4970Sstevel@tonic-gate void * 4980Sstevel@tonic-gate atomic_swap_ptr(volatile void *target, void *new) 4990Sstevel@tonic-gate { 5000Sstevel@tonic-gate void *old = *(void **)target; 5010Sstevel@tonic-gate *(void **)target = new; 5020Sstevel@tonic-gate return (old); 5030Sstevel@tonic-gate } 5040Sstevel@tonic-gate 5050Sstevel@tonic-gate ulong_t 5060Sstevel@tonic-gate atomic_swap_ulong(volatile ulong_t *target, ulong_t new) 5070Sstevel@tonic-gate { 5080Sstevel@tonic-gate ulong_t old = *target; 5090Sstevel@tonic-gate *target = new; 5100Sstevel@tonic-gate return (old); 5110Sstevel@tonic-gate } 5120Sstevel@tonic-gate 5130Sstevel@tonic-gate int 5140Sstevel@tonic-gate atomic_set_long_excl(volatile ulong_t *target, uint_t value) 5150Sstevel@tonic-gate { 5160Sstevel@tonic-gate ulong_t bit = (1UL << value); 5170Sstevel@tonic-gate if ((*target & bit) != 0) 5180Sstevel@tonic-gate return (-1); 5190Sstevel@tonic-gate *target |= bit; 5200Sstevel@tonic-gate return (0); 5210Sstevel@tonic-gate } 5220Sstevel@tonic-gate 5230Sstevel@tonic-gate int 5240Sstevel@tonic-gate atomic_clear_long_excl(volatile ulong_t *target, uint_t value) 5250Sstevel@tonic-gate { 5260Sstevel@tonic-gate ulong_t bit = (1UL << value); 5270Sstevel@tonic-gate if ((*target & bit) == 0) 5280Sstevel@tonic-gate return (-1); 5290Sstevel@tonic-gate *target &= ~bit; 5300Sstevel@tonic-gate return (0); 5310Sstevel@tonic-gate } 5320Sstevel@tonic-gate 5330Sstevel@tonic-gate #if !defined(_KERNEL) 5340Sstevel@tonic-gate 5350Sstevel@tonic-gate void 5360Sstevel@tonic-gate membar_enter(void) 5370Sstevel@tonic-gate {} 5380Sstevel@tonic-gate 5390Sstevel@tonic-gate void 5400Sstevel@tonic-gate membar_exit(void) 5410Sstevel@tonic-gate {} 5420Sstevel@tonic-gate 5430Sstevel@tonic-gate void 5440Sstevel@tonic-gate membar_producer(void) 5450Sstevel@tonic-gate {} 5460Sstevel@tonic-gate 5470Sstevel@tonic-gate void 5480Sstevel@tonic-gate membar_consumer(void) 5490Sstevel@tonic-gate {} 5500Sstevel@tonic-gate 5510Sstevel@tonic-gate #endif /* _KERNEL */ 5520Sstevel@tonic-gate 5530Sstevel@tonic-gate #endif /* __lint */ 554