OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2013 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #ifndef SkAtomics_none_DEFINED | |
9 #define SkAtomics_none_DEFINED | |
10 | |
11 /** Non-atomic atomics for uniprocessor systems. */ | |
12 | |
13 #include <stdint.h> | |
14 | |
15 static inline int32_t sk_atomic_inc(int32_t* addr) { | |
16 int32_t value = *addr; | |
17 *addr = value + 1; | |
18 return value; | |
19 } | |
20 | |
21 static inline int32_t sk_atomic_add(int32_t* addr, int32_t inc) { | |
22 int32_t value = *addr; | |
23 *addr = value + inc; | |
24 return value; | |
25 } | |
26 | |
27 static inline int32_t sk_atomic_dec(int32_t* addr) { | |
28 int32_t value = *addr; | |
29 *addr = value - 1; | |
30 return value; | |
31 } | |
32 | |
33 static inline void sk_membar_acquire__after_atomic_dec() { } | |
34 | |
35 static inline bool sk_atomic_cas(int32_t* addr, int32_t before, int32_t after) { | |
36 if (*addr != before) return false; | |
37 *addr = after; | |
38 return true; | |
39 } | |
40 | |
41 static inline void sk_membar_acquire__after_atomic_conditional_inc() { } | |
42 | |
43 #endif | |
OLD | NEW |