]> git.proxmox.com Git - libgit2.git/blob - src/libgit2/mwindow.h
New upstream version 1.5.0+ds
[libgit2.git] / src / libgit2 / mwindow.h
1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
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 */
7
8 #ifndef INCLUDE_mwindow__
9 #define INCLUDE_mwindow__
10
11 #include "common.h"
12
13 #include "map.h"
14 #include "vector.h"
15
16 typedef struct git_mwindow {
17 struct git_mwindow *next;
18 git_map window_map;
19 off64_t offset;
20 size_t last_used;
21 size_t inuse_cnt;
22 } git_mwindow;
23
24 typedef struct git_mwindow_file {
25 git_mutex lock; /* protects updates to fd */
26 git_mwindow *windows;
27 int fd;
28 off64_t size;
29 } git_mwindow_file;
30
31 typedef struct git_mwindow_ctl {
32 size_t mapped;
33 unsigned int open_windows;
34 unsigned int mmap_calls;
35 unsigned int peak_open_windows;
36 size_t peak_mapped;
37 size_t used_ctr;
38 git_vector windowfiles;
39 } git_mwindow_ctl;
40
41 int git_mwindow_contains(git_mwindow *win, off64_t offset, off64_t extra);
42 int git_mwindow_free_all(git_mwindow_file *mwf); /* locks */
43 unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor, off64_t offset, size_t extra, unsigned int *left);
44 int git_mwindow_file_register(git_mwindow_file *mwf);
45 void git_mwindow_file_deregister(git_mwindow_file *mwf);
46 void git_mwindow_close(git_mwindow **w_cursor);
47
48 extern int git_mwindow_global_init(void);
49
50 struct git_pack_file; /* just declaration to avoid cyclical includes */
51 int git_mwindow_get_pack(struct git_pack_file **out, const char *path);
52 int git_mwindow_put_pack(struct git_pack_file *pack);
53
54 #endif