Debian Codegraph @

interfaces/cc/gcc/ppc32/atomic.h

raw
1 /*===========================================================================
2 *
3 * PUBLIC DOMAIN NOTICE
4 * National Center for Biotechnology Information
5 *
6 * This software/database is a "United States Government Work" under the
7 * terms of the United States Copyright Act. It was written as part of
8 * the author's official duties as a United States Government employee and
9 * thus cannot be copyrighted. This software/database is freely available
10 * to the public for use. The National Library of Medicine and the U.S.
11 * Government have not placed any restriction on its use or reproduction.
12 *
13 * Although all reasonable efforts have been taken to ensure the accuracy
14 * and reliability of the software and data, the NLM and the U.S.
15 * Government do not and cannot warrant the performance or results that
16 * may be obtained by using this software or data. The NLM and the U.S.
17 * Government disclaim all warranties, express or implied, including
18 * warranties of performance, merchantability or fitness for any particular
19 * purpose.
20 *
21 * Please cite the author in any work or product based on this material.
22 *
23 * ===========================================================================
24 *
25 */
26
27 #ifndef _h_atomic_
28 #define _h_atomic_
29
30 #ifndef _h_atomic32_
31 #include "atomic32.h"
32 #endif
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 typedef int atomic_int;
39 typedef atomic32_t atomic_t;
40
41 /* ( * v ) */
42 #define atomic_read( v ) \
43 atomic32_read ( v )
44
45 /* ( * v ) = i */
46 #define atomic_set( v, i ) \
47 atomic32_set ( v, i )
48
49 /* prior = ( * v ), ( * v ) += i, prior */
50 #define atomic_read_and_add( v, i ) \
51 atomic32_read_and_add ( v, i )
52
53 /* ( * v ) += i */
54 #define atomic_add( v, i ) \
55 atomic32_add ( v, i )
56
57 /* ( * v ) += i */
58 #define atomic_add_and_read( v, i ) \
59 atomic32_add_and_read ( v, i )
60
61 /* ( void ) ++ ( * v ) */
62 #define atomic_inc( v ) \
63 atomic32_inc ( v )
64
65 /* ( void ) -- ( * v ) */
66 #define atomic_dec( v ) \
67 atomic32_dec ( v )
68
69 /* -- ( * v ) == 0 */
70 #define atomic_dec_and_test( v ) \
71 atomic32_dec_and_test ( v )
72
73 /* ++ ( * v ) == 0
74 when atomic_dec_and_test uses predecrement, you want
75 postincrement to this function. so it isn't very useful */
76 #define atomic_inc_and_test( v ) \
77 atomic32_inc_and_test ( v )
78
79 /* ( * v ) -- == 0
80 HERE's useful */
81 #define atomic_test_and_inc( v ) \
82 atomic32_test_and_inc ( v )
83
84 /* prior = ( * v ), ( * v ) = ( prior == t ? s : prior ), prior */
85 #define atomic_test_and_set( v, s, t ) \
86 atomic32_test_and_set ( v, s, t )
87
88 /* N.B. - THIS FUNCTION IS FOR 32 BIT PTRS ONLY */
89 static __inline__ void *atomic_test_and_set_ptr ( void *volatile *v, void *s, void *t )
90 {
91 void *rtn = * v;
92 if ( rtn == t )
93 * v = s;
94 return rtn;
95 }
96
97 /* val = ( * v ), ( ( * v ) = ( val < t ) ? val + i : val ), val */
98 #define atomic_read_and_add_lt( v, i, t ) \
99 atomic32_read_and_add_lt ( v, i, t )
100
101 /* val = ( * v ), ( ( * v ) = ( val <= t ) ? val + i : val ), val */
102 #define atomic_read_and_add_le( v, i, t ) \
103 atomic32_read_and_add_le ( v, i, t )
104
105 /* val = ( * v ), ( ( * v ) = ( val == t ) ? val + i : val ), val */
106 #define atomic_read_and_add_eq( v, i, t ) \
107 atomic32_read_and_add_eq ( v, i, t )
108
109 /* val = ( * v ), ( ( * v ) = ( val != t ) ? val + i : val ), val */
110 #define atomic_read_and_add_ne( v, i, t ) \
111 atomic32_read_and_add_ne ( v, i, t )
112
113 /* val = ( * v ), ( ( * v ) = ( val >= t ) ? val + i : val ), val */
114 #define atomic_read_and_add_ge( v, i, t ) \
115 atomic32_read_and_add_ge ( v, i, t )
116
117 /* val = ( * v ), ( ( * v ) = ( val > t ) ? val + i : val ), val */
118 #define atomic_read_and_add_gt( v, i, t ) \
119 atomic32_read_and_add_gt ( v, i, t )
120
121 /* val = ( * v ), ( ( * v ) = ( ( val & 1 ) == 1 ) ? val + i : val ), val */
122 #define atomic_read_and_add_odd( v, i ) \
123 atomic32_read_and_add_odd ( v, i )
124
125 /* val = ( * v ), ( ( * v ) = ( ( val & 1 ) == 0 ) ? val + i : val ), val */
126 #define atomic_read_and_add_even( v, i ) \
127 atomic32_read_and_add_even ( v, i )
128
129 /* DEPRECATED */
130
131 /* val = ( * v ), ( * v ) = ( val < t ? val + i : val ), ( val < t ? 1 : 0 ) */
132 #define atomic_add_if_lt( v, i, t ) \
133 atomic32_add_if_lt ( v, i, t )
134
135 /* val = ( * v ), ( * v ) = ( val <= t ? val + i : val ), ( val <= t ? 1 : 0 ) */
136 #define atomic_add_if_le( v, i, t ) \
137 atomic32_add_if_le ( v, i, t )
138
139 /* val = ( * v ), ( * v ) = ( val == t ? val + i : val ), ( val == t ? 1 : 0 ) */
140 #define atomic_add_if_eq( v, i, t ) \
141 atomic32_add_if_eq ( v, i, t )
142
143 /* val = ( * v ), ( * v ) = ( val >= t ? val + i : val ), ( val >= t ? 1 : 0 ) */
144 #define atomic_add_if_ge( v, i, t ) \
145 atomic32_add_if_ge ( v, i, t )
146
147 /* val = ( * v ), ( * v ) = ( val > t ? val + i : val ), ( val > t ? 1 : 0 ) */
148 #define atomic_add_if_gt( v, i, t ) \
149 atomic32_add_if_gt ( v, i, t )
150
151 #undef LOCK
152
153 #ifdef __cplusplus
154 }
155 #endif
156
157 #endif /* _h_atomic_ */