aboutsummaryrefslogtreecommitdiff
path: root/osdep.c
diff options
context:
space:
mode:
Diffstat (limited to 'osdep.c')
-rw-r--r--osdep.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/osdep.c b/osdep.c
index 30426ffa9a..2e05b21ad9 100644
--- a/osdep.c
+++ b/osdep.c
@@ -32,9 +32,16 @@
/* Needed early for CONFIG_BSD etc. */
#include "config-host.h"
+#if defined(CONFIG_MADVISE) || defined(CONFIG_POSIX_MADVISE)
+#include <sys/mman.h>
+#endif
+
#ifdef CONFIG_SOLARIS
#include <sys/types.h>
#include <sys/statvfs.h>
+/* See MySQL bug #7156 (http://bugs.mysql.com/bug.php?id=7156) for
+ discussion about Solaris header problems */
+extern int madvise(caddr_t, size_t, int);
#endif
#ifdef CONFIG_EVENTFD
@@ -139,6 +146,22 @@ void qemu_vfree(void *ptr)
#endif
+int qemu_madvise(void *addr, size_t len, int advice)
+{
+ if (advice == QEMU_MADV_INVALID) {
+ errno = EINVAL;
+ return -1;
+ }
+#if defined(CONFIG_MADVISE)
+ return madvise(addr, len, advice);
+#elif defined(CONFIG_POSIX_MADVISE)
+ return posix_madvise(addr, len, advice);
+#else
+ errno = EINVAL;
+ return -1;
+#endif
+}
+
int qemu_create_pidfile(const char *filename)
{
char buffer[128];