v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
atomicops_internals_atomicword_compat.h
Go to the documentation of this file.
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 
50  AtomicWord old_value,
51  AtomicWord new_value) {
53  reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
54 }
55 
57  AtomicWord new_value) {
59  reinterpret_cast<volatile Atomic32*>(ptr), new_value);
60 }
61 
63  AtomicWord increment) {
65  reinterpret_cast<volatile Atomic32*>(ptr), increment);
66 }
67 
69  AtomicWord increment) {
71  reinterpret_cast<volatile Atomic32*>(ptr), increment);
72 }
73 
75  AtomicWord old_value,
76  AtomicWord new_value) {
78  reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
79 }
80 
82  AtomicWord old_value,
83  AtomicWord new_value) {
85  reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
86 }
87 
88 inline void NoBarrier_Store(volatile AtomicWord *ptr, AtomicWord value) {
90  reinterpret_cast<volatile Atomic32*>(ptr), value);
91 }
92 
93 inline void Acquire_Store(volatile AtomicWord* ptr, AtomicWord value) {
95  reinterpret_cast<volatile Atomic32*>(ptr), value);
96 }
97 
98 inline void Release_Store(volatile AtomicWord* ptr, AtomicWord value) {
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) {
110  reinterpret_cast<volatile const Atomic32*>(ptr));
111 }
112 
113 inline AtomicWord Release_Load(volatile const AtomicWord* ptr) {
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_
void Acquire_Store(volatile Atomic32 *ptr, Atomic32 value)
Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32 *ptr, Atomic32 old_value, Atomic32 new_value)
Atomic32 Release_CompareAndSwap(volatile Atomic32 *ptr, Atomic32 old_value, Atomic32 new_value)
void NoBarrier_Store(volatile Atomic32 *ptr, Atomic32 value)
Atomic32 NoBarrier_AtomicExchange(volatile Atomic32 *ptr, Atomic32 new_value)
intptr_t AtomicWord
Definition: atomicops.h:79
Atomic32 Release_Load(volatile const Atomic32 *ptr)
Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32 *ptr, Atomic32 increment)
void Release_Store(volatile Atomic32 *ptr, Atomic32 value)
Atomic32 Barrier_AtomicIncrement(volatile Atomic32 *ptr, Atomic32 increment)
Atomic32 NoBarrier_Load(volatile const Atomic32 *ptr)
Atomic32 Acquire_Load(volatile const Atomic32 *ptr)
Atomic32 Acquire_CompareAndSwap(volatile Atomic32 *ptr, Atomic32 old_value, Atomic32 new_value)