2 * Copyright (C) 2008 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #ifndef _LIBDEX_SYSUTIL
20 #define _LIBDEX_SYSUTIL
22 #include <sys/types.h>
25 * Use this to keep track of mapped segments.
27 typedef struct MemMapping {
28 void* addr; /* start of data */
29 size_t length; /* length of data */
31 void* baseAddr; /* page-aligned base address */
32 size_t baseLength; /* length of mapping */
38 void sysCopyMap(MemMapping* dst, const MemMapping* src);
41 * Load a file into a new shared memory segment. All data from the current
42 * offset to the end of the file is pulled in.
44 * The segment is read-write, allowing VM fixups. (It should be modified
45 * to support .gz/.zip compressed data.)
47 * On success, "pMap" is filled in, and zero is returned.
49 int sysLoadFileInShmem(int fd, MemMapping* pMap);
52 * Map a file (from fd's current offset) into a shared,
53 * read-only memory segment.
55 * On success, "pMap" is filled in, and zero is returned.
57 int sysMapFileInShmem(int fd, MemMapping* pMap);
60 * Like sysMapFileInShmem, but on only part of a file.
62 int sysMapFileSegmentInShmem(int fd, off_t start, long length,
66 * Release the pages associated with a shared memory segment.
68 * This does not free "pMap"; it just releases the memory.
70 void sysReleaseShmem(MemMapping* pMap);
72 #endif /*_DALVIK_SYSUTIL*/