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
// See port_example.h for documentation for the following types/functions.
7
#ifndef STORAGE_LEVELDB_PORT_PORT_ANDROID_H_
8
#define STORAGE_LEVELDB_PORT_PORT_ANDROID_H_
17
// Collapse the plethora of ARM flavors available to an easier to manage set
18
// Defs reference is at https://wiki.edubuntu.org/ARM/Thumb2PortingHowto
19
#if defined(__ARM_ARCH_6__) || \
20
defined(__ARM_ARCH_6J__) || \
21
defined(__ARM_ARCH_6K__) || \
22
defined(__ARM_ARCH_6Z__) || \
23
defined(__ARM_ARCH_6T2__) || \
24
defined(__ARM_ARCH_6ZK__) || \
25
defined(__ARM_ARCH_7__) || \
26
defined(__ARM_ARCH_7R__) || \
27
defined(__ARM_ARCH_7A__)
32
size_t fread_unlocked(void *a, size_t b, size_t c, FILE *d);
33
size_t fwrite_unlocked(const void *a, size_t b, size_t c, FILE *d);
34
int fflush_unlocked(FILE *f);
35
int fdatasync (int fd);
41
static const bool kLittleEndian = __BYTE_ORDER == __LITTLE_ENDIAN;
53
//TODO(gabor): How can I implement this?
62
void operator=(const Mutex&);
67
explicit CondVar(Mutex* mu);
78
// On ARM chipsets <V6, 0xffff0fa0 is the hard coded address of a
79
// memory barrier function provided by the kernel.
80
typedef void (*LinuxKernelMemoryBarrierFunc)(void);
81
LinuxKernelMemoryBarrierFunc pLinuxKernelMemoryBarrier ATTRIBUTE_WEAK =
82
(LinuxKernelMemoryBarrierFunc) 0xffff0fa0;
85
// Storage for a lock-free pointer
90
inline void MemoryBarrier() const {
91
// TODO(gabor): This only works on Android instruction sets >= V6
93
__asm__ __volatile__("dmb" : : : "memory");
95
pLinuxKernelMemoryBarrier();
101
explicit AtomicPointer(void* v) : rep_(v) { }
102
inline void* Acquire_Load() const {
107
inline void Release_Store(void* v) {
111
inline void* NoBarrier_Load() const {
115
inline void NoBarrier_Store(void* v) {
120
// TODO(gabor): Implement compress
121
inline bool Snappy_Compress(
124
std::string* output) {
128
// TODO(gabor): Implement uncompress
129
inline bool Snappy_GetUncompressedLength(const char* input, size_t length,
134
// TODO(gabor): Implement uncompress
135
inline bool Snappy_Uncompress(
136
const char* input_data,
142
inline uint64_t ThreadIdentifier() {
143
pthread_t tid = pthread_self();
145
memcpy(&r, &tid, sizeof(r) < sizeof(tid) ? sizeof(r) : sizeof(tid));
149
inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) {
154
} // namespace leveldb
156
#endif // STORAGE_LEVELDB_PORT_PORT_ANDROID_H_