Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

242 rader
7.1 KiB

Release 1.18 Changes are: * Update version number to 1.18 * Replace the basic fprintf call with a call to fwrite in order to work around the apparent compiler optimization/rewrite failure that we are seeing with the new toolchain/iOS SDKs provided with Xcode6 and iOS8. * Fix ALL the header guards. * Createed a README.md with the LevelDB project description. * A new CONTRIBUTING file. * Don't implicitly convert uint64_t to size_t or int. Either preserve it as uint64_t, or explicitly cast. This fixes MSVC warnings about possible value truncation when compiling this code in Chromium. * Added a DumpFile() library function that encapsulates the guts of the "leveldbutil dump" command. This will allow clients to dump data to their log files instead of stdout. It will also allow clients to supply their own environment. * leveldb: Remove unused function 'ConsumeChar'. * leveldbutil: Remove unused member variables from WriteBatchItemPrinter. * OpenBSD, NetBSD and DragonflyBSD have _LITTLE_ENDIAN, so define PLATFORM_IS_LITTLE_ENDIAN like on FreeBSD. This fixes: * issue #143 * issue #198 * issue #249 * Switch from <cstdatomic> to <atomic>. The former never made it into the standard and doesn't exist in modern gcc versions at all. The later contains everything that leveldb was using from the former. This problem was noticed when porting to Portable Native Client where no memory barrier is defined. The fact that <cstdatomic> is missing normally goes unnoticed since memory barriers are defined for most architectures. * Make Hash() treat its input as unsigned. Before this change LevelDB files from platforms with different signedness of char were not compatible. This change fixes: issue #243 * Verify checksums of index/meta/filter blocks when paranoid_checks set. * Invoke all tools for iOS with xcrun. (This was causing problems with the new XCode 5.1.1 image on pulse.) * include <sys/stat.h> only once, and fix the following linter warning: "Found C system header after C++ system header" * When encountering a corrupted table file, return Status::Corruption instead of Status::InvalidArgument. * Support cygwin as build platform, patch is from https://code.google.com/p/leveldb/issues/detail?id=188 * Fix typo, merge patch from https://code.google.com/p/leveldb/issues/detail?id=159 * Fix typos and comments, and address the following two issues: * issue #166 * issue #241 * Add missing db synchronize after "fillseq" in the benchmark. * Removed unused variable in SeekRandom: value (issue #201)
10 år sedan
Release 1.18 Changes are: * Update version number to 1.18 * Replace the basic fprintf call with a call to fwrite in order to work around the apparent compiler optimization/rewrite failure that we are seeing with the new toolchain/iOS SDKs provided with Xcode6 and iOS8. * Fix ALL the header guards. * Createed a README.md with the LevelDB project description. * A new CONTRIBUTING file. * Don't implicitly convert uint64_t to size_t or int. Either preserve it as uint64_t, or explicitly cast. This fixes MSVC warnings about possible value truncation when compiling this code in Chromium. * Added a DumpFile() library function that encapsulates the guts of the "leveldbutil dump" command. This will allow clients to dump data to their log files instead of stdout. It will also allow clients to supply their own environment. * leveldb: Remove unused function 'ConsumeChar'. * leveldbutil: Remove unused member variables from WriteBatchItemPrinter. * OpenBSD, NetBSD and DragonflyBSD have _LITTLE_ENDIAN, so define PLATFORM_IS_LITTLE_ENDIAN like on FreeBSD. This fixes: * issue #143 * issue #198 * issue #249 * Switch from <cstdatomic> to <atomic>. The former never made it into the standard and doesn't exist in modern gcc versions at all. The later contains everything that leveldb was using from the former. This problem was noticed when porting to Portable Native Client where no memory barrier is defined. The fact that <cstdatomic> is missing normally goes unnoticed since memory barriers are defined for most architectures. * Make Hash() treat its input as unsigned. Before this change LevelDB files from platforms with different signedness of char were not compatible. This change fixes: issue #243 * Verify checksums of index/meta/filter blocks when paranoid_checks set. * Invoke all tools for iOS with xcrun. (This was causing problems with the new XCode 5.1.1 image on pulse.) * include <sys/stat.h> only once, and fix the following linter warning: "Found C system header after C++ system header" * When encountering a corrupted table file, return Status::Corruption instead of Status::InvalidArgument. * Support cygwin as build platform, patch is from https://code.google.com/p/leveldb/issues/detail?id=188 * Fix typo, merge patch from https://code.google.com/p/leveldb/issues/detail?id=159 * Fix typos and comments, and address the following two issues: * issue #166 * issue #241 * Add missing db synchronize after "fillseq" in the benchmark. * Removed unused variable in SeekRandom: value (issue #201)
10 år sedan
Release 1.18 Changes are: * Update version number to 1.18 * Replace the basic fprintf call with a call to fwrite in order to work around the apparent compiler optimization/rewrite failure that we are seeing with the new toolchain/iOS SDKs provided with Xcode6 and iOS8. * Fix ALL the header guards. * Createed a README.md with the LevelDB project description. * A new CONTRIBUTING file. * Don't implicitly convert uint64_t to size_t or int. Either preserve it as uint64_t, or explicitly cast. This fixes MSVC warnings about possible value truncation when compiling this code in Chromium. * Added a DumpFile() library function that encapsulates the guts of the "leveldbutil dump" command. This will allow clients to dump data to their log files instead of stdout. It will also allow clients to supply their own environment. * leveldb: Remove unused function 'ConsumeChar'. * leveldbutil: Remove unused member variables from WriteBatchItemPrinter. * OpenBSD, NetBSD and DragonflyBSD have _LITTLE_ENDIAN, so define PLATFORM_IS_LITTLE_ENDIAN like on FreeBSD. This fixes: * issue #143 * issue #198 * issue #249 * Switch from <cstdatomic> to <atomic>. The former never made it into the standard and doesn't exist in modern gcc versions at all. The later contains everything that leveldb was using from the former. This problem was noticed when porting to Portable Native Client where no memory barrier is defined. The fact that <cstdatomic> is missing normally goes unnoticed since memory barriers are defined for most architectures. * Make Hash() treat its input as unsigned. Before this change LevelDB files from platforms with different signedness of char were not compatible. This change fixes: issue #243 * Verify checksums of index/meta/filter blocks when paranoid_checks set. * Invoke all tools for iOS with xcrun. (This was causing problems with the new XCode 5.1.1 image on pulse.) * include <sys/stat.h> only once, and fix the following linter warning: "Found C system header after C++ system header" * When encountering a corrupted table file, return Status::Corruption instead of Status::InvalidArgument. * Support cygwin as build platform, patch is from https://code.google.com/p/leveldb/issues/detail?id=188 * Fix typo, merge patch from https://code.google.com/p/leveldb/issues/detail?id=159 * Fix typos and comments, and address the following two issues: * issue #166 * issue #241 * Add missing db synchronize after "fillseq" in the benchmark. * Removed unused variable in SeekRandom: value (issue #201)
10 år sedan
Release 1.18 Changes are: * Update version number to 1.18 * Replace the basic fprintf call with a call to fwrite in order to work around the apparent compiler optimization/rewrite failure that we are seeing with the new toolchain/iOS SDKs provided with Xcode6 and iOS8. * Fix ALL the header guards. * Createed a README.md with the LevelDB project description. * A new CONTRIBUTING file. * Don't implicitly convert uint64_t to size_t or int. Either preserve it as uint64_t, or explicitly cast. This fixes MSVC warnings about possible value truncation when compiling this code in Chromium. * Added a DumpFile() library function that encapsulates the guts of the "leveldbutil dump" command. This will allow clients to dump data to their log files instead of stdout. It will also allow clients to supply their own environment. * leveldb: Remove unused function 'ConsumeChar'. * leveldbutil: Remove unused member variables from WriteBatchItemPrinter. * OpenBSD, NetBSD and DragonflyBSD have _LITTLE_ENDIAN, so define PLATFORM_IS_LITTLE_ENDIAN like on FreeBSD. This fixes: * issue #143 * issue #198 * issue #249 * Switch from <cstdatomic> to <atomic>. The former never made it into the standard and doesn't exist in modern gcc versions at all. The later contains everything that leveldb was using from the former. This problem was noticed when porting to Portable Native Client where no memory barrier is defined. The fact that <cstdatomic> is missing normally goes unnoticed since memory barriers are defined for most architectures. * Make Hash() treat its input as unsigned. Before this change LevelDB files from platforms with different signedness of char were not compatible. This change fixes: issue #243 * Verify checksums of index/meta/filter blocks when paranoid_checks set. * Invoke all tools for iOS with xcrun. (This was causing problems with the new XCode 5.1.1 image on pulse.) * include <sys/stat.h> only once, and fix the following linter warning: "Found C system header after C++ system header" * When encountering a corrupted table file, return Status::Corruption instead of Status::InvalidArgument. * Support cygwin as build platform, patch is from https://code.google.com/p/leveldb/issues/detail?id=188 * Fix typo, merge patch from https://code.google.com/p/leveldb/issues/detail?id=159 * Fix typos and comments, and address the following two issues: * issue #166 * issue #241 * Add missing db synchronize after "fillseq" in the benchmark. * Removed unused variable in SeekRandom: value (issue #201)
10 år sedan
Release 1.18 Changes are: * Update version number to 1.18 * Replace the basic fprintf call with a call to fwrite in order to work around the apparent compiler optimization/rewrite failure that we are seeing with the new toolchain/iOS SDKs provided with Xcode6 and iOS8. * Fix ALL the header guards. * Createed a README.md with the LevelDB project description. * A new CONTRIBUTING file. * Don't implicitly convert uint64_t to size_t or int. Either preserve it as uint64_t, or explicitly cast. This fixes MSVC warnings about possible value truncation when compiling this code in Chromium. * Added a DumpFile() library function that encapsulates the guts of the "leveldbutil dump" command. This will allow clients to dump data to their log files instead of stdout. It will also allow clients to supply their own environment. * leveldb: Remove unused function 'ConsumeChar'. * leveldbutil: Remove unused member variables from WriteBatchItemPrinter. * OpenBSD, NetBSD and DragonflyBSD have _LITTLE_ENDIAN, so define PLATFORM_IS_LITTLE_ENDIAN like on FreeBSD. This fixes: * issue #143 * issue #198 * issue #249 * Switch from <cstdatomic> to <atomic>. The former never made it into the standard and doesn't exist in modern gcc versions at all. The later contains everything that leveldb was using from the former. This problem was noticed when porting to Portable Native Client where no memory barrier is defined. The fact that <cstdatomic> is missing normally goes unnoticed since memory barriers are defined for most architectures. * Make Hash() treat its input as unsigned. Before this change LevelDB files from platforms with different signedness of char were not compatible. This change fixes: issue #243 * Verify checksums of index/meta/filter blocks when paranoid_checks set. * Invoke all tools for iOS with xcrun. (This was causing problems with the new XCode 5.1.1 image on pulse.) * include <sys/stat.h> only once, and fix the following linter warning: "Found C system header after C++ system header" * When encountering a corrupted table file, return Status::Corruption instead of Status::InvalidArgument. * Support cygwin as build platform, patch is from https://code.google.com/p/leveldb/issues/detail?id=188 * Fix typo, merge patch from https://code.google.com/p/leveldb/issues/detail?id=159 * Fix typos and comments, and address the following two issues: * issue #166 * issue #241 * Add missing db synchronize after "fillseq" in the benchmark. * Removed unused variable in SeekRandom: value (issue #201)
10 år sedan
  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
  3. // found in the LICENSE file. See the AUTHORS file for names of contributors.
  4. // AtomicPointer provides storage for a lock-free pointer.
  5. // Platform-dependent implementation of AtomicPointer:
  6. // - If the platform provides a cheap barrier, we use it with raw pointers
  7. // - If <atomic> is present (on newer versions of gcc, it is), we use
  8. // a <atomic>-based AtomicPointer. However we prefer the memory
  9. // barrier based version, because at least on a gcc 4.4 32-bit build
  10. // on linux, we have encountered a buggy <atomic> implementation.
  11. // Also, some <atomic> implementations are much slower than a memory-barrier
  12. // based implementation (~16ns for <atomic> based acquire-load vs. ~1ns for
  13. // a barrier based acquire-load).
  14. // This code is based on atomicops-internals-* in Google's perftools:
  15. // http://code.google.com/p/google-perftools/source/browse/#svn%2Ftrunk%2Fsrc%2Fbase
  16. #ifndef PORT_ATOMIC_POINTER_H_
  17. #define PORT_ATOMIC_POINTER_H_
  18. #include <stdint.h>
  19. #ifdef LEVELDB_ATOMIC_PRESENT
  20. #include <atomic>
  21. #endif
  22. #ifdef OS_WIN
  23. #include <windows.h>
  24. #endif
  25. #ifdef OS_MACOSX
  26. #include <libkern/OSAtomic.h>
  27. #endif
  28. #if defined(_M_X64) || defined(__x86_64__)
  29. #define ARCH_CPU_X86_FAMILY 1
  30. #elif defined(_M_IX86) || defined(__i386__) || defined(__i386)
  31. #define ARCH_CPU_X86_FAMILY 1
  32. #elif defined(__ARMEL__)
  33. #define ARCH_CPU_ARM_FAMILY 1
  34. #elif defined(__aarch64__)
  35. #define ARCH_CPU_ARM64_FAMILY 1
  36. #elif defined(__ppc__) || defined(__powerpc__) || defined(__powerpc64__)
  37. #define ARCH_CPU_PPC_FAMILY 1
  38. #elif defined(__mips__)
  39. #define ARCH_CPU_MIPS_FAMILY 1
  40. #endif
  41. namespace leveldb {
  42. namespace port {
  43. // Define MemoryBarrier() if available
  44. // Windows on x86
  45. #if defined(OS_WIN) && defined(COMPILER_MSVC) && defined(ARCH_CPU_X86_FAMILY)
  46. // windows.h already provides a MemoryBarrier(void) macro
  47. // http://msdn.microsoft.com/en-us/library/ms684208(v=vs.85).aspx
  48. #define LEVELDB_HAVE_MEMORY_BARRIER
  49. // Mac OS
  50. #elif defined(OS_MACOSX)
  51. inline void MemoryBarrier() {
  52. OSMemoryBarrier();
  53. }
  54. #define LEVELDB_HAVE_MEMORY_BARRIER
  55. // Gcc on x86
  56. #elif defined(ARCH_CPU_X86_FAMILY) && defined(__GNUC__)
  57. inline void MemoryBarrier() {
  58. // See http://gcc.gnu.org/ml/gcc/2003-04/msg01180.html for a discussion on
  59. // this idiom. Also see http://en.wikipedia.org/wiki/Memory_ordering.
  60. __asm__ __volatile__("" : : : "memory");
  61. }
  62. #define LEVELDB_HAVE_MEMORY_BARRIER
  63. // Sun Studio
  64. #elif defined(ARCH_CPU_X86_FAMILY) && defined(__SUNPRO_CC)
  65. inline void MemoryBarrier() {
  66. // See http://gcc.gnu.org/ml/gcc/2003-04/msg01180.html for a discussion on
  67. // this idiom. Also see http://en.wikipedia.org/wiki/Memory_ordering.
  68. asm volatile("" : : : "memory");
  69. }
  70. #define LEVELDB_HAVE_MEMORY_BARRIER
  71. // ARM Linux
  72. #elif defined(ARCH_CPU_ARM_FAMILY) && defined(__linux__)
  73. typedef void (*LinuxKernelMemoryBarrierFunc)(void);
  74. // The Linux ARM kernel provides a highly optimized device-specific memory
  75. // barrier function at a fixed memory address that is mapped in every
  76. // user-level process.
  77. //
  78. // This beats using CPU-specific instructions which are, on single-core
  79. // devices, un-necessary and very costly (e.g. ARMv7-A "dmb" takes more
  80. // than 180ns on a Cortex-A8 like the one on a Nexus One). Benchmarking
  81. // shows that the extra function call cost is completely negligible on
  82. // multi-core devices.
  83. //
  84. inline void MemoryBarrier() {
  85. (*(LinuxKernelMemoryBarrierFunc)0xffff0fa0)();
  86. }
  87. #define LEVELDB_HAVE_MEMORY_BARRIER
  88. // ARM64
  89. #elif defined(ARCH_CPU_ARM64_FAMILY)
  90. inline void MemoryBarrier() {
  91. asm volatile("dmb sy" : : : "memory");
  92. }
  93. #define LEVELDB_HAVE_MEMORY_BARRIER
  94. // PPC
  95. #elif defined(ARCH_CPU_PPC_FAMILY) && defined(__GNUC__)
  96. inline void MemoryBarrier() {
  97. // TODO for some powerpc expert: is there a cheaper suitable variant?
  98. // Perhaps by having separate barriers for acquire and release ops.
  99. asm volatile("sync" : : : "memory");
  100. }
  101. #define LEVELDB_HAVE_MEMORY_BARRIER
  102. // MIPS
  103. #elif defined(ARCH_CPU_MIPS_FAMILY) && defined(__GNUC__)
  104. inline void MemoryBarrier() {
  105. __asm__ __volatile__("sync" : : : "memory");
  106. }
  107. #define LEVELDB_HAVE_MEMORY_BARRIER
  108. #endif
  109. // AtomicPointer built using platform-specific MemoryBarrier()
  110. #if defined(LEVELDB_HAVE_MEMORY_BARRIER)
  111. class AtomicPointer {
  112. private:
  113. void* rep_;
  114. public:
  115. AtomicPointer() { }
  116. explicit AtomicPointer(void* p) : rep_(p) {}
  117. inline void* NoBarrier_Load() const { return rep_; }
  118. inline void NoBarrier_Store(void* v) { rep_ = v; }
  119. inline void* Acquire_Load() const {
  120. void* result = rep_;
  121. MemoryBarrier();
  122. return result;
  123. }
  124. inline void Release_Store(void* v) {
  125. MemoryBarrier();
  126. rep_ = v;
  127. }
  128. };
  129. // AtomicPointer based on <cstdatomic>
  130. #elif defined(LEVELDB_ATOMIC_PRESENT)
  131. class AtomicPointer {
  132. private:
  133. std::atomic<void*> rep_;
  134. public:
  135. AtomicPointer() { }
  136. explicit AtomicPointer(void* v) : rep_(v) { }
  137. inline void* Acquire_Load() const {
  138. return rep_.load(std::memory_order_acquire);
  139. }
  140. inline void Release_Store(void* v) {
  141. rep_.store(v, std::memory_order_release);
  142. }
  143. inline void* NoBarrier_Load() const {
  144. return rep_.load(std::memory_order_relaxed);
  145. }
  146. inline void NoBarrier_Store(void* v) {
  147. rep_.store(v, std::memory_order_relaxed);
  148. }
  149. };
  150. // Atomic pointer based on sparc memory barriers
  151. #elif defined(__sparcv9) && defined(__GNUC__)
  152. class AtomicPointer {
  153. private:
  154. void* rep_;
  155. public:
  156. AtomicPointer() { }
  157. explicit AtomicPointer(void* v) : rep_(v) { }
  158. inline void* Acquire_Load() const {
  159. void* val;
  160. __asm__ __volatile__ (
  161. "ldx [%[rep_]], %[val] \n\t"
  162. "membar #LoadLoad|#LoadStore \n\t"
  163. : [val] "=r" (val)
  164. : [rep_] "r" (&rep_)
  165. : "memory");
  166. return val;
  167. }
  168. inline void Release_Store(void* v) {
  169. __asm__ __volatile__ (
  170. "membar #LoadStore|#StoreStore \n\t"
  171. "stx %[v], [%[rep_]] \n\t"
  172. :
  173. : [rep_] "r" (&rep_), [v] "r" (v)
  174. : "memory");
  175. }
  176. inline void* NoBarrier_Load() const { return rep_; }
  177. inline void NoBarrier_Store(void* v) { rep_ = v; }
  178. };
  179. // Atomic pointer based on ia64 acq/rel
  180. #elif defined(__ia64) && defined(__GNUC__)
  181. class AtomicPointer {
  182. private:
  183. void* rep_;
  184. public:
  185. AtomicPointer() { }
  186. explicit AtomicPointer(void* v) : rep_(v) { }
  187. inline void* Acquire_Load() const {
  188. void* val ;
  189. __asm__ __volatile__ (
  190. "ld8.acq %[val] = [%[rep_]] \n\t"
  191. : [val] "=r" (val)
  192. : [rep_] "r" (&rep_)
  193. : "memory"
  194. );
  195. return val;
  196. }
  197. inline void Release_Store(void* v) {
  198. __asm__ __volatile__ (
  199. "st8.rel [%[rep_]] = %[v] \n\t"
  200. :
  201. : [rep_] "r" (&rep_), [v] "r" (v)
  202. : "memory"
  203. );
  204. }
  205. inline void* NoBarrier_Load() const { return rep_; }
  206. inline void NoBarrier_Store(void* v) { rep_ = v; }
  207. };
  208. // We have neither MemoryBarrier(), nor <atomic>
  209. #else
  210. #error Please implement AtomicPointer for this platform.
  211. #endif
  212. #undef LEVELDB_HAVE_MEMORY_BARRIER
  213. #undef ARCH_CPU_X86_FAMILY
  214. #undef ARCH_CPU_ARM_FAMILY
  215. #undef ARCH_CPU_ARM64_FAMILY
  216. #undef ARCH_CPU_PPC_FAMILY
  217. } // namespace port
  218. } // namespace leveldb
  219. #endif // PORT_ATOMIC_POINTER_H_