diff options
author | Benny Wong <Benny.Wong@motorola.com> | 2009-08-17 15:28:30 -0500 |
---|---|---|
committer | James Dong <jdong@google.com> | 2009-08-20 03:55:20 -0700 |
commit | d4851d74ac9c737acda85f1fdbc028c68f481a36 (patch) | |
tree | 74e5f73442fdbe503aa82e751af1ddf9bb3e7691 /libs | |
parent | 8039e6edac4754113b31d6ed748b6a377874c65e (diff) | |
download | frameworks_native-d4851d74ac9c737acda85f1fdbc028c68f481a36.zip frameworks_native-d4851d74ac9c737acda85f1fdbc028c68f481a36.tar.gz frameworks_native-d4851d74ac9c737acda85f1fdbc028c68f481a36.tar.bz2 |
Add offset handling in MemoryHeapBase class
Diffstat (limited to 'libs')
-rw-r--r-- | libs/binder/MemoryHeapBase.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libs/binder/MemoryHeapBase.cpp b/libs/binder/MemoryHeapBase.cpp index ac38f51..5df078f 100644 --- a/libs/binder/MemoryHeapBase.cpp +++ b/libs/binder/MemoryHeapBase.cpp @@ -78,13 +78,13 @@ MemoryHeapBase::MemoryHeapBase(const char* device, size_t size, uint32_t flags) } } -MemoryHeapBase::MemoryHeapBase(int fd, size_t size, uint32_t flags) +MemoryHeapBase::MemoryHeapBase(int fd, size_t size, uint32_t flags, uint32_t offset) : mFD(-1), mSize(0), mBase(MAP_FAILED), mFlags(flags), mDevice(0), mNeedUnmap(false) { const size_t pagesize = getpagesize(); size = ((size + pagesize-1) & ~(pagesize-1)); - mapfd(dup(fd), size); + mapfd(dup(fd), size, offset); } status_t MemoryHeapBase::init(int fd, void *base, int size, int flags, const char* device) @@ -100,7 +100,7 @@ status_t MemoryHeapBase::init(int fd, void *base, int size, int flags, const cha return NO_ERROR; } -status_t MemoryHeapBase::mapfd(int fd, size_t size) +status_t MemoryHeapBase::mapfd(int fd, size_t size, uint32_t offset) { if (size == 0) { // try to figure out the size automatically @@ -121,7 +121,7 @@ status_t MemoryHeapBase::mapfd(int fd, size_t size) if ((mFlags & DONT_MAP_LOCALLY) == 0) { void* base = (uint8_t*)mmap(0, size, - PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); + PROT_READ|PROT_WRITE, MAP_SHARED, fd, offset); if (base == MAP_FAILED) { LOGE("mmap(fd=%d, size=%u) failed (%s)", fd, uint32_t(size), strerror(errno)); |