From b914f91b1049699aa2d0e08660aa9246b87bdcb7 Mon Sep 17 00:00:00 2001 From: Sanjay Ghemawat Date: Wed, 30 May 2012 09:50:57 -0700 Subject: [PATCH] remove obsolete android port files --- port/port_android.cc | 64 --------------------- port/port_android.h | 159 --------------------------------------------------- 2 files changed, 223 deletions(-) delete mode 100644 port/port_android.cc delete mode 100644 port/port_android.h diff --git a/port/port_android.cc b/port/port_android.cc deleted file mode 100644 index 815abf2..0000000 --- a/port/port_android.cc +++ /dev/null @@ -1,64 +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_android.h" - -#include - -extern "C" { -size_t fread_unlocked(void *a, size_t b, size_t c, FILE *d) { - return fread(a, b, c, d); -} - -size_t fwrite_unlocked(const void *a, size_t b, size_t c, FILE *d) { - return fwrite(a, b, c, d); -} - -int fflush_unlocked(FILE *f) { - return fflush(f); -} - -int fdatasync(int fd) { - return fsync(fd); -} -} - -namespace leveldb { -namespace port { - -static void PthreadCall(const char* label, int result) { - if (result != 0) { - fprintf(stderr, "pthread %s: %s\n", label, strerror(result)); - abort(); - } -} - -Mutex::Mutex() { PthreadCall("init mutex", pthread_mutex_init(&mu_, NULL)); } -Mutex::~Mutex() { PthreadCall("destroy mutex", pthread_mutex_destroy(&mu_)); } -void Mutex::Lock() { PthreadCall("lock", pthread_mutex_lock(&mu_)); } -void Mutex::Unlock() { PthreadCall("unlock", pthread_mutex_unlock(&mu_)); } - -CondVar::CondVar(Mutex* mu) - : mu_(mu) { - PthreadCall("init cv", pthread_cond_init(&cv_, NULL)); -} - -CondVar::~CondVar() { - PthreadCall("destroy cv", pthread_cond_destroy(&cv_)); -} - -void CondVar::Wait() { - PthreadCall("wait", pthread_cond_wait(&cv_, &mu_->mu_)); -} - -void CondVar::Signal(){ - PthreadCall("signal", pthread_cond_signal(&cv_)); -} - -void CondVar::SignalAll() { - PthreadCall("broadcast", pthread_cond_broadcast(&cv_)); -} - -} // namespace port -} // namespace leveldb diff --git a/port/port_android.h b/port/port_android.h deleted file mode 100644 index b733388..0000000 --- a/port/port_android.h +++ /dev/null @@ -1,159 +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_ANDROID_H_ -#define STORAGE_LEVELDB_PORT_PORT_ANDROID_H_ - -#include -#include -#include -#include -#include -#include - -// Collapse the plethora of ARM flavors available to an easier to manage set -// Defs reference is at https://wiki.edubuntu.org/ARM/Thumb2PortingHowto -#if defined(__ARM_ARCH_6__) || \ - defined(__ARM_ARCH_6J__) || \ - defined(__ARM_ARCH_6K__) || \ - defined(__ARM_ARCH_6Z__) || \ - defined(__ARM_ARCH_6T2__) || \ - defined(__ARM_ARCH_6ZK__) || \ - defined(__ARM_ARCH_7__) || \ - defined(__ARM_ARCH_7R__) || \ - defined(__ARM_ARCH_7A__) -#define ARMV6_OR_7 1 -#endif - -extern "C" { - size_t fread_unlocked(void *a, size_t b, size_t c, FILE *d); - size_t fwrite_unlocked(const void *a, size_t b, size_t c, FILE *d); - int fflush_unlocked(FILE *f); - int fdatasync (int fd); -} - -namespace leveldb { -namespace port { - -static const bool kLittleEndian = __BYTE_ORDER == __LITTLE_ENDIAN; - -class CondVar; - -class Mutex { - public: - Mutex(); - ~Mutex(); - - void Lock(); - void Unlock(); - void AssertHeld() { - //TODO(gabor): How can I implement this? - } - - private: - friend class CondVar; - pthread_mutex_t mu_; - - // No copying - Mutex(const Mutex&); - void operator=(const Mutex&); -}; - -class CondVar { - public: - explicit CondVar(Mutex* mu); - ~CondVar(); - void Wait(); - void Signal(); - void SignalAll(); - private: - Mutex* mu_; - pthread_cond_t cv_; -}; - -#ifndef ARMV6_OR_7 -// On ARM chipsets = V6 -#ifdef ARMV6_OR_7 - __asm__ __volatile__("dmb" : : : "memory"); -#else - pLinuxKernelMemoryBarrier(); -#endif - } - - public: - AtomicPointer() { } - explicit AtomicPointer(void* v) : rep_(v) { } - inline void* Acquire_Load() const { - void* r = rep_; - MemoryBarrier(); - return r; - } - inline void Release_Store(void* v) { - MemoryBarrier(); - rep_ = v; - } - inline void* NoBarrier_Load() const { - void* r = rep_; - return r; - } - inline void NoBarrier_Store(void* v) { - rep_ = v; - } -}; - -// TODO(gabor): Implement compress -inline bool Snappy_Compress( - const char* input, - size_t input_length, - std::string* output) { - return false; -} - -// TODO(gabor): Implement uncompress -inline bool Snappy_GetUncompressedLength(const char* input, size_t length, - size_t* result) { - return false; -} - -// TODO(gabor): Implement uncompress -inline bool Snappy_Uncompress( - const char* input_data, - size_t input_length, - char* output) { - return false; -} - -inline uint64_t ThreadIdentifier() { - pthread_t tid = pthread_self(); - uint64_t r = 0; - memcpy(&r, &tid, sizeof(r) < sizeof(tid) ? sizeof(r) : sizeof(tid)); - return r; -} - -inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) { - return false; -} - -} // namespace port -} // namespace leveldb - -#endif // STORAGE_LEVELDB_PORT_PORT_ANDROID_H_