]>
Commit | Line | Data |
---|---|---|
b85ea5fa PM |
1 | /* |
2 | * QEMU madvise wrapper functions | |
3 | * | |
4 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | |
5 | * See the COPYING file in the top-level directory. | |
6 | */ | |
7 | ||
8 | #ifndef QEMU_MADVISE_H | |
9 | #define QEMU_MADVISE_H | |
10 | ||
11 | #define QEMU_MADV_INVALID -1 | |
12 | ||
13 | #if defined(CONFIG_MADVISE) | |
14 | ||
15 | #define QEMU_MADV_WILLNEED MADV_WILLNEED | |
16 | #define QEMU_MADV_DONTNEED MADV_DONTNEED | |
17 | #ifdef MADV_DONTFORK | |
18 | #define QEMU_MADV_DONTFORK MADV_DONTFORK | |
19 | #else | |
20 | #define QEMU_MADV_DONTFORK QEMU_MADV_INVALID | |
21 | #endif | |
22 | #ifdef MADV_MERGEABLE | |
23 | #define QEMU_MADV_MERGEABLE MADV_MERGEABLE | |
24 | #else | |
25 | #define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID | |
26 | #endif | |
27 | #ifdef MADV_UNMERGEABLE | |
28 | #define QEMU_MADV_UNMERGEABLE MADV_UNMERGEABLE | |
29 | #else | |
30 | #define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID | |
31 | #endif | |
32 | #ifdef MADV_DODUMP | |
33 | #define QEMU_MADV_DODUMP MADV_DODUMP | |
34 | #else | |
35 | #define QEMU_MADV_DODUMP QEMU_MADV_INVALID | |
36 | #endif | |
37 | #ifdef MADV_DONTDUMP | |
38 | #define QEMU_MADV_DONTDUMP MADV_DONTDUMP | |
39 | #else | |
40 | #define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID | |
41 | #endif | |
42 | #ifdef MADV_HUGEPAGE | |
43 | #define QEMU_MADV_HUGEPAGE MADV_HUGEPAGE | |
44 | #else | |
45 | #define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID | |
46 | #endif | |
47 | #ifdef MADV_NOHUGEPAGE | |
48 | #define QEMU_MADV_NOHUGEPAGE MADV_NOHUGEPAGE | |
49 | #else | |
50 | #define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID | |
51 | #endif | |
52 | #ifdef MADV_REMOVE | |
53 | #define QEMU_MADV_REMOVE MADV_REMOVE | |
54 | #else | |
55 | #define QEMU_MADV_REMOVE QEMU_MADV_DONTNEED | |
56 | #endif | |
57 | #ifdef MADV_POPULATE_WRITE | |
58 | #define QEMU_MADV_POPULATE_WRITE MADV_POPULATE_WRITE | |
59 | #else | |
60 | #define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID | |
61 | #endif | |
62 | ||
63 | #elif defined(CONFIG_POSIX_MADVISE) | |
64 | ||
65 | #define QEMU_MADV_WILLNEED POSIX_MADV_WILLNEED | |
66 | #define QEMU_MADV_DONTNEED POSIX_MADV_DONTNEED | |
67 | #define QEMU_MADV_DONTFORK QEMU_MADV_INVALID | |
68 | #define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID | |
69 | #define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID | |
70 | #define QEMU_MADV_DODUMP QEMU_MADV_INVALID | |
71 | #define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID | |
72 | #define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID | |
73 | #define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID | |
74 | #define QEMU_MADV_REMOVE QEMU_MADV_DONTNEED | |
75 | #define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID | |
76 | ||
77 | #else /* no-op */ | |
78 | ||
79 | #define QEMU_MADV_WILLNEED QEMU_MADV_INVALID | |
80 | #define QEMU_MADV_DONTNEED QEMU_MADV_INVALID | |
81 | #define QEMU_MADV_DONTFORK QEMU_MADV_INVALID | |
82 | #define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID | |
83 | #define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID | |
84 | #define QEMU_MADV_DODUMP QEMU_MADV_INVALID | |
85 | #define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID | |
86 | #define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID | |
87 | #define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID | |
88 | #define QEMU_MADV_REMOVE QEMU_MADV_INVALID | |
89 | #define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID | |
90 | ||
91 | #endif | |
92 | ||
93 | int qemu_madvise(void *addr, size_t len, int advice); | |
94 | ||
95 | #endif |