1 /*
2  * This code is (c) 2012 Johannes Thoma
3  *
4  * This file is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This file is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this file.  If not, see <http://www.gnu.org/licenses/>.
16  *
17  * You can download original source from https://github.com/johannesthoma/mmap_allocator.git
18  */
19 
20 #ifndef _MMAP_ACCESS_MODE
21 #define _MMAP_ACCESS_MODE
22 
23 #include <stdio.h>
24 
25 #define ALIGN_TO_PAGE(x) ((x) & ~(getpagesize() - 1))
26 #define UPPER_ALIGN_TO_PAGE(x) ALIGN_TO_PAGE((x)+(getpagesize()-1))
27 #define OFFSET_INTO_PAGE(x) ((x) & (getpagesize() - 1))
28 
29 namespace mmap_allocator_namespace
30 {
31 	enum access_mode {
32 		DEFAULT_STL_ALLOCATOR, /* Default STL allocator (malloc based). Reason is to have containers that do both and are compatible */
33 		READ_ONLY,  /* Readonly modus. Segfaults when vector content is written to */
34 		READ_WRITE_PRIVATE, /* Read/write access, writes are not propagated to disk */
35 		READ_WRITE_SHARED  /* Read/write access, writes are propagated to disk (file is modified) */
36 	};
37 
38 	enum allocator_flags {
39 		MAP_WHOLE_FILE = 1,
40 		ALLOW_REMAP = 2,
41 		BYPASS_FILE_POOL = 4,
42 		KEEP_FOREVER = 8
43 	};
44 
45 	void set_verbosity(int v);
46 	int get_verbosity(void);
47 }
48 
49 #endif
50