summaryrefslogtreecommitdiffstats
path: root/libs/binder/MemoryHeapBase.cpp
diff options
context:
space:
mode:
authorBenny Wong <Benny.Wong@motorola.com>2009-08-17 15:28:30 -0500
committerJames Dong <jdong@google.com>2009-08-20 03:55:20 -0700
commitd4851d74ac9c737acda85f1fdbc028c68f481a36 (patch)
tree74e5f73442fdbe503aa82e751af1ddf9bb3e7691 /libs/binder/MemoryHeapBase.cpp
parent8039e6edac4754113b31d6ed748b6a377874c65e (diff)
downloadframeworks_native-d4851d74ac9c737acda85f1fdbc028c68f481a36.zip
frameworks_native-d4851d74ac9c737acda85f1fdbc028c68f481a36.tar.gz
frameworks_native-d4851d74ac9c737acda85f1fdbc028c68f481a36.tar.bz2
Add offset handling in MemoryHeapBase class
Diffstat (limited to 'libs/binder/MemoryHeapBase.cpp')
-rw-r--r--libs/binder/MemoryHeapBase.cpp8
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));