Print this page
5042 stop using deprecated atomic functions
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/io/nge/nge_atomic.c
+++ new/usr/src/uts/common/io/nge/nge_atomic.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 -#pragma ident "%Z%%M% %I% %E% SMI"
28 -
29 27 #include "nge.h"
30 28
31 29 /*
32 30 * Atomically decrement a counter, but only if it will remain
33 31 * positive (>=0) afterwards.
34 32 */
35 33 boolean_t
36 34 nge_atomic_decrease(uint64_t *count_p, uint64_t n)
37 35 {
38 36 uint64_t oldval;
39 37 uint64_t newval;
40 38
41 39 /* ATOMICALLY */
42 40 do {
43 41 oldval = *count_p;
44 42 newval = oldval - n;
45 43 if (oldval < n)
46 44 return (B_FALSE);
47 - } while (cas64(count_p, oldval, newval) != oldval);
45 + } while (atomic_cas_64(count_p, oldval, newval) != oldval);
48 46
49 47 return (B_TRUE);
50 48 }
51 49
52 50 /*
53 51 * Atomically increment a counter
54 52 */
55 53 void
56 54 nge_atomic_increase(uint64_t *count_p, uint64_t n)
57 55 {
58 56 uint64_t oldval;
59 57 uint64_t newval;
60 58
61 59 /* ATOMICALLY */
62 60 do {
63 61 oldval = *count_p;
64 62 newval = oldval + n;
65 - } while (cas64(count_p, oldval, newval) != oldval);
63 + } while (atomic_cas_64(count_p, oldval, newval) != oldval);
66 64 }
67 65
68 66
69 67 /*
70 68 * Atomically shift a 32-bit word left, returning
71 69 * the value it had *before* the shift was applied
72 70 */
73 71 uint32_t
74 72 nge_atomic_shl32(uint32_t *sp, uint_t count)
75 73 {
76 74 uint32_t oldval;
77 75 uint32_t newval;
78 76
79 77 /* ATOMICALLY */
80 78 do {
81 79 oldval = *sp;
82 80 newval = oldval << count;
83 - } while (cas32(sp, oldval, newval) != oldval);
81 + } while (atomic_cas_32(sp, oldval, newval) != oldval);
84 82
85 83 return (oldval);
86 84 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX