aboutsummaryrefslogtreecommitdiffstats
path: root/osdep.c
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2009-09-14 14:32:27 -0700
committerDavid 'Digit' Turner <digit@google.com>2009-09-14 14:32:27 -0700
commit5d8f37ad78fc66901af50c762029a501561f3b23 (patch)
tree206790f8f21000850a98c4f9590a79e779106278 /osdep.c
parentcd059b15f2c7df69f4a087bd66900eb172e41d1c (diff)
downloadexternal_qemu-5d8f37ad78fc66901af50c762029a501561f3b23.zip
external_qemu-5d8f37ad78fc66901af50c762029a501561f3b23.tar.gz
external_qemu-5d8f37ad78fc66901af50c762029a501561f3b23.tar.bz2
Merge upstream QEMU 10.0.50 into the Android source tree.
This change integrates many changes from the upstream QEMU sources. Its main purpose is to enable correct ARMv6 and ARMv7 support to the Android emulator. Due to the nature of the upstream code base, this unfortunately also required changes to many other parts of the source. Note that to ensure easier integrations in the future, some source files and directories that have heavy Android-specific customization have been renamed with an -android suffix. The original files are still there for easier integration tracking, but *never* compiled. For example: net.c net-android.c qemu-char.c qemu-char-android.c slirp/ slirp-android/ etc... Tested on linux-x86, darwin-x86 and windows host machines.
Diffstat (limited to 'osdep.c')
-rw-r--r--osdep.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/osdep.c b/osdep.c
index 49193e9..5065079 100644
--- a/osdep.c
+++ b/osdep.c
@@ -67,15 +67,17 @@ void qemu_vfree(void *ptr)
#else
-#if defined(USE_KQEMU)
+#if defined(CONFIG_KQEMU)
#ifdef __OpenBSD__
#include <sys/param.h>
#include <sys/types.h>
#include <sys/mount.h>
#else
+#ifndef __FreeBSD__
#include <sys/vfs.h>
#endif
+#endif
#include <sys/mman.h>
#include <fcntl.h>
@@ -86,7 +88,8 @@ static void *kqemu_vmalloc(size_t size)
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;
@@ -153,7 +156,7 @@ static void *kqemu_vmalloc(size_t size)
}
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,
@@ -182,7 +185,7 @@ void *qemu_memalign(size_t alignment, size_t size)
if (ret != 0)
return NULL;
return ptr;
-#elif defined(_BSD)
+#elif defined(HOST_BSD)
return valloc(size);
#else
return memalign(alignment, size);
@@ -192,20 +195,16 @@ void *qemu_memalign(size_t alignment, size_t size)
/* alloc shared memory pages */
void *qemu_vmalloc(size_t size)
{
-#if defined(USE_KQEMU)
+#if defined(CONFIG_KQEMU)
if (kqemu_allowed)
return kqemu_vmalloc(size);
#endif
-#ifdef _BSD
- return valloc(size);
-#else
- return memalign(4096, size);
-#endif
+ return qemu_memalign(getpagesize(), size);
}
void qemu_vfree(void *ptr)
{
-#if defined(USE_KQEMU)
+#if defined(CONFIG_KQEMU)
if (kqemu_allowed)
kqemu_vfree(ptr);
#endif
@@ -283,6 +282,18 @@ int qemu_gettimeofday(qemu_timeval *tp)
Do not set errno on error. */
return 0;
}
+
+int ffs(int val)
+{
+ int nn;
+
+ for (nn = 0; nn < sizeof(int)*8; nn++)
+ if (val & (1 << nn))
+ return nn+1;
+
+ return 0;
+}
+
#endif /* _WIN32 */