mwindow.h 1.47 KB
Newer Older
1
/*
Edward Thomson committed
2
 * Copyright (C) the libgit2 contributors. All rights reserved.
3
 *
Vicent Marti committed
4 5
 * This file is part of libgit2, distributed under the GNU GPL v2 with
 * a Linking Exception. For full terms see the included COPYING file.
6 7 8 9 10
 */

#ifndef INCLUDE_mwindow__
#define INCLUDE_mwindow__

11 12
#include "common.h"

13 14 15 16 17 18
#include "map.h"
#include "vector.h"

typedef struct git_mwindow {
	struct git_mwindow *next;
	git_map window_map;
19
	off64_t offset;
20 21
	size_t last_used;
	size_t inuse_cnt;
22 23 24
} git_mwindow;

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 30 31 32 33 34 35 36 37 38 39 40
} git_mwindow_file;

typedef struct git_mwindow_ctl {
	size_t mapped;
	unsigned int open_windows;
	unsigned int mmap_calls;
	unsigned int peak_open_windows;
	size_t peak_mapped;
	size_t used_ctr;
	git_vector windowfiles;
} git_mwindow_ctl;

41
int git_mwindow_contains(git_mwindow *win, off64_t offset);
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 47
void git_mwindow_close(git_mwindow **w_cursor);

48
extern int git_mwindow_global_init(void);
49 50 51

struct git_pack_file; /* just declaration to avoid cyclical includes */
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