--- Begin Message ---
Package: qemu
Version: 0.7.0-4+kbsd
Severity: important
Tags: patch
Attached is a patch to build qemu on GNU/kFreeBSD. It requires to update the
package to 0.7.2 source first.
Please take the following considerations (from patch header):
Don't send to upstream. This patch conflicts with the one in the FreeBSD
ports
collection, where sane replacements for some of these hunks are being merged.
Don't modify this patch directly. It is generated semi-automaticaly from the
stuff in http://glibc-bsd.alioth.debian.org/patches/qemu/. When updating for
a
new qemu release, it should be generated the same way.
-- System Information:
Debian Release: testing/unstable
Architecture: kfreebsd-i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: GNU/kFreeBSD 5.3-1
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ANSI_X3.4-1968) (ignored: LC_ALL
set to C)
Versions of packages qemu depends on:
ii bochsbios 2.2.1-1 BIOS for the Bochs emulator
ii libc0.1 2.3-1+kbsd.11 GNU C Library: Shared libraries an
ii libsdl1.2debi 1.2.7+1.2.8cvs20041007-5.3 Simple DirectMedia Layer
ii openhackware 0.4.1-1 OpenFirmware emulator for PowerPC
ii proll 18-1 JavaStation PROM 2.x compatible re
ii vgabios 0.5c-1 VGA BIOS software for the Bochs an
ii zlib1g 1:1.2.3-4 compression library - runtime
Versions of packages qemu recommends:
pn debootstrap <none> (no description available)
ii sharutils 1:4.2.1-15 shar, unshar, uuencode, uudecode
-- no debconf information
#DPATCHLEVEL=1
Don't send to upstream. This patch conflicts with the one in the FreeBSD ports
collection, where sane replacements for some of these hunks are being merged.
Don't modify this patch directly. It is generated semi-automaticaly from the
stuff in http://glibc-bsd.alioth.debian.org/patches/qemu/. When updating for a
new qemu release, it should be generated the same way.
diff -ur qemu-0.7.2.old/audio/audio.c qemu-0.7.2/audio/audio.c
--- qemu-0.7.2.old/audio/audio.c 2005-09-04 19:11:31.000000000 +0200
+++ qemu-0.7.2/audio/audio.c 2005-09-11 17:01:16.000000000 +0200
@@ -28,6 +28,10 @@
#include "audio/audio_int.h"
+#ifndef INT16_MAX
+#define INT16_MAX 0x7fff
+#endif
+
#define dolog(...) AUD_log ("audio", __VA_ARGS__)
#ifdef DEBUG
#define ldebug(...) dolog (__VA_ARGS__)
diff -ur qemu-0.7.2.old/configure qemu-0.7.2/configure
--- qemu-0.7.2.old/configure 2005-09-04 19:11:31.000000000 +0200
+++ qemu-0.7.2/configure 2005-09-11 17:01:16.000000000 +0200
@@ -96,7 +96,7 @@
MINGW32*)
mingw32="yes"
;;
-FreeBSD)
+*FreeBSD)
bsd="yes"
oss="yes"
if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
@@ -124,11 +124,7 @@
;;
esac
-if [ "$bsd" = "yes" ] ; then
- if [ ! "$darwin" = "yes" ] ; then
- make="gmake"
- fi
-fi
+make="`which gmake || which make`"
# find source path
# XXX: we assume an absolute path is given when launching configure,
@@ -593,13 +589,19 @@
echo "SRC_PATH=$source_path" >> $config_mak
echo "TARGET_DIRS=$target_list" >> $config_mak
-# XXX: suppress that
if [ "$bsd" = "yes" ] ; then
- echo "#define O_LARGEFILE 0" >> $config_h
- echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
echo "#define _BSD 1" >> $config_h
fi
+cat >> $config_h << __EOF__
+#ifndef O_LARGEFILE
+# define O_LARGEFILE 0
+#endif
+#ifndef MAP_ANONYMOUS
+# define MAP_ANONYMOUS MAP_ANON
+#endif
+__EOF__
+
for target in $target_list; do
target_dir="$target"
diff -ur qemu-0.7.2.old/fpu/softfloat-native.c qemu-0.7.2/fpu/softfloat-native.c
--- qemu-0.7.2.old/fpu/softfloat-native.c 2005-09-04 19:11:31.000000000
+0200
+++ qemu-0.7.2/fpu/softfloat-native.c 2005-09-11 17:01:49.000000000 +0200
@@ -6,7 +6,8 @@
void set_float_rounding_mode(int val STATUS_PARAM)
{
STATUS(float_rounding_mode) = val;
-#if defined(_BSD) && !defined(__APPLE__)
+#if defined(_BSD) && !defined(__APPLE__) && \
+ (defined(__FreeBSD__) && __FreeBSD_version < 500000)
fpsetround(val);
#elif defined(__arm__)
/* nothing to do */
@@ -22,7 +23,7 @@
}
#endif
-#if defined(_BSD)
+#if defined(_BSD) && !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
#define lrint(d) ((int32_t)rint(d))
#define llrint(d) ((int64_t)rint(d))
#endif
diff -ur qemu-0.7.2.old/fpu/softfloat-native.h qemu-0.7.2/fpu/softfloat-native.h
--- qemu-0.7.2.old/fpu/softfloat-native.h 2005-09-04 19:11:31.000000000
+0200
+++ qemu-0.7.2/fpu/softfloat-native.h 2005-09-11 17:03:01.000000000 +0200
@@ -1,6 +1,6 @@
/* Native implementation of soft float functions */
#include <math.h>
-#if defined(_BSD) && !defined(__APPLE__)
+#if defined(_BSD) && !defined(__APPLE__) && !defined(__GLIBC__)
#include <ieeefp.h>
#else
#include <fenv.h>
@@ -33,12 +33,13 @@
/*----------------------------------------------------------------------------
| Software IEC/IEEE floating-point rounding mode.
*----------------------------------------------------------------------------*/
-#if defined(_BSD) && !defined(__APPLE__)
+#if defined(_BSD) && !defined(__APPLE__) && !defined(__GLIBC__) && \
+ (!defined(__FreeBSD__) || __FreeBSD_version < 500000)
enum {
float_round_nearest_even = FP_RN,
- float_round_down = FE_RM,
- float_round_up = FE_RP,
- float_round_to_zero = FE_RZ
+ float_round_down = FP_RM,
+ float_round_up = FP_RP,
+ float_round_to_zero = FP_RZ
};
#elif defined(__arm__)
enum {
diff -ur qemu-0.7.2.old/fpu/softfloat.h qemu-0.7.2/fpu/softfloat.h
--- qemu-0.7.2.old/fpu/softfloat.h 2005-09-04 19:11:31.000000000 +0200
+++ qemu-0.7.2/fpu/softfloat.h 2005-09-11 17:01:16.000000000 +0200
@@ -84,7 +84,8 @@
#define FLOAT128
#else
/* native float support */
-#if (defined(__i386__) || defined(__x86_64__)) && !defined(_BSD)
+#if (defined(__i386__) || defined(__x86_64__)) && \
+ (!defined(_BSD) || defined(__FreeBSD__) || defined(__GLIBC__))
#define FLOATX80
#endif
#endif /* !CONFIG_SOFTFLOAT */
diff -ur qemu-0.7.2.old/i386-dis.c qemu-0.7.2/i386-dis.c
--- qemu-0.7.2.old/i386-dis.c 2005-09-04 19:11:31.000000000 +0200
+++ qemu-0.7.2/i386-dis.c 2005-09-11 17:01:16.000000000 +0200
@@ -2896,6 +2896,10 @@
OP_E (bytemode, sizeflag);
}
+#ifndef PRIx64
+#define PRIx64 "llx"
+#endif
+
static void
print_operand_value (buf, hex, disp)
char *buf;
diff -ur qemu-0.7.2.old/osdep.c qemu-0.7.2/osdep.c
--- qemu-0.7.2.old/osdep.c 2005-09-04 19:11:31.000000000 +0200
+++ qemu-0.7.2/osdep.c 2005-09-11 17:01:16.000000000 +0200
@@ -323,7 +323,9 @@
#elif defined(USE_KQEMU)
+#ifdef __linux__
#include <sys/vfs.h>
+#endif
#include <sys/mman.h>
#include <fcntl.h>
@@ -334,6 +336,7 @@
const char *tmpdir;
char phys_ram_file[1024];
void *ptr;
+#ifdef __linux__
struct statfs stfs;
if (phys_ram_fd < 0) {
@@ -389,12 +392,20 @@
}
unlink(phys_ram_file);
}
+#endif
size = (size + 4095) & ~4095;
+#ifdef __linux__
ftruncate(phys_ram_fd, phys_ram_size + size);
ptr = mmap(NULL,
size,
PROT_WRITE | PROT_READ, MAP_SHARED,
phys_ram_fd, phys_ram_size);
+#else
+ ptr = mmap(NULL,
+ size,
+ PROT_WRITE | PROT_READ, MAP_PRIVATE|MAP_ANON,
+ -1, 0);
+#endif
if (ptr == MAP_FAILED) {
fprintf(stderr, "Could not map physical memory\n");
exit(1);
diff -ur qemu-0.7.2.old/vl.c qemu-0.7.2/vl.c
--- qemu-0.7.2.old/vl.c 2005-09-04 19:11:31.000000000 +0200
+++ qemu-0.7.2/vl.c 2005-09-11 17:04:25.000000000 +0200
@@ -42,9 +42,12 @@
#include <dirent.h>
#ifdef _BSD
#include <sys/stat.h>
-#ifndef __APPLE__
+#if !defined(__APPLE__) && !defined(__GLIBC__)
#include <libutil.h>
#endif
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#include <sys/module.h>
+#endif
#else
#include <linux/if.h>
#include <linux/if_tun.h>
@@ -767,6 +770,14 @@
case QEMU_TIMER_REALTIME:
#ifdef _WIN32
return GetTickCount();
+#elif defined(_BSD)
+ {
+ struct timeval r;
+ if (!gettimeofday(&r, NULL)) {
+ return ((timer_freq * 1000LL) * (int64_t)r.tv_sec
+ + ((int64_t)r.tv_usec * timer_freq) / 1000) / timer_freq;
+ }
+ }
#else
{
struct tms tp;
@@ -1317,7 +1328,7 @@
return chr;
}
-#if defined(__linux__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__GLIBC__)
CharDriverState *qemu_chr_open_pty(void)
{
char slave_name[1024];
@@ -1629,6 +1640,34 @@
#endif /* CONFIG_SLIRP */
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#define LOAD_QUIETLY 1
+#define LOAD_VERBOSLY 2
+
+int
+loadmodules(int how, const char *module, ...)
+{
+ int loaded = 0;
+ va_list ap;
+
+ va_start(ap, module);
+#ifndef NO_MODULES
+ while (module != NULL) {
+ if (modfind(module) == -1) {
+ if (kldload(module) == -1) {
+ if (how == LOAD_VERBOSLY)
+ fprintf(stderr, "%s: Cannot load module\n", module);
+ } else
+ loaded++;
+ }
+ module = va_arg(ap, const char *);
+ }
+ va_end(ap);
+#endif
+ return loaded;
+}
+#endif
+
#if !defined(_WIN32)
#ifdef _BSD
static int tun_open(char *ifname, int ifname_size)
@@ -1637,14 +1676,58 @@
char *dev;
struct stat s;
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ int i, kldtried = 0, enoentcount = 0, err = 0;
+ char dname[100];
+#ifdef USE_DEVTAP
+ /*
+ * 5.x has /dev/tap, but that seems to just blindly increase its
+ * couter on every open() for some people(??), i.e. on every qemu run.
+ */
+ i = -1;
+#else
+ i = 0;
+#endif
+ for (; i < 10; i++) {
+ if (i == -1)
+ strcpy(dname, "/dev/tap");
+ else
+ snprintf(dname, sizeof dname, "%s%d",
+ "/dev/tap", i);
+ fd = open(dname, O_RDWR);
+ if (fd >= 0)
+ break;
+ else if (errno == ENXIO || errno == ENOENT) {
+ if (i == 0 && !kldtried++) {
+ /*
+ * Attempt to load the tunnel interface KLD if it isn't loaded
+ * already.
+ */
+ if (loadmodules(LOAD_VERBOSLY, "if_tap", NULL))
+ i = -1;
+ continue;
+ }
+ if (errno != ENOENT || ++enoentcount > 3) {
+ err = errno;
+ break;
+ }
+ } else
+ err = errno;
+ }
+ if (fd < 0) {
+ fprintf(stderr, "warning: could not open %s (%s): no virtual network
emulation\n", dname, strerror(err));
+ return -1;
+ }
+#else
fd = open("/dev/tap", O_RDWR);
if (fd < 0) {
- fprintf(stderr, "warning: could not open /dev/tap: no virtual network
emulation\n");
+ fprintf(stderr, "warning: could not open /dev/tap (%s): no virtual
network emulation\n", strerror(errno));
return -1;
}
+#endif
fstat(fd, &s);
- dev = devname(s.st_rdev, S_IFCHR);
+ dev = "/dev/tap";
pstrcpy(ifname, ifname_size, dev);
fcntl(fd, F_SETFL, O_NONBLOCK);
--- End Message ---