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