1 /* 2 * Copyright 2006 The Android Open Source Project 3 * 4 * System utilities. 5 */ 6 #ifndef _MINZIP_SYSUTIL 7 #define _MINZIP_SYSUTIL 8 9 #include <stdio.h> 10 #include <sys/types.h> 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif 15 16 typedef struct MappedRange { 17 void* addr; 18 size_t length; 19 } MappedRange; 20 21 /* 22 * Use this to keep track of mapped segments. 23 */ 24 typedef struct MemMapping { 25 unsigned char* addr; /* start of data */ 26 size_t length; /* length of data */ 27 28 int range_count; 29 MappedRange* ranges; 30 } MemMapping; 31 32 /* 33 * Map a file into a private, read-only memory segment. If 'fn' 34 * begins with an '@' character, it is a map of blocks to be mapped, 35 * otherwise it is treated as an ordinary file. 36 * 37 * On success, "pMap" is filled in, and zero is returned. 38 */ 39 int sysMapFile(const char* fn, MemMapping* pMap); 40 41 /* 42 * Release the pages associated with a shared memory segment. 43 * 44 * This does not free "pMap"; it just releases the memory. 45 */ 46 void sysReleaseMap(MemMapping* pMap); 47 48 #ifdef __cplusplus 49 } 50 #endif 51 52 #endif /*_MINZIP_SYSUTIL*/ 53