• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "inline_magic.h"
10  
11  #include <sys/types.h>
12  
13  /*
14   * Use this to keep track of mapped segments.
15   */
16  typedef struct MemMapping {
17      void*   addr;           /* start of data */
18      size_t  length;         /* length of data */
19  
20      void*   baseAddr;       /* page-aligned base address */
21      size_t  baseLength;     /* length of mapping */
22  } MemMapping;
23  
24  /* copy a map */
sysCopyMap(MemMapping * dst,const MemMapping * src)25  INLINE void sysCopyMap(MemMapping* dst, const MemMapping* src) {
26      *dst = *src;
27  }
28  
29  /*
30   * Load a file into a new shared memory segment.  All data from the current
31   * offset to the end of the file is pulled in.
32   *
33   * The segment is read-write, allowing VM fixups.  (It should be modified
34   * to support .gz/.zip compressed data.)
35   *
36   * On success, "pMap" is filled in, and zero is returned.
37   */
38  int sysLoadFileInShmem(int fd, MemMapping* pMap);
39  
40  /*
41   * Map a file (from fd's current offset) into a shared,
42   * read-only memory segment.
43   *
44   * On success, "pMap" is filled in, and zero is returned.
45   */
46  int sysMapFileInShmem(int fd, MemMapping* pMap);
47  
48  /*
49   * Like sysMapFileInShmem, but on only part of a file.
50   */
51  int sysMapFileSegmentInShmem(int fd, off_t start, long length,
52      MemMapping* pMap);
53  
54  /*
55   * Release the pages associated with a shared memory segment.
56   *
57   * This does not free "pMap"; it just releases the memory.
58   */
59  void sysReleaseShmem(MemMapping* pMap);
60  
61  #endif /*_MINZIP_SYSUTIL*/
62