Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib/mmap-util.h @ 1793:82e19ad18784 HEAD
If we don't have function foo, do it always as #define foo my_foo and create
your own my_foo. Did this to pread/pwrite/madvise.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 03 Oct 2003 17:50:48 +0300 |
parents | 52fd3d82e59a |
children | 7d6ca38c8c37 |
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 | |
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 |
0 | 40 #endif |