You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
4.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 years ago
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 years ago
  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 SNAPPY
  40. #include <snappy.h>
  41. #endif
  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_SOLARIS) || defined(OS_FREEBSD) ||\
  49. defined(OS_NETBSD) || defined(OS_OPENBSD) || defined(OS_DRAGONFLYBSD) ||\
  50. defined(OS_ANDROID) || defined(OS_HPUX) || defined(CYGWIN)
  51. // Use fread/fwrite/fflush on platforms without _unlocked variants
  52. #define fread_unlocked fread
  53. #define fwrite_unlocked fwrite
  54. #define fflush_unlocked fflush
  55. #endif
  56. #if defined(__APPLE__) || defined(OS_FREEBSD) ||\
  57. defined(OS_OPENBSD) || defined(OS_DRAGONFLYBSD)
  58. // Use fsync() on platforms without fdatasync()
  59. #define fdatasync fsync
  60. #endif
  61. #if defined(OS_ANDROID) && __ANDROID_API__ < 9
  62. // fdatasync() was only introduced in API level 9 on Android. Use fsync()
  63. // when targetting older platforms.
  64. #define fdatasync fsync
  65. #endif
  66. namespace leveldb {
  67. namespace port {
  68. static const bool kLittleEndian = PLATFORM_IS_LITTLE_ENDIAN;
  69. #undef PLATFORM_IS_LITTLE_ENDIAN
  70. class CondVar;
  71. class Mutex {
  72. public:
  73. Mutex();
  74. ~Mutex();
  75. void Lock();
  76. void Unlock();
  77. void AssertHeld() { }
  78. private:
  79. friend class CondVar;
  80. pthread_mutex_t mu_;
  81. // No copying
  82. Mutex(const Mutex&);
  83. void operator=(const Mutex&);
  84. };
  85. class CondVar {
  86. public:
  87. explicit CondVar(Mutex* mu);
  88. ~CondVar();
  89. void Wait();
  90. void Signal();
  91. void SignalAll();
  92. private:
  93. pthread_cond_t cv_;
  94. Mutex* mu_;
  95. };
  96. typedef pthread_once_t OnceType;
  97. #define LEVELDB_ONCE_INIT PTHREAD_ONCE_INIT
  98. extern void InitOnce(OnceType* once, void (*initializer)());
  99. inline bool Snappy_Compress(const char* input, size_t length,
  100. ::std::string* output) {
  101. #ifdef SNAPPY
  102. output->resize(snappy::MaxCompressedLength(length));
  103. size_t outlen;
  104. snappy::RawCompress(input, length, &(*output)[0], &outlen);
  105. output->resize(outlen);
  106. return true;
  107. #endif
  108. return false;
  109. }
  110. inline bool Snappy_GetUncompressedLength(const char* input, size_t length,
  111. size_t* result) {
  112. #ifdef SNAPPY
  113. return snappy::GetUncompressedLength(input, length, result);
  114. #else
  115. return false;
  116. #endif
  117. }
  118. inline bool Snappy_Uncompress(const char* input, size_t length,
  119. char* output) {
  120. #ifdef SNAPPY
  121. return snappy::RawUncompress(input, length, output);
  122. #else
  123. return false;
  124. #endif
  125. }
  126. inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) {
  127. return false;
  128. }
  129. uint32_t AcceleratedCRC32C(uint32_t crc, const char* buf, size_t size);
  130. } // namespace port
  131. } // namespace leveldb
  132. #endif // STORAGE_LEVELDB_PORT_PORT_POSIX_H_