OLD | NEW |
1 // Copyright (c) 2011 The LevelDB Authors. All rights reserved. | 1 // Copyright (c) 2011 The LevelDB Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. See the AUTHORS file for names of contributors. | 3 // found in the LICENSE file. See the AUTHORS file for names of contributors. |
4 // | 4 // |
5 // See port_example.h for documentation for the following types/functions. | 5 // See port_example.h for documentation for the following types/functions. |
6 | 6 |
7 #ifndef STORAGE_LEVELDB_PORT_PORT_CHROMIUM_H_ | 7 #ifndef STORAGE_LEVELDB_PORT_PORT_CHROMIUM_H_ |
8 #define STORAGE_LEVELDB_PORT_PORT_CHROMIUM_H_ | 8 #define STORAGE_LEVELDB_PORT_PORT_CHROMIUM_H_ |
9 | 9 |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 }; | 64 }; |
65 | 65 |
66 class AtomicPointer { | 66 class AtomicPointer { |
67 private: | 67 private: |
68 typedef base::subtle::AtomicWord Rep; | 68 typedef base::subtle::AtomicWord Rep; |
69 Rep rep_; | 69 Rep rep_; |
70 public: | 70 public: |
71 AtomicPointer() { } | 71 AtomicPointer() { } |
72 explicit AtomicPointer(void* p) : rep_(reinterpret_cast<Rep>(p)) {} | 72 explicit AtomicPointer(void* p) : rep_(reinterpret_cast<Rep>(p)) {} |
73 inline void* Acquire_Load() const { | 73 inline void* Acquire_Load() const { |
74 return reinterpret_cast<void*>(::base::subtle::Acquire_Load(&rep_)); | 74 return reinterpret_cast<void*>(base::subtle::Acquire_Load(&rep_)); |
75 } | 75 } |
76 inline void Release_Store(void* v) { | 76 inline void Release_Store(void* v) { |
77 ::base::subtle::Release_Store(&rep_, reinterpret_cast<Rep>(v)); | 77 base::subtle::Release_Store(&rep_, reinterpret_cast<Rep>(v)); |
78 } | 78 } |
79 inline void* NoBarrier_Load() const { | 79 inline void* NoBarrier_Load() const { |
80 return reinterpret_cast<void*>(::base::subtle::NoBarrier_Load(&rep_)); | 80 return reinterpret_cast<void*>(base::subtle::NoBarrier_Load(&rep_)); |
81 } | 81 } |
82 inline void NoBarrier_Store(void* v) { | 82 inline void NoBarrier_Store(void* v) { |
83 ::base::subtle::NoBarrier_Store(&rep_, reinterpret_cast<Rep>(v)); | 83 base::subtle::NoBarrier_Store(&rep_, reinterpret_cast<Rep>(v)); |
84 } | 84 } |
85 }; | 85 }; |
86 | 86 |
87 // Implementation of OnceType and InitOnce() pair, this is equivalent to | 87 // Implementation of OnceType and InitOnce() pair, this is equivalent to |
88 // pthread_once_t and pthread_once(). | 88 // pthread_once_t and pthread_once(). |
89 typedef ::base::subtle::Atomic32 OnceType; | 89 typedef base::subtle::Atomic32 OnceType; |
90 | 90 |
91 enum { | 91 enum { |
92 ONCE_STATE_UNINITIALIZED = 0, | 92 ONCE_STATE_UNINITIALIZED = 0, |
93 ONCE_STATE_EXECUTING_CLOSURE = 1, | 93 ONCE_STATE_EXECUTING_CLOSURE = 1, |
94 ONCE_STATE_DONE = 2 | 94 ONCE_STATE_DONE = 2 |
95 }; | 95 }; |
96 | 96 |
97 #define LEVELDB_ONCE_INIT leveldb::port::ONCE_STATE_UNINITIALIZED | 97 #define LEVELDB_ONCE_INIT leveldb::port::ONCE_STATE_UNINITIALIZED |
98 | 98 |
99 // slow code path | 99 // slow code path |
100 void InitOnceImpl(OnceType* once, void (*initializer)()); | 100 void InitOnceImpl(OnceType* once, void (*initializer)()); |
101 | 101 |
102 static inline void InitOnce(OnceType* once, void (*initializer)()) { | 102 static inline void InitOnce(OnceType* once, void (*initializer)()) { |
103 if (::base::subtle::Acquire_Load(once) != ONCE_STATE_DONE) | 103 if (base::subtle::Acquire_Load(once) != ONCE_STATE_DONE) |
104 InitOnceImpl(once, initializer); | 104 InitOnceImpl(once, initializer); |
105 } | 105 } |
106 | 106 |
107 bool Snappy_Compress(const char* input, size_t input_length, | 107 bool Snappy_Compress(const char* input, size_t input_length, |
108 std::string* output); | 108 std::string* output); |
109 bool Snappy_GetUncompressedLength(const char* input, size_t length, | 109 bool Snappy_GetUncompressedLength(const char* input, size_t length, |
110 size_t* result); | 110 size_t* result); |
111 bool Snappy_Uncompress(const char* input_data, size_t input_length, | 111 bool Snappy_Uncompress(const char* input_data, size_t input_length, |
112 char* output); | 112 char* output); |
113 | 113 |
114 inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) { | 114 inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) { |
115 return false; | 115 return false; |
116 } | 116 } |
117 | 117 |
118 } | 118 } |
119 } | 119 } |
120 | 120 |
121 #endif // STORAGE_LEVELDB_PORT_PORT_CHROMIUM_H_ | 121 #endif // STORAGE_LEVELDB_PORT_PORT_CHROMIUM_H_ |
OLD | NEW |