From bbe8cb53ab16b5c3ff2520ba2af4f2a4a5947a9d Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 17 Dec 2012 09:21:54 -0800 Subject: [PATCH] Remove dead code. Change-Id: I56c27c510c8fc0ba2d8e691c788b433dce250f7a --- libdex/SysUtil.cpp | 75 ------------------------------------------------------ libdex/SysUtil.h | 23 +++-------------- 2 files changed, 3 insertions(+), 95 deletions(-) diff --git a/libdex/SysUtil.cpp b/libdex/SysUtil.cpp index 456d26ec4..ba82de2ea 100644 --- a/libdex/SysUtil.cpp +++ b/libdex/SysUtil.cpp @@ -106,46 +106,6 @@ static int getFileStartAndLength(int fd, off_t *start_, size_t *length_) return 0; } -/* - * Pull the contents of a file into an new shared memory segment. We grab - * everything from fd's current offset on. - * - * We need to know the length ahead of time so we can allocate a segment - * of sufficient size. - */ -int sysLoadFileInShmem(int fd, MemMapping* pMap) -{ -#ifdef HAVE_POSIX_FILEMAP - off_t start; - size_t length, actual; - void* memPtr; - - assert(pMap != NULL); - - if (getFileStartAndLength(fd, &start, &length) < 0) - return -1; - - memPtr = sysCreateAnonShmem(length); - if (memPtr == NULL) - return -1; - - actual = read(fd, memPtr, length); - if (actual != length) { - ALOGE("only read %d of %d bytes", (int) actual, (int) length); - sysReleaseShmem(pMap); - return -1; - } - - pMap->baseAddr = pMap->addr = memPtr; - pMap->baseLength = pMap->length = length; - - return 0; -#else - ALOGE("sysLoadFileInShmem not implemented."); - return -1; -#endif -} - #ifndef HAVE_POSIX_FILEMAP int sysFakeMapFile(int fd, MemMapping* pMap) { @@ -177,41 +137,6 @@ int sysFakeMapFile(int fd, MemMapping* pMap) #endif /* - * Map a file (from fd's current offset) into a shared, read-only memory - * segment. The file offset must be a multiple of the system page size. - * - * On success, returns 0 and fills out "pMap". On failure, returns a nonzero - * value and does not disturb "pMap". - */ -int sysMapFileInShmemReadOnly(int fd, MemMapping* pMap) -{ -#ifdef HAVE_POSIX_FILEMAP - off_t start; - size_t length; - void* memPtr; - - assert(pMap != NULL); - - if (getFileStartAndLength(fd, &start, &length) < 0) - return -1; - - memPtr = mmap(NULL, length, PROT_READ, MAP_FILE | MAP_SHARED, fd, start); - if (memPtr == MAP_FAILED) { - ALOGW("mmap(%d, RO, FILE|SHARED, %d, %d) failed: %s", (int) length, - fd, (int) start, strerror(errno)); - return -1; - } - - pMap->baseAddr = pMap->addr = memPtr; - pMap->baseLength = pMap->length = length; - - return 0; -#else - return sysFakeMapFile(fd, pMap); -#endif -} - -/* * Map a file (from fd's current offset) into a private, read-write memory * segment that will be marked read-only (a/k/a "writable read-only"). The * file offset must be a multiple of the system page size. diff --git a/libdex/SysUtil.h b/libdex/SysUtil.h index 90a63ca2a..c02ec6eda 100644 --- a/libdex/SysUtil.h +++ b/libdex/SysUtil.h @@ -54,25 +54,6 @@ struct MemMapping { void sysCopyMap(MemMapping* dst, const MemMapping* src); /* - * Load a file into a new shared memory segment. All data from the current - * offset to the end of the file is pulled in. - * - * The segment is read-write, allowing VM fixups. (It should be modified - * to support .gz/.zip compressed data.) - * - * On success, "pMap" is filled in, and zero is returned. - */ -int sysLoadFileInShmem(int fd, MemMapping* pMap); - -/* - * Map a file (from fd's current offset) into a shared, - * read-only memory segment. - * - * On success, "pMap" is filled in, and zero is returned. - */ -int sysMapFileInShmemReadOnly(int fd, MemMapping* pMap); - -/* * Map a file (from fd's current offset) into a shared, read-only memory * segment that can be made writable. (In some cases, such as when * mapping a file on a FAT filesystem, the result may be fully writable.) @@ -82,7 +63,9 @@ int sysMapFileInShmemReadOnly(int fd, MemMapping* pMap); int sysMapFileInShmemWritableReadOnly(int fd, MemMapping* pMap); /* - * Like sysMapFileInShmemReadOnly, but on only part of a file. + * Map part of a file into a shared, read-only memory segment. + * + * On success, "pMap" is filled in, and zero is returned. */ int sysMapFileSegmentInShmem(int fd, off_t start, size_t length, MemMapping* pMap); -- 2.11.0