1 // Copyright 2014 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.
5 // This file is an internal atomic implementation, use atomicops.h instead.
7 #ifndef V8_BASE_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_
8 #define V8_BASE_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_
10 // AtomicWord is a synonym for intptr_t, and Atomic32 is a synonym for int32,
11 // which in turn means int. On some LP32 platforms, intptr_t is an int, but
12 // on others, it's a long. When AtomicWord and Atomic32 are based on different
13 // fundamental types, their pointers are incompatible.
15 // This file defines function overloads to allow both AtomicWord and Atomic32
16 // data to be used with this interface.
18 // On LP64 platforms, AtomicWord and Atomic64 are both always long,
19 // so this problem doesn't occur.
21 #if !defined(V8_HOST_ARCH_64_BIT)
26 inline AtomicWord NoBarrier_CompareAndSwap(volatile AtomicWord* ptr,
28 AtomicWord new_value) {
29 return NoBarrier_CompareAndSwap(
30 reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
33 inline AtomicWord NoBarrier_AtomicExchange(volatile AtomicWord* ptr,
34 AtomicWord new_value) {
35 return NoBarrier_AtomicExchange(
36 reinterpret_cast<volatile Atomic32*>(ptr), new_value);
39 inline AtomicWord NoBarrier_AtomicIncrement(volatile AtomicWord* ptr,
40 AtomicWord increment) {
41 return NoBarrier_AtomicIncrement(
42 reinterpret_cast<volatile Atomic32*>(ptr), increment);
45 inline AtomicWord Barrier_AtomicIncrement(volatile AtomicWord* ptr,
46 AtomicWord increment) {
47 return Barrier_AtomicIncrement(
48 reinterpret_cast<volatile Atomic32*>(ptr), increment);
51 inline AtomicWord Acquire_CompareAndSwap(volatile AtomicWord* ptr,
53 AtomicWord new_value) {
54 return v8::base::Acquire_CompareAndSwap(
55 reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
58 inline AtomicWord Release_CompareAndSwap(volatile AtomicWord* ptr,
60 AtomicWord new_value) {
61 return v8::base::Release_CompareAndSwap(
62 reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
65 inline void NoBarrier_Store(volatile AtomicWord *ptr, AtomicWord value) {
67 reinterpret_cast<volatile Atomic32*>(ptr), value);
70 inline void Acquire_Store(volatile AtomicWord* ptr, AtomicWord value) {
71 return v8::base::Acquire_Store(
72 reinterpret_cast<volatile Atomic32*>(ptr), value);
75 inline void Release_Store(volatile AtomicWord* ptr, AtomicWord value) {
76 return v8::base::Release_Store(
77 reinterpret_cast<volatile Atomic32*>(ptr), value);
80 inline AtomicWord NoBarrier_Load(volatile const AtomicWord *ptr) {
81 return NoBarrier_Load(
82 reinterpret_cast<volatile const Atomic32*>(ptr));
85 inline AtomicWord Acquire_Load(volatile const AtomicWord* ptr) {
86 return v8::base::Acquire_Load(
87 reinterpret_cast<volatile const Atomic32*>(ptr));
90 inline AtomicWord Release_Load(volatile const AtomicWord* ptr) {
91 return v8::base::Release_Load(
92 reinterpret_cast<volatile const Atomic32*>(ptr));
98 #endif // !defined(V8_HOST_ARCH_64_BIT)
100 #endif // V8_BASE_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_