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 5*b02e9a2dSsvemuri * Common Development and Distribution License (the "License"). 6*b02e9a2dSsvemuri * 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 */ 217c478bd9Sstevel@tonic-gate /* 22*b02e9a2dSsvemuri * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #include <sys/atomic.h> 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate /* 317c478bd9Sstevel@tonic-gate * This file exists only for the purpose of running lint. 327c478bd9Sstevel@tonic-gate */ 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #if defined(__lint) 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate void 377c478bd9Sstevel@tonic-gate atomic_inc_8(volatile uint8_t *target) 387c478bd9Sstevel@tonic-gate { (*target)++; } 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate void 417c478bd9Sstevel@tonic-gate atomic_inc_uchar(volatile uchar_t *target) 427c478bd9Sstevel@tonic-gate { (*target)++; } 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate void 457c478bd9Sstevel@tonic-gate atomic_inc_16(volatile uint16_t *target) 467c478bd9Sstevel@tonic-gate { (*target)++; } 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate void 497c478bd9Sstevel@tonic-gate atomic_inc_ushort(volatile ushort_t *target) 507c478bd9Sstevel@tonic-gate { (*target)++; } 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate void 537c478bd9Sstevel@tonic-gate atomic_inc_32(volatile uint32_t *target) 547c478bd9Sstevel@tonic-gate { (*target)++; } 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate void 577c478bd9Sstevel@tonic-gate atomic_inc_uint(volatile uint_t *target) 587c478bd9Sstevel@tonic-gate { (*target)++; } 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate void 617c478bd9Sstevel@tonic-gate atomic_inc_ulong(volatile ulong_t *target) 627c478bd9Sstevel@tonic-gate { (*target)++; } 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate void 657c478bd9Sstevel@tonic-gate atomic_inc_64(volatile uint64_t *target) 667c478bd9Sstevel@tonic-gate { (*target)++; } 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate void 697c478bd9Sstevel@tonic-gate atomic_dec_8(volatile uint8_t *target) 707c478bd9Sstevel@tonic-gate { (*target)--; } 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate void 737c478bd9Sstevel@tonic-gate atomic_dec_uchar(volatile uchar_t *target) 747c478bd9Sstevel@tonic-gate { (*target)--; } 757c478bd9Sstevel@tonic-gate 767c478bd9Sstevel@tonic-gate void 777c478bd9Sstevel@tonic-gate atomic_dec_16(volatile uint16_t *target) 787c478bd9Sstevel@tonic-gate { (*target)--; } 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate void 817c478bd9Sstevel@tonic-gate atomic_dec_ushort(volatile ushort_t *target) 827c478bd9Sstevel@tonic-gate { (*target)--; } 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate void 857c478bd9Sstevel@tonic-gate atomic_dec_32(volatile uint32_t *target) 867c478bd9Sstevel@tonic-gate { (*target)--; } 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate void 897c478bd9Sstevel@tonic-gate atomic_dec_uint(volatile uint_t *target) 907c478bd9Sstevel@tonic-gate { (*target)--; } 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate void 937c478bd9Sstevel@tonic-gate atomic_dec_ulong(volatile ulong_t *target) 947c478bd9Sstevel@tonic-gate { (*target)--; } 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate void 977c478bd9Sstevel@tonic-gate atomic_dec_64(volatile uint64_t *target) 987c478bd9Sstevel@tonic-gate { (*target)--; } 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate void 1017c478bd9Sstevel@tonic-gate atomic_add_8(volatile uint8_t *target, int8_t value) 1027c478bd9Sstevel@tonic-gate { *target += value; } 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate void 1057c478bd9Sstevel@tonic-gate atomic_add_char(volatile uchar_t *target, signed char value) 1067c478bd9Sstevel@tonic-gate { *target += value; } 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate void 1097c478bd9Sstevel@tonic-gate atomic_add_16(volatile uint16_t *target, int16_t delta) 1107c478bd9Sstevel@tonic-gate { *target += delta; } 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate void 1137c478bd9Sstevel@tonic-gate atomic_add_ushort(volatile ushort_t *target, short value) 1147c478bd9Sstevel@tonic-gate { *target += value; } 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate void 1177c478bd9Sstevel@tonic-gate atomic_add_32(volatile uint32_t *target, int32_t delta) 1187c478bd9Sstevel@tonic-gate { *target += delta; } 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate void 1217c478bd9Sstevel@tonic-gate atomic_add_ptr(volatile void *target, ssize_t value) 1227c478bd9Sstevel@tonic-gate { *(caddr_t *)target += value; } 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate void 1257c478bd9Sstevel@tonic-gate atomic_add_long(volatile ulong_t *target, long delta) 1267c478bd9Sstevel@tonic-gate { *target += delta; } 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate void 1297c478bd9Sstevel@tonic-gate atomic_add_64(volatile uint64_t *target, int64_t delta) 1307c478bd9Sstevel@tonic-gate { *target += delta; } 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate void 1337c478bd9Sstevel@tonic-gate atomic_or_8(volatile uint8_t *target, uint8_t bits) 1347c478bd9Sstevel@tonic-gate { *target |= bits; } 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate void 1377c478bd9Sstevel@tonic-gate atomic_or_uchar(volatile uchar_t *target, uchar_t bits) 1387c478bd9Sstevel@tonic-gate { *target |= bits; } 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate void 1417c478bd9Sstevel@tonic-gate atomic_or_16(volatile uint16_t *target, uint16_t bits) 1427c478bd9Sstevel@tonic-gate { *target |= bits; } 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate void 1457c478bd9Sstevel@tonic-gate atomic_or_ushort(volatile ushort_t *target, ushort_t bits) 1467c478bd9Sstevel@tonic-gate { *target |= bits; } 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate void 1497c478bd9Sstevel@tonic-gate atomic_or_32(volatile uint32_t *target, uint32_t bits) 1507c478bd9Sstevel@tonic-gate { *target |= bits; } 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate void 1537c478bd9Sstevel@tonic-gate atomic_or_uint(volatile uint_t *target, uint_t bits) 1547c478bd9Sstevel@tonic-gate { *target |= bits; } 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate void 1577c478bd9Sstevel@tonic-gate atomic_or_ulong(volatile ulong_t *target, ulong_t bits) 1587c478bd9Sstevel@tonic-gate { *target |= bits; } 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate void 1617c478bd9Sstevel@tonic-gate atomic_or_64(volatile uint64_t *target, uint64_t bits) 1627c478bd9Sstevel@tonic-gate { *target |= bits; } 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate void 1657c478bd9Sstevel@tonic-gate atomic_and_8(volatile uint8_t *target, uint8_t bits) 1667c478bd9Sstevel@tonic-gate { *target &= bits; } 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate void 1697c478bd9Sstevel@tonic-gate atomic_and_uchar(volatile uchar_t *target, uchar_t bits) 1707c478bd9Sstevel@tonic-gate { *target &= bits; } 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate void 1737c478bd9Sstevel@tonic-gate atomic_and_16(volatile uint16_t *target, uint16_t bits) 1747c478bd9Sstevel@tonic-gate { *target &= bits; } 1757c478bd9Sstevel@tonic-gate 1767c478bd9Sstevel@tonic-gate void 1777c478bd9Sstevel@tonic-gate atomic_and_ushort(volatile ushort_t *target, ushort_t bits) 1787c478bd9Sstevel@tonic-gate { *target &= bits; } 1797c478bd9Sstevel@tonic-gate 1807c478bd9Sstevel@tonic-gate void 1817c478bd9Sstevel@tonic-gate atomic_and_32(volatile uint32_t *target, uint32_t bits) 1827c478bd9Sstevel@tonic-gate { *target &= bits; } 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate void 1857c478bd9Sstevel@tonic-gate atomic_and_uint(volatile uint_t *target, uint_t bits) 1867c478bd9Sstevel@tonic-gate { *target &= bits; } 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate void 1897c478bd9Sstevel@tonic-gate atomic_and_ulong(volatile ulong_t *target, ulong_t bits) 1907c478bd9Sstevel@tonic-gate { *target &= bits; } 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate void 1937c478bd9Sstevel@tonic-gate atomic_and_64(volatile uint64_t *target, uint64_t bits) 1947c478bd9Sstevel@tonic-gate { *target &= bits; } 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate uint8_t 1977c478bd9Sstevel@tonic-gate atomic_inc_8_nv(volatile uint8_t *target) 1987c478bd9Sstevel@tonic-gate { return (++(*target)); } 1997c478bd9Sstevel@tonic-gate 2007c478bd9Sstevel@tonic-gate uchar_t 2017c478bd9Sstevel@tonic-gate atomic_inc_uchar_nv(volatile uchar_t *target) 2027c478bd9Sstevel@tonic-gate { return (++(*target)); } 2037c478bd9Sstevel@tonic-gate 2047c478bd9Sstevel@tonic-gate uint16_t 2057c478bd9Sstevel@tonic-gate atomic_inc_16_nv(volatile uint16_t *target) 2067c478bd9Sstevel@tonic-gate { return (++(*target)); } 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate ushort_t 2097c478bd9Sstevel@tonic-gate atomic_inc_ushort_nv(volatile ushort_t *target) 2107c478bd9Sstevel@tonic-gate { return (++(*target)); } 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate uint32_t 2137c478bd9Sstevel@tonic-gate atomic_inc_32_nv(volatile uint32_t *target) 2147c478bd9Sstevel@tonic-gate { return (++(*target)); } 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate uint_t 2177c478bd9Sstevel@tonic-gate atomic_inc_uint_nv(volatile uint_t *target) 2187c478bd9Sstevel@tonic-gate { return (++(*target)); } 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate ulong_t 2217c478bd9Sstevel@tonic-gate atomic_inc_ulong_nv(volatile ulong_t *target) 2227c478bd9Sstevel@tonic-gate { return (++(*target)); } 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate uint64_t 2257c478bd9Sstevel@tonic-gate atomic_inc_64_nv(volatile uint64_t *target) 2267c478bd9Sstevel@tonic-gate { return (++(*target)); } 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate uint8_t 2297c478bd9Sstevel@tonic-gate atomic_dec_8_nv(volatile uint8_t *target) 2307c478bd9Sstevel@tonic-gate { return (--(*target)); } 2317c478bd9Sstevel@tonic-gate 2327c478bd9Sstevel@tonic-gate uchar_t 2337c478bd9Sstevel@tonic-gate atomic_dec_uchar_nv(volatile uchar_t *target) 2347c478bd9Sstevel@tonic-gate { return (--(*target)); } 2357c478bd9Sstevel@tonic-gate 2367c478bd9Sstevel@tonic-gate uint16_t 2377c478bd9Sstevel@tonic-gate atomic_dec_16_nv(volatile uint16_t *target) 2387c478bd9Sstevel@tonic-gate { return (--(*target)); } 2397c478bd9Sstevel@tonic-gate 2407c478bd9Sstevel@tonic-gate ushort_t 2417c478bd9Sstevel@tonic-gate atomic_dec_ushort_nv(volatile ushort_t *target) 2427c478bd9Sstevel@tonic-gate { return (--(*target)); } 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate uint32_t 2457c478bd9Sstevel@tonic-gate atomic_dec_32_nv(volatile uint32_t *target) 2467c478bd9Sstevel@tonic-gate { return (--(*target)); } 2477c478bd9Sstevel@tonic-gate 2487c478bd9Sstevel@tonic-gate uint_t 2497c478bd9Sstevel@tonic-gate atomic_dec_uint_nv(volatile uint_t *target) 2507c478bd9Sstevel@tonic-gate { return (--(*target)); } 2517c478bd9Sstevel@tonic-gate 2527c478bd9Sstevel@tonic-gate ulong_t 2537c478bd9Sstevel@tonic-gate atomic_dec_ulong_nv(volatile ulong_t *target) 2547c478bd9Sstevel@tonic-gate { return (--(*target)); } 2557c478bd9Sstevel@tonic-gate 2567c478bd9Sstevel@tonic-gate uint64_t 2577c478bd9Sstevel@tonic-gate atomic_dec_64_nv(volatile uint64_t *target) 2587c478bd9Sstevel@tonic-gate { return (--(*target)); } 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate uint8_t 2617c478bd9Sstevel@tonic-gate atomic_add_8_nv(volatile uint8_t *target, int8_t value) 2627c478bd9Sstevel@tonic-gate { return (*target += value); } 2637c478bd9Sstevel@tonic-gate 2647c478bd9Sstevel@tonic-gate uchar_t 2657c478bd9Sstevel@tonic-gate atomic_add_char_nv(volatile uchar_t *target, signed char value) 2667c478bd9Sstevel@tonic-gate { return (*target += value); } 2677c478bd9Sstevel@tonic-gate 2687c478bd9Sstevel@tonic-gate uint16_t 2697c478bd9Sstevel@tonic-gate atomic_add_16_nv(volatile uint16_t *target, int16_t delta) 2707c478bd9Sstevel@tonic-gate { return (*target += delta); } 2717c478bd9Sstevel@tonic-gate 2727c478bd9Sstevel@tonic-gate ushort_t 2737c478bd9Sstevel@tonic-gate atomic_add_short_nv(volatile ushort_t *target, short value) 2747c478bd9Sstevel@tonic-gate { return (*target += value); } 2757c478bd9Sstevel@tonic-gate 2767c478bd9Sstevel@tonic-gate uint32_t 2777c478bd9Sstevel@tonic-gate atomic_add_32_nv(volatile uint32_t *target, int32_t delta) 2787c478bd9Sstevel@tonic-gate { return (*target += delta); } 2797c478bd9Sstevel@tonic-gate 2807c478bd9Sstevel@tonic-gate uint_t 2817c478bd9Sstevel@tonic-gate atomic_add_int_nv(volatile uint_t *target, int delta) 2827c478bd9Sstevel@tonic-gate { return (*target += delta); } 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate void * 2857c478bd9Sstevel@tonic-gate atomic_add_ptr_nv(volatile void *target, ssize_t value) 2867c478bd9Sstevel@tonic-gate { return (*(caddr_t *)target += value); } 2877c478bd9Sstevel@tonic-gate 2887c478bd9Sstevel@tonic-gate ulong_t 2897c478bd9Sstevel@tonic-gate atomic_add_long_nv(volatile ulong_t *target, long delta) 2907c478bd9Sstevel@tonic-gate { return (*target += delta); } 2917c478bd9Sstevel@tonic-gate 2927c478bd9Sstevel@tonic-gate uint64_t 2937c478bd9Sstevel@tonic-gate atomic_add_64_nv(volatile uint64_t *target, int64_t delta) 2947c478bd9Sstevel@tonic-gate { return (*target += delta); } 2957c478bd9Sstevel@tonic-gate 2967c478bd9Sstevel@tonic-gate uint8_t 2977c478bd9Sstevel@tonic-gate atomic_or_8_nv(volatile uint8_t *target, uint8_t value) 2987c478bd9Sstevel@tonic-gate { return (*target |= value); } 2997c478bd9Sstevel@tonic-gate 3007c478bd9Sstevel@tonic-gate uchar_t 3017c478bd9Sstevel@tonic-gate atomic_or_uchar_nv(volatile uchar_t *target, uchar_t value) 3027c478bd9Sstevel@tonic-gate { return (*target |= value); } 3037c478bd9Sstevel@tonic-gate 3047c478bd9Sstevel@tonic-gate uint16_t 3057c478bd9Sstevel@tonic-gate atomic_or_16_nv(volatile uint16_t *target, uint16_t value) 3067c478bd9Sstevel@tonic-gate { return (*target |= value); } 3077c478bd9Sstevel@tonic-gate 3087c478bd9Sstevel@tonic-gate ushort_t 3097c478bd9Sstevel@tonic-gate atomic_or_ushort_nv(volatile ushort_t *target, ushort_t value) 3107c478bd9Sstevel@tonic-gate { return (*target |= value); } 3117c478bd9Sstevel@tonic-gate 3127c478bd9Sstevel@tonic-gate uint32_t 3137c478bd9Sstevel@tonic-gate atomic_or_32_nv(volatile uint32_t *target, uint32_t value) 3147c478bd9Sstevel@tonic-gate { return (*target |= value); } 3157c478bd9Sstevel@tonic-gate 3167c478bd9Sstevel@tonic-gate uint_t 3177c478bd9Sstevel@tonic-gate atomic_or_uint_nv(volatile uint_t *target, uint_t value) 3187c478bd9Sstevel@tonic-gate { return (*target |= value); } 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate ulong_t 3217c478bd9Sstevel@tonic-gate atomic_or_ulong_nv(volatile ulong_t *target, ulong_t value) 3227c478bd9Sstevel@tonic-gate { return (*target |= value); } 3237c478bd9Sstevel@tonic-gate 3247c478bd9Sstevel@tonic-gate uint64_t 3257c478bd9Sstevel@tonic-gate atomic_or_64_nv(volatile uint64_t *target, uint64_t value) 3267c478bd9Sstevel@tonic-gate { return (*target |= value); } 3277c478bd9Sstevel@tonic-gate 3287c478bd9Sstevel@tonic-gate uint8_t 3297c478bd9Sstevel@tonic-gate atomic_and_8_nv(volatile uint8_t *target, uint8_t value) 3307c478bd9Sstevel@tonic-gate { return (*target &= value); } 3317c478bd9Sstevel@tonic-gate 3327c478bd9Sstevel@tonic-gate uchar_t 3337c478bd9Sstevel@tonic-gate atomic_and_uchar_nv(volatile uchar_t *target, uchar_t value) 3347c478bd9Sstevel@tonic-gate { return (*target &= value); } 3357c478bd9Sstevel@tonic-gate 3367c478bd9Sstevel@tonic-gate uint16_t 3377c478bd9Sstevel@tonic-gate atomic_and_16_nv(volatile uint16_t *target, uint16_t value) 3387c478bd9Sstevel@tonic-gate { return (*target &= value); } 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gate ushort_t 3417c478bd9Sstevel@tonic-gate atomic_and_ushort_nv(volatile ushort_t *target, ushort_t value) 3427c478bd9Sstevel@tonic-gate { return (*target &= value); } 3437c478bd9Sstevel@tonic-gate 3447c478bd9Sstevel@tonic-gate uint32_t 3457c478bd9Sstevel@tonic-gate atomic_and_32_nv(volatile uint32_t *target, uint32_t value) 3467c478bd9Sstevel@tonic-gate { return (*target &= value); } 3477c478bd9Sstevel@tonic-gate 3487c478bd9Sstevel@tonic-gate uint_t 3497c478bd9Sstevel@tonic-gate atomic_and_uint_nv(volatile uint_t *target, uint_t value) 3507c478bd9Sstevel@tonic-gate { return (*target &= value); } 3517c478bd9Sstevel@tonic-gate 3527c478bd9Sstevel@tonic-gate ulong_t 3537c478bd9Sstevel@tonic-gate atomic_and_ulong_nv(volatile ulong_t *target, ulong_t value) 3547c478bd9Sstevel@tonic-gate { return (*target &= value); } 3557c478bd9Sstevel@tonic-gate 3567c478bd9Sstevel@tonic-gate uint64_t 3577c478bd9Sstevel@tonic-gate atomic_and_64_nv(volatile uint64_t *target, uint64_t value) 3587c478bd9Sstevel@tonic-gate { return (*target &= value); } 3597c478bd9Sstevel@tonic-gate 3607c478bd9Sstevel@tonic-gate uint8_t 3617c478bd9Sstevel@tonic-gate atomic_cas_8(volatile uint8_t *target, uint8_t cmp, uint8_t new) 3627c478bd9Sstevel@tonic-gate { 3637c478bd9Sstevel@tonic-gate uint8_t old = *target; 3647c478bd9Sstevel@tonic-gate if (old == cmp) 3657c478bd9Sstevel@tonic-gate *target = new; 3667c478bd9Sstevel@tonic-gate return (old); 3677c478bd9Sstevel@tonic-gate } 3687c478bd9Sstevel@tonic-gate 3697c478bd9Sstevel@tonic-gate uchar_t 3707c478bd9Sstevel@tonic-gate atomic_cas_uchar(volatile uchar_t *target, uchar_t cmp, uchar_t new) 3717c478bd9Sstevel@tonic-gate { 3727c478bd9Sstevel@tonic-gate uchar_t old = *target; 3737c478bd9Sstevel@tonic-gate if (old == cmp) 3747c478bd9Sstevel@tonic-gate *target = new; 3757c478bd9Sstevel@tonic-gate return (old); 3767c478bd9Sstevel@tonic-gate } 3777c478bd9Sstevel@tonic-gate 3787c478bd9Sstevel@tonic-gate uint16_t 3797c478bd9Sstevel@tonic-gate atomic_cas_16(volatile uint16_t *target, uint16_t cmp, uint16_t new) 3807c478bd9Sstevel@tonic-gate { 3817c478bd9Sstevel@tonic-gate uint16_t old = *target; 3827c478bd9Sstevel@tonic-gate if (old == cmp) 3837c478bd9Sstevel@tonic-gate *target = new; 3847c478bd9Sstevel@tonic-gate return (old); 3857c478bd9Sstevel@tonic-gate } 3867c478bd9Sstevel@tonic-gate 3877c478bd9Sstevel@tonic-gate ushort_t 3887c478bd9Sstevel@tonic-gate atomic_cas_ushort(volatile ushort_t *target, ushort_t cmp, ushort_t new) 3897c478bd9Sstevel@tonic-gate { 3907c478bd9Sstevel@tonic-gate ushort_t old = *target; 3917c478bd9Sstevel@tonic-gate if (old == cmp) 3927c478bd9Sstevel@tonic-gate *target = new; 3937c478bd9Sstevel@tonic-gate return (old); 3947c478bd9Sstevel@tonic-gate } 3957c478bd9Sstevel@tonic-gate 3967c478bd9Sstevel@tonic-gate uint32_t 3977c478bd9Sstevel@tonic-gate atomic_cas_32(volatile uint32_t *target, uint32_t cmp, uint32_t new) 3987c478bd9Sstevel@tonic-gate { 3997c478bd9Sstevel@tonic-gate uint32_t old = *target; 4007c478bd9Sstevel@tonic-gate if (old == cmp) 4017c478bd9Sstevel@tonic-gate *target = new; 4027c478bd9Sstevel@tonic-gate return (old); 4037c478bd9Sstevel@tonic-gate } 4047c478bd9Sstevel@tonic-gate 4057c478bd9Sstevel@tonic-gate uint_t 4067c478bd9Sstevel@tonic-gate atomic_cas_uint(volatile uint_t *target, uint_t cmp, uint_t new) 4077c478bd9Sstevel@tonic-gate { 4087c478bd9Sstevel@tonic-gate uint_t old = *target; 4097c478bd9Sstevel@tonic-gate if (old == cmp) 4107c478bd9Sstevel@tonic-gate *target = new; 4117c478bd9Sstevel@tonic-gate return (old); 4127c478bd9Sstevel@tonic-gate } 4137c478bd9Sstevel@tonic-gate 4147c478bd9Sstevel@tonic-gate ulong_t 4157c478bd9Sstevel@tonic-gate atomic_cas_ulong(volatile ulong_t *target, ulong_t cmp, ulong_t new) 4167c478bd9Sstevel@tonic-gate { 4177c478bd9Sstevel@tonic-gate ulong_t old = *target; 4187c478bd9Sstevel@tonic-gate if (old == cmp) 4197c478bd9Sstevel@tonic-gate *target = new; 4207c478bd9Sstevel@tonic-gate return (old); 4217c478bd9Sstevel@tonic-gate } 4227c478bd9Sstevel@tonic-gate 4237c478bd9Sstevel@tonic-gate uint64_t 4247c478bd9Sstevel@tonic-gate atomic_cas_uint64(volatile uint64_t *target, ulong_t cmp, uint64_t new) 4257c478bd9Sstevel@tonic-gate { 4267c478bd9Sstevel@tonic-gate uint64_t old = *target; 4277c478bd9Sstevel@tonic-gate if (old == cmp) 4287c478bd9Sstevel@tonic-gate *target = new; 4297c478bd9Sstevel@tonic-gate return (old); 4307c478bd9Sstevel@tonic-gate } 4317c478bd9Sstevel@tonic-gate 4327c478bd9Sstevel@tonic-gate void * 4337c478bd9Sstevel@tonic-gate atomic_cas_ptr(volatile void *target, void *cmp, void *new) 4347c478bd9Sstevel@tonic-gate { 4357c478bd9Sstevel@tonic-gate void *old = *(void **)target; 4367c478bd9Sstevel@tonic-gate if (old == cmp) 4377c478bd9Sstevel@tonic-gate *(void **)target = new; 4387c478bd9Sstevel@tonic-gate return (old); 4397c478bd9Sstevel@tonic-gate } 4407c478bd9Sstevel@tonic-gate 4417c478bd9Sstevel@tonic-gate uint8_t 4427c478bd9Sstevel@tonic-gate atomic_swap_8(volatile uint8_t *target, uint8_t new) 4437c478bd9Sstevel@tonic-gate { 4447c478bd9Sstevel@tonic-gate uint8_t old = *target; 4457c478bd9Sstevel@tonic-gate *target = new; 4467c478bd9Sstevel@tonic-gate return (old); 4477c478bd9Sstevel@tonic-gate } 4487c478bd9Sstevel@tonic-gate 4497c478bd9Sstevel@tonic-gate uchar_t 4507c478bd9Sstevel@tonic-gate atomic_swap_char(volatile uchar_t *target, uchar_t new) 4517c478bd9Sstevel@tonic-gate { 4527c478bd9Sstevel@tonic-gate uchar_t old = *target; 4537c478bd9Sstevel@tonic-gate *target = new; 4547c478bd9Sstevel@tonic-gate return (old); 4557c478bd9Sstevel@tonic-gate } 4567c478bd9Sstevel@tonic-gate 4577c478bd9Sstevel@tonic-gate uint16_t 4587c478bd9Sstevel@tonic-gate atomic_swap_16(volatile uint16_t *target, uint16_t new) 4597c478bd9Sstevel@tonic-gate { 4607c478bd9Sstevel@tonic-gate uint16_t old = *target; 4617c478bd9Sstevel@tonic-gate *target = new; 4627c478bd9Sstevel@tonic-gate return (old); 4637c478bd9Sstevel@tonic-gate } 4647c478bd9Sstevel@tonic-gate 4657c478bd9Sstevel@tonic-gate ushort_t 4667c478bd9Sstevel@tonic-gate atomic_swap_ushort(volatile ushort_t *target, ushort_t new) 4677c478bd9Sstevel@tonic-gate { 4687c478bd9Sstevel@tonic-gate ushort_t old = *target; 4697c478bd9Sstevel@tonic-gate *target = new; 4707c478bd9Sstevel@tonic-gate return (old); 4717c478bd9Sstevel@tonic-gate } 4727c478bd9Sstevel@tonic-gate 4737c478bd9Sstevel@tonic-gate uint32_t 4747c478bd9Sstevel@tonic-gate atomic_swap_32(volatile uint32_t *target, uint32_t new) 4757c478bd9Sstevel@tonic-gate { 4767c478bd9Sstevel@tonic-gate uint32_t old = *target; 4777c478bd9Sstevel@tonic-gate *target = new; 4787c478bd9Sstevel@tonic-gate return (old); 4797c478bd9Sstevel@tonic-gate } 4807c478bd9Sstevel@tonic-gate 4817c478bd9Sstevel@tonic-gate uint_t 4827c478bd9Sstevel@tonic-gate atomic_swap_uint(volatile uint_t *target, uint_t new) 4837c478bd9Sstevel@tonic-gate { 484*b02e9a2dSsvemuri uint_t old = *target; 4857c478bd9Sstevel@tonic-gate *target = new; 4867c478bd9Sstevel@tonic-gate return (old); 4877c478bd9Sstevel@tonic-gate } 4887c478bd9Sstevel@tonic-gate 4897c478bd9Sstevel@tonic-gate uint64_t 4907c478bd9Sstevel@tonic-gate atomic_swap_64(volatile uint64_t *target, uint64_t new) 4917c478bd9Sstevel@tonic-gate { 4927c478bd9Sstevel@tonic-gate uint64_t old = *target; 4937c478bd9Sstevel@tonic-gate *target = new; 4947c478bd9Sstevel@tonic-gate return (old); 4957c478bd9Sstevel@tonic-gate } 4967c478bd9Sstevel@tonic-gate 4977c478bd9Sstevel@tonic-gate void * 4987c478bd9Sstevel@tonic-gate atomic_swap_ptr(volatile void *target, void *new) 4997c478bd9Sstevel@tonic-gate { 5007c478bd9Sstevel@tonic-gate void *old = *(void **)target; 5017c478bd9Sstevel@tonic-gate *(void **)target = new; 5027c478bd9Sstevel@tonic-gate return (old); 5037c478bd9Sstevel@tonic-gate } 5047c478bd9Sstevel@tonic-gate 5057c478bd9Sstevel@tonic-gate ulong_t 5067c478bd9Sstevel@tonic-gate atomic_swap_ulong(volatile ulong_t *target, ulong_t new) 5077c478bd9Sstevel@tonic-gate { 5087c478bd9Sstevel@tonic-gate ulong_t old = *target; 5097c478bd9Sstevel@tonic-gate *target = new; 5107c478bd9Sstevel@tonic-gate return (old); 5117c478bd9Sstevel@tonic-gate } 5127c478bd9Sstevel@tonic-gate 5137c478bd9Sstevel@tonic-gate int 5147c478bd9Sstevel@tonic-gate atomic_set_long_excl(volatile ulong_t *target, uint_t value) 5157c478bd9Sstevel@tonic-gate { 5167c478bd9Sstevel@tonic-gate ulong_t bit = (1UL << value); 5177c478bd9Sstevel@tonic-gate if ((*target & bit) != 0) 5187c478bd9Sstevel@tonic-gate return (-1); 5197c478bd9Sstevel@tonic-gate *target |= bit; 5207c478bd9Sstevel@tonic-gate return (0); 5217c478bd9Sstevel@tonic-gate } 5227c478bd9Sstevel@tonic-gate 5237c478bd9Sstevel@tonic-gate int 5247c478bd9Sstevel@tonic-gate atomic_clear_long_excl(volatile ulong_t *target, uint_t value) 5257c478bd9Sstevel@tonic-gate { 5267c478bd9Sstevel@tonic-gate ulong_t bit = (1UL << value); 5277c478bd9Sstevel@tonic-gate if ((*target & bit) == 0) 5287c478bd9Sstevel@tonic-gate return (-1); 5297c478bd9Sstevel@tonic-gate *target &= ~bit; 5307c478bd9Sstevel@tonic-gate return (0); 5317c478bd9Sstevel@tonic-gate } 5327c478bd9Sstevel@tonic-gate 5337c478bd9Sstevel@tonic-gate #if !defined(_KERNEL) 5347c478bd9Sstevel@tonic-gate 5357c478bd9Sstevel@tonic-gate void 5367c478bd9Sstevel@tonic-gate membar_enter(void) 5377c478bd9Sstevel@tonic-gate {} 5387c478bd9Sstevel@tonic-gate 5397c478bd9Sstevel@tonic-gate void 5407c478bd9Sstevel@tonic-gate membar_exit(void) 5417c478bd9Sstevel@tonic-gate {} 5427c478bd9Sstevel@tonic-gate 5437c478bd9Sstevel@tonic-gate void 5447c478bd9Sstevel@tonic-gate membar_producer(void) 5457c478bd9Sstevel@tonic-gate {} 5467c478bd9Sstevel@tonic-gate 5477c478bd9Sstevel@tonic-gate void 5487c478bd9Sstevel@tonic-gate membar_consumer(void) 5497c478bd9Sstevel@tonic-gate {} 5507c478bd9Sstevel@tonic-gate 5517c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 5527c478bd9Sstevel@tonic-gate 5537c478bd9Sstevel@tonic-gate #endif /* __lint */ 554