summaryrefslogtreecommitdiffstats
path: root/minzip
diff options
context:
space:
mode:
Diffstat (limited to 'minzip')
-rw-r--r--minzip/Android.mk30
-rw-r--r--minzip/SysUtil.c11
2 files changed, 40 insertions, 1 deletions
diff --git a/minzip/Android.mk b/minzip/Android.mk
index 045f35570..6cca09239 100644
--- a/minzip/Android.mk
+++ b/minzip/Android.mk
@@ -14,8 +14,38 @@ LOCAL_C_INCLUDES := \
LOCAL_STATIC_LIBRARIES := libselinux
+LOCAL_CFLAGS += -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION)
+
+LOCAL_MODULE := libminzip
+
+LOCAL_CFLAGS += -Wall
+LOCAL_SHARED_LIBRARIES := libz
+
+include $(BUILD_SHARED_LIBRARY)
+
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ Hash.c \
+ SysUtil.c \
+ DirUtil.c \
+ Inlines.c \
+ Zip.c
+
+LOCAL_C_INCLUDES += \
+ external/zlib \
+ external/safe-iop/include
+
+ifeq ($(TWHAVE_SELINUX),true)
+LOCAL_C_INCLUDES += external/libselinux/include
+LOCAL_STATIC_LIBRARIES += libselinux
+LOCAL_CFLAGS += -DHAVE_SELINUX
+endif
+
LOCAL_MODULE := libminzip
LOCAL_CFLAGS += -Wall
+LOCAL_STATIC_LIBRARIES := libz
include $(BUILD_STATIC_LIBRARY)
diff --git a/minzip/SysUtil.c b/minzip/SysUtil.c
index b160c9e3d..1858cd515 100644
--- a/minzip/SysUtil.c
+++ b/minzip/SysUtil.c
@@ -118,7 +118,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;
@@ -140,8 +145,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;