The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2006 The Android Open Source Project |
| 3 | * |
| 4 | * System utilities. |
| 5 | */ |
| 6 | #ifndef _MINZIP_SYSUTIL |
| 7 | #define _MINZIP_SYSUTIL |
| 8 | |
Doug Zongker | 99916f0 | 2014-01-13 14:16:58 -0800 | [diff] [blame] | 9 | #include <stdio.h> |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 10 | #include <sys/types.h> |
| 11 | |
Doug Zongker | 99916f0 | 2014-01-13 14:16:58 -0800 | [diff] [blame] | 12 | #ifdef __cplusplus |
| 13 | extern "C" { |
| 14 | #endif |
| 15 | |
| 16 | typedef struct MappedRange { |
| 17 | void* addr; |
| 18 | size_t length; |
| 19 | } MappedRange; |
| 20 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 21 | /* |
| 22 | * Use this to keep track of mapped segments. |
| 23 | */ |
| 24 | typedef struct MemMapping { |
Doug Zongker | 99916f0 | 2014-01-13 14:16:58 -0800 | [diff] [blame] | 25 | unsigned char* addr; /* start of data */ |
| 26 | size_t length; /* length of data */ |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 27 | |
Doug Zongker | 99916f0 | 2014-01-13 14:16:58 -0800 | [diff] [blame] | 28 | int range_count; |
| 29 | MappedRange* ranges; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 30 | } MemMapping; |
| 31 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 32 | /* |
Doug Zongker | 99916f0 | 2014-01-13 14:16:58 -0800 | [diff] [blame] | 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. |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 36 | * |
| 37 | * On success, "pMap" is filled in, and zero is returned. |
| 38 | */ |
Doug Zongker | 99916f0 | 2014-01-13 14:16:58 -0800 | [diff] [blame] | 39 | int sysMapFile(const char* fn, MemMapping* pMap); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 40 | |
| 41 | /* |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 42 | * Release the pages associated with a shared memory segment. |
| 43 | * |
| 44 | * This does not free "pMap"; it just releases the memory. |
| 45 | */ |
Doug Zongker | 99916f0 | 2014-01-13 14:16:58 -0800 | [diff] [blame] | 46 | void sysReleaseMap(MemMapping* pMap); |
| 47 | |
| 48 | #ifdef __cplusplus |
| 49 | } |
| 50 | #endif |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 51 | |
| 52 | #endif /*_MINZIP_SYSUTIL*/ |