OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 namespace v8 { |
| 6 namespace internal { |
| 7 namespace atomics { |
| 8 |
| 9 template <typename T> |
| 10 inline T LoadSeqCst(T* p) { |
| 11 T result; |
| 12 __atomic_load(p, &result, __ATOMIC_SEQ_CST); |
| 13 return result; |
| 14 } |
| 15 |
| 16 |
| 17 template <typename T> |
| 18 inline void StoreSeqCst(T* p, T value) { |
| 19 __atomic_store_n(p, value, __ATOMIC_SEQ_CST); |
| 20 } |
| 21 |
| 22 |
| 23 template <typename T> |
| 24 inline T AddSeqCst(T* p, T value) { |
| 25 return __atomic_fetch_add(p, value, __ATOMIC_SEQ_CST); |
| 26 } |
| 27 |
| 28 |
| 29 template <typename T> |
| 30 inline T SubSeqCst(T* p, T value) { |
| 31 return __atomic_fetch_sub(p, value, __ATOMIC_SEQ_CST); |
| 32 } |
| 33 |
| 34 |
| 35 template <typename T> |
| 36 inline T AndSeqCst(T* p, T value) { |
| 37 return __atomic_fetch_and(p, value, __ATOMIC_SEQ_CST); |
| 38 } |
| 39 |
| 40 |
| 41 template <typename T> |
| 42 inline T OrSeqCst(T* p, T value) { |
| 43 return __atomic_fetch_or(p, value, __ATOMIC_SEQ_CST); |
| 44 } |
| 45 |
| 46 |
| 47 template <typename T> |
| 48 inline T XorSeqCst(T* p, T value) { |
| 49 return __atomic_fetch_xor(p, value, __ATOMIC_SEQ_CST); |
| 50 } |
| 51 |
| 52 |
| 53 template <typename T> |
| 54 inline T ExchangeSeqCst(T* p, T value) { |
| 55 return __atomic_exchange_n(p, value, __ATOMIC_SEQ_CST); |
| 56 } |
| 57 |
| 58 |
| 59 template <typename T> |
| 60 inline T CompareExchangeSeqCst(T* p, T oldval, T newval) { |
| 61 (void)__atomic_compare_exchange_n(p, &oldval, newval, 0, __ATOMIC_SEQ_CST, |
| 62 __ATOMIC_SEQ_CST); |
| 63 return oldval; |
| 64 } |
| 65 |
| 66 } // namespace atomics |
| 67 } // namespace internal |
| 68 } // namespace v8 |
OLD | NEW |