]> git.proxmox.com Git - libgit2.git/blob - src/mwindow.h
Merge pull request #3097 from libgit2/cmn/submodule-config-state
[libgit2.git] / src / 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 "map.h"
12 #include "vector.h"
13
14 typedef struct git_mwindow {
15 struct git_mwindow *next;
16 git_map window_map;
17 git_off_t offset;
18 size_t last_used;
19 size_t inuse_cnt;
20 } git_mwindow;
21
22 typedef struct git_mwindow_file {
23 git_mwindow *windows;
24 int fd;
25 git_off_t size;
26 } git_mwindow_file;
27
28 typedef struct git_mwindow_ctl {
29 size_t mapped;
30 unsigned int open_windows;
31 unsigned int mmap_calls;
32 unsigned int peak_open_windows;
33 size_t peak_mapped;
34 size_t used_ctr;
35 git_vector windowfiles;
36 } git_mwindow_ctl;
37
38 int git_mwindow_contains(git_mwindow *win, git_off_t offset);
39 void git_mwindow_free_all(git_mwindow_file *mwf); /* locks */
40 void git_mwindow_free_all_locked(git_mwindow_file *mwf); /* run under lock */
41 unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor, git_off_t offset, size_t extra, unsigned int *left);
42 int git_mwindow_file_register(git_mwindow_file *mwf);
43 void git_mwindow_file_deregister(git_mwindow_file *mwf);
44 void git_mwindow_close(git_mwindow **w_cursor);
45
46 int git_mwindow_files_init(void);
47 void git_mwindow_files_free(void);
48
49 struct git_pack_file; /* just declaration to avoid cyclical includes */
50 int git_mwindow_get_pack(struct git_pack_file **out, const char *path);
51 void git_mwindow_put_pack(struct git_pack_file *pack);
52
53 #endif