Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib/mmap-util.h @ 543:52fd3d82e59a HEAD
Removed mmap_aligned() which isn't used anywhere. Added mmap_file() which
accepts prot argument. We use now fstat() instead of lseek() to get file
size.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 28 Oct 2002 11:00:25 +0200 |
parents | cf4d065f2f85 |
children | 82e19ad18784 |
rev | line source |
---|---|
0 | 1 #ifndef __MMAP_UTIL_H |
2 #define __MMAP_UTIL_H | |
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 | |
18 int madvise(void *start, size_t length, int advice); | |
19 # ifndef MADV_NORMAL | |
20 # define MADV_NORMAL 0 | |
21 # define MADV_RANDOM 0 | |
22 # define MADV_SEQUENTIAL 0 | |
23 # define MADV_WILLNEED 0 | |
24 # define MADV_DONTNEED 0 | |
25 # endif | |
26 #endif | |
27 | |
543
52fd3d82e59a
Removed mmap_aligned() which isn't used anywhere. Added mmap_file() which
Timo Sirainen <tss@iki.fi>
parents:
222
diff
changeset
|
28 void *mmap_file(int fd, size_t *length, int prot); |
0 | 29 void *mmap_ro_file(int fd, size_t *length); |
30 void *mmap_rw_file(int fd, size_t *length); | |
31 | |
222
cf4d065f2f85
lots of cleanups. also index/datafile is now capable of staying in memory,
Timo Sirainen <tss@iki.fi>
parents:
221
diff
changeset
|
32 /* 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
|
33 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
|
34 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
|
35 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
|
36 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
|
37 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
|
38 |
0 | 39 #endif |