#include <sys/statvfs.h>
#endif
-#include "qemu-common.h"
-#include "sysemu.h"
+/* Needed early for HOST_BSD etc. */
+#include "config-host.h"
#ifdef _WIN32
-#define WIN32_LEAN_AND_MEAN
#include <windows.h>
-#elif defined(_BSD)
+#elif defined(HOST_BSD)
#include <stdlib.h>
#else
#include <malloc.h>
#endif
+#include "qemu-common.h"
+#include "sysemu.h"
#include "qemu_socket.h"
#if defined(_WIN32)
#include <sys/types.h>
#include <sys/mount.h>
#else
+#ifndef __FreeBSD__
#include <sys/vfs.h>
#endif
+#endif
#include <sys/mman.h>
#include <fcntl.h>
static int phys_ram_size = 0;
void *ptr;
-#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */
+/* no need (?) for a dummy file on OpenBSD/FreeBSD */
+#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
int map_anon = MAP_ANON;
#else
int map_anon = 0;
}
size = (size + 4095) & ~4095;
ftruncate(phys_ram_fd, phys_ram_size + size);
-#endif /* !__OpenBSD__ */
+#endif /* !(__OpenBSD__ || __FreeBSD__ || __DragonFly__) */
ptr = mmap(NULL,
size,
PROT_WRITE | PROT_READ, map_anon | MAP_SHARED,
if (ret != 0)
return NULL;
return ptr;
-#elif defined(_BSD)
+#elif defined(HOST_BSD)
return valloc(size);
#else
return memalign(alignment, size);
if (kqemu_allowed)
return kqemu_vmalloc(size);
#endif
-#ifdef _BSD
- return valloc(size);
-#else
- return memalign(getpagesize(), size);
-#endif
+ return qemu_memalign(getpagesize(), size);
}
void qemu_vfree(void *ptr)