OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are |
| 4 // met: |
| 5 // |
| 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. |
| 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
| 28 // This file is an internal atomic implementation, use atomicops.h instead. |
| 29 |
| 30 #ifndef V8_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_ |
| 31 #define V8_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_ |
| 32 |
| 33 // AtomicWord is a synonym for intptr_t, and Atomic32 is a synonym for int32, |
| 34 // which in turn means int. On some LP32 platforms, intptr_t is an int, but |
| 35 // on others, it's a long. When AtomicWord and Atomic32 are based on different |
| 36 // fundamental types, their pointers are incompatible. |
| 37 // |
| 38 // This file defines function overloads to allow both AtomicWord and Atomic32 |
| 39 // data to be used with this interface. |
| 40 // |
| 41 // On LP64 platforms, AtomicWord and Atomic64 are both always long, |
| 42 // so this problem doesn't occur. |
| 43 |
| 44 #if !defined(V8_HOST_ARCH_64_BIT) |
| 45 |
| 46 namespace v8 { |
| 47 namespace internal { |
| 48 |
| 49 inline AtomicWord NoBarrier_CompareAndSwap(volatile AtomicWord* ptr, |
| 50 AtomicWord old_value, |
| 51 AtomicWord new_value) { |
| 52 return NoBarrier_CompareAndSwap( |
| 53 reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value); |
| 54 } |
| 55 |
| 56 inline AtomicWord NoBarrier_AtomicExchange(volatile AtomicWord* ptr, |
| 57 AtomicWord new_value) { |
| 58 return NoBarrier_AtomicExchange( |
| 59 reinterpret_cast<volatile Atomic32*>(ptr), new_value); |
| 60 } |
| 61 |
| 62 inline AtomicWord NoBarrier_AtomicIncrement(volatile AtomicWord* ptr, |
| 63 AtomicWord increment) { |
| 64 return NoBarrier_AtomicIncrement( |
| 65 reinterpret_cast<volatile Atomic32*>(ptr), increment); |
| 66 } |
| 67 |
| 68 inline AtomicWord Barrier_AtomicIncrement(volatile AtomicWord* ptr, |
| 69 AtomicWord increment) { |
| 70 return Barrier_AtomicIncrement( |
| 71 reinterpret_cast<volatile Atomic32*>(ptr), increment); |
| 72 } |
| 73 |
| 74 inline AtomicWord Acquire_CompareAndSwap(volatile AtomicWord* ptr, |
| 75 AtomicWord old_value, |
| 76 AtomicWord new_value) { |
| 77 return v8::internal::Acquire_CompareAndSwap( |
| 78 reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value); |
| 79 } |
| 80 |
| 81 inline AtomicWord Release_CompareAndSwap(volatile AtomicWord* ptr, |
| 82 AtomicWord old_value, |
| 83 AtomicWord new_value) { |
| 84 return v8::internal::Release_CompareAndSwap( |
| 85 reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value); |
| 86 } |
| 87 |
| 88 inline void NoBarrier_Store(volatile AtomicWord *ptr, AtomicWord value) { |
| 89 NoBarrier_Store( |
| 90 reinterpret_cast<volatile Atomic32*>(ptr), value); |
| 91 } |
| 92 |
| 93 inline void Acquire_Store(volatile AtomicWord* ptr, AtomicWord value) { |
| 94 return v8::internal::Acquire_Store( |
| 95 reinterpret_cast<volatile Atomic32*>(ptr), value); |
| 96 } |
| 97 |
| 98 inline void Release_Store(volatile AtomicWord* ptr, AtomicWord value) { |
| 99 return v8::internal::Release_Store( |
| 100 reinterpret_cast<volatile Atomic32*>(ptr), value); |
| 101 } |
| 102 |
| 103 inline AtomicWord NoBarrier_Load(volatile const AtomicWord *ptr) { |
| 104 return NoBarrier_Load( |
| 105 reinterpret_cast<volatile const Atomic32*>(ptr)); |
| 106 } |
| 107 |
| 108 inline AtomicWord Acquire_Load(volatile const AtomicWord* ptr) { |
| 109 return v8::internal::Acquire_Load( |
| 110 reinterpret_cast<volatile const Atomic32*>(ptr)); |
| 111 } |
| 112 |
| 113 inline AtomicWord Release_Load(volatile const AtomicWord* ptr) { |
| 114 return v8::internal::Release_Load( |
| 115 reinterpret_cast<volatile const Atomic32*>(ptr)); |
| 116 } |
| 117 |
| 118 } } // namespace v8::internal |
| 119 |
| 120 #endif // !defined(V8_HOST_ARCH_64_BIT) |
| 121 |
| 122 #endif // V8_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_ |
OLD | NEW |