| .. | .. |
|---|
| 9 | 9 | /* An 64bit atomic type */ |
|---|
| 10 | 10 | |
|---|
| 11 | 11 | typedef struct { |
|---|
| 12 | | - u64 __aligned(8) counter; |
|---|
| 12 | + s64 __aligned(8) counter; |
|---|
| 13 | 13 | } atomic64_t; |
|---|
| 14 | 14 | |
|---|
| 15 | 15 | #define ATOMIC64_INIT(val) { (val) } |
|---|
| .. | .. |
|---|
| 71 | 71 | * the old value. |
|---|
| 72 | 72 | */ |
|---|
| 73 | 73 | |
|---|
| 74 | | -static inline long long arch_atomic64_cmpxchg(atomic64_t *v, long long o, |
|---|
| 75 | | - long long n) |
|---|
| 74 | +static inline s64 arch_atomic64_cmpxchg(atomic64_t *v, s64 o, s64 n) |
|---|
| 76 | 75 | { |
|---|
| 77 | 76 | return arch_cmpxchg64(&v->counter, o, n); |
|---|
| 78 | 77 | } |
|---|
| 78 | +#define arch_atomic64_cmpxchg arch_atomic64_cmpxchg |
|---|
| 79 | 79 | |
|---|
| 80 | 80 | /** |
|---|
| 81 | 81 | * arch_atomic64_xchg - xchg atomic64 variable |
|---|
| .. | .. |
|---|
| 85 | 85 | * Atomically xchgs the value of @v to @n and returns |
|---|
| 86 | 86 | * the old value. |
|---|
| 87 | 87 | */ |
|---|
| 88 | | -static inline long long arch_atomic64_xchg(atomic64_t *v, long long n) |
|---|
| 88 | +static inline s64 arch_atomic64_xchg(atomic64_t *v, s64 n) |
|---|
| 89 | 89 | { |
|---|
| 90 | | - long long o; |
|---|
| 90 | + s64 o; |
|---|
| 91 | 91 | unsigned high = (unsigned)(n >> 32); |
|---|
| 92 | 92 | unsigned low = (unsigned)n; |
|---|
| 93 | 93 | alternative_atomic64(xchg, "=&A" (o), |
|---|
| .. | .. |
|---|
| 95 | 95 | : "memory"); |
|---|
| 96 | 96 | return o; |
|---|
| 97 | 97 | } |
|---|
| 98 | +#define arch_atomic64_xchg arch_atomic64_xchg |
|---|
| 98 | 99 | |
|---|
| 99 | 100 | /** |
|---|
| 100 | 101 | * arch_atomic64_set - set atomic64 variable |
|---|
| .. | .. |
|---|
| 103 | 104 | * |
|---|
| 104 | 105 | * Atomically sets the value of @v to @n. |
|---|
| 105 | 106 | */ |
|---|
| 106 | | -static inline void arch_atomic64_set(atomic64_t *v, long long i) |
|---|
| 107 | +static inline void arch_atomic64_set(atomic64_t *v, s64 i) |
|---|
| 107 | 108 | { |
|---|
| 108 | 109 | unsigned high = (unsigned)(i >> 32); |
|---|
| 109 | 110 | unsigned low = (unsigned)i; |
|---|
| .. | .. |
|---|
| 118 | 119 | * |
|---|
| 119 | 120 | * Atomically reads the value of @v and returns it. |
|---|
| 120 | 121 | */ |
|---|
| 121 | | -static inline long long arch_atomic64_read(const atomic64_t *v) |
|---|
| 122 | +static inline s64 arch_atomic64_read(const atomic64_t *v) |
|---|
| 122 | 123 | { |
|---|
| 123 | | - long long r; |
|---|
| 124 | + s64 r; |
|---|
| 124 | 125 | alternative_atomic64(read, "=&A" (r), "c" (v) : "memory"); |
|---|
| 125 | 126 | return r; |
|---|
| 126 | 127 | } |
|---|
| .. | .. |
|---|
| 132 | 133 | * |
|---|
| 133 | 134 | * Atomically adds @i to @v and returns @i + *@v |
|---|
| 134 | 135 | */ |
|---|
| 135 | | -static inline long long arch_atomic64_add_return(long long i, atomic64_t *v) |
|---|
| 136 | +static inline s64 arch_atomic64_add_return(s64 i, atomic64_t *v) |
|---|
| 136 | 137 | { |
|---|
| 137 | 138 | alternative_atomic64(add_return, |
|---|
| 138 | 139 | ASM_OUTPUT2("+A" (i), "+c" (v)), |
|---|
| 139 | 140 | ASM_NO_INPUT_CLOBBER("memory")); |
|---|
| 140 | 141 | return i; |
|---|
| 141 | 142 | } |
|---|
| 143 | +#define arch_atomic64_add_return arch_atomic64_add_return |
|---|
| 142 | 144 | |
|---|
| 143 | 145 | /* |
|---|
| 144 | 146 | * Other variants with different arithmetic operators: |
|---|
| 145 | 147 | */ |
|---|
| 146 | | -static inline long long arch_atomic64_sub_return(long long i, atomic64_t *v) |
|---|
| 148 | +static inline s64 arch_atomic64_sub_return(s64 i, atomic64_t *v) |
|---|
| 147 | 149 | { |
|---|
| 148 | 150 | alternative_atomic64(sub_return, |
|---|
| 149 | 151 | ASM_OUTPUT2("+A" (i), "+c" (v)), |
|---|
| 150 | 152 | ASM_NO_INPUT_CLOBBER("memory")); |
|---|
| 151 | 153 | return i; |
|---|
| 152 | 154 | } |
|---|
| 155 | +#define arch_atomic64_sub_return arch_atomic64_sub_return |
|---|
| 153 | 156 | |
|---|
| 154 | | -static inline long long arch_atomic64_inc_return(atomic64_t *v) |
|---|
| 157 | +static inline s64 arch_atomic64_inc_return(atomic64_t *v) |
|---|
| 155 | 158 | { |
|---|
| 156 | | - long long a; |
|---|
| 159 | + s64 a; |
|---|
| 157 | 160 | alternative_atomic64(inc_return, "=&A" (a), |
|---|
| 158 | 161 | "S" (v) : "memory", "ecx"); |
|---|
| 159 | 162 | return a; |
|---|
| 160 | 163 | } |
|---|
| 161 | 164 | #define arch_atomic64_inc_return arch_atomic64_inc_return |
|---|
| 162 | 165 | |
|---|
| 163 | | -static inline long long arch_atomic64_dec_return(atomic64_t *v) |
|---|
| 166 | +static inline s64 arch_atomic64_dec_return(atomic64_t *v) |
|---|
| 164 | 167 | { |
|---|
| 165 | | - long long a; |
|---|
| 168 | + s64 a; |
|---|
| 166 | 169 | alternative_atomic64(dec_return, "=&A" (a), |
|---|
| 167 | 170 | "S" (v) : "memory", "ecx"); |
|---|
| 168 | 171 | return a; |
|---|
| .. | .. |
|---|
| 176 | 179 | * |
|---|
| 177 | 180 | * Atomically adds @i to @v. |
|---|
| 178 | 181 | */ |
|---|
| 179 | | -static inline long long arch_atomic64_add(long long i, atomic64_t *v) |
|---|
| 182 | +static inline s64 arch_atomic64_add(s64 i, atomic64_t *v) |
|---|
| 180 | 183 | { |
|---|
| 181 | 184 | __alternative_atomic64(add, add_return, |
|---|
| 182 | 185 | ASM_OUTPUT2("+A" (i), "+c" (v)), |
|---|
| .. | .. |
|---|
| 191 | 194 | * |
|---|
| 192 | 195 | * Atomically subtracts @i from @v. |
|---|
| 193 | 196 | */ |
|---|
| 194 | | -static inline long long arch_atomic64_sub(long long i, atomic64_t *v) |
|---|
| 197 | +static inline s64 arch_atomic64_sub(s64 i, atomic64_t *v) |
|---|
| 195 | 198 | { |
|---|
| 196 | 199 | __alternative_atomic64(sub, sub_return, |
|---|
| 197 | 200 | ASM_OUTPUT2("+A" (i), "+c" (v)), |
|---|
| .. | .. |
|---|
| 234 | 237 | * Atomically adds @a to @v, so long as it was not @u. |
|---|
| 235 | 238 | * Returns non-zero if the add was done, zero otherwise. |
|---|
| 236 | 239 | */ |
|---|
| 237 | | -static inline int arch_atomic64_add_unless(atomic64_t *v, long long a, |
|---|
| 238 | | - long long u) |
|---|
| 240 | +static inline int arch_atomic64_add_unless(atomic64_t *v, s64 a, s64 u) |
|---|
| 239 | 241 | { |
|---|
| 240 | 242 | unsigned low = (unsigned)u; |
|---|
| 241 | 243 | unsigned high = (unsigned)(u >> 32); |
|---|
| .. | .. |
|---|
| 244 | 246 | "S" (v) : "memory"); |
|---|
| 245 | 247 | return (int)a; |
|---|
| 246 | 248 | } |
|---|
| 249 | +#define arch_atomic64_add_unless arch_atomic64_add_unless |
|---|
| 247 | 250 | |
|---|
| 248 | 251 | static inline int arch_atomic64_inc_not_zero(atomic64_t *v) |
|---|
| 249 | 252 | { |
|---|
| .. | .. |
|---|
| 254 | 257 | } |
|---|
| 255 | 258 | #define arch_atomic64_inc_not_zero arch_atomic64_inc_not_zero |
|---|
| 256 | 259 | |
|---|
| 257 | | -static inline long long arch_atomic64_dec_if_positive(atomic64_t *v) |
|---|
| 260 | +static inline s64 arch_atomic64_dec_if_positive(atomic64_t *v) |
|---|
| 258 | 261 | { |
|---|
| 259 | | - long long r; |
|---|
| 262 | + s64 r; |
|---|
| 260 | 263 | alternative_atomic64(dec_if_positive, "=&A" (r), |
|---|
| 261 | 264 | "S" (v) : "ecx", "memory"); |
|---|
| 262 | 265 | return r; |
|---|
| .. | .. |
|---|
| 266 | 269 | #undef alternative_atomic64 |
|---|
| 267 | 270 | #undef __alternative_atomic64 |
|---|
| 268 | 271 | |
|---|
| 269 | | -static inline void arch_atomic64_and(long long i, atomic64_t *v) |
|---|
| 272 | +static inline void arch_atomic64_and(s64 i, atomic64_t *v) |
|---|
| 270 | 273 | { |
|---|
| 271 | | - long long old, c = 0; |
|---|
| 274 | + s64 old, c = 0; |
|---|
| 272 | 275 | |
|---|
| 273 | 276 | while ((old = arch_atomic64_cmpxchg(v, c, c & i)) != c) |
|---|
| 274 | 277 | c = old; |
|---|
| 275 | 278 | } |
|---|
| 276 | 279 | |
|---|
| 277 | | -static inline long long arch_atomic64_fetch_and(long long i, atomic64_t *v) |
|---|
| 280 | +static inline s64 arch_atomic64_fetch_and(s64 i, atomic64_t *v) |
|---|
| 278 | 281 | { |
|---|
| 279 | | - long long old, c = 0; |
|---|
| 282 | + s64 old, c = 0; |
|---|
| 280 | 283 | |
|---|
| 281 | 284 | while ((old = arch_atomic64_cmpxchg(v, c, c & i)) != c) |
|---|
| 282 | 285 | c = old; |
|---|
| 283 | 286 | |
|---|
| 284 | 287 | return old; |
|---|
| 285 | 288 | } |
|---|
| 289 | +#define arch_atomic64_fetch_and arch_atomic64_fetch_and |
|---|
| 286 | 290 | |
|---|
| 287 | | -static inline void arch_atomic64_or(long long i, atomic64_t *v) |
|---|
| 291 | +static inline void arch_atomic64_or(s64 i, atomic64_t *v) |
|---|
| 288 | 292 | { |
|---|
| 289 | | - long long old, c = 0; |
|---|
| 293 | + s64 old, c = 0; |
|---|
| 290 | 294 | |
|---|
| 291 | 295 | while ((old = arch_atomic64_cmpxchg(v, c, c | i)) != c) |
|---|
| 292 | 296 | c = old; |
|---|
| 293 | 297 | } |
|---|
| 294 | 298 | |
|---|
| 295 | | -static inline long long arch_atomic64_fetch_or(long long i, atomic64_t *v) |
|---|
| 299 | +static inline s64 arch_atomic64_fetch_or(s64 i, atomic64_t *v) |
|---|
| 296 | 300 | { |
|---|
| 297 | | - long long old, c = 0; |
|---|
| 301 | + s64 old, c = 0; |
|---|
| 298 | 302 | |
|---|
| 299 | 303 | while ((old = arch_atomic64_cmpxchg(v, c, c | i)) != c) |
|---|
| 300 | 304 | c = old; |
|---|
| 301 | 305 | |
|---|
| 302 | 306 | return old; |
|---|
| 303 | 307 | } |
|---|
| 308 | +#define arch_atomic64_fetch_or arch_atomic64_fetch_or |
|---|
| 304 | 309 | |
|---|
| 305 | | -static inline void arch_atomic64_xor(long long i, atomic64_t *v) |
|---|
| 310 | +static inline void arch_atomic64_xor(s64 i, atomic64_t *v) |
|---|
| 306 | 311 | { |
|---|
| 307 | | - long long old, c = 0; |
|---|
| 312 | + s64 old, c = 0; |
|---|
| 308 | 313 | |
|---|
| 309 | 314 | while ((old = arch_atomic64_cmpxchg(v, c, c ^ i)) != c) |
|---|
| 310 | 315 | c = old; |
|---|
| 311 | 316 | } |
|---|
| 312 | 317 | |
|---|
| 313 | | -static inline long long arch_atomic64_fetch_xor(long long i, atomic64_t *v) |
|---|
| 318 | +static inline s64 arch_atomic64_fetch_xor(s64 i, atomic64_t *v) |
|---|
| 314 | 319 | { |
|---|
| 315 | | - long long old, c = 0; |
|---|
| 320 | + s64 old, c = 0; |
|---|
| 316 | 321 | |
|---|
| 317 | 322 | while ((old = arch_atomic64_cmpxchg(v, c, c ^ i)) != c) |
|---|
| 318 | 323 | c = old; |
|---|
| 319 | 324 | |
|---|
| 320 | 325 | return old; |
|---|
| 321 | 326 | } |
|---|
| 327 | +#define arch_atomic64_fetch_xor arch_atomic64_fetch_xor |
|---|
| 322 | 328 | |
|---|
| 323 | | -static inline long long arch_atomic64_fetch_add(long long i, atomic64_t *v) |
|---|
| 329 | +static inline s64 arch_atomic64_fetch_add(s64 i, atomic64_t *v) |
|---|
| 324 | 330 | { |
|---|
| 325 | | - long long old, c = 0; |
|---|
| 331 | + s64 old, c = 0; |
|---|
| 326 | 332 | |
|---|
| 327 | 333 | while ((old = arch_atomic64_cmpxchg(v, c, c + i)) != c) |
|---|
| 328 | 334 | c = old; |
|---|
| 329 | 335 | |
|---|
| 330 | 336 | return old; |
|---|
| 331 | 337 | } |
|---|
| 338 | +#define arch_atomic64_fetch_add arch_atomic64_fetch_add |
|---|
| 332 | 339 | |
|---|
| 333 | 340 | #define arch_atomic64_fetch_sub(i, v) arch_atomic64_fetch_add(-(i), (v)) |
|---|
| 334 | 341 | |
|---|