openbsd-ports/emulators/qemu/patches/patch-osdep_c
2008-01-19 23:53:58 +00:00

51 lines
1.3 KiB
Plaintext

$OpenBSD: patch-osdep_c,v 1.1 2008/01/19 23:53:58 todd Exp $
--- osdep.c.orig Mon Feb 5 17:01:54 2007
+++ osdep.c Mon Jan 7 19:01:42 2008
@@ -79,7 +79,14 @@ void qemu_vfree(void *ptr)
#if defined(USE_KQEMU)
+#ifdef __OpenBSD__
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/mount.h>
+#else
#include <sys/vfs.h>
+#endif
+
#include <sys/mman.h>
#include <fcntl.h>
@@ -87,9 +94,15 @@ void *kqemu_vmalloc(size_t size)
{
static int phys_ram_fd = -1;
static int phys_ram_size = 0;
+ void *ptr;
+
+#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */
+ int map_anon = MAP_ANON;
+#else
+ int map_anon = 0;
const char *tmpdir;
char phys_ram_file[1024];
- void *ptr;
+
#ifdef HOST_SOLARIS
struct statvfs stfs;
#else
@@ -151,11 +164,13 @@ void *kqemu_vmalloc(size_t size)
}
unlink(phys_ram_file);
}
+#endif /* !__OpenBSD__ */
+
size = (size + 4095) & ~4095;
ftruncate(phys_ram_fd, phys_ram_size + size);
ptr = mmap(NULL,
size,
- PROT_WRITE | PROT_READ, MAP_SHARED,
+ PROT_WRITE | PROT_READ, map_anon|MAP_SHARED,
phys_ram_fd, phys_ram_size);
if (ptr == MAP_FAILED) {
fprintf(stderr, "Could not map physical memory\n");