summaryrefslogtreecommitdiff
path: root/port
diff options
context:
space:
mode:
authorgabor@google.com <gabor@google.com@62dab493-f737-651d-591e-8d6aee1b9529>2011-07-27 01:46:25 +0000
committergabor@google.com <gabor@google.com@62dab493-f737-651d-591e-8d6aee1b9529>2011-07-27 01:46:25 +0000
commitf122c6dfbb4afacd0ac39f95106da81f8a714e72 (patch)
tree330b6d7f4d0c90541a67394d098bf19ff45fd967 /port
parent60bd8015f21fdb63d5409b1191f8ea9d8f1a1b87 (diff)
downloadleveldb-f122c6dfbb4afacd0ac39f95106da81f8a714e72.tar.gz
Adding FreeBSD support, removing Chromium files, adding benchmark.
- LevelDB patch for FreeBSD. This resolves Issue 22. Contributed by dforsythe (thanks!). - Removing Chromium-specific files. They are now going to live in the Chromium repository. - Adding a benchmark page comparing LevelDB performance to SQLite and Kyoto Cabinet's TreeDB, along with code to generate the benchmarks. Thanks to Kevin Tseng for compiling the benchmarks, and Scott Hess and Mikio Hirabayashi for their help and advice. git-svn-id: https://leveldb.googlecode.com/svn/trunk@40 62dab493-f737-651d-591e-8d6aee1b9529
Diffstat (limited to 'port')
-rw-r--r--port/port_chromium.cc84
-rw-r--r--port/port_chromium.h99
-rw-r--r--port/port_posix.h6
3 files changed, 3 insertions, 186 deletions
diff --git a/port/port_chromium.cc b/port/port_chromium.cc
deleted file mode 100644
index 7f6de92..0000000
--- a/port/port_chromium.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file. See the AUTHORS file for names of contributors.
-
-#include "port/port_chromium.h"
-
-#include "util/logging.h"
-
-#if defined(USE_SNAPPY)
-# include "third_party/snappy/src/snappy.h"
-#endif
-
-namespace leveldb {
-namespace port {
-
-Mutex::Mutex() {
-}
-
-Mutex::~Mutex() {
-}
-
-void Mutex::Lock() {
- mu_.Acquire();
-}
-
-void Mutex::Unlock() {
- mu_.Release();
-}
-
-void Mutex::AssertHeld() {
- mu_.AssertAcquired();
-}
-
-CondVar::CondVar(Mutex* mu)
- : cv_(&mu->mu_) {
-}
-
-CondVar::~CondVar() { }
-
-void CondVar::Wait() {
- cv_.Wait();
-}
-
-void CondVar::Signal(){
- cv_.Signal();
-}
-
-void CondVar::SignalAll() {
- cv_.Broadcast();
-}
-
-bool Snappy_Compress(const char* input, size_t input_length,
- std::string* output) {
-#if defined(USE_SNAPPY)
- output->resize(snappy::MaxCompressedLength(input_length));
- size_t outlen;
- snappy::RawCompress(input, input_length, &(*output)[0], &outlen);
- output->resize(outlen);
- return true;
-#else
- return false;
-#endif
-}
-
-bool Snappy_GetUncompressedLength(const char* input, size_t length,
- size_t* result) {
-#if defined(USE_SNAPPY)
- return snappy::GetUncompressedLength(input_data, input_length, result);
-#else
- return false;
-#endif
-}
-
-bool Snappy_Uncompress(const char* input_data, size_t input_length,
- char* output) {
-#if defined(USE_SNAPPY)
- return snappy::RawUncompress(input_data, input_length, output);
-#else
- return false;
-#endif
-}
-
-}
-}
diff --git a/port/port_chromium.h b/port/port_chromium.h
deleted file mode 100644
index feecd5b..0000000
--- a/port/port_chromium.h
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file. See the AUTHORS file for names of contributors.
-//
-// See port_example.h for documentation for the following types/functions.
-
-#ifndef STORAGE_LEVELDB_PORT_PORT_CHROMIUM_H_
-#define STORAGE_LEVELDB_PORT_PORT_CHROMIUM_H_
-
-#include <stdint.h>
-#include <string>
-#include <cstring>
-#include "base/atomicops.h"
-#include "base/basictypes.h"
-#include "base/logging.h"
-#include "base/synchronization/condition_variable.h"
-#include "base/synchronization/lock.h"
-
-// Linux's ThreadIdentifier() needs this.
-#if defined(OS_LINUX)
-# include <linux/unistd.h>
-#endif
-
-#if defined(OS_WIN)
-#define snprintf _snprintf
-#define va_copy(a, b) do { (a) = (b); } while (0)
-#endif
-
-namespace leveldb {
-namespace port {
-
-// Chromium only supports little endian.
-static const bool kLittleEndian = true;
-
-class Mutex {
- public:
- Mutex();
- ~Mutex();
- void Lock();
- void Unlock();
- void AssertHeld();
-
- private:
- base::Lock mu_;
-
- friend class CondVar;
- DISALLOW_COPY_AND_ASSIGN(Mutex);
-};
-
-class CondVar {
- public:
- explicit CondVar(Mutex* mu);
- ~CondVar();
- void Wait();
- void Signal();
- void SignalAll();
-
- private:
- base::ConditionVariable cv_;
-
- DISALLOW_COPY_AND_ASSIGN(CondVar);
-};
-
-class AtomicPointer {
- private:
- typedef base::subtle::AtomicWord Rep;
- Rep rep_;
- public:
- AtomicPointer() { }
- explicit AtomicPointer(void* p) : rep_(reinterpret_cast<Rep>(p)) {}
- inline void* Acquire_Load() const {
- return reinterpret_cast<void*>(::base::subtle::Acquire_Load(&rep_));
- }
- inline void Release_Store(void* v) {
- ::base::subtle::Release_Store(&rep_, reinterpret_cast<Rep>(v));
- }
- inline void* NoBarrier_Load() const {
- return reinterpret_cast<void*>(::base::subtle::NoBarrier_Load(&rep_));
- }
- inline void NoBarrier_Store(void* v) {
- ::base::subtle::NoBarrier_Store(&rep_, reinterpret_cast<Rep>(v));
- }
-};
-
-bool Snappy_Compress(const char* input, size_t input_length,
- std::string* output);
-bool Snappy_GetUncompressedLength(const char* input, size_t length,
- size_t* result);
-bool Snappy_Uncompress(const char* input_data, size_t input_length,
- char* output);
-
-inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) {
- return false;
-}
-
-}
-}
-
-#endif // STORAGE_LEVELDB_PORT_PORT_CHROMIUM_H_
diff --git a/port/port_posix.h b/port/port_posix.h
index ef01de3..9666391 100644
--- a/port/port_posix.h
+++ b/port/port_posix.h
@@ -7,7 +7,7 @@
#ifndef STORAGE_LEVELDB_PORT_PORT_POSIX_H_
#define STORAGE_LEVELDB_PORT_PORT_POSIX_H_
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) || defined(OS_FREEBSD)
#include <machine/endian.h>
#elif defined(OS_SOLARIS)
#include <sys/isa_defs.h>
@@ -33,13 +33,13 @@
#define IS_LITTLE_ENDIAN (__BYTE_ORDER == __LITTLE_ENDIAN)
#endif
-#if defined(OS_MACOSX) || defined(OS_SOLARIS)
+#if defined(OS_MACOSX) || defined(OS_SOLARIS) || defined(OS_FREEBSD)
#define fread_unlocked fread
#define fwrite_unlocked fwrite
#define fflush_unlocked fflush
#endif
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) || defined(OS_FREEBSD)
#define fdatasync fsync
#endif