]> git.proxmox.com Git - libgit2.git/blame - src/map.h
Merge branch 'debian/experimental' into debian/sid
[libgit2.git] / src / map.h
CommitLineData
bb742ede 1/*
359fc2d2 2 * Copyright (C) the libgit2 contributors. All rights reserved.
bb742ede
VM
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
79ca2edc
RJ
7#ifndef INCLUDE_map_h__
8#define INCLUDE_map_h__
9
10#include "common.h"
11
12
f79026b4 13/* p_mmap() prot values */
87d9869f
VM
14#define GIT_PROT_NONE 0x0
15#define GIT_PROT_READ 0x1
79ca2edc 16#define GIT_PROT_WRITE 0x2
87d9869f 17#define GIT_PROT_EXEC 0x4
79ca2edc
RJ
18
19/* git__mmmap() flags values */
87d9869f
VM
20#define GIT_MAP_FILE 0
21#define GIT_MAP_SHARED 1
79ca2edc 22#define GIT_MAP_PRIVATE 2
87d9869f
VM
23#define GIT_MAP_TYPE 0xf
24#define GIT_MAP_FIXED 0x10
79ca2edc 25
90490113
CY
26#ifdef __amigaos4__
27#define MAP_FAILED 0
28#endif
29
87d9869f
VM
30typedef struct { /* memory mapped buffer */
31 void *data; /* data bytes */
32 size_t len; /* data length */
79ca2edc 33#ifdef GIT_WIN32
87d9869f 34 HANDLE fmh; /* file mapping handle */
79ca2edc
RJ
35#endif
36} git_map;
37
e3c47510
RB
38#define GIT_MMAP_VALIDATE(out, len, prot, flags) do { \
39 assert(out != NULL && len > 0); \
40 assert((prot & GIT_PROT_WRITE) || (prot & GIT_PROT_READ)); \
41 assert((flags & GIT_MAP_FIXED) == 0); } while (0)
e1de726c 42
0c9c969a 43extern int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, off64_t offset);
f79026b4 44extern int p_munmap(git_map *map);
79ca2edc 45
eae0bfdc 46#endif