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