作者: 韩晨旭 10225101440 李畅 10225102463
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

147 рядки
3.8 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 роки тому
  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. //
  5. // See port_example.h for documentation for the following types/functions.
  6. #ifndef STORAGE_LEVELDB_PORT_PORT_POSIX_H_
  7. #define STORAGE_LEVELDB_PORT_PORT_POSIX_H_
  8. #undef PLATFORM_IS_LITTLE_ENDIAN
  9. #if defined(__APPLE__)
  10. #include <machine/endian.h>
  11. #if defined(__DARWIN_LITTLE_ENDIAN) && defined(__DARWIN_BYTE_ORDER)
  12. #define PLATFORM_IS_LITTLE_ENDIAN \
  13. (__DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN)
  14. #endif
  15. #elif defined(OS_SOLARIS)
  16. #include <sys/isa_defs.h>
  17. #ifdef _LITTLE_ENDIAN
  18. #define PLATFORM_IS_LITTLE_ENDIAN true
  19. #else
  20. #define PLATFORM_IS_LITTLE_ENDIAN false
  21. #endif
  22. #elif defined(OS_FREEBSD) || defined(OS_OPENBSD) ||\
  23. defined(OS_NETBSD) || defined(OS_DRAGONFLYBSD)
  24. #include <sys/types.h>
  25. #include <sys/endian.h>
  26. #define PLATFORM_IS_LITTLE_ENDIAN (_BYTE_ORDER == _LITTLE_ENDIAN)
  27. #elif defined(OS_HPUX)
  28. #define PLATFORM_IS_LITTLE_ENDIAN false
  29. #elif defined(OS_ANDROID)
  30. // Due to a bug in the NDK x86 <sys/endian.h> definition,
  31. // _BYTE_ORDER must be used instead of __BYTE_ORDER on Android.
  32. // See http://code.google.com/p/android/issues/detail?id=39824
  33. #include <endian.h>
  34. #define PLATFORM_IS_LITTLE_ENDIAN (_BYTE_ORDER == _LITTLE_ENDIAN)
  35. #else
  36. #include <endian.h>
  37. #endif
  38. #include <pthread.h>
  39. #ifdef HAVE_SNAPPY
  40. #include <snappy.h>
  41. #endif // defined(HAVE_SNAPPY)
  42. #include <stdint.h>
  43. #include <string>
  44. #include "port/atomic_pointer.h"
  45. #ifndef PLATFORM_IS_LITTLE_ENDIAN
  46. #define PLATFORM_IS_LITTLE_ENDIAN (__BYTE_ORDER == __LITTLE_ENDIAN)
  47. #endif
  48. #if defined(__APPLE__) || defined(OS_FREEBSD) ||\
  49. defined(OS_OPENBSD) || defined(OS_DRAGONFLYBSD)
  50. // Use fsync() on platforms without fdatasync()
  51. #define fdatasync fsync
  52. #endif
  53. #if defined(OS_ANDROID) && __ANDROID_API__ < 9
  54. // fdatasync() was only introduced in API level 9 on Android. Use fsync()
  55. // when targetting older platforms.
  56. #define fdatasync fsync
  57. #endif
  58. namespace leveldb {
  59. namespace port {
  60. static const bool kLittleEndian = PLATFORM_IS_LITTLE_ENDIAN;
  61. #undef PLATFORM_IS_LITTLE_ENDIAN
  62. class CondVar;
  63. class Mutex {
  64. public:
  65. Mutex();
  66. ~Mutex();
  67. void Lock();
  68. void Unlock();
  69. void AssertHeld() { }
  70. private:
  71. friend class CondVar;
  72. pthread_mutex_t mu_;
  73. // No copying
  74. Mutex(const Mutex&);
  75. void operator=(const Mutex&);
  76. };
  77. class CondVar {
  78. public:
  79. explicit CondVar(Mutex* mu);
  80. ~CondVar();
  81. void Wait();
  82. void Signal();
  83. void SignalAll();
  84. private:
  85. pthread_cond_t cv_;
  86. Mutex* mu_;
  87. };
  88. typedef pthread_once_t OnceType;
  89. #define LEVELDB_ONCE_INIT PTHREAD_ONCE_INIT
  90. extern void InitOnce(OnceType* once, void (*initializer)());
  91. inline bool Snappy_Compress(const char* input, size_t length,
  92. ::std::string* output) {
  93. #ifdef HAVE_SNAPPY
  94. output->resize(snappy::MaxCompressedLength(length));
  95. size_t outlen;
  96. snappy::RawCompress(input, length, &(*output)[0], &outlen);
  97. output->resize(outlen);
  98. return true;
  99. #endif // defined(HAVE_SNAPPY)
  100. return false;
  101. }
  102. inline bool Snappy_GetUncompressedLength(const char* input, size_t length,
  103. size_t* result) {
  104. #ifdef HAVE_SNAPPY
  105. return snappy::GetUncompressedLength(input, length, result);
  106. #else
  107. return false;
  108. #endif // defined(HAVE_SNAPPY)
  109. }
  110. inline bool Snappy_Uncompress(const char* input, size_t length,
  111. char* output) {
  112. #ifdef HAVE_SNAPPY
  113. return snappy::RawUncompress(input, length, output);
  114. #else
  115. return false;
  116. #endif // defined(HAVE_SNAPPY)
  117. }
  118. inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) {
  119. return false;
  120. }
  121. uint32_t AcceleratedCRC32C(uint32_t crc, const char* buf, size_t size);
  122. } // namespace port
  123. } // namespace leveldb
  124. #endif // STORAGE_LEVELDB_PORT_PORT_POSIX_H_