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.
5 #include "port/port_android.h"
10 size_t fread_unlocked(void *a, size_t b, size_t c, FILE *d) {
11 return fread(a, b, c, d);
14 size_t fwrite_unlocked(const void *a, size_t b, size_t c, FILE *d) {
15 return fwrite(a, b, c, d);
18 int fflush_unlocked(FILE *f) {
22 int fdatasync(int fd) {
30 static void PthreadCall(const char* label, int result) {
32 fprintf(stderr, "pthread %s: %s\n", label, strerror(result));
37 Mutex::Mutex() { PthreadCall("init mutex", pthread_mutex_init(&mu_, NULL)); }
38 Mutex::~Mutex() { PthreadCall("destroy mutex", pthread_mutex_destroy(&mu_)); }
39 void Mutex::Lock() { PthreadCall("lock", pthread_mutex_lock(&mu_)); }
40 void Mutex::Unlock() { PthreadCall("unlock", pthread_mutex_unlock(&mu_)); }
42 CondVar::CondVar(Mutex* mu)
44 PthreadCall("init cv", pthread_cond_init(&cv_, NULL));
48 PthreadCall("destroy cv", pthread_cond_destroy(&cv_));
51 void CondVar::Wait() {
52 PthreadCall("wait", pthread_cond_wait(&cv_, &mu_->mu_));
55 void CondVar::Signal(){
56 PthreadCall("signal", pthread_cond_signal(&cv_));
59 void CondVar::SignalAll() {
60 PthreadCall("broadcast", pthread_cond_broadcast(&cv_));
64 } // namespace leveldb