diff options
Diffstat (limited to 'minzip')
-rw-r--r-- | minzip/Android.mk | 2 | ||||
-rw-r--r-- | minzip/SysUtil.c | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/minzip/Android.mk b/minzip/Android.mk index 68485abe1..6cca09239 100644 --- a/minzip/Android.mk +++ b/minzip/Android.mk @@ -14,6 +14,8 @@ LOCAL_C_INCLUDES := \ LOCAL_STATIC_LIBRARIES := libselinux +LOCAL_CFLAGS += -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION) + LOCAL_MODULE := libminzip LOCAL_CFLAGS += -Wall diff --git a/minzip/SysUtil.c b/minzip/SysUtil.c index ac6f5c33f..aac162d3a 100644 --- a/minzip/SysUtil.c +++ b/minzip/SysUtil.c @@ -116,7 +116,12 @@ static int sysMapBlockFile(FILE* mapf, MemMapping* pMap) // Reserve enough contiguous address space for the whole file. unsigned char* reserve; +#if (PLATFORM_SDK_VERSION >= 21) reserve = mmap64(NULL, blocks * blksize, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0); +#else + // Older versions of Android do not have mmap64 so we will just use mmap instead + reserve = mmap(NULL, blocks * blksize, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0); +#endif if (reserve == MAP_FAILED) { LOGW("failed to reserve address space: %s\n", strerror(errno)); return -1; @@ -138,8 +143,12 @@ static int sysMapBlockFile(FILE* mapf, MemMapping* pMap) LOGW("failed to parse range %d in block map\n", i); return -1; } - +#if (PLATFORM_SDK_VERSION >= 21) void* addr = mmap64(next, (end-start)*blksize, PROT_READ, MAP_PRIVATE | MAP_FIXED, fd, ((off64_t)start)*blksize); +#else + // Older versions of Android do not have mmap64 so we will just use mmap instead + void* addr = mmap(next, (end-start)*blksize, PROT_READ, MAP_PRIVATE | MAP_FIXED, fd, ((off64_t)start)*blksize); +#endif if (addr == MAP_FAILED) { LOGW("failed to map block %d: %s\n", i, strerror(errno)); return -1; |