作者: 谢瑞阳 10225101483 徐翔宇 10225101535
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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