Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib/mmap-util.h @ 9354:687ac828b964 HEAD
lib-index: modseqs weren't tracked properly within session when changes were done.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 01 Sep 2009 13:05:03 -0400 |
parents | 6a64e64fa3a3 |
children |
rev | line source |
---|---|
6410
e4eb71ae8e96
Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents:
5478
diff
changeset
|
1 #ifndef MMAP_UTIL_H |
e4eb71ae8e96
Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents:
5478
diff
changeset
|
2 #define MMAP_UTIL_H |
0 | 3 |
4 #include <unistd.h> | |
222
cf4d065f2f85
lots of cleanups. also index/datafile is now capable of staying in memory,
Timo Sirainen <tss@iki.fi>
parents:
221
diff
changeset
|
5 |
cf4d065f2f85
lots of cleanups. also index/datafile is now capable of staying in memory,
Timo Sirainen <tss@iki.fi>
parents:
221
diff
changeset
|
6 #ifdef HAVE_LINUX_MREMAP |
cf4d065f2f85
lots of cleanups. also index/datafile is now capable of staying in memory,
Timo Sirainen <tss@iki.fi>
parents:
221
diff
changeset
|
7 # define __USE_GNU /* for MREMAP_MAYMOVE */ |
cf4d065f2f85
lots of cleanups. also index/datafile is now capable of staying in memory,
Timo Sirainen <tss@iki.fi>
parents:
221
diff
changeset
|
8 #endif |
cf4d065f2f85
lots of cleanups. also index/datafile is now capable of staying in memory,
Timo Sirainen <tss@iki.fi>
parents:
221
diff
changeset
|
9 |
0 | 10 #include <sys/mman.h> |
222
cf4d065f2f85
lots of cleanups. also index/datafile is now capable of staying in memory,
Timo Sirainen <tss@iki.fi>
parents:
221
diff
changeset
|
11 #undef __USE_GNU |
cf4d065f2f85
lots of cleanups. also index/datafile is now capable of staying in memory,
Timo Sirainen <tss@iki.fi>
parents:
221
diff
changeset
|
12 |
cf4d065f2f85
lots of cleanups. also index/datafile is now capable of staying in memory,
Timo Sirainen <tss@iki.fi>
parents:
221
diff
changeset
|
13 #if !defined (MREMAP_MAYMOVE) && !defined (HAVE_LINUX_MREMAP) |
cf4d065f2f85
lots of cleanups. also index/datafile is now capable of staying in memory,
Timo Sirainen <tss@iki.fi>
parents:
221
diff
changeset
|
14 # define MREMAP_MAYMOVE 1 |
cf4d065f2f85
lots of cleanups. also index/datafile is now capable of staying in memory,
Timo Sirainen <tss@iki.fi>
parents:
221
diff
changeset
|
15 #endif |
0 | 16 |
17 #ifndef HAVE_MADVISE | |
1793
82e19ad18784
If we don't have function foo, do it always as #define foo my_foo and create
Timo Sirainen <tss@iki.fi>
parents:
543
diff
changeset
|
18 # define madvise my_madvise |
82e19ad18784
If we don't have function foo, do it always as #define foo my_foo and create
Timo Sirainen <tss@iki.fi>
parents:
543
diff
changeset
|
19 int my_madvise(void *start, size_t length, int advice); |
0 | 20 # ifndef MADV_NORMAL |
21 # define MADV_NORMAL 0 | |
22 # define MADV_RANDOM 0 | |
23 # define MADV_SEQUENTIAL 0 | |
24 # define MADV_WILLNEED 0 | |
25 # define MADV_DONTNEED 0 | |
26 # endif | |
27 #endif | |
28 | |
543
52fd3d82e59a
Removed mmap_aligned() which isn't used anywhere. Added mmap_file() which
Timo Sirainen <tss@iki.fi>
parents:
222
diff
changeset
|
29 void *mmap_file(int fd, size_t *length, int prot); |
0 | 30 void *mmap_ro_file(int fd, size_t *length); |
31 void *mmap_rw_file(int fd, size_t *length); | |
32 | |
222
cf4d065f2f85
lots of cleanups. also index/datafile is now capable of staying in memory,
Timo Sirainen <tss@iki.fi>
parents:
221
diff
changeset
|
33 /* for allocating anonymous mmap()s, with portable mremap(). these must not |
cf4d065f2f85
lots of cleanups. also index/datafile is now capable of staying in memory,
Timo Sirainen <tss@iki.fi>
parents:
221
diff
changeset
|
34 be mixed with any standard mmap calls. */ |
cf4d065f2f85
lots of cleanups. also index/datafile is now capable of staying in memory,
Timo Sirainen <tss@iki.fi>
parents:
221
diff
changeset
|
35 void *mmap_anon(size_t length); |
cf4d065f2f85
lots of cleanups. also index/datafile is now capable of staying in memory,
Timo Sirainen <tss@iki.fi>
parents:
221
diff
changeset
|
36 void *mremap_anon(void *old_address, size_t old_size, size_t new_size, |
cf4d065f2f85
lots of cleanups. also index/datafile is now capable of staying in memory,
Timo Sirainen <tss@iki.fi>
parents:
221
diff
changeset
|
37 unsigned long flags); |
cf4d065f2f85
lots of cleanups. also index/datafile is now capable of staying in memory,
Timo Sirainen <tss@iki.fi>
parents:
221
diff
changeset
|
38 int munmap_anon(void *start, size_t length); |
221
ed0d5b17c7a4
Added extra functions for easier printing of error messages. Moved
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
39 |
6411
6a64e64fa3a3
Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
40 size_t mmap_get_page_size(void) ATTR_CONST; |
2439
7d6ca38c8c37
Added mmap_get_page_size() call which basically returns getpagesize() but
Timo Sirainen <tss@iki.fi>
parents:
1793
diff
changeset
|
41 |
0 | 42 #endif |