Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

171 lignes
5.3 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)
il y a 10 ans
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)
il y a 10 ans
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)
il y a 10 ans
  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. #include <atomic>
  20. #if defined(_M_X64) || defined(__x86_64__)
  21. #define ARCH_CPU_X86_FAMILY 1
  22. #elif defined(_M_IX86) || defined(__i386__) || defined(__i386)
  23. #define ARCH_CPU_X86_FAMILY 1
  24. #elif defined(__ARMEL__)
  25. #define ARCH_CPU_ARM_FAMILY 1
  26. #elif defined(__aarch64__)
  27. #define ARCH_CPU_ARM64_FAMILY 1
  28. #elif defined(__ppc__) || defined(__powerpc__) || defined(__powerpc64__)
  29. #define ARCH_CPU_PPC_FAMILY 1
  30. #elif defined(__mips__)
  31. #define ARCH_CPU_MIPS_FAMILY 1
  32. #endif
  33. namespace leveldb {
  34. namespace port {
  35. // Define MemoryBarrier() if available
  36. // Windows on x86
  37. #if defined(OS_WIN) && defined(COMPILER_MSVC) && defined(ARCH_CPU_X86_FAMILY)
  38. // windows.h already provides a MemoryBarrier(void) macro
  39. // http://msdn.microsoft.com/en-us/library/ms684208(v=vs.85).aspx
  40. #define LEVELDB_HAVE_MEMORY_BARRIER
  41. // Mac OS
  42. #elif defined(__APPLE__)
  43. inline void MemoryBarrier() {
  44. std::atomic_thread_fence(std::memory_order_seq_cst);
  45. }
  46. #define LEVELDB_HAVE_MEMORY_BARRIER
  47. // Gcc on x86
  48. #elif defined(ARCH_CPU_X86_FAMILY) && defined(__GNUC__)
  49. inline void MemoryBarrier() {
  50. // See http://gcc.gnu.org/ml/gcc/2003-04/msg01180.html for a discussion on
  51. // this idiom. Also see http://en.wikipedia.org/wiki/Memory_ordering.
  52. __asm__ __volatile__("" : : : "memory");
  53. }
  54. #define LEVELDB_HAVE_MEMORY_BARRIER
  55. // Sun Studio
  56. #elif defined(ARCH_CPU_X86_FAMILY) && defined(__SUNPRO_CC)
  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. // ARM Linux
  64. #elif defined(ARCH_CPU_ARM_FAMILY) && defined(__linux__)
  65. typedef void (*LinuxKernelMemoryBarrierFunc)(void);
  66. // The Linux ARM kernel provides a highly optimized device-specific memory
  67. // barrier function at a fixed memory address that is mapped in every
  68. // user-level process.
  69. //
  70. // This beats using CPU-specific instructions which are, on single-core
  71. // devices, un-necessary and very costly (e.g. ARMv7-A "dmb" takes more
  72. // than 180ns on a Cortex-A8 like the one on a Nexus One). Benchmarking
  73. // shows that the extra function call cost is completely negligible on
  74. // multi-core devices.
  75. //
  76. inline void MemoryBarrier() {
  77. (*(LinuxKernelMemoryBarrierFunc)0xffff0fa0)();
  78. }
  79. #define LEVELDB_HAVE_MEMORY_BARRIER
  80. // ARM64
  81. #elif defined(ARCH_CPU_ARM64_FAMILY)
  82. inline void MemoryBarrier() {
  83. asm volatile("dmb sy" : : : "memory");
  84. }
  85. #define LEVELDB_HAVE_MEMORY_BARRIER
  86. // PPC
  87. #elif defined(ARCH_CPU_PPC_FAMILY) && defined(__GNUC__)
  88. inline void MemoryBarrier() {
  89. // TODO for some powerpc expert: is there a cheaper suitable variant?
  90. // Perhaps by having separate barriers for acquire and release ops.
  91. asm volatile("sync" : : : "memory");
  92. }
  93. #define LEVELDB_HAVE_MEMORY_BARRIER
  94. // MIPS
  95. #elif defined(ARCH_CPU_MIPS_FAMILY) && defined(__GNUC__)
  96. inline void MemoryBarrier() {
  97. __asm__ __volatile__("sync" : : : "memory");
  98. }
  99. #define LEVELDB_HAVE_MEMORY_BARRIER
  100. #endif
  101. // AtomicPointer built using platform-specific MemoryBarrier().
  102. #if defined(LEVELDB_HAVE_MEMORY_BARRIER)
  103. class AtomicPointer {
  104. private:
  105. void* rep_;
  106. public:
  107. AtomicPointer() { }
  108. explicit AtomicPointer(void* p) : rep_(p) {}
  109. inline void* NoBarrier_Load() const { return rep_; }
  110. inline void NoBarrier_Store(void* v) { rep_ = v; }
  111. inline void* Acquire_Load() const {
  112. void* result = rep_;
  113. MemoryBarrier();
  114. return result;
  115. }
  116. inline void Release_Store(void* v) {
  117. MemoryBarrier();
  118. rep_ = v;
  119. }
  120. };
  121. // AtomicPointer based on C++11 <atomic>.
  122. #else
  123. class AtomicPointer {
  124. private:
  125. std::atomic<void*> rep_;
  126. public:
  127. AtomicPointer() { }
  128. explicit AtomicPointer(void* v) : rep_(v) { }
  129. inline void* Acquire_Load() const {
  130. return rep_.load(std::memory_order_acquire);
  131. }
  132. inline void Release_Store(void* v) {
  133. rep_.store(v, std::memory_order_release);
  134. }
  135. inline void* NoBarrier_Load() const {
  136. return rep_.load(std::memory_order_relaxed);
  137. }
  138. inline void NoBarrier_Store(void* v) {
  139. rep_.store(v, std::memory_order_relaxed);
  140. }
  141. };
  142. #endif
  143. #undef LEVELDB_HAVE_MEMORY_BARRIER
  144. #undef ARCH_CPU_X86_FAMILY
  145. #undef ARCH_CPU_ARM_FAMILY
  146. #undef ARCH_CPU_ARM64_FAMILY
  147. #undef ARCH_CPU_PPC_FAMILY
  148. } // namespace port
  149. } // namespace leveldb
  150. #endif // PORT_ATOMIC_POINTER_H_