blob: 7adff1e54405acdb011dc04934811972af32b92a [file] [log] [blame]
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -08001/*
2 * Copyright 2006 The Android Open Source Project
3 *
4 * System utilities.
5 */
6#ifndef _MINZIP_SYSUTIL
7#define _MINZIP_SYSUTIL
8
Doug Zongker99916f02014-01-13 14:16:58 -08009#include <stdio.h>
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080010#include <sys/types.h>
11
Doug Zongker99916f02014-01-13 14:16:58 -080012#ifdef __cplusplus
13extern "C" {
14#endif
15
16typedef struct MappedRange {
17 void* addr;
18 size_t length;
19} MappedRange;
20
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080021/*
22 * Use this to keep track of mapped segments.
23 */
24typedef struct MemMapping {
Doug Zongker99916f02014-01-13 14:16:58 -080025 unsigned char* addr; /* start of data */
26 size_t length; /* length of data */
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080027
Doug Zongker99916f02014-01-13 14:16:58 -080028 int range_count;
29 MappedRange* ranges;
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080030} MemMapping;
31
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080032/*
Doug Zongker99916f02014-01-13 14:16:58 -080033 * 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 Projectc24a8e62009-03-03 19:28:42 -080036 *
37 * On success, "pMap" is filled in, and zero is returned.
38 */
Doug Zongker99916f02014-01-13 14:16:58 -080039int sysMapFile(const char* fn, MemMapping* pMap);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080040
41/*
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080042 * Release the pages associated with a shared memory segment.
43 *
44 * This does not free "pMap"; it just releases the memory.
45 */
Doug Zongker99916f02014-01-13 14:16:58 -080046void sysReleaseMap(MemMapping* pMap);
47
48#ifdef __cplusplus
49}
50#endif
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080051
52#endif /*_MINZIP_SYSUTIL*/