Loading include/utils/MemoryHeapBase.h +4 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,10 @@ class MemoryHeapBase : public virtual BnMemoryHeap public: enum { READ_ONLY = IMemoryHeap::READ_ONLY, MAP_ONCE = IMemoryHeap::MAP_ONCE MAP_ONCE = IMemoryHeap::MAP_ONCE, // memory won't be mapped locally, but will be mapped in the remote // process. DONT_MAP_LOCALLY = 0x00000100 }; /* Loading include/utils/RefBase.h +24 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #ifndef ANDROID_REF_BASE_H #define ANDROID_REF_BASE_H #include <cutils/atomic.h> #include <utils/TextOutput.h> #include <stdint.h> Loading Loading @@ -142,6 +143,29 @@ private: // --------------------------------------------------------------------------- template <class T> class LightRefBase { public: inline LightRefBase() : mCount(0) { } inline void incStrong(const void* id) const { android_atomic_inc(&mCount); } inline void decStrong(const void* id) const { if (android_atomic_dec(&mCount) == 1) { delete static_cast<const T*>(this); } } protected: inline ~LightRefBase() { } private: mutable volatile int32_t mCount; }; // --------------------------------------------------------------------------- template <typename T> class sp { Loading libs/utils/MemoryHeapBase.cpp +15 −10 Original line number Diff line number Diff line Loading @@ -119,6 +119,7 @@ status_t MemoryHeapBase::mapfd(int fd, size_t size) // if it didn't work, let mmap() fail. } if ((mFlags & DONT_MAP_LOCALLY) == 0) { void* base = (uint8_t*)mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if (base == MAP_FAILED) { Loading @@ -128,10 +129,14 @@ status_t MemoryHeapBase::mapfd(int fd, size_t size) return -errno; } //LOGD("mmap(fd=%d, base=%p, size=%lu)", fd, base, size); mFD = fd; mBase = base; mSize = size; mNeedUnmap = true; } else { mBase = 0; // not MAP_FAILED mNeedUnmap = false; } mFD = fd; mSize = size; return NO_ERROR; } Loading Loading
include/utils/MemoryHeapBase.h +4 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,10 @@ class MemoryHeapBase : public virtual BnMemoryHeap public: enum { READ_ONLY = IMemoryHeap::READ_ONLY, MAP_ONCE = IMemoryHeap::MAP_ONCE MAP_ONCE = IMemoryHeap::MAP_ONCE, // memory won't be mapped locally, but will be mapped in the remote // process. DONT_MAP_LOCALLY = 0x00000100 }; /* Loading
include/utils/RefBase.h +24 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #ifndef ANDROID_REF_BASE_H #define ANDROID_REF_BASE_H #include <cutils/atomic.h> #include <utils/TextOutput.h> #include <stdint.h> Loading Loading @@ -142,6 +143,29 @@ private: // --------------------------------------------------------------------------- template <class T> class LightRefBase { public: inline LightRefBase() : mCount(0) { } inline void incStrong(const void* id) const { android_atomic_inc(&mCount); } inline void decStrong(const void* id) const { if (android_atomic_dec(&mCount) == 1) { delete static_cast<const T*>(this); } } protected: inline ~LightRefBase() { } private: mutable volatile int32_t mCount; }; // --------------------------------------------------------------------------- template <typename T> class sp { Loading
libs/utils/MemoryHeapBase.cpp +15 −10 Original line number Diff line number Diff line Loading @@ -119,6 +119,7 @@ status_t MemoryHeapBase::mapfd(int fd, size_t size) // if it didn't work, let mmap() fail. } if ((mFlags & DONT_MAP_LOCALLY) == 0) { void* base = (uint8_t*)mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if (base == MAP_FAILED) { Loading @@ -128,10 +129,14 @@ status_t MemoryHeapBase::mapfd(int fd, size_t size) return -errno; } //LOGD("mmap(fd=%d, base=%p, size=%lu)", fd, base, size); mFD = fd; mBase = base; mSize = size; mNeedUnmap = true; } else { mBase = 0; // not MAP_FAILED mNeedUnmap = false; } mFD = fd; mSize = size; return NO_ERROR; } Loading