summaryrefslogtreecommitdiffstats
path: root/libs/binder
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
commitf99c18083e87ccf83430b29b53c7dea52a1675de (patch)
tree602d616cdcc91d974299fca1e4f40fce00a2fbc4 /libs/binder
parent41b379da57d3125de038636d72fba95e2255483d (diff)
downloadframeworks_base-f99c18083e87ccf83430b29b53c7dea52a1675de.zip
frameworks_base-f99c18083e87ccf83430b29b53c7dea52a1675de.tar.gz
frameworks_base-f99c18083e87ccf83430b29b53c7dea52a1675de.tar.bz2
Add offset handling in MemoryHeapBase class
Diffstat (limited to 'libs/binder')
-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));