In article you write:
>On 11/7/08, Juergen Lock wrote:
>> Hi!
>>
>> I just prepared another experimental emulators/qemu-devel port update,
>> http://people.freebsd.org/~nox/qemu/...20081107.patch
>> I haven't tested it that much yet (you are welcome to help there!
>> but so far didn't notice much changes compared to last time (r5499),
>> usb is still slow with my Linux 2.6.26 guest (probably to be expected,
>> nothing committed there since.)

>
>The patch is against a bunch of patches, which makes it hard to see
>what has really changed. Could you make an updated set of patches
>available somewhere? At least osdep.c and qemu-char.c patches look
>reasonable enough to be committed.
>

I'll add a shar of the 20081107 qemu-devel port's files/*patch* below,
(yes most of these probably shouldn't be merged... The ones named *-patch
are conditionally applied depending on user-set OPTIONS.)

Oh and btw the osdep.c patch was already posted here, see
http://lists.gnu.org/archive/html/qe.../msg00038.html

>> In other news: The new sparc64-bsd-user target doesn't build because
>> SYSCALL_G7RFLAG and SYSCALL_G2RFLAG are undefined, and I noticed a few
>> warnings that may be interesting:

>
>The attached patch should fix the undefined flag problem, please test.


Nope, still two of them left at line 219ff.

Here comes the shar:

# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# files/
# files/cdrom-dma-patch
# files/patch-90_security
# files/patch-CVE-2008-0928
# files/patch-CVE-2008-4539
# files/patch-Makefile
# files/patch-aa
# files/patch-ac
# files/patch-audio-4
# files/patch-audio-sdlaudio.c
# files/patch-bc
# files/patch-bd
# files/patch-be
# files/patch-bf
# files/patch-bg
# files/patch-block.c
# files/patch-bsdusb.patch
# files/patch-bt
# files/patch-configure
# files/patch-cpu-exec.c
# files/patch-emulate-aio
# files/patch-exec-all.h
# files/patch-exec.c
# files/patch-fbsd
# files/patch-fix_bsd_user_fbsd
# files/patch-fpu-softfloat-native.c
# files/patch-hw-eepro100.c
# files/patch-hw-vmware_vga.c
# files/patch-libmath
# files/patch-libmath2
# files/patch-libmath4
# files/patch-osdep.c
# files/patch-qemu-doc.texi
# files/patch-target-i386-translate.c
# files/patch-target-mips-cpu.h
# files/patch-tcg-i386-tcg-target.c
# files/patch-vl.c
# files/patch-vl.c-ppbus
# files/patch-vl.c-serial
# files/patch-x_keymap.c
# files/pcap-patch
# files/rtl8139-re-patch
#
echo c - files/
mkdir -p files/ > /dev/null 2>&1
echo x - files/cdrom-dma-patch
sed 's/^X//' >files/cdrom-dma-patch << 'END-of-files/cdrom-dma-patch'
XIndex: hw/ide.c
X@@ -27,7 +27,7 @@
X //#define DEBUG_IDE
X //#define DEBUG_IDE_ATAPI
X //#define DEBUG_AIO
X-#define USE_DMA_CDROM
X+// #define USE_DMA_CDROM
X
X /* Bits of HD_STATUS */
X #define ERR_STAT 0x01
END-of-files/cdrom-dma-patch
echo x - files/patch-90_security
sed 's/^X//' >files/patch-90_security << 'END-of-files/patch-90_security'
XIndex: qemu-0.8.2/hw/dma.c
X================================================= ==================
X--- qemu-0.8.2.orig/hw/dma.c 2006-07-22 20:23:34.000000000 +0300
X+++ qemu-0.8.2/hw/dma.c 2007-04-20 06:05:59.000000000 +0300
X@@ -340,9 +340,11 @@ static void channel_run (int ncont, int
X #endif
X
X r = dma_controllers[ncont].regs + ichan;
X- n = r->transfer_handler (r->opaque, ichan + (ncont << 2),
X- r->now[COUNT], (r->base[COUNT] + 1) << ncont);
X- r->now[COUNT] = n;
X+ if (r->transfer_handler) {
X+ n = r->transfer_handler (r->opaque, ichan + (ncont << 2),
X+ r->now[COUNT], (r->base[COUNT] + 1) << ncont);
X+ r->now[COUNT] = n;
X+ }
X ldebug ("dma_pos %d size %d\n", n, (r->base[COUNT] + 1) << ncont);
X }
X
XIndex: qemu/hw/fdc.c
X@@ -1322,7 +1322,8 @@
X fd_sector(cur_drv));
X return 0;
X }
X- if (bdrv_read(cur_drv->bs, fd_sector(cur_drv), fdctrl->fifo, 1) < 0) {
X+ if (cur_drv->bs == NULL ||
X+ bdrv_read(cur_drv->bs, fd_sector(cur_drv), fdctrl->fifo, 1) < 0) {
X FLOPPY_DPRINTF("error getting sector %d\n",
X fd_sector(cur_drv));
X /* Sure, image size is too small... */
X@@ -1776,7 +1777,8 @@
X if (pos == FD_SECTOR_LEN - 1 ||
X fdctrl->data_pos == fdctrl->data_len) {
X cur_drv = get_cur_drv(fdctrl);
X- if (bdrv_write(cur_drv->bs, fd_sector(cur_drv), fdctrl->fifo, 1) < 0) {
X+ if (cur_drv->bs == NULL ||
X+ bdrv_write(cur_drv->bs, fd_sector(cur_drv), fdctrl->fifo, 1) < 0) {
X FLOPPY_ERROR("writing sector %d\n", fd_sector(cur_drv));
X return;
X }
XIndex: qemu-0.8.2/hw/pc.c
X================================================= ==================
X--- qemu-0.8.2.orig/hw/pc.c 2007-04-20 06:05:58.000000000 +0300
X+++ qemu-0.8.2/hw/pc.c 2007-04-20 06:05:59.000000000 +0300
X@@ -312,7 +312,8 @@ void bochs_bios_write(void *opaque, uint
X case 0x400:
X case 0x401:
X fprintf(stderr, "BIOS panic at rombios.c, line %d\n", val);
X- exit(1);
X+ /* according to documentation, these can be safely ignored */
X+ break;
X case 0x402:
X case 0x403:
X #ifdef DEBUG_BIOS
X@@ -335,8 +336,9 @@ void bochs_bios_write(void *opaque, uint
X /* LGPL'ed VGA BIOS messages */
X case 0x501:
X case 0x502:
X+ /* according to documentation, these can be safely ignored */
X fprintf(stderr, "VGA BIOS panic, line %d\n", val);
X- exit(1);
X+ break;
X case 0x500:
X case 0x503:
X #ifdef DEBUG_BIOS
XIndex: qemu-0.8.2/hw/sb16.c
X================================================= ==================
X--- qemu-0.8.2.orig/hw/sb16.c 2006-07-22 20:23:34.000000000 +0300
X+++ qemu-0.8.2/hw/sb16.c 2007-04-20 06:05:59.000000000 +0300
X@@ -1235,8 +1235,10 @@ static int SB_read_DMA (void *opaque, in
X s->block_size);
X #endif
X
X- while (s->left_till_irq <= 0) {
X- s->left_till_irq = s->block_size + s->left_till_irq;
X+ if (s->block_size) {
X+ while (s->left_till_irq <= 0) {
X+ s->left_till_irq = s->block_size + s->left_till_irq;
X+ }
X }
X
X return dma_pos;
XIndex: qemu-0.8.2/slirp/slirp.c
X================================================= ==================
X--- qemu-0.8.2.orig/slirp/slirp.c 2006-07-22 20:23:34.000000000 +0300
X+++ qemu-0.8.2/slirp/slirp.c 2007-04-20 06:05:59.000000000 +0300
X@@ -611,6 +611,10 @@ void slirp_input(const uint8_t *pkt, int
X if (!m)
X return;
X /* Note: we add to align the IP header */
X+ /* taviso: large values in ne2k TCNT register may exceed msize on transmit */
X+ if (M_FREEROOM(m) < pkt_len + 2) {
X+ m_inc(m, pkt_len + 2);
X+ }
X m->m_len = pkt_len + 2;
X memcpy(m->m_data + 2, pkt, pkt_len);
X
XIndex: qemu-0.8.2/target-i386/translate.c
X================================================= ==================
X--- qemu-0.8.2.orig/target-i386/translate.c 2006-07-22 20:23:34.000000000 +0300
X+++ qemu-0.8.2/target-i386/translate.c 2007-04-20 06:05:59.000000000 +0300
X@@ -5292,6 +5297,7 @@ static target_ulong disas_insn(DisasCont
X gen_jmp_im(pc_start - s->cs_base);
X gen_op_into(s->pc - pc_start);
X break;
X+#ifdef WANT_ICEBP
X case 0xf1: /* icebp (undocumented, exits to external debugger) */
X #if 1
X gen_debug(s, pc_start - s->cs_base);
X@@ -5301,6 +5307,7 @@ static target_ulong disas_insn(DisasCont
X cpu_set_log(CPU_LOG_INT | CPU_LOG_TB_IN_ASM);
X #endif
X break;
X+#endif /* icebp */
X case 0xfa: /* cli */
X if (!s->vm86) {
X if (s->cpl <= s->iopl) {
XIndex: qemu-0.8.2/net.c
X@@ -3139,8 +3139,8 @@ typedef struct NetSocketState {
X VLANClientState *vc;
X int fd;
X int state; /* 0 = getting length, 1 = getting data */
X- int index;
X- int packet_len;
X+ unsigned int index;
X+ unsigned int packet_len;
X uint8_t buf[4096];
X struct sockaddr_in dgram_dst; /* contains inet host and port destination iff connectionless (SOCK_DGRAM) */
X } NetSocketState;
X@@ -3171,7 +3171,8 @@ static void net_socket_receive_dgram(voi
X static void net_socket_send(void *opaque)
X {
X NetSocketState *s = opaque;
X- int l, size, err;
X+ int size, err;
X+ unsigned l;
X uint8_t buf1[4096];
X const uint8_t *buf;
X
X@@ -3210,7 +3211,15 @@ static void net_socket_send(void *opaque
X l = s->packet_len - s->index;
X if (l > size)
X l = size;
X- memcpy(s->buf + s->index, buf, l);
X+ if (s->index + l <= sizeof(s->buf)) {
X+ memcpy(s->buf + s->index, buf, l);
X+ } else {
X+ fprintf(stderr, "serious error: oversized packet received,"
X+ "connection terminated.\n");
X+ s->state = 0;
X+ goto eoc;
X+ }
X+
X s->index += l;
X buf += l;
X size -= l;
XIndex: qemu/block.c
X@@ -539,8 +539,15 @@
X return -ENOMEDIUM;
X if (bs->read_only)
X return -EACCES;
X+ if (sector_num < 0)
X+ return -EACCES;
X if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) {
X memcpy(bs->boot_sector_data, buf, 512);
X+ }
X+ {
X+ unsigned int ns = sector_num * 512;
X+ if (ns < 0)
X+ return -EACCES;
X }
X if (drv->bdrv_pwrite) {
X int ret, len;
XIndex: qemu/hw/i8259.c
X@@ -302,7 +302,8 @@
X s->init4 = val & 1;
X s->single_mode = val & 2;
X if (val & 0x08)
X- hw_error("level sensitive irq not supported");
X+ /* hw_error("level sensitive irq not supported"); */
X+ return;
X } else if (val & 0x08) {
X if (val & 0x04)
X s->poll = 1;
END-of-files/patch-90_security
echo x - files/patch-CVE-2008-0928
sed 's/^X//' >files/patch-CVE-2008-0928 << 'END-of-files/patch-CVE-2008-0928'
XIndex: qemu/block-qcow.c
X================================================= ==================
XRCS file: /sources/qemu/qemu/block-qcow.c,v
Xretrieving revision 1.15
Xretrieving revision 1.16
Xdiff -u -p -u -p -r1.15 -r1.16
X--- block-qcow.c 11 Nov 2007 02:51:16 -0000 1.15
X+++ block-qcow.c 11 Mar 2008 17:17:58 -0000 1.16
X@@ -95,7 +95,7 @@ static int qcow_open(BlockDriverState *b
X int len, i, shift, ret;
X QCowHeader header;
X
X- ret = bdrv_file_open(&s->hd, filename, flags);
X+ ret = bdrv_file_open(&s->hd, filename, flags | BDRV_O_AUTOGROW);
X if (ret < 0)
X return ret;
X if (bdrv_pread(s->hd, 0, &header, sizeof(header)) != sizeof(header))
XIndex: qemu/block-qcow2.c
X================================================= ==================
XRCS file: /sources/qemu/qemu/block-qcow2.c,v
Xretrieving revision 1.10
Xretrieving revision 1.11
Xdiff -u -p -u -p -r1.10 -r1.11
X--- block-qcow2.c 11 Nov 2007 02:51:16 -0000 1.10
X+++ block-qcow2.c 11 Mar 2008 17:17:58 -0000 1.11
X@@ -191,7 +191,7 @@ static int qcow_open(BlockDriverState *b
X int len, i, shift, ret;
X QCowHeader header;
X
X- ret = bdrv_file_open(&s->hd, filename, flags);
X+ ret = bdrv_file_open(&s->hd, filename, flags | BDRV_O_AUTOGROW);
X if (ret < 0)
X return ret;
X if (bdrv_pread(s->hd, 0, &header, sizeof(header)) != sizeof(header))
XIndex: qemu/block-vmdk.c
X================================================= ==================
XRCS file: /sources/qemu/qemu/block-vmdk.c,v
Xretrieving revision 1.19
Xretrieving revision 1.20
Xdiff -u -p -u -p -r1.19 -r1.20
X--- block-vmdk.c 14 Jan 2008 03:48:37 -0000 1.19
X+++ block-vmdk.c 11 Mar 2008 17:17:58 -0000 1.20
X@@ -378,7 +378,7 @@ static int vmdk_open(BlockDriverState *b
X flags = BDRV_O_RDONLY;
X fprintf(stderr, "(VMDK) image open: flags=0x%x filename=%s\n", flags, bs->filename);
X
X- ret = bdrv_file_open(&s->hd, filename, flags);
X+ ret = bdrv_file_open(&s->hd, filename, flags | BDRV_O_AUTOGROW);
X if (ret < 0)
X return ret;
X if (bdrv_pread(s->hd, 0, &magic, sizeof(magic)) != sizeof(magic))
XIndex: qemu/block.c
X================================================= ==================
XRCS file: /sources/qemu/qemu/block.c,v
Xretrieving revision 1.54
Xretrieving revision 1.55
Xdiff -u -p -u -p -r1.54 -r1.55
X--- block.c 10 Mar 2008 00:05:34 -0000 1.54
X+++ block.c 11 Mar 2008 17:17:58 -0000 1.55
X@@ -123,6 +123,60 @@ void path_combine(char *dest, int dest_s
X }
X }
X
X+static int bdrv_rd_badreq_sectors(BlockDriverState *bs,
X+ int64_t sector_num, int nb_sectors)
X+{
X+ return
X+ nb_sectors < 0 ||
X+ sector_num < 0 ||
X+ nb_sectors > bs->total_sectors ||
X+ sector_num > bs->total_sectors - nb_sectors;
X+}
X+
X+static int bdrv_rd_badreq_bytes(BlockDriverState *bs,
X+ int64_t offset, int count)
X+{
X+ int64_t size = bs->total_sectors << SECTOR_BITS;
X+ return
X+ count < 0 ||
X+ size < 0 ||
X+ count > size ||
X+ offset > size - count;
X+}
X+
X+static int bdrv_wr_badreq_sectors(BlockDriverState *bs,
X+ int64_t sector_num, int nb_sectors)
X+{
X+ if (sector_num < 0 ||
X+ nb_sectors < 0)
X+ return 1;
X+
X+ if (sector_num > bs->total_sectors - nb_sectors) {
X+ if (bs->autogrow)
X+ bs->total_sectors = sector_num + nb_sectors;
X+ else
X+ return 1;
X+ }
X+ return 0;
X+}
X+
X+static int bdrv_wr_badreq_bytes(BlockDriverState *bs,
X+ int64_t offset, int count)
X+{
X+ int64_t size = bs->total_sectors << SECTOR_BITS;
X+ if (count < 0 ||
X+ offset < 0)
X+ return 1;
X+
X+ if (offset > size - count) {
X+ if (bs->autogrow)
X+ bs->total_sectors = (offset + count + SECTOR_SIZE - 1) >> SECTOR_BITS;
X+ else
X+ return 1;
X+ }
X+ return 0;
X+}
X+
X
X static void bdrv_register(BlockDriver *bdrv)
X {
X@@ -335,6 +389,10 @@ int bdrv_open2(BlockDriverState *bs, con
X bs->read_only = 0;
X bs->is_temporary = 0;
X bs->encrypted = 0;
X+ bs->autogrow = 0;
X+
X+ if (flags & BDRV_O_AUTOGROW)
X+ bs->autogrow = 1;
X
X if (flags & BDRV_O_SNAPSHOT) {
X BlockDriverState *bs1;
X@@ -379,6 +437,7 @@ int bdrv_open2(BlockDriverState *bs, con
X }
X bs->drv = drv;
X bs->opaque = qemu_mallocz(drv->instance_size);
X+ bs->total_sectors = 0; /* driver will set if it does not do getlength */
X if (bs->opaque == NULL && drv->instance_size > 0)
X return -1;
X /* Note: for compatibility, we open disk image files as RDWR, and
X@@ -444,6 +503,7 @@ void bdrv_close(BlockDriverState *bs)
X bs->drv = NULL;
X
X /* call the change callback */
X+ bs->total_sectors = 0;
X bs->media_changed = 1;
X if (bs->change_cb)
X bs->change_cb(bs->change_opaque);
X@@ -509,6 +569,8 @@ int bdrv_read(BlockDriverState *bs, int6
X if (!drv)
X return -ENOMEDIUM;
X
X+ if (bdrv_rd_badreq_sectors(bs, sector_num, nb_sectors))
X+ return -EDOM;
X if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) {
X memcpy(buf, bs->boot_sector_data, 512);
X sector_num++;
X@@ -549,6 +611,8 @@ int bdrv_write(BlockDriverState *bs, int
X return -ENOMEDIUM;
X if (bs->read_only)
X return -EACCES;
X+ if (bdrv_wr_badreq_sectors(bs, sector_num, nb_sectors))
X+ return -EDOM;
X if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) {
X memcpy(bs->boot_sector_data, buf, 512);
X }
X@@ -674,6 +738,8 @@ int bdrv_pread(BlockDriverState *bs, int
X return -ENOMEDIUM;
X if (!drv->bdrv_pread)
X return bdrv_pread_em(bs, offset, buf1, count1);
X+ if (bdrv_rd_badreq_bytes(bs, offset, count1))
X+ return -EDOM;
X return drv->bdrv_pread(bs, offset, buf1, count1);
X }
X
X@@ -689,6 +755,8 @@ int bdrv_pwrite(BlockDriverState *bs, in
X return -ENOMEDIUM;
X if (!drv->bdrv_pwrite)
X return bdrv_pwrite_em(bs, offset, buf1, count1);
X+ if (bdrv_wr_badreq_bytes(bs, offset, count1))
X+ return -EDOM;
X return drv->bdrv_pwrite(bs, offset, buf1, count1);
X }
X
X@@ -955,6 +1023,8 @@ int bdrv_write_compressed(BlockDriverSta
X return -ENOMEDIUM;
X if (!drv->bdrv_write_compressed)
X return -ENOTSUP;
X+ if (bdrv_wr_badreq_sectors(bs, sector_num, nb_sectors))
X+ return -EDOM;
X return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors);
X }
X
X@@ -1101,6 +1171,8 @@ BlockDriverAIOCB *bdrv_aio_read(BlockDri
X
X if (!drv)
X return NULL;
X+ if (bdrv_rd_badreq_sectors(bs, sector_num, nb_sectors))
X+ return NULL;
X
X /* XXX: we assume that nb_sectors == 0 is suppored by the async read */
X if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) {
X@@ -1132,6 +1204,8 @@ BlockDriverAIOCB *bdrv_aio_write(BlockDr
X return NULL;
X if (bs->read_only)
X return NULL;
X+ if (bdrv_wr_badreq_sectors(bs, sector_num, nb_sectors))
X+ return NULL;
X if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) {
X memcpy(bs->boot_sector_data, buf, 512);
X }
XIndex: qemu/block.h
X================================================= ==================
X@@ -49,6 +49,7 @@
X bdrv_file_open()) */
X #define BDRV_O_NOCACHE 0x0020 /* do not use the host page cache */
X #define BDRV_O_CACHE_WB 0x0040 /* use write-back caching */
X+#define BDRV_O_AUTOGROW 0x0080 /* Allow backing file to extend when writing past end of file */
X
X #define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_CACHE_WB)
X
XIndex: qemu/block_int.h
X================================================= ==================
XRCS file: /sources/qemu/qemu/block_int.h,v
Xretrieving revision 1.16
Xretrieving revision 1.17
Xdiff -u -p -u -p -r1.16 -r1.17
X--- block_int.h 24 Dec 2007 16:10:43 -0000 1.16
X+++ block_int.h 11 Mar 2008 17:17:59 -0000 1.17
X@@ -97,6 +97,7 @@ struct BlockDriverState {
X int locked; /* if true, the media cannot temporarily be ejected */
X int encrypted; /* if true, the media is encrypted */
X int sg; /* if true, the device is a /dev/sg* */
X+ int autogrow; /* if true, the backing store can auto-extend to allocate new extents */
X /* event callback when inserting/removing */
X void (*change_cb)(void *opaque);
X void *change_opaque;
END-of-files/patch-CVE-2008-0928
echo x - files/patch-CVE-2008-4539
sed 's/^X//' >files/patch-CVE-2008-4539 << 'END-of-files/patch-CVE-2008-4539'
END-of-files/patch-CVE-2008-4539
echo x - files/patch-Makefile
sed 's/^X//' >files/patch-Makefile << 'END-of-files/patch-Makefile'
XIndex: qemu/Makefile
X@@ -17,7 +17,11 @@
X LDFLAGS += -static
X endif
X ifdef BUILD_DOCS
X+ifdef NOPORTDOCS
X+DOCS=qemu.1 qemu-img.1 qemu-nbd.8
X+else
X DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1 qemu-nbd.8
X+endif
X else
X DOCS=
X endif
X@@ -203,13 +211,13 @@
X common de-ch es fo fr-ca hu ja mk nl-be pt sl tr
X
X install-doc: $(DOCS)
X+ifndef NOPORTDOCS
X mkdir -p "$(DESTDIR)$(docdir)"
X $(INSTALL) -m 644 qemu-doc.html qemu-tech.html "$(DESTDIR)$(docdir)"
X+endif
X ifndef CONFIG_WIN32
X mkdir -p "$(DESTDIR)$(mandir)/man1"
X $(INSTALL) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1"
X- mkdir -p "$(DESTDIR)$(mandir)/man8"
X- $(INSTALL) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
X endif
X
X install: all $(if $(BUILD_DOCS),install-doc)
END-of-files/patch-Makefile
echo x - files/patch-aa
sed 's/^X//' >files/patch-aa << 'END-of-files/patch-aa'
Xdiff -urd --exclude=CVS ../cvs/qemu/Makefile qemu-0.5.5/Makefile
X--- ../cvs/qemu/Makefile Mon May 17 21:06:42 2004
X+++ qemu-0.5.5/Makefile Sun May 30 05:26:19 2004
X@@ -70,7 +70,7 @@
X
X # documentation
X %.html: %.texi
X- texi2html -monolithic -number $<
X+ -texi2html -monolithic -number $<
X
X qemu.1: qemu-doc.texi
X ./texi2pod.pl $< qemu.pod
END-of-files/patch-aa
echo x - files/patch-ac
sed 's/^X//' >files/patch-ac << 'END-of-files/patch-ac'
XIndex: qemu/configure
X@@ -540,7 +540,7 @@
X sdl_too_old=no
X
X if test -z "$sdl" ; then
X- sdl_config="sdl-config"
X+ sdl_config="${SDL_CONFIG}"
X sdl=no
X sdl_static=no
X
END-of-files/patch-ac
echo x - files/patch-audio-4
sed 's/^X//' >files/patch-audio-4 << 'END-of-files/patch-audio-4'
XIndex: qemu/audio/audio_template.h
X@@ -32,6 +32,10 @@
X #define SW glue (SWVoice, In)
X #endif
X
X+#ifndef UINT64_MAX
X+#define UINT64_MAX ((uint64_t)(18446744073709551615ULL))
X+#endif
X+
X static void glue (audio_pcm_sw_fini_, TYPE) (SW *sw)
X {
X glue (audio_pcm_sw_free_resources_, TYPE) (sw);
XIndex: qemu/audio/audio.c
X@@ -36,6 +36,10 @@
X /* #define DEBUG_LIVE */
X /* #define DEBUG_OUT */
X
X+#ifndef INT16_MAX
X+#define INT16_MAX (32767)
X+#endif
X+
X static struct audio_driver *drvtab[] = {
X #ifdef CONFIG_OSS
X &oss_audio_driver,
END-of-files/patch-audio-4
echo x - files/patch-audio-sdlaudio.c
sed 's/^X//' >files/patch-audio-sdlaudio.c << 'END-of-files/patch-audio-sdlaudio.c'
END-of-files/patch-audio-sdlaudio.c
echo x - files/patch-bc
sed 's/^X//' >files/patch-bc << 'END-of-files/patch-bc'
XIndex: qemu/i386-dis.c
X@@ -2896,6 +2896,10 @@
X OP_E (bytemode, sizeflag);
X }
X
X+#ifndef PRIx64
X+#define PRIx64 "llx"
X+#endif
X+
X static void
X print_operand_value (buf, hex, disp)
X char *buf;
END-of-files/patch-bc
echo x - files/patch-bd
sed 's/^X//' >files/patch-bd << 'END-of-files/patch-bd'
XIndex: qemu/configure
X@@ -570,7 +570,7 @@
X if test -z "$prefix" ; then
X prefix="/usr/local"
X fi
X- mansuffix="/share/man"
X+ mansuffix="/man"
X datasuffix="/share/qemu"
X docsuffix="/share/doc/qemu"
X binsuffix="/bin"
END-of-files/patch-bd
echo x - files/patch-be
sed 's/^X//' >files/patch-be << 'END-of-files/patch-be'
END-of-files/patch-be
echo x - files/patch-bf
sed 's/^X//' >files/patch-bf << 'END-of-files/patch-bf'
XIndex: qemu/slirp/slirp_config.h
X@@ -86,7 +86,7 @@
X #undef BAD_SPRINTF
X
X /* Define if you have readv */
X-#undef HAVE_READV
X+#define HAVE_READV
X
X /* Define if iovec needs to be declared */
X #undef DECLARE_IOVEC
X@@ -95,7 +95,7 @@
X #undef DECLARE_SPRINTF
X
X /* Define if you have a POSIX.1 sys/wait.h */
X-#undef HAVE_SYS_WAIT_H
X+#define HAVE_SYS_WAIT_H
X
X /* Define if you have sys/select.h */
X #define HAVE_SYS_SELECT_H
X@@ -107,7 +107,7 @@
X #define HAVE_ARPA_INET_H
X
X /* Define if you have sys/signal.h */
X-#undef HAVE_SYS_SIGNAL_H
X+#define HAVE_SYS_SIGNAL_H
X
X /* Define if you have sys/stropts.h */
X #undef HAVE_SYS_STROPTS_H
X@@ -180,7 +180,7 @@
X #undef HAVE_GRANTPT
X
X /* Define if you have fchmod */
X-#undef HAVE_FCHMOD
X+#define HAVE_FCHMOD
X
X /* Define if you have */
X #undef HAVE_SYS_TYPES32_H
END-of-files/patch-bf
echo x - files/patch-bg
sed 's/^X//' >files/patch-bg << 'END-of-files/patch-bg'
XIndex: qemu/Makefile.target
X@@ -179,7 +179,7 @@
X
X ################################################## #######
X
X-CPPFLAGS+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
X+CPPFLAGS+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DSMBD_COMMAND=\"${LOCALBASE}/sbin/smbd\" -I${LOCALBASE}/include -DPREFIX=\"${PREFIX}\"
X LIBS+=-lm
X ifndef CONFIG_USER_ONLY
X LIBS+=-lz
XIndex: qemu/net.c
X@@ -133,10 +133,12 @@
X
X-#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
X-#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
X+#define DEFAULT_NETWORK_SCRIPT PREFIX "/etc/qemu-ifup"
X+#define DEFAULT_NETWORK_DOWN_SCRIPT PREFIX "/etc/qemu-ifdown"
X+#ifndef SMBD_COMMAND
X #ifdef __sun__
X #define SMBD_COMMAND "/usr/sfw/sbin/smbd"
X #else
X #define SMBD_COMMAND "/usr/sbin/smbd"
X+#endif
X #endif
X
X //#define DEBUG_UNUSED_IOPORT
END-of-files/patch-bg
echo x - files/patch-block.c
sed 's/^X//' >files/patch-block.c << 'END-of-files/patch-block.c'
END-of-files/patch-block.c
echo x - files/patch-bsdusb.patch
sed 's/^X//' >files/patch-bsdusb.patch << 'END-of-files/patch-bsdusb.patch'
XIndex: qemu/configure
X@@ -139,6 +139,7 @@
X oss="yes"
X linux="yes"
X linux_user="yes"
X+usb="linux"
X if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
X kqemu="yes"
X fi
X@@ -148,6 +149,7 @@
X if [ "$bsd" = "yes" ] ; then
X if [ "$darwin" != "yes" ] ; then
X make="gmake"
X+ usb="bsd"
X fi
X fi
X
X@@ -786,6 +788,19 @@
X fi
X
X echo "#define CONFIG_UNAME_RELEASE \"$uname_release\"" >> $config_h
X+
X+# USB host support
X+case "$usb" in
X+linux)
X+ echo "HOST_USB=linux" >> $conig_mak
X+;;
X+bsd)
X+ echo "HOST_USB=bsd" >> $config_mak
X+;;
X+*)
X+ echo "HOST_USB=stub" >> $config_mak
X+;;
X+esac
X
X for target in $target_list; do
X target_dir="$target"
XIndex: qemu/Makefile
X@@ -75,7 +75,7 @@
X OBJS+=tmp105.o lm832x.o
X OBJS+=scsi-disk.o cdrom.o
X OBJS+=scsi-generic.o
X-OBJS+=usb.o usb-hub.o usb-linux.o usb-hid.o usb-msd.o usb-wacom.o
X+OBJS+=usb.o usb-hub.o usb-$(HOST_USB).o usb-hid.o usb-msd.o usb-wacom.o
X OBJS+=usb-serial.o usb-net.o
X OBJS+=sd.o ssi-sd.o
X
XIndex: qemu/usb-stub.c
X@@ -0,0 +1,11 @@
X+#include "vl.h"
X+
X+void usb_host_info(void)
X+{
X+ term_printf("USB host devices not supported\n");
X+}
X+
X+USBDevice *usb_host_device_open(const char *devname)
X+{
X+ return NULL;
X+}
XIndex: qemu/usb-bsd.c
X@@ -0,0 +1,608 @@
X+/*
X+ * BSD host USB redirector
X+ *
X+ * Copyright (c) 2006 Lonnie Mendez
X+ * Portions of code and concepts borrowed from
X+ * usb-linux.c and libusb's bsd.c and are copyright their respective owners.
X+ *
X+ * Permission is hereby granted, free of charge, to any person obtaining a copy
X+ * of this software and associated documentation files (the "Software"), to deal
X+ * in the Software without restriction, including without limitation the rights
X+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
X+ * copies of the Software, and to permit persons to whom the Software is
X+ * furnished to do so, subject to the following conditions:
X+ *
X+ * The above copyright notice and this permission notice shall be included in
X+ * all copies or substantial portions of the Software.
X+ *
X+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
X+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
X+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
X+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
X+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
X+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
X+ * THE SOFTWARE.
X+ */
X+
X+#include "qemu-common.h"
X+#include "console.h"
X+#include "hw/usb.h"
X+
X+/* usb.h declares these */
X+#undef USB_SPEED_HIGH
X+#undef USB_SPEED_FULL
X+#undef USB_SPEED_LOW
X+
X+#include
X+#include
X+#include
X+
X+/* This value has maximum potential at 16.
X+ * You should also set hw.usb.debug to gain
X+ * more detailed view.
X+ */
X+//#define DEBUG
X+#define UGEN_DEBUG_LEVEL 0
X+
X+
X+typedef int USBScanFunc(void *opaque, int bus_num, int addr, int class_id,
X+ int vendor_id, int product_id,
X+ const char *product_name, int speed);
X+static int usb_host_find_device(int *pbus_num, int *paddr,
X+ const char *devname);
X+
X+typedef struct USBHostDevice {
X+ USBDevice dev;
X+ int ep_fd[USB_MAX_ENDPOINTS];
X+ int devfd;
X+ char devpath[32];
X+} USBHostDevice;
X+
X+
X+static int ensure_ep_open(USBHostDevice *dev, int ep, int mode)
X+{
X+ char buf[32];
X+ int fd;
X+
X+ /* Get the address for this endpoint */
X+ ep = UE_GET_ADDR(ep);
X+
X+ if (dev->ep_fd[ep] < 0) {
X+#if __FreeBSD__
X+ snprintf(buf, sizeof(buf) - 1, "%s.%d", dev->devpath, ep);
X+#else
X+ snprintf(buf, sizeof(buf) - 1, "%s.%02d", dev->devpath, ep);
X+#endif
X+ /* Try to open it O_RDWR first for those devices which have in and out
X+ * endpoints with the same address (eg 0x02 and 0x82)
X+ */
X+ fd = open(buf, O_RDWR);
X+ if (fd < 0 && errno == ENXIO)
X+ fd = open(buf, mode);
X+ if (fd < 0) {
X+#ifdef DEBUG
X+ printf("ensure_ep_open: failed to open device endpoint %s: %s\n",
X+ buf, strerror(errno));
X+#endif
X+ }
X+ dev->ep_fd[ep] = fd;
X+ }
X+
X+ return dev->ep_fd[ep];
X+}
X+
X+static void ensure_eps_closed(USBHostDevice *dev)
X+{
X+ int epnum = 1;
X+
X+ if (!dev)
X+ return;
X+
X+ while (epnum < USB_MAX_ENDPOINTS) {
X+ if (dev->ep_fd[epnum] >= 0) {
X+ close(dev->ep_fd[epnum]);
X+ dev->ep_fd[epnum] = -1;
X+ }
X+ epnum++;
X+ }
X+}
X+
X+static void usb_host_handle_reset(USBDevice *dev)
X+{
X+#if 0
X+ USBHostDevice *s = (USBHostDevice *)dev;
X+#endif
X+}
X+
X+/* XXX:
X+ * -check device states against transfer requests
X+ * and return appropriate response
X+ */
X+static int usb_host_handle_control(USBDevice *dev,
X+ int request,
X+ int value,
X+ int index,
X+ int length,
X+ uint8_t *data)
X+{
X+ USBHostDevice *s = (USBHostDevice *)dev;
X+ struct usb_ctl_request req;
X+ struct usb_alt_interface aiface;
X+ int ret, timeout = 50;
X+
X+ if ((request >> 8) == UT_WRITE_DEVICE &&
X+ (request & 0xff) == UR_SET_ADDRESS) {
X+
X+ /* specific SET_ADDRESS support */
X+ dev->addr = value;
X+ return 0;
X+ } else if ((request >> 8) == UT_WRITE_DEVICE &&
X+ (request & 0xff) == UR_SET_CONFIG) {
X+
X+ ensure_eps_closed(s); /* can't do this without all eps closed */
X+
X+ ret = ioctl(s->devfd, USB_SET_CONFIG, &value);
X+ if (ret < 0) {
X+#ifdef DEBUG
X+ printf("handle_control: failed to set configuration - %s\n",
X+ strerror(errno));
X+#endif
X+ return USB_RET_STALL;
X+ }
X+
X+ return 0;
X+ } else if ((request >> 8) == UT_WRITE_INTERFACE &&
X+ (request & 0xff) == UR_SET_INTERFACE) {
X+
X+ aiface.uai_interface_index = index;
X+ aiface.uai_alt_no = value;
X+
X+ ensure_eps_closed(s); /* can't do this without all eps closed */
X+ ret = ioctl(s->devfd, USB_SET_ALTINTERFACE, &aiface);
X+ if (ret < 0) {
X+#ifdef DEBUG
X+ printf("handle_control: failed to set alternate interface - %s\n",
X+ strerror(errno));
X+#endif
X+ return USB_RET_STALL;
X+ }
X+
X+ return 0;
X+ } else {
X+ req.ucr_request.bmRequestType = request >> 8;
X+ req.ucr_request.bRequest = request & 0xff;
X+ USETW(req.ucr_request.wValue, value);
X+ USETW(req.ucr_request.wIndex, index);
X+ USETW(req.ucr_request.wLength, length);
X+ req.ucr_data = data;
X+ req.ucr_flags = USBD_SHORT_XFER_OK;
X+
X+ ret = ioctl(s->devfd, USB_SET_TIMEOUT, &timeout);
X+#if (__NetBSD__ || __OpenBSD__)
X+ if (ret < 0 && errno != EINVAL) {
X+#else
X+ if (ret < 0) {
X+#endif
X+#ifdef DEBUG
X+ printf("handle_control: setting timeout failed - %s\n",
X+ strerror(errno));
X+#endif
X+ }
X+
X+ ret = ioctl(s->devfd, USB_DO_REQUEST, &req);
X+ /* ugen returns EIO for usbd_do_request_ no matter what
X+ * happens with the transfer */
X+ if (ret < 0) {
X+#ifdef DEBUG
X+ printf("handle_control: error after request - %s\n",
X+ strerror(errno));
X+#endif
X+ return USB_RET_NAK; // STALL
X+ } else {
X+ return req.ucr_actlen;
X+ }
X+ }
X+}
X+
X+static int usb_host_handle_data(USBDevice *dev, USBPacket *p)
X+{
X+ USBHostDevice *s = (USBHostDevice *)dev;
X+ int ret, fd, mode;
X+ int one = 1, shortpacket = 0, timeout = 50;
X+ sigset_t new_mask, old_mask;
X+ uint8_t devep = p->devep;
X+
X+ /* protect data transfers from SIGALRM signal */
X+ sigemptyset(&new_mask);
X+ sigaddset(&new_mask, SIGALRM);
X+ sigprocmask(SIG_BLOCK, &new_mask, &old_mask);
X+
X+ if (p->pid == USB_TOKEN_IN) {
X+ devep |= 0x80;
X+ mode = O_RDONLY;
X+ shortpacket = 1;
X+ } else {
X+ mode = O_WRONLY;
X+ }
X+
X+ fd = ensure_ep_open(s, devep, mode);
X+ if (fd < 0) {
X+ sigprocmask(SIG_SETMASK, &old_mask, NULL);
X+ return USB_RET_NODEV;
X+ }
X+
X+ if (ioctl(fd, USB_SET_TIMEOUT, &timeout) < 0) {
X+#ifdef DEBUG
X+ printf("handle_data: failed to set timeout - %s\n",
X+ strerror(errno));
X+#endif
X+ }
X+
X+ if (shortpacket) {
X+ if (ioctl(fd, USB_SET_SHORT_XFER, &one) < 0) {
X+#ifdef DEBUG
X+ printf("handle_data: failed to set short xfer mode - %s\n",
X+ strerror(errno));
X+#endif
X+ sigprocmask(SIG_SETMASK, &old_mask, NULL);
X+ }
X+ }
X+
X+ if (p->pid == USB_TOKEN_IN)
X+ ret = read(fd, p->data, p->len);
X+ else
X+ ret = write(fd, p->data, p->len);
X+
X+ sigprocmask(SIG_SETMASK, &old_mask, NULL);
X+
X+ if (ret < 0) {
X+#ifdef DEBUG
X+ printf("handle_data: error after %s data - %s\n",
X+ pid == USB_TOKEN_IN ? "reading" : "writing", strerror(errno));
X+#endif
X+ switch(errno) {
X+ case ETIMEDOUT:
X+ case EINTR:
X+ return USB_RET_NAK;
X+ default:
X+ return USB_RET_STALL;
X+ }
X+ } else {
X+ return ret;
X+ }
X+}
X+
X+static void usb_host_handle_destroy(USBDevice *opaque)
X+{
X+ USBHostDevice *s = (USBHostDevice *)opaque;
X+ int i;
X+
X+ for (i = 0; i < USB_MAX_ENDPOINTS; i++)
X+ if (s->ep_fd[i] >= 0)
X+ close(s->ep_fd[i]);
X+
X+ if (s->devfd < 0)
X+ return;
X+
X+ close(s->devfd);
X+
X+ qemu_free(s);
X+}
X+
X+USBDevice *usb_host_device_open(const char *devname)
X+{
X+ struct usb_device_info bus_info, dev_info;
X+ USBHostDevice *dev;
X+ char ctlpath[PATH_MAX + 1];
X+ char buspath[PATH_MAX + 1];
X+ int bfd, dfd, bus, address, i;
X+ int ugendebug = UGEN_DEBUG_LEVEL;
X+
X+ if (usb_host_find_device(&bus, &address, devname) < 0)
X+ return NULL;
X+
X+ snprintf(buspath, PATH_MAX, "/dev/usb%d", bus);
X+
X+ bfd = open(buspath, O_RDWR);
X+ if (bfd < 0) {
X+#ifdef DEBUG
X+ printf("usb_host_device_open: failed to open usb bus - %s\n",
X+ strerror(errno));
X+#endif
X+ return NULL;
X+ }
X+
X+ bus_info.udi_addr = address;
X+ if (ioctl(bfd, USB_DEVICEINFO, &bus_info) < 0) {
X+#ifdef DEBUG
X+ printf("usb_host_device_open: failed to grab bus information - %s\n",
X+ strerror(errno));
X+#endif
X+ return NULL;
X+ }
X+
X+#if __FreeBSD__
X+ snprintf(ctlpath, PATH_MAX, "/dev/%s", bus_info.udi_devnames[0]);
X+#else
X+ snprintf(ctlpath, PATH_MAX, "/dev/%s.00", bus_info.udi_devnames[0]);
X+#endif
X+
X+ dfd = open(ctlpath, O_RDWR);
X+ if (dfd < 0) {
X+ dfd = open(ctlpath, O_RDONLY);
X+ if (dfd < 0) {
X+#ifdef DEBUG
X+ printf("usb_host_device_open: failed to open usb device %s - %s\n",
X+ ctlpath, strerror(errno));
X+#endif
X+ }
X+ }
X+
X+ if (dfd >= 0) {
X+ dev = qemu_mallocz(sizeof(USBHostDevice));
X+ if (!dev)
X+ goto fail;
X+ dev->devfd = dfd;
X+
X+ if (ioctl(dfd, USB_GET_DEVICEINFO, &dev_info) < 0) {
X+#ifdef DEBUG
X+ printf("usb_host_device_open: failed to grab device info - %s\n",
X+ strerror(errno));
X+#endif
X+ goto fail;
X+ }
X+
X+ if (dev_info.udi_speed == 1)
X+ dev->dev.speed = USB_SPEED_LOW - 1;
X+ else
X+ dev->dev.speed = USB_SPEED_FULL - 1;
X+
X+ dev->dev.handle_packet = usb_generic_handle_packet;
X+
X+ dev->dev.handle_reset = usb_host_handle_reset;
X+ dev->dev.handle_control = usb_host_handle_control;
X+ dev->dev.handle_data = usb_host_handle_data;
X+ dev->dev.handle_destroy = usb_host_handle_destroy;
X+
X+ if (strncmp(dev_info.udi_product, "product", 7) != 0)
X+ pstrcpy(dev->dev.devname, sizeof(dev->dev.devname),
X+ dev_info.udi_product);
X+ else
X+ snprintf(dev->dev.devname, sizeof(dev->dev.devname),
X+ "host:%s", devname);
X+
X+ pstrcpy(dev->devpath, sizeof(dev->devpath), "/dev/");
X+ strcat(dev->devpath, dev_info.udi_devnames[0]);
X+
X+ /* Mark the endpoints as not yet open */
X+ for (i = 0; i < USB_MAX_ENDPOINTS; i++)
X+ dev->ep_fd[i] = -1;
X+
X+ ioctl(dfd, USB_SETDEBUG, &ugendebug);
X+
X+ return (USBDevice *)dev;
X+ }
X+
X+fail:
X+ return NULL;
X+}
X+
X+static int usb_host_scan(void *opaque, USBScanFunc *func)
X+{
X+ struct usb_device_info bus_info;
X+ struct usb_device_info dev_info;
X+ uint16_t vendor_id, product_id, class_id, speed;
X+ int bfd, dfd, bus, address;
X+ char busbuf[20], devbuf[20], product_name[256];
X+ int ret = 0;
X+
X+ for (bus = 0; bus < 10; bus++) {
X+
X+ snprintf(busbuf, sizeof(busbuf) - 1, "/dev/usb%d", bus);
X+ bfd = open(busbuf, O_RDWR);
X+ if (bfd < 0)
X+ continue;
X+
X+ for (address = 1; address < 127; address++) {
X+
X+ bus_info.udi_addr = address;
X+ if (ioctl(bfd, USB_DEVICEINFO, &bus_info) < 0)
X+ continue;
X+
X+ /* only list devices that can be used by generic layer */
X+ if (strncmp(bus_info.udi_devnames[0], "ugen", 4) != 0)
X+ continue;
X+
X+#if __FreeBSD__
X+ snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s", bus_info.udi_devnames[0]);
X+#else
X+ snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s.00", bus_info.udi_devnames[0]);
X+#endif
X+
X+ dfd = open(devbuf, O_RDONLY);
X+ if (dfd < 0) {
X+#ifdef DEBUG
X+ printf("usb_host_scan: couldn't open device %s - %s\n", devbuf,
X+ strerror(errno));
X+#endif
X+ continue;
X+ }
X+
X+ if (ioctl(dfd, USB_GET_DEVICEINFO, &dev_info) < 0)
X+ printf("usb_host_scan: couldn't get device information for %s - %s\n",
X+ devbuf, strerror(errno));
X+
X+ // XXX: might need to fixup endianess of word values before copying over
X+
X+ vendor_id = dev_info.udi_vendorNo;
X+ product_id = dev_info.udi_productNo;
X+ class_id = dev_info.udi_class;
X+ speed = dev_info.udi_speed;
X+
X+ if (strncmp(dev_info.udi_product, "product", 7) != 0)
X+ pstrcpy(product_name, sizeof(product_name),
X+ dev_info.udi_product);
X+ else
X+ product_name[0] = '\0';
X+
X+ ret = func(opaque, bus, address, class_id, vendor_id,
X+ product_id, product_name, speed);
X+
X+ close(dfd);
X+
X+ if (ret)
X+ goto the_end;
X+ }
X+
X+ close(bfd);
X+ }
X+
X+the_end:
X+ return ret;
X+}
X+
X+typedef struct FindDeviceState {
X+ int vendor_id;
X+ int product_id;
X+ int bus_num;
X+ int addr;
X+} FindDeviceState;
X+
X+static int usb_host_find_device_scan(void *opaque, int bus_num, int addr,
X+ int class_id,
X+ int vendor_id, int product_id,
X+ const char *product_name, int speed)
X+{
X+ FindDeviceState *s = opaque;
X+ if (vendor_id == s->vendor_id &&
X+ product_id == s->product_id) {
X+ s->bus_num = bus_num;
X+ s->addr = addr;
X+ return 1;
X+ } else {
X+ return 0;
X+ }
X+}
X+
X+
X+/* the syntax is :
X+ 'bus.addr' (decimal numbers) or
X+ 'vendor_idroduct_id' (hexa numbers) */
X+static int usb_host_find_device(int *pbus_num, int *paddr,
X+ const char *devname)
X+{
X+ const char *p;
X+ int ret;
X+ FindDeviceState fs;
X+
X+ p = strchr(devname, '.');
X+ if (p) {
X+ *pbus_num = strtoul(devname, NULL, 0);
X+ *paddr = strtoul(p + 1, NULL, 0);
X+ return 0;
X+ }
X+ p = strchr(devname, ':');
X+ if (p) {
X+ fs.vendor_id = strtoul(devname, NULL, 16);
X+ fs.product_id = strtoul(p + 1, NULL, 16);
X+ ret = usb_host_scan(&fs, usb_host_find_device_scan);
X+ if (ret) {
X+ *pbus_num = fs.bus_num;
X+ *paddr = fs.addr;
X+ return 0;
X+ }
X+ }
X+ return -1;
X+}
X+
X+/**********************/
X+/* USB host device info */
X+
X+struct usb_class_info {
X+ int class;
X+ const char *class_name;
X+};
X+
X+static const struct usb_class_info usb_class_info[] = {
X+ { USB_CLASS_AUDIO, "Audio"},
X+ { USB_CLASS_COMM, "Communication"},
X+ { USB_CLASS_HID, "HID"},
X+ { USB_CLASS_HUB, "Hub" },
X+ { USB_CLASS_PHYSICAL, "Physical" },
X+ { USB_CLASS_PRINTER, "Printer" },
X+ { USB_CLASS_MASS_STORAGE, "Storage" },
X+ { USB_CLASS_CDC_DATA, "Data" },
X+ { USB_CLASS_APP_SPEC, "Application Specific" },
X+ { USB_CLASS_VENDOR_SPEC, "Vendor Specific" },
X+ { USB_CLASS_STILL_IMAGE, "Still Image" },
X+ { USB_CLASS_CSCID, "Smart Card" },
X+ { USB_CLASS_CONTENT_SEC, "Content Security" },
X+ { -1, NULL }
X+};
X+
X+static const char *usb_class_str(uint8_t class)
X+{
X+ const struct usb_class_info *p;
X+ for (p = usb_class_info; p->class != -1; p++) {
X+ if (p->class == class)
X+ break;
X+ }
X+ return p->class_name;
X+}
X+
X+void usb_info_device(int bus_num, int addr, int class_id,
X+ int vendor_id, int product_id,
X+ const char *product_name,
X+ int speed)
X+{
X+ const char *class_str, *speed_str;
X+
X+ switch(speed) {
X+ case USB_SPEED_LOW:
X+ speed_str = "1.5";
X+ break;
X+ case USB_SPEED_FULL:
X+ speed_str = "12";
X+ break;
X+ case USB_SPEED_HIGH:
X+ speed_str = "480";
X+ break;
X+ default:
X+ speed_str = "?";
X+ break;
X+ }
X+
X+ term_printf(" Device %d.%d, speed %s Mb/s\n",
X+ bus_num, addr, speed_str);
X+ class_str = usb_class_str(class_id);
X+ if (class_str)
X+ term_printf(" %s:", class_str);
X+ else
X+ term_printf(" Class %02x:", class_id);
X+ term_printf(" USB device %04x:%04x", vendor_id, product_id);
X+ if (product_name[0] != '\0')
X+ term_printf(", %s", product_name);
X+ term_printf("\n");
X+}
X+
X+static int usb_host_info_device(void *opaque, int bus_num, int addr,
X+ int class_id,
X+ int vendor_id, int product_id,
X+ const char *product_name,
X+ int speed)
X+{
X+ usb_info_device(bus_num, addr, class_id, vendor_id, product_id,
X+ product_name, speed);
X+ return 0;
X+}
X+
X+void usb_host_info(void)
X+{
X+ usb_host_scan(NULL, usb_host_info_device);
X+}
X+
X+/* XXX add this */
X+int usb_host_device_close(const char *devname)
X+{
X+ return 0;
X+}
END-of-files/patch-bsdusb.patch
echo x - files/patch-bt
sed 's/^X//' >files/patch-bt << 'END-of-files/patch-bt'
XIndex: qemu/net.c
X@@ -76,6 +76,11 @@
X #endif
X #endif
X #endif
X+#ifdef __FreeBSD__
X+#include
X+#include
X+#include
X+#endif
X
X #if defined(CONFIG_SLIRP)
X #include "libslirp.h"
X@@ -3407,6 +3410,34 @@
X
X #endif /* CONFIG_SLIRP */
X
X+#ifdef __FreeBSD__
X+#define LOAD_QUIETLY 1
X+#define LOAD_VERBOSLY 2
X+
X+int
X+loadmodules(int how, const char *module, ...)
X+{
X+ int loaded = 0;
X+ va_list ap;
X+
X+ va_start(ap, module);
X+#ifndef NO_MODULES
X+ while (module != NULL) {
X+ if (modfind(module) == -1) {
X+ if (kldload(module) == -1) {
X+ if (how == LOAD_VERBOSLY)
X+ fprintf(stderr, "%s: Cannot load module\n", module);
X+ } else
X+ loaded++;
X+ }
X+ module = va_arg(ap, const char *);
X+ }
X+ va_end(ap);
X+#endif
X+ return loaded;
X+}
X+#endif
X+
X #if !defined(_WIN32)
X
X typedef struct TAPState {
X@@ -3470,11 +3501,59 @@
X char *dev;
X struct stat s;
X
X+#ifdef __FreeBSD__
X+ int i, kldtried = 0, enoentcount = 0, err = 0;
X+ char dname[100];
X+#ifdef USE_DEVTAP
X+ /*
X+ * 5.x has /dev/tap, but that seems to just blindly increase its
X+ * couter on every open() for some people(??), i.e. on every qemu run.
X+ */
X+ i = -1;
X+#else
X+ i = 0;
X+#endif
X+ for (; i < 10; i++) {
X+ if (*ifname)
X+ snprintf(dname, sizeof dname, "/dev/%s", ifname);
X+ else if (i == -1)
X+ strcpy(dname, "/dev/tap");
X+ else
X+ snprintf(dname, sizeof dname, "%s%d",
X+ "/dev/tap", i);
X+ TFR(fd = open(dname, O_RDWR));
X+ if (fd >= 0)
X+ break;
X+ else if (errno == ENXIO || errno == ENOENT) {
X+ if (i == 0 && !kldtried++) {
X+ /*
X+ * Attempt to load the tunnel interface KLD if it isn't loaded
X+ * already.
X+ */
X+ if (loadmodules(LOAD_VERBOSLY, "if_tap", NULL))
X+ i = -1;
X+ continue;
X+ }
X+ if (errno != ENOENT || ++enoentcount > 3) {
X+ err = errno;
X+ break;
X+ }
X+ } else
X+ err = errno;
X+ if (*ifname)
X+ break;
X+ }
X+ if (fd < 0) {
X+ fprintf(stderr, "warning: could not open %s (%s): no virtual network emulation\n", dname, strerror(err));
X+ return -1;
X+ }
X+#else
X TFR(fd = open("/dev/tap", O_RDWR));
X if (fd < 0) {
X- fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation\n");
X+ fprintf(stderr, "warning: could not open /dev/tap (%s): no virtual network emulation\n", strerror(errno));
X return -1;
X }
X+#endif
X
X fstat(fd, &s);
X dev = devname(s.st_rdev, S_IFCHR);
END-of-files/patch-bt
echo x - files/patch-configure
sed 's/^X//' >files/patch-configure << 'END-of-files/patch-configure'
XIndex: qemu/configure
X@@ -490,7 +490,7 @@
X if [ "$darwin" = "yes" -o "$mingw32" = "yes" ] ; then
X AIOLIBS=
X elif [ "$bsd" = "yes" ]; then
X- AIOLIBS="-lpthread"
X+# AIOLIBS="-lpthread"
X else
X # Some Linux architectures (e.g. s390) don't imply -lpthread automatically.
X AIOLIBS="-lrt -lpthread"
X@@ -689,7 +689,7 @@
X fi # test "$curses"
X
X # Check if tools are available to build documentation.
X-if [ -x "`which texi2html 2>/dev/null`" ] && \
X+if [ "x$NOPORTDOCS" != "x" -o -x "`which texi2html 2>/dev/null`" ] && \
X [ -x "`which pod2man 2>/dev/null`" ]; then
X build_docs="yes"
X fi
END-of-files/patch-configure
echo x - files/patch-cpu-exec.c
sed 's/^X//' >files/patch-cpu-exec.c << 'END-of-files/patch-cpu-exec.c'
END-of-files/patch-cpu-exec.c
echo x - files/patch-emulate-aio
sed 's/^X//' >files/patch-emulate-aio << 'END-of-files/patch-emulate-aio'
XIndex: qemu/block.h
X@@ -53,10 +53,9 @@
X
X #define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_CACHE_WB)
X
X-void bdrv_info(void);
X+void bdrv_init(int emulate_aio);
X void bdrv_info_stats(void);
X
X-void bdrv_init(void);
X BlockDriver *bdrv_find_format(const char *format_name);
X int bdrv_create(BlockDriver *drv,
X const char *filename, int64_t size_in_sectors,
XIndex: qemu/block.c
X@@ -177,9 +177,9 @@
X }
X
X
X-static void bdrv_register(BlockDriver *bdrv)
X+static void bdrv_register(BlockDriver *bdrv, int emulate_aio)
X {
X- if (!bdrv->bdrv_aio_read) {
X+ if (!bdrv->bdrv_aio_read || emulate_aio) {
X /* add AIO emulation layer */
X bdrv->bdrv_aio_read = bdrv_aio_read_em;
X bdrv->bdrv_aio_write = bdrv_aio_write_em;
X@@ -1374,23 +1374,23 @@
X return async_ret;
X }
X
X-void bdrv_init(void)
X+void bdrv_init(int emulate_aio)
X {
X- bdrv_register(&bdrv_raw);
X- bdrv_register(&bdrv_host_device);
X+ bdrv_register(&bdrv_raw, emulate_aio);
X+ bdrv_register(&bdrv_host_device, emulate_aio);
X #ifndef _WIN32
X- bdrv_register(&bdrv_cow);
X+ bdrv_register(&bdrv_cow, 0);
X #endif
X- bdrv_register(&bdrv_qcow);
X- bdrv_register(&bdrv_vmdk);
X- bdrv_register(&bdrv_cloop);
X- bdrv_register(&bdrv_dmg);
X- bdrv_register(&bdrv_bochs);
X- bdrv_register(&bdrv_vpc);
X- bdrv_register(&bdrv_vvfat);
X- bdrv_register(&bdrv_qcow2);
X- bdrv_register(&bdrv_parallels);
X- bdrv_register(&bdrv_nbd);
X+ bdrv_register(&bdrv_qcow, 0);
X+ bdrv_register(&bdrv_vmdk, 0);
X+ bdrv_register(&bdrv_cloop, 0);
X+ bdrv_register(&bdrv_dmg, 0);
X+ bdrv_register(&bdrv_bochs, 0);
X+ bdrv_register(&bdrv_vpc, 0);
X+ bdrv_register(&bdrv_vvfat, 0);
X+ bdrv_register(&bdrv_qcow2, 0);
X+ bdrv_register(&bdrv_parallels, 0);
X+ bdrv_register(&bdrv_nbd, 0);
X }
X
X void *qemu_aio_get(BlockDriverState *bs, BlockDriverCompletionFunc *cb,
XIndex: qemu/vl.c
X@@ -76,6 +76,10 @@
X #endif
X #endif
X #endif
X+#ifdef __FreeBSD__
X+#include
X+#include
X+#endif
X
X #if defined(CONFIG_SLIRP)
X #include "libslirp.h"
X@@ -8884,6 +8884,7 @@
X VLANState *vlan;
X int autostart;
X const char *incoming = NULL;
X+ int emulate_aio = 0;
X
X LIST_INIT (&vm_change_state_head);
X #ifndef _WIN32
X@@ -8957,6 +8958,13 @@
X tb_size = 0;
X autostart= 1;
X
X+#ifdef __FreeBSD__
X+ if (modfind("aio") == -1) {
X+ emulate_aio = 1;
X+ fprintf(stderr, "warning: aio not (kld)loaded, disabling (may slow down on disk IO)\n");
X+ }
X+#endif
X+
X optind = 1;
X for(; {
X if (optind >= argc)
X@@ -9692,7 +9700,7 @@
X /* init the dynamic translator */
X cpu_exec_init_all(tb_size * 1024 * 1024);
X
X- bdrv_init();
X+ bdrv_init(emulate_aio);
X
X /* we always create the cdrom drive, even if no disk is there */
X
XIndex: qemu/qemu-img.c
X@@ -733,7 +733,7 @@
X {
X const char *cmd;
X
X- bdrv_init();
X+ bdrv_init(1);
X if (argc < 2)
X help();
X cmd = argv[1];
END-of-files/patch-emulate-aio
echo x - files/patch-exec-all.h
sed 's/^X//' >files/patch-exec-all.h << 'END-of-files/patch-exec-all.h'
XIndex: qemu/exec-all.h
X@@ -30,7 +30,7 @@
X struct TranslationBlock;
X
X /* XXX: make safe guess about sizes */
X-#define MAX_OP_PER_INSTR 64
X+#define MAX_OP_PER_INSTR 128 /* 64 */
X /* A Call op needs up to 6 + 2N parameters (N = number of arguments). */
X #define MAX_OPC_PARAM 10
X #define OPC_BUF_SIZE 512
END-of-files/patch-exec-all.h
echo x - files/patch-exec.c
sed 's/^X//' >files/patch-exec.c << 'END-of-files/patch-exec.c'
END-of-files/patch-exec.c
echo x - files/patch-fbsd
sed 's/^X//' >files/patch-fbsd << 'END-of-files/patch-fbsd'
XIndex: qemu/Makefile
X@@ -25,7 +25,10 @@
X DOCS=
X endif
X
X-all: $(TOOLS) $(DOCS) recurse-all
X+all: bsd/libmath.a $(TOOLS) $(DOCS) recurse-all
X+
X+bsd/libmath.a:
X+ ( cd bsd ; $(BSD_MAKE) CC=$(CC) )
X
X subdir-%: dyngen$(EXESUF)
X $(MAKE) -C $(subst subdir-,,$@) all
X@@ -40,6 +43,7 @@
X
X clean:
X # avoid old build problems by removing potentially incorrect old files
X+ ( cd bsd ; $(BSD_MAKE) clean )
X rm -f config.mak config.h op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
X rm -f *.o *.a $(TOOLS) dyngen$(EXESUF) TAGS *.pod *~ */*~
X $(MAKE) -C tests clean
XIndex: qemu/Makefile.target
X@@ -663,8 +663,8 @@
X main.o: CFLAGS+=-p
X endif
X
X-$(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a
X- $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS) $(VDE_LIBS)
X+$(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a ../bsd/libmath.a
X+ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS) $(VDE_LIBS) $(OS_LDFLAGS) ../bsd/libmath.a
X
X endif # !CONFIG_USER_ONLY
X
XIndex: qemu/fpu/softfloat-native.c
X@@ -2,11 +2,16 @@
X context is supported */
X #include "softfloat.h"
X #include
X+#if defined(__FreeBSD__) && __FreeBSD_version < 500000
X+#include
X+#endif
X
X void set_float_rounding_mode(int val STATUS_PARAM)
X {
X STATUS(float_rounding_mode) = val;
X-#if defined(_BSD) && !defined(__APPLE__) || (defined(HOST_SOLARIS) && HOST_SOLARIS < 10)
X+#if defined(_BSD) && !defined(__APPLE__) && !defined(__FreeBSD__) || \
X+ (defined(__FreeBSD__) && __FreeBSD_version < 500000) || \
X+ (defined(HOST_SOLARIS) && HOST_SOLARIS < 10)
X fpsetround(val);
X #elif defined(__arm__)
X /* nothing to do */
X@@ -22,7 +25,7 @@
X }
X #endif
X
X-#if defined(_BSD) || (defined(HOST_SOLARIS) && HOST_SOLARIS < 10)
X+#if (defined(_BSD) && !defined(__FreeBSD__)) || (defined(HOST_SOLARIS) && HOST_SOLARIS < 10)
X #define lrint(d) ((int32_t)rint(d))
X #define llrint(d) ((int64_t)rint(d))
X #define lrintf(f) ((int32_t)rint(f))
XIndex: qemu/fpu/softfloat-native.h
X@@ -1,8 +1,28 @@
X /* Native implementation of soft float functions */
X #include
X
X-#if (defined(_BSD) && !defined(__APPLE__)) || defined(HOST_SOLARIS)
X+#ifdef __FreeBSD__
X+#include
X+long double fabsl(long double x);
X+long double remainderl(long double x, long double y);
X+long double sqrtl(long double x);
X+long double rintl(long double x);
X+long lrintl(long double x);
X+long long llrintl(long double x);
X+#endif
X+
X+#if (defined(_BSD) && !defined(__APPLE__) && \
X+ (!defined(__FreeBSD__) || __FreeBSD_version < 500000)) || \
X+ defined(HOST_SOLARIS)
X #include
X+#if defined(__FreeBSD__)
X+#define isgreater(x, y) __builtin_isgreater((x), (y))
X+#define isgreaterequal(x, y) __builtin_isgreaterequal((x), (y))
X+#define isless(x, y) __builtin_isless((x), (y))
X+#define islessequal(x, y) __builtin_islessequal((x), (y))
X+#define islessgreater(x, y) __builtin_islessgreater((x), (y))
X+#define isunordered(x, y) __builtin_isunordered((x), (y))
X+#endif
X #define fabsf(f) ((float)fabs(f))
X #else
X #include
X@@ -109,6 +109,8 @@
X | Software IEC/IEEE floating-point rounding mode.
X *----------------------------------------------------------------------------*/
X-#if (defined(_BSD) && !defined(__APPLE__)) || defined(HOST_SOLARIS)
X+#if (defined(_BSD) && !defined(__APPLE__) && \
X+ (!defined(__FreeBSD__) || __FreeBSD_version < 500000)) || \
X+ defined(HOST_SOLARIS)
X #if defined(__OpenBSD__)
X #define FE_RM FP_RM
X #define FE_RP FP_RP
XIndex: qemu/fpu/softfloat.h
X@@ -84,7 +84,8 @@
X #define FLOAT128
X #else
X /* native float support */
X-#if (defined(__i386__) || defined(__x86_64__)) && !defined(_BSD)
X+#if (defined(__i386__) || defined(__x86_64__)) && \
X+ (!defined(_BSD) || defined(__FreeBSD__))
X #define FLOATX80
X #endif
X #endif /* !CONFIG_SOFTFLOAT */
XIndex: qemu/target-ppc/op_helper.c
X@@ -303,6 +303,13 @@
X FT0 = sqrt(FT0);
X }
X
X+#ifndef isnormal
X+#define isnormal(x) \
X+ ((sizeof (x) == sizeof (float)) ? __isnormalf(x) \
X+ : (sizeof (x) == sizeof (double)) ? __isnormal(x) \
X+ : __isnormall(x))
X+#endif
X+
X void do_fres (void)
X {
X union {
XIndex: qemu/x86_64.ld
X@@ -2,7 +2,7 @@
X OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
X OUTPUT_ARCH(i386:x86-64)
X ENTRY(_start)
X-SEARCH_DIR("/lib64"); SEARCH_DIR("/usr/lib64"); SEARCH_DIR("/usr/local/lib64");
X+SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib"); SEARCH_DIR("/usr/local/lib");
X SECTIONS
X {
X /* Read-only sections, merged into text segment: */
END-of-files/patch-fbsd
echo x - files/patch-fix_bsd_user_fbsd
sed 's/^X//' >files/patch-fix_bsd_user_fbsd << 'END-of-files/patch-fix_bsd_user_fbsd'
XIndex: qemu/bsd-user/main.c
X================================================= ==================
X--- qemu.orig/bsd-user/main.c 2008-11-08 06:22:53.000000000 +0000
X+++ qemu/bsd-user/main.c 2008-11-08 06:27:22.000000000 +0000
X@@ -182,9 +182,6 @@
X switch (trapnr) {
X case 0x100:
X syscall_nr = env->gregs[1];
X-#if defined(TARGET_SPARC)
X- syscall_nr &= ~(SYSCALL_G7RFLAG | SYSCALL_G2RFLAG);
X-#endif
X if (bsd_type == target_freebsd)
X ret = do_freebsd_syscall(env, syscall_nr,
X env->regwptr[0], env->regwptr[1],
X@@ -195,11 +192,16 @@
X env->regwptr[0], env->regwptr[1],
X env->regwptr[2], env->regwptr[3],
X env->regwptr[4], env->regwptr[5]);
X- else //if (bsd_type == target_openbsd)
X+ else { //if (bsd_type == target_openbsd)
X+#if defined(TARGET_SPARC)
X+ syscall_nr &= ~(TARGET_OPENBSD_SYSCALL_G7RFLAG |
X+ TARGET_OPENBSD_SYSCALL_G2RFLAG);
X+#endif
X ret = do_openbsd_syscall(env, syscall_nr,
X env->regwptr[0], env->regwptr[1],
X env->regwptr[2], env->regwptr[3],
X env->regwptr[4], env->regwptr[5]);
X+ }
X if ((unsigned int)ret >= (unsigned int)(-515)) {
X #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
X env->xcc |= PSR_CARRY;
XIndex: qemu/bsd-user/openbsd/syscall_nr.h
X================================================= ==================
X--- qemu.orig/bsd-user/openbsd/syscall_nr.h 2008-11-08 06:25:23.000000000 +0000
X+++ qemu/bsd-user/openbsd/syscall_nr.h 2008-11-08 06:36:02.000000000 +0000
X@@ -193,3 +193,33 @@
X #define TARGET_OPENBSD_NR_statfs 307
X #define TARGET_OPENBSD_NR_fstatfs 308
X #define TARGET_OPENBSD_NR_fhstatfs 309
X+
X+/* syscall flags from machine/trap.h */
X+
X+/* $OpenBSD: trap.h,v 1.4 2008/07/04 22:04:37 kettenis Exp $ */
X+/* $NetBSD: trap.h,v 1.4 1999/06/07 05:28:04 eeh Exp $ */
X+
X+/*
X+ * Copyright (c) 1996-1999 Eduardo Horvath
X+ *
X+ * Redistribution and use in source and binary forms, with or without
X+ * modification, are permitted provided that the following conditions
X+ * are met:
X+ * 1. Redistributions of source code must retain the above copyright
X+ * notice, this list of conditions and the following disclaimer.
X+ *
X+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
X+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
X+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X+ * SUCH DAMAGE.
X+ *
X+ */
X+#define TARGET_OPENBSD_SYSCALL_G2RFLAG 0x400 /* on success, return to %g2 rather than npc */
X+#define TARGET_OPENBSD_SYSCALL_G7RFLAG 0x800 /* use %g7 as above (deprecated) */
END-of-files/patch-fix_bsd_user_fbsd
echo x - files/patch-fpu-softfloat-native.c
sed 's/^X//' >files/patch-fpu-softfloat-native.c << 'END-of-files/patch-fpu-softfloat-native.c'
XIndex: qemu/fpu/softfloat-native.c
X@@ -228,7 +228,15 @@
X *----------------------------------------------------------------------------*/
X float64 float64_trunc_to_int( float64 a STATUS_PARAM )
X {
X+#if defined(__FreeBSD__) && __FreeBSD__ <= 4
X+ float64 ret;
X+ fpsetround(FP_RZ);
X+ ret = rint(a);
X+ fpsetround(STATUS(float_rounding_mode));
X+ return ret;
X+#else
X return trunc(a);
X+#endif
X }
X
X float64 float64_round_to_int( float64 a STATUS_PARAM )
END-of-files/patch-fpu-softfloat-native.c
echo x - files/patch-hw-eepro100.c
sed 's/^X//' >files/patch-hw-eepro100.c << 'END-of-files/patch-hw-eepro100.c'
XIndex: qemu/hw/eepro100.c
X@@ -729,6 +729,7 @@
X logout
X ("TBD (simplified mode): buffer address 0x%08x, size 0x%04x\n",
X tx_buffer_address, tx_buffer_size);
X+ assert(size + tx_buffer_size <= sizeof(buf));
X cpu_physical_memory_read(tx_buffer_address, &buf[size],
X tx_buffer_size);
X size += tx_buffer_size;
X@@ -749,9 +750,13 @@
X logout
X ("TBD (extended mode): buffer address 0x%08x, size 0x%04x\n",
X tx_buffer_address, tx_buffer_size);
X- cpu_physical_memory_read(tx_buffer_address, &buf[size],
X- tx_buffer_size);
X- size += tx_buffer_size;
X+ if (size + tx_buffer_size > sizeof(buf)) {
X+ logout("bad extended TCB with size 0x%04x\n", tx_buffer_size);
X+ } else {
X+ cpu_physical_memory_read(tx_buffer_address, &buf[size],
X+ tx_buffer_size);
X+ size += tx_buffer_size;
X+ }
X if (tx_buffer_el & 1) {
X break;
X }
X@@ -766,14 +771,20 @@
X logout
X ("TBD (flexible mode): buffer address 0x%08x, size 0x%04x\n",
X tx_buffer_address, tx_buffer_size);
X- cpu_physical_memory_read(tx_buffer_address, &buf[size],
X- tx_buffer_size);
X- size += tx_buffer_size;
X+ if (size + tx_buffer_size > sizeof(buf)) {
X+ logout("bad flexible TCB with size 0x%04x\n", tx_buffer_size);
X+ } else {
X+ cpu_physical_memory_read(tx_buffer_address, &buf[size],
X+ tx_buffer_size);
X+ size += tx_buffer_size;
X+ }
X if (tx_buffer_el & 1) {
X break;
X }
X }
X }
X+ logout("%p sending frame, len=%d,%s\n", s, size, nic_dump(buf, size));
X+ assert(size <= sizeof(buf));
X qemu_send_packet(s->vc, buf, size);
X s->statistics.tx_good_frames++;
X /* Transmit with bad status would raise an CX/TNO interrupt.
END-of-files/patch-hw-eepro100.c
echo x - files/patch-hw-vmware_vga.c
sed 's/^X//' >files/patch-hw-vmware_vga.c << 'END-of-files/patch-hw-vmware_vga.c'
XIndex: qemu/hw/vmware_vga.c
X@@ -26,8 +26,8 @@
X #define VERBOSE
X #define EMBED_STDVGA
X #undef DIRECT_VRAM
X-#define HW_RECT_ACCEL
X-#define HW_FILL_ACCEL
X+/* #define HW_RECT_ACCEL */
X+/* #define HW_FILL_ACCEL */
X #define HW_MOUSE_ACCEL
X
X #ifdef EMBED_STDVGA
X@@ -76,6 +76,7 @@
X uint32_t wblue;
X int syncing;
X int fb_size;
X+ int empty;
X
X union {
X uint32_t *fifo;
X@@ -487,7 +488,7 @@
X
X static inline int vmsvga_fifo_empty(struct vmsvga_state_s *s)
X {
X- if (!s->config || !s->enable)
X+ if (!s->config || !s->enable || s->empty)
X return 1;
X return (s->cmd->next_cmd == s->cmd->stop);
X }
X@@ -495,6 +496,10 @@
X static inline uint32_t vmsvga_fifo_read_raw(struct vmsvga_state_s *s)
X {
X uint32_t cmd = s->fifo[CMD(stop) >> 2];
X+ if (s->cmd->next_cmd == s->cmd->stop) {
X+ s->empty = 1;
X+ return 0;
X+ }
X s->cmd->stop = cpu_to_le32(CMD(stop) + 4);
X if (CMD(stop) >= CMD(max))
X s->cmd->stop = s->cmd->min;
X@@ -512,6 +517,7 @@
X int args = 0;
X int x, y, dx, dy, width, height;
X struct vmsvga_cursor_definition_s cursor;
X+ s->empty = 0;
X while (!vmsvga_fifo_empty(s))
X switch (cmd = vmsvga_fifo_read(s)) {
X case SVGA_CMD_UPDATE:
X@@ -533,6 +539,7 @@
X vmsvga_fill_rect(s, colour, x, y, width, height);
X break;
X #else
X+ args = 0;
X goto badcmd;
X #endif
X
X@@ -547,6 +554,7 @@
X vmsvga_copy_rect(s, x, y, dx, dy, width, height);
X break;
X #else
X+ args = 0;
X goto badcmd;
X #endif
X
X@@ -609,6 +617,7 @@
X break; /* Nop */
X
X default:
X+ args = 0;
X badcmd:
X while (args --)
X vmsvga_fifo_read(s);
END-of-files/patch-hw-vmware_vga.c
echo x - files/patch-libmath
sed 's/^X//' >files/patch-libmath << 'END-of-files/patch-libmath'
Xdiff -Nru qemu-0.7.0/bsd.orig/Makefile qemu-0.7.0/bsd/Makefile
X--- qemu-0.7.0/bsd.orig/Makefile Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/Makefile Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,32 @@
X+SRCS= ${MACHINE_ARCH}/e_atan2l.c \
X+ ${MACHINE_ARCH}/e_logl.S \
X+ ${MACHINE_ARCH}/e_powl.S \
X+ ${MACHINE_ARCH}/e_remainderl.S \
X+ ${MACHINE_ARCH}/e_sqrtl.c \
X+ ${MACHINE_ARCH}/s_ceill.S \
X+ ${MACHINE_ARCH}/s_cosl.S \
X+ ${MACHINE_ARCH}/s_floorl.S \
X+ ${MACHINE_ARCH}/s_isnormal.c \
X+ ${MACHINE_ARCH}/s_llrint.S \
X+ ${MACHINE_ARCH}/s_llrintf.S \
X+ ${MACHINE_ARCH}/s_llrintl.S \
X+ ${MACHINE_ARCH}/s_lrint.S \
X+ ${MACHINE_ARCH}/s_lrintf.S \
X+ ${MACHINE_ARCH}/s_lrintl.S \
X+ ${MACHINE_ARCH}/s_rintl.c \
X+ ${MACHINE_ARCH}/s_round.c \
X+ ${MACHINE_ARCH}/s_sinl.S \
X+ ${MACHINE_ARCH}/s_tanl.S
X+
X+OBJS= ${SRCS:R:S/$/.o/}
X+
X+CFLAGS+= -I.
X+
X+all: libmath.a
X+
X+libmath.a: ${OBJS}
X+ rm -f $@
X+ ${AR} rcs $@ ${OBJS:T}
X+
X+clean:
X+ rm -f ${OBJS:T} libmath.a
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/e_atan2l.c qemu-0.7.0/bsd/amd64/e_atan2l.c
X--- qemu-0.7.0/bsd.orig/amd64/e_atan2l.c Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/e_atan2l.c Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,20 @@
X+/*
X+ * Written by J.T. Conklin .
X+ * Public domain.
X+ *
X+ * Adapted for `long double' by Ulrich Drepper .
X+ */
X+
X+#include
X+
X+long double
X+__ieee754_atan2l (long double y, long double x)
X+{
X+ long double res;
X+
X+ asm ("fpatan" : "=t" (res) : "u" (y), "0" (x) : "st(1)");
X+
X+ return res;
X+}
X+
X+weak_alias(__ieee754_atan2l, atan2l)
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/e_logl.S qemu-0.7.0/bsd/amd64/e_logl.S
X--- qemu-0.7.0/bsd.orig/amd64/e_logl.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/e_logl.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,59 @@
X+/*
X+ * Written by J.T. Conklin .
X+ * Public domain.
X+ *
X+ * Adapted for `long double' by Ulrich Drepper .
X+ * Adapted for x86-64 by Andreas Jaeger .
X+ */
X+
X+#include
X+#include
X+
X+RCSID("$NetBSD: $")
X+
X+
X+#ifdef __ELF__
X+ .section .rodata
X+#else
X+ .text
X+#endif
X+ .align ALIGNARG(4)
X+ ASM_TYPE_DIRECTIVE(one,@object)
X+one: .double 1.0
X+ ASM_SIZE_DIRECTIVE(one)
X+ /* It is not important that this constant is precise. It is only
X+ a value which is known to be on the safe side for using the
X+ fyl2xp1 instruction. */
X+ ASM_TYPE_DIRECTIVE(limit,@object)
X+limit: .double 0.29
X+ ASM_SIZE_DIRECTIVE(limit)
X+
X+
X+#ifdef PIC
X+#define MO(op) op##(%rip)
X+#else
X+#define MO(op) op
X+#endif
X+
X+ .text
X+ENTRY(__ieee754_logl)
X+ fldln2 // log(2)
X+ fldt 8(%rsp) // x : log(2)
X+ fld %st // x : x : log(2)
X+ fsubl MO(one) // x-1 : x : log(2)
X+ fld %st // x-1 : x-1 : x : log(2)
X+ fabs // |x-1| : x-1 : x : log(2)
X+ fcompl MO(limit) // x-1 : x : log(2)
X+ fnstsw // x-1 : x : log(2)
X+ andb $0x45, %ah
X+ jz 2f
X+ fstp %st(1) // x-1 : log(2)
X+ fyl2xp1 // log(x)
X+ ret
X+
X+2: fstp %st(0) // x : log(2)
X+ fyl2x // log(x)
X+ ret
X+END (__ieee754_logl)
X+
X+weak_alias(__ieee754_logl,logl)
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/e_powl.S qemu-0.7.0/bsd/amd64/e_powl.S
X--- qemu-0.7.0/bsd.orig/amd64/e_powl.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/e_powl.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,341 @@
X+/* ix87 specific implementation of pow function.
X+ Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004 Free Software Foundation, Inc.
X+ This file is part of the GNU C Library.
X+ Contributed by Ulrich Drepper , 1996.
X+
X+ The GNU C Library is free software; you can redistribute it and/or
X+ modify it under the terms of the GNU Lesser General Public
X+ License as published by the Free Software Foundation; either
X+ version 2.1 of the License, or (at your option) any later version.
X+
X+ The GNU C Library is distributed in the hope that it will be useful,
X+ but WITHOUT ANY WARRANTY; without even the implied warranty of
X+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
X+ Lesser General Public License for more details.
X+
X+ You should have received a copy of the GNU Lesser General Public
X+ License along with the GNU C Library; if not, write to the Free
X+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
X+ 02111-1307 USA. */
X+
X+#include
X+#include
X+
X+#ifdef __ELF__
X+ .section .rodata
X+#else
X+ .text
X+#endif
X+
X+ .align ALIGNARG(4)
X+ ASM_TYPE_DIRECTIVE(infinity,@object)
X+inf_zero:
X+infinity:
X+ .byte 0, 0, 0, 0, 0, 0, 0xf0, 0x7f
X+ ASM_SIZE_DIRECTIVE(infinity)
X+ ASM_TYPE_DIRECTIVE(zero,@object)
X+zero: .double 0.0
X+ ASM_SIZE_DIRECTIVE(zero)
X+ ASM_TYPE_DIRECTIVE(minf_mzero,@object)
X+minf_mzero:
X+minfinity:
X+ .byte 0, 0, 0, 0, 0, 0, 0xf0, 0xff
X+mzero:
X+ .byte 0, 0, 0, 0, 0, 0, 0, 0x80
X+ ASM_SIZE_DIRECTIVE(minf_mzero)
X+ ASM_TYPE_DIRECTIVE(one,@object)
X+one: .double 1.0
X+ ASM_SIZE_DIRECTIVE(one)
X+ ASM_TYPE_DIRECTIVE(limit,@object)
X+limit: .double 0.29
X+ ASM_SIZE_DIRECTIVE(limit)
X+ ASM_TYPE_DIRECTIVE(p63,@object)
X+p63:
X+ .byte 0, 0, 0, 0, 0, 0, 0xe0, 0x43
X+ ASM_SIZE_DIRECTIVE(p63)
X+
X+#ifdef PIC
X+#define MO(op) op##(%rip)
X+#else
X+#define MO(op) op
X+#endif
X+
X+ .text
X+ENTRY(__ieee754_powl)
X+ fldt 24(%rsp) // y
X+ fxam
X+
X+
X+ fnstsw
X+ movb %ah, %dl
X+ andb $0x45, %ah
X+ cmpb $0x40, %ah // is y == 0 ?
X+ je 11f
X+
X+ cmpb $0x05, %ah // is y == ±inf ?
X+ je 12f
X+
X+ cmpb $0x01, %ah // is y == NaN ?
X+ je 30f
X+
X+ fldt 8(%rsp) // x : y
X+
X+ fxam
X+ fnstsw
X+ movb %ah, %dh
X+ andb $0x45, %ah
X+ cmpb $0x40, %ah
X+ je 20f // x is ±0
X+
X+ cmpb $0x05, %ah
X+ je 15f // x is ±inf
X+
X+ fxch // y : x
X+
X+ /* fistpll raises invalid exception for |y| >= 1L<<63. */
X+ fldl MO(p63) // 1L<<63 : y : x
X+ fld %st(1) // y : 1L<<63 : y : x
X+ fabs // |y| : 1L<<63 : y : x
X+ fcomip %st(1), %st // 1L<<63 : y : x
X+ fstp %st(0) // y : x
X+ jnc 2f
X+
X+ /* First see whether `y' is a natural number. In this case we
X+ can use a more precise algorithm. */
X+ fld %st // y : y : x
X+ fistpll -8(%rsp) // y : x
X+ fildll -8(%rsp) // int(y) : y : x
X+ fucomip %st(1),%st // y : x
X+ jne 2f
X+
X+ /* OK, we have an integer value for y. */
X+ mov -8(%rsp),%eax
X+ mov -4(%rsp),%edx
X+ orl $0, %edx
X+ fstp %st(0) // x
X+ jns 4f // y >= 0, jump
X+ fdivrl MO(one) // 1/x (now referred to as x)
X+ negl %eax
X+ adcl $0, %edx
X+ negl %edx
X+4: fldl MO(one) // 1 : x
X+ fxch
X+
X+6: shrdl $1, %edx, %eax
X+ jnc 5f
X+ fxch
X+ fmul %st(1) // x : ST*x
X+ fxch
X+5: fmul %st(0), %st // x*x : ST*x
X+ shrl $1, %edx
X+ movl %eax, %ecx
X+ orl %edx, %ecx
X+ jnz 6b
X+ fstp %st(0) // ST*x
X+ ret
X+
X+ /* y is ±NAN */
X+30: fldt 8(%rsp) // x : y
X+ fldl MO(one) // 1.0 : x : y
X+ fucomip %st(1),%st // x : y
X+ je 31f
X+ fxch // y : x
X+31: fstp %st(1)
X+ ret
X+
X+ .align ALIGNARG(4)
X+2: /* y is a real number. */
X+ fxch // x : y
X+ fldl MO(one) // 1.0 : x : y
X+ fld %st(1) // x : 1.0 : x : y
X+ fsub %st(1) // x-1 : 1.0 : x : y
X+ fabs // |x-1| : 1.0 : x : y
X+ fcompl MO(limit) // 1.0 : x : y
X+ fnstsw
X+ fxch // x : 1.0 : y
X+ test $4500,%eax
X+ jz 7f
X+ fsub %st(1) // x-1 : 1.0 : y
X+ fyl2xp1 // log2(x) : y
X+ jmp 8f
X+
X+7: fyl2x // log2(x) : y
X+8: fmul %st(1) // y*log2(x) : y
X+ fxam
X+ fnstsw
X+ andb $0x45, %ah
X+ cmpb $0x05, %ah // is y*log2(x) == ±inf ?
X+ je 28f
X+ fst %st(1) // y*log2(x) : y*log2(x)
X+ frndint // int(y*log2(x)) : y*log2(x)
X+ fsubr %st, %st(1) // int(y*log2(x)) : fract(y*log2(x))
X+ fxch // fract(y*log2(x)) : int(y*log2(x))
X+ f2xm1 // 2^fract(y*log2(x))-1 : int(y*log2(x))
X+ faddl MO(one) // 2^fract(y*log2(x)) : int(y*log2(x))
X+ fscale // 2^fract(y*log2(x))*2^int(y*log2(x)) : int(y*log2(x))
X+ fstp %st(1) // 2^fract(y*log2(x))*2^int(y*log2(x))
X+ ret
X+
X+28: fstp %st(1) // y*log2(x)
X+ fldl MO(one) // 1 : y*log2(x)
X+ fscale // 2^(y*log2(x)) : y*log2(x)
X+ fstp %st(1) // 2^(y*log2(x))
X+ ret
X+
X+ // pow(x,±0) = 1
X+ .align ALIGNARG(4)
X+11: fstp %st(0) // pop y
X+ fldl MO(one)
X+ ret
X+
X+ // y == ±inf
X+ .align ALIGNARG(4)
X+12: fstp %st(0) // pop y
X+ fldt 8(%rsp) // x
X+ fabs
X+ fcompl MO(one) // < 1, == 1, or > 1
X+ fnstsw
X+ andb $0x45, %ah
X+ cmpb $0x45, %ah
X+ je 13f // jump if x is NaN
X+
X+ cmpb $0x40, %ah
X+ je 14f // jump if |x| == 1
X+
X+ shlb $1, %ah
X+ xorb %ah, %dl
X+ andl $2, %edx
X+#ifdef PIC
X+ lea inf_zero(%rip),%rcx
X+ fldl (%rcx, %rdx, 4)
X+#else
X+ fldl inf_zero(,%rdx, 4)
X+#endif
X+ ret
X+
X+ .align ALIGNARG(4)
X+14: fldl MO(one)
X+ ret
X+
X+ .align ALIGNARG(4)
X+13: fldt 8(%rsp) // load x == NaN
X+ ret
X+
X+ .align ALIGNARG(4)
X+ // x is ±inf
X+15: fstp %st(0) // y
X+ testb $2, %dh
X+ jz 16f // jump if x == +inf
X+
X+ // We must find out whether y is an odd integer.
X+ fld %st // y : y
X+ fistpll -8(%rsp) // y
X+ fildll -8(%rsp) // int(y) : y
X+ fucomip %st(1),%st
X+ ffreep %st //
X+ jne 17f
X+
X+ // OK, the value is an integer, but is it odd?
X+ mov -8(%rsp), %eax
X+ mov -4(%rsp), %edx
X+ andb $1, %al
X+ jz 18f // jump if not odd
X+ // It's an odd integer.
X+ shrl $31, %edx
X+#ifdef PIC
X+ lea minf_mzero(%rip),%rcx
X+ fldl (%rcx, %rdx, 8)
X+#else
X+ fldl minf_mzero(,%rdx, 8)
X+#endif
X+ ret
X+
X+ .align ALIGNARG(4)
X+16: fcompl MO(zero)
X+ fnstsw
X+ shrl $5, %eax
X+ andl $8, %eax
X+#ifdef PIC
X+ lea inf_zero(%rip),%rcx
X+ fldl (%rcx, %rax, 1)
X+#else
X+ fldl inf_zero(,%rax, 1)
X+#endif
X+ ret
X+
X+ .align ALIGNARG(4)
X+17: shll $30, %edx // sign bit for y in right position
X+18: shrl $31, %edx
X+#ifdef PIC
X+ lea inf_zero(%rip),%rcx
X+ fldl (%rcx, %rdx, 8)
X+#else
X+ fldl inf_zero(,%rdx, 8)
X+#endif
X+ ret
X+
X+ .align ALIGNARG(4)
X+ // x is ±0
X+20: fstp %st(0) // y
X+ testb $2, %dl
X+ jz 21f // y > 0
X+
X+ // x is ±0 and y is < 0. We must find out whether y is an odd integer.
X+ testb $2, %dh
X+ jz 25f
X+
X+ fld %st // y : y
X+ fistpll -8(%rsp) // y
X+ fildll -8(%rsp) // int(y) : y
X+ fucomip %st(1),%st
X+ ffreep %st //
X+ jne 26f
X+
X+ // OK, the value is an integer, but is it odd?
X+ mov -8(%rsp),%eax
X+ mov -4(%rsp),%edx
X+ andb $1, %al
X+ jz 27f // jump if not odd
X+ // It's an odd integer.
X+ // Raise divide-by-zero exception and get minus infinity value.
X+ fldl MO(one)
X+ fdivl MO(zero)
X+ fchs
X+ ret
X+
X+25: fstp %st(0)
X+26:
X+27: // Raise divide-by-zero exception and get infinity value.
X+ fldl MO(one)
X+ fdivl MO(zero)
X+ ret
X+
X+ .align ALIGNARG(4)
X+ // x is ±0 and y is > 0. We must find out whether y is an odd integer.
X+21: testb $2, %dh
X+ jz 22f
X+
X+ fld %st // y : y
X+ fistpll -8(%rsp) // y
X+ fildll -8(%rsp) // int(y) : y
X+ fucomip %st(1),%st
X+ ffreep %st //
X+ jne 23f
X+
X+ // OK, the value is an integer, but is it odd?
X+ mov -8(%rsp),%eax
X+ mov -4(%rsp),%edx
X+ andb $1, %al
X+ jz 24f // jump if not odd
X+ // It's an odd integer.
X+ fldl MO(mzero)
X+ ret
X+
X+22: fstp %st(0)
X+23:
X+24: fldl MO(zero)
X+ ret
X+
X+END(__ieee754_powl)
X+
X+weak_alias(__ieee754_powl,powl)
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/e_remainderl.S qemu-0.7.0/bsd/amd64/e_remainderl.S
X--- qemu-0.7.0/bsd.orig/amd64/e_remainderl.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/e_remainderl.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,23 @@
X+/*
X+ * Written by J.T. Conklin .
X+ * Public domain.
X+ *
X+ * Adapted for `long double' by Ulrich Drepper .
X+ * Adapted for x86-64 by Andreas Jaeger .
X+ */
X+
X+#include
X+#include
X+
X+ENTRY(__ieee754_remainderl)
X+ fldt 24(%rsp)
X+ fldt 8(%rsp)
X+1: fprem1
X+ fstsw %ax
X+ testl $0x400,%eax
X+ jnz 1b
X+ fstp %st(1)
X+ ret
X+END (__ieee754_remainderl)
X+
X+weak_alias(__ieee754_remainderl,remainderl)
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/e_sqrtl.c qemu-0.7.0/bsd/amd64/e_sqrtl.c
X--- qemu-0.7.0/bsd.orig/amd64/e_sqrtl.c Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/e_sqrtl.c Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,20 @@
X+/*
X+ * Written by J.T. Conklin .
X+ * Public domain.
X+ *
X+ * Adapted for `long double' by Ulrich Drepper .
X+ */
X+
X+#include
X+
X+long double
X+__ieee754_sqrtl (long double x)
X+{
X+ long double res;
X+
X+ asm ("fsqrt" : "=t" (res) : "0" (x));
X+
X+ return res;
X+}
X+
X+weak_alias(__ieee754_sqrtl,sqrtl)
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/s_ceill.S qemu-0.7.0/bsd/amd64/s_ceill.S
X--- qemu-0.7.0/bsd.orig/amd64/s_ceill.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/s_ceill.S Fri Apr 29 02:22:18 2005
X@@ -0,0 +1,246 @@
X+/*
X+ * ================================================== ==
X+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
X+ *
X+ * Developed at SunPro, a Sun Microsystems, Inc. business.
X+ * Permission to use, copy, modify, and distribute this
X+ * software is freely granted, provided that this notice
X+ * is preserved.
X+ * ================================================== ==
X+ *
X+ * From: @(#)s_ceil.c 5.1 93/09/24
X+ */
X+/* XXX: generated from src/lib/msun/src/s_ceill.c */
X+
X+#include
X+
X+__FBSDID("$FreeBSD: ports/emulators/qemu-devel/files/patch-libmath,v 1.4 2007/03/10 17:03:05 nox Exp $")
X+
X+ .file "s_ceill.c"
X+ .section .rodata.cst8,"aM",@progbits,8
X+ .p2align 3
X+.LC0:
X+ .long 2281731484
X+ .long 2117592124
X+ .text
X+ .p2align 4,,15
X+.globl ceill
X+ .type ceill, @function
X+ceill:
X+.LFB17:
X+ pushq %rbp
X+.LCFI0:
X+ pushq %rbx
X+.LCFI1:
X+ fldt 24(%rsp)
X+ movq $0, -16(%rsp)
X+ fld %st(0)
X+ fstpt -40(%rsp)
X+ movl -32(%rsp), %edi
X+ movq -40(%rsp), %rsi
X+ movl %edi, -16(%rsp)
X+ movl -16(%rsp), %r11d
X+ movq %rsi, -24(%rsp)
X+ movl %r11d, %r10d
X+ andl $32767, %r10d
X+ leal -16383(%r10), %r8d
X+ cmpl $30, %r8d
X+ jg .L2
X+ testl %r8d, %r8d
X+ js .L38
X+ movl -20(%rsp), %r9d
X+ leal 1(%r8), %ecx
X+ mov -24(%rsp), %eax
X+ movl $4294967295, %ebp
X+ movq %rsi, -40(%rsp)
X+ movl %edi, -32(%rsp)
X+ shrq %cl, %rbp
X+ mov %r9d, %ebx
X+ movq %rbx, %rdx
X+ andq %rbp, %rdx
X+ orq %rax, %rdx
X+ fldt -40(%rsp)
X+ je .L42
X+ ffreep %st(0)
X+ testb $-128, -15(%rsp)
X+ jne .L12
X+ movl $31, %ecx
X+ movl $1, %eax
X+ subl %r8d, %ecx
X+ salq %cl, %rax
X+ addl %eax, %r9d
X+ mov %r9d, %eax
X+ cmpq %rbx, %rax
X+ jae .L32
X+ leal 1(%r10), %edx
X+ movl %r11d, %eax
X+ orl $-2147483648, %r9d
X+ andw $-32768, %ax
X+ andw $32767, %dx
X+ orl %edx, %eax
X+ movw %ax, -16(%rsp)
X+.L32:
X+ movl %r9d, -20(%rsp)
X+.L12:
X+ faddl .LC0(%rip)
X+ fldz
X+ fxch %st(1)
X+ fucomip %st(1), %st
X+ fstp %st(0)
X+ jbe .L31
X+ movl %ebp, %eax
X+ movl $0, -24(%rsp)
X+ notl %eax
X+ andl %eax, %r9d
X+ movl %r9d, -20(%rsp)
X+ .p2align 4,,7
X+.L31:
X+ movq -24(%rsp), %rsi
X+ movl -16(%rsp), %edi
X+ movq %rsi, -40(%rsp)
X+ movl %edi, -32(%rsp)
X+ fldt -40(%rsp)
X+ popq %rbx
X+ popq %rbp
X+ ret
X+ .p2align 4,,7
X+.L2:
X+ cmpl $62, %r8d
X+ jle .L45
X+.L44:
X+ ffreep %st(0)
X+.L17:
X+ movq %rsi, -40(%rsp)
X+ movl %edi, -32(%rsp)
X+ fldt -40(%rsp)
X+ popq %rbx
X+ popq %rbp
X+ ret
X+ .p2align 4,,7
X+.L45:
X+ movl -24(%rsp), %edx
X+ leal 1(%r8), %ecx
X+ movq $-1, %rbx
X+ movq %rsi, -40(%rsp)
X+ movl %edi, -32(%rsp)
X+ shrq %cl, %rbx
X+ mov %edx, %r9d
X+ testq %rbx, %r9
X+ fldt -40(%rsp)
X+ je .L42
X+ ffreep %st(0)
X+ testb $-128, -15(%rsp)
X+ jne .L20
X+ cmpl $31, %r8d
X+ je .L36
X+ movl $63, %ecx
X+ movl $1, %eax
X+ subl %r8d, %ecx
X+ salq %cl, %rax
X+ leal (%rdx,%rax), %eax
X+ movl %eax, -24(%rsp)
X+ mov %eax, %eax
X+ cmpq %r9, %rax
X+ jae .L20
X+.L36:
X+ movl -20(%rsp), %eax
X+ leal 1(%rax), %ecx
X+ cmpl %eax, %ecx
X+ jae .L34
X+ leal 1(%r10), %edx
X+ movl %r11d, %eax
X+ orl $-2147483648, %ecx
X+ andw $-32768, %ax
X+ andw $32767, %dx
X+ orl %edx, %eax
X+ movw %ax, -16(%rsp)
X+.L34:
X+ movl %ecx, -20(%rsp)
X+ .p2align 4,,7
X+.L20:
X+ faddl .LC0(%rip)
X+ fldz
X+ fxch %st(1)
X+ fucomip %st(1), %st
X+ fstp %st(0)
X+ jbe .L31
X+ movl %ebx, %eax
X+ notl %eax
X+ andl %eax, -24(%rsp)
X+ jmp .L31
X+ .p2align 4,,7
X+.L42:
X+ fstp %st(1)
X+ popq %rbx
X+ popq %rbp
X+ ret
X+ .p2align 4,,7
X+.L38:
X+ fldl .LC0(%rip)
X+ faddp %st, %st(1)
X+ fldz
X+ fxch %st(1)
X+ fucomip %st(1), %st
X+ jbe .L44
X+ testl %r10d, %r10d
X+ jle .L39
X+.L7:
X+ movabsq $-9223372036854775808, %rsi
X+ movl $16383, %edi
X+ testb $-128, -15(%rsp)
X+ movq %rsi, -40(%rsp)
X+ movl %edi, -32(%rsp)
X+ fldt -40(%rsp)
X+ fcmovne %st(1), %st
X+ fstp %st(1)
X+ fstpt -40(%rsp)
X+ movq -40(%rsp), %rsi
X+ movl -32(%rsp), %edi
X+ movq %rsi, -24(%rsp)
X+ movl %edi, -16(%rsp)
X+ jmp .L17
X+.L39:
X+ movl -24(%rsp), %eax
X+ orl -20(%rsp), %eax
X+ je .L44
X+ jmp .L7
X+.LFE17:
X+ .size ceill, .-ceill
X+ .section .eh_frame,"a",@progbits
X+.Lframe1:
X+ .long .LECIE1-.LSCIE1
X+.LSCIE1:
X+ .long 0x0
X+ .byte 0x1
X+ .string ""
X+ .uleb128 0x1
X+ .sleb128 -8
X+ .byte 0x10
X+ .byte 0xc
X+ .uleb128 0x7
X+ .uleb128 0x8
X+ .byte 0x90
X+ .uleb128 0x1
X+ .p2align 3
X+.LECIE1:
X+.LSFDE1:
X+ .long .LEFDE1-.LASFDE1
X+.LASFDE1:
X+ .long .LASFDE1-.Lframe1
X+ .quad .LFB17
X+ .quad .LFE17-.LFB17
X+ .byte 0x4
X+ .long .LCFI0-.LFB17
X+ .byte 0xe
X+ .uleb128 0x10
X+ .byte 0x4
X+ .long .LCFI1-.LCFI0
X+ .byte 0xe
X+ .uleb128 0x18
X+ .byte 0x83
X+ .uleb128 0x3
X+ .byte 0x86
X+ .uleb128 0x2
X+ .p2align 3
X+.LEFDE1:
X+ .ident "GCC: (GNU) 3.4.4 [FreeBSD] 20050421"
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/s_cosl.S qemu-0.7.0/bsd/amd64/s_cosl.S
X--- qemu-0.7.0/bsd.orig/amd64/s_cosl.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/s_cosl.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,33 @@
X+/*
X+ * Written by J.T. Conklin .
X+ * Public domain.
X+ *
X+ * Adapted for `long double' by Ulrich Drepper .
X+ * Adapted for x86-64 by Andreas Jaeger .
X+ */
X+
X+#include
X+#include
X+
X+RCSID("$NetBSD: $")
X+
X+ENTRY(__cosl)
X+ fldt 8(%rsp)
X+ fcos
X+ fnstsw %ax
X+ testl $0x400,%eax
X+ jnz 1f
X+ ret
X+ .align ALIGNARG(4)
X+1: fldpi
X+ fadd %st(0)
X+ fxch %st(1)
X+2: fprem1
X+ fnstsw %ax
X+ testl $0x400,%eax
X+ jnz 2b
X+ fstp %st(1)
X+ fcos
X+ ret
X+END (__cosl)
X+weak_alias (__cosl, cosl)
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/s_floorl.S qemu-0.7.0/bsd/amd64/s_floorl.S
X--- qemu-0.7.0/bsd.orig/amd64/s_floorl.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/s_floorl.S Fri Apr 29 02:24:32 2005
X@@ -0,0 +1,247 @@
X+/*
X+ * ================================================== ==
X+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
X+ *
X+ * Developed at SunPro, a Sun Microsystems, Inc. business.
X+ * Permission to use, copy, modify, and distribute this
X+ * software is freely granted, provided that this notice
X+ * is preserved.
X+ * ================================================== ==
X+ *
X+ * From: @(#)s_floor.c 5.1 93/09/24
X+ */
X+/* XXX: generated from src/lib/msun/src/s_floorl.c */
X+
X+#include
X+
X+__FBSDID("$FreeBSD: ports/emulators/qemu-devel/files/patch-libmath,v 1.4 2007/03/10 17:03:05 nox Exp $")
X+
X+ .file "s_floorl.c"
X+ .section .rodata.cst8,"aM",@progbits,8
X+ .p2align 3
X+.LC0:
X+ .long 2281731484
X+ .long 2117592124
X+ .section .rodata.cst4,"aM",@progbits,4
X+ .p2align 2
X+.LC2:
X+ .long 3212836864
X+ .text
X+ .p2align 4,,15
X+.globl floorl
X+ .type floorl, @function
X+floorl:
X+.LFB17:
X+ pushq %rbp
X+.LCFI0:
X+ pushq %rbx
X+.LCFI1:
X+ fldt 24(%rsp)
X+ movq $0, -16(%rsp)
X+ fld %st(0)
X+ fstpt -40(%rsp)
X+ movl -32(%rsp), %edi
X+ movq -40(%rsp), %rsi
X+ movl %edi, -16(%rsp)
X+ movl -16(%rsp), %r11d
X+ movq %rsi, -24(%rsp)
X+ movl %r11d, %r10d
X+ andl $32767, %r10d
X+ leal -16383(%r10), %r8d
X+ cmpl $30, %r8d
X+ jg .L2
X+ testl %r8d, %r8d
X+ js .L38
X+ movl -20(%rsp), %r9d
X+ leal 1(%r8), %ecx
X+ mov -24(%rsp), %eax
X+ movl $4294967295, %ebp
X+ movq %rsi, -40(%rsp)
X+ movl %edi, -32(%rsp)
X+ shrq %cl, %rbp
X+ mov %r9d, %ebx
X+ movq %rbx, %rdx
X+ andq %rbp, %rdx
X+ orq %rax, %rdx
X+ fldt -40(%rsp)
X+ je .L42
X+ ffreep %st(0)
X+ testb $-128, -15(%rsp)
X+ je .L12
X+ movl $31, %ecx
X+ movl $1, %eax
X+ subl %r8d, %ecx
X+ salq %cl, %rax
X+ addl %eax, %r9d
X+ mov %r9d, %eax
X+ cmpq %rbx, %rax
X+ jae .L32
X+ leal 1(%r10), %edx
X+ movl %r11d, %eax
X+ orl $-2147483648, %r9d
X+ andw $-32768, %ax
X+ andw $32767, %dx
X+ orl %edx, %eax
X+ movw %ax, -16(%rsp)
X+.L32:
X+ movl %r9d, -20(%rsp)
X+.L12:
X+ faddl .LC0(%rip)
X+ fldz
X+ fxch %st(1)
X+ fucomip %st(1), %st
X+ fstp %st(0)
X+ jbe .L31
X+ movl %ebp, %eax
X+ movl $0, -24(%rsp)
X+ notl %eax
X+ andl %eax, %r9d
X+ movl %r9d, -20(%rsp)
X+ .p2align 4,,7
X+.L31:
X+ movq -24(%rsp), %rsi
X+ movl -16(%rsp), %edi
X+ movq %rsi, -40(%rsp)
X+ movl %edi, -32(%rsp)
X+ fldt -40(%rsp)
X+ popq %rbx
X+ popq %rbp
X+ ret
X+ .p2align 4,,7
X+.L2:
X+ cmpl $62, %r8d
X+ jle .L45
X+.L44:
X+ ffreep %st(0)
X+.L17:
X+ movq %rsi, -40(%rsp)
X+ movl %edi, -32(%rsp)
X+ fldt -40(%rsp)
X+ popq %rbx
X+ popq %rbp
X+ ret
X+ .p2align 4,,7
X+.L45:
X+ movl -24(%rsp), %edx
X+ leal 1(%r8), %ecx
X+ movq $-1, %rbx
X+ movq %rsi, -40(%rsp)
X+ movl %edi, -32(%rsp)
X+ shrq %cl, %rbx
X+ mov %edx, %r9d
X+ testq %rbx, %r9
X+ fldt -40(%rsp)
X+ je .L42
X+ ffreep %st(0)
X+ testb $-128, -15(%rsp)
X+ je .L20
X+ cmpl $31, %r8d
X+ je .L36
X+ movl $63, %ecx
X+ movl $1, %eax
X+ subl %r8d, %ecx
X+ salq %cl, %rax
X+ leal (%rdx,%rax), %eax
X+ movl %eax, -24(%rsp)
X+ mov %eax, %eax
X+ cmpq %r9, %rax
X+ jae .L20
X+.L36:
X+ movl -20(%rsp), %eax
X+ leal 1(%rax), %ecx
X+ cmpl %eax, %ecx
X+ jae .L34
X+ leal 1(%r10), %edx
X+ movl %r11d, %eax
X+ orl $-2147483648, %ecx
X+ andw $-32768, %ax
X+ andw $32767, %dx
X+ orl %edx, %eax
X+ movw %ax, -16(%rsp)
X+.L34:
X+ movl %ecx, -20(%rsp)
X+ .p2align 4,,7
X+.L20:
X+ faddl .LC0(%rip)
X+ fldz
X+ fxch %st(1)
X+ fucomip %st(1), %st
X+ fstp %st(0)
X+ jbe .L31
X+ movl %ebx, %eax
X+ notl %eax
X+ andl %eax, -24(%rsp)
X+ jmp .L31
X+ .p2align 4,,7
X+.L42:
X+ fstp %st(1)
X+ popq %rbx
X+ popq %rbp
X+ ret
X+ .p2align 4,,7
X+.L38:
X+ fldl .LC0(%rip)
X+ faddp %st, %st(1)
X+ fldz
X+ fxch %st(1)
X+ fucomip %st(1), %st
X+ jbe .L44
X+ testl %r10d, %r10d
X+ jle .L39
X+.L7:
X+ testb $-128, -15(%rsp)
X+ je .L9
X+ ffreep %st(0)
X+ flds .LC2(%rip)
X+.L9:
X+ fstpt -40(%rsp)
X+ movq -40(%rsp), %rsi
X+ movl -32(%rsp), %edi
X+ movq %rsi, -24(%rsp)
X+ movl %edi, -16(%rsp)
X+ jmp .L17
X+.L39:
X+ movl -24(%rsp), %eax
X+ orl -20(%rsp), %eax
X+ je .L44
X+ jmp .L7
X+.LFE17:
X+ .size floorl, .-floorl
X+ .section .eh_frame,"a",@progbits
X+.Lframe1:
X+ .long .LECIE1-.LSCIE1
X+.LSCIE1:
X+ .long 0x0
X+ .byte 0x1
X+ .string ""
X+ .uleb128 0x1
X+ .sleb128 -8
X+ .byte 0x10
X+ .byte 0xc
X+ .uleb128 0x7
X+ .uleb128 0x8
X+ .byte 0x90
X+ .uleb128 0x1
X+ .p2align 3
X+.LECIE1:
X+.LSFDE1:
X+ .long .LEFDE1-.LASFDE1
X+.LASFDE1:
X+ .long .LASFDE1-.Lframe1
X+ .quad .LFB17
X+ .quad .LFE17-.LFB17
X+ .byte 0x4
X+ .long .LCFI0-.LFB17
X+ .byte 0xe
X+ .uleb128 0x10
X+ .byte 0x4
X+ .long .LCFI1-.LCFI0
X+ .byte 0xe
X+ .uleb128 0x18
X+ .byte 0x83
X+ .uleb128 0x3
X+ .byte 0x86
X+ .uleb128 0x2
X+ .p2align 3
X+.LEFDE1:
X+ .ident "GCC: (GNU) 3.4.4 [FreeBSD] 20050421"
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/s_isnormal.c qemu-0.7.0/bsd/amd64/s_isnormal.c
X--- qemu-0.7.0/bsd.orig/amd64/s_isnormal.c Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/s_isnormal.c Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,85 @@
X+/*-
X+ * Copyright (c) 2003 Mike Barcroft
X+ * Copyright (c) 2002-2004 David Schultz
X+ * All rights reserved.
X+ *
X+ * Redistribution and use in source and binary forms, with or without
X+ * modification, are permitted provided that the following conditions
X+ * are met:
X+ * 1. Redistributions of source code must retain the above copyright
X+ * notice, this list of conditions and the following disclaimer.
X+ * 2. Redistributions in binary form must reproduce the above copyright
X+ * notice, this list of conditions and the following disclaimer in the
X+ * documentation and/or other materials provided with the distribution.
X+ *
X+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
X+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
X+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X+ * SUCH DAMAGE.
X+ *
X+ * $FreeBSD: ports/emulators/qemu-devel/files/patch-libmath,v 1.4 2007/03/10 17:03:05 nox Exp $
X+ */
X+
X+union IEEEf2bits {
X+ float f;
X+ struct {
X+ unsigned int man :23;
X+ unsigned int exp :8;
X+ unsigned int sign :1;
X+ } bits;
X+};
X+
X+union IEEEd2bits {
X+ double d;
X+ struct {
X+ unsigned int manl :32;
X+ unsigned int manh :20;
X+ unsigned int exp :11;
X+ unsigned int sign :1;
X+ } bits;
X+};
X+
X+union IEEEl2bits {
X+ long double e;
X+ struct {
X+ unsigned int manl :32;
X+ unsigned int manh :32;
X+ unsigned int exp :15;
X+ unsigned int sign :1;
X+ unsigned int junk :16;
X+ } bits;
X+};
X+
X+int
X+__isnormal(double d)
X+{
X+ union IEEEd2bits u;
X+
X+ u.d = d;
X+ return (u.bits.exp != 0 && u.bits.exp != 2047);
X+}
X+
X+int
X+__isnormalf(float f)
X+{
X+ union IEEEf2bits u;
X+
X+ u.f = f;
X+ return (u.bits.exp != 0 && u.bits.exp != 255);
X+}
X+
X+int
X+__isnormall(long double e)
X+{
X+ union IEEEl2bits u;
X+
X+ u.e = e;
X+ return (u.bits.exp != 0 && u.bits.exp != 32767);
X+}
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/s_llrint.S qemu-0.7.0/bsd/amd64/s_llrint.S
X--- qemu-0.7.0/bsd.orig/amd64/s_llrint.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/s_llrint.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,6 @@
X+#include
X+__FBSDID("$FreeBSD: ports/emulators/qemu-devel/files/patch-libmath,v 1.4 2007/03/10 17:03:05 nox Exp $")
X+
X+/* sizeof(long) == sizeof(long long) */
X+#define fn llrint
X+#include "s_lrint.S"
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/s_llrintf.S qemu-0.7.0/bsd/amd64/s_llrintf.S
X--- qemu-0.7.0/bsd.orig/amd64/s_llrintf.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/s_llrintf.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,6 @@
X+#include
X+__FBSDID("$FreeBSD: ports/emulators/qemu-devel/files/patch-libmath,v 1.4 2007/03/10 17:03:05 nox Exp $")
X+
X+/* sizeof(long) == sizeof(long long) */
X+#define fn llrintf
X+#include "s_lrintf.S"
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/s_llrintl.S qemu-0.7.0/bsd/amd64/s_llrintl.S
X--- qemu-0.7.0/bsd.orig/amd64/s_llrintl.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/s_llrintl.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,35 @@
X+/* Round argument to nearest integral value according to current rounding
X+ direction.
X+ Copyright (C) 1997, 2002 Free Software Foundation, Inc.
X+ This file is part of the GNU C Library.
X+
X+ The GNU C Library is free software; you can redistribute it and/or
X+ modify it under the terms of the GNU Lesser General Public
X+ License as published by the Free Software Foundation; either
X+ version 2.1 of the License, or (at your option) any later version.
X+
X+ The GNU C Library is distributed in the hope that it will be useful,
X+ but WITHOUT ANY WARRANTY; without even the implied warranty of
X+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
X+ Lesser General Public License for more details.
X+
X+ You should have received a copy of the GNU Lesser General Public
X+ License along with the GNU C Library; if not, write to the Free
X+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
X+ 02111-1307 USA. */
X+
X+#include
X+#include
X+
X+ .text
X+ENTRY(__llrintl)
X+ fldt 8(%rsp)
X+ fistpll -8(%rsp)
X+ fwait
X+ movq -8(%rsp),%rax
X+ ret
X+END(__llrintl)
X+weak_alias (__llrintl, llrintl)
X+strong_alias (__llrintl, __lrintl)
X+weak_alias (__llrintl, lrintl)
X+
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/s_lrint.S qemu-0.7.0/bsd/amd64/s_lrint.S
X--- qemu-0.7.0/bsd.orig/amd64/s_lrint.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/s_lrint.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,36 @@
X+/*-
X+ * Copyright (c) 2005 David Schultz
X+ * All rights reserved.
X+ *
X+ * Redistribution and use in source and binary forms, with or without
X+ * modification, are permitted provided that the following conditions
X+ * are met:
X+ * 1. Redistributions of source code must retain the above copyright
X+ * notice, this list of conditions and the following disclaimer.
X+ * 2. Redistributions in binary form must reproduce the above copyright
X+ * notice, this list of conditions and the following disclaimer in the
X+ * documentation and/or other materials provided with the distribution.
X+ *
X+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
X+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
X+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X+ * SUCH DAMAGE.
X+ */
X+
X+#include
X+
X+#ifndef fn
X+__FBSDID("$FreeBSD: ports/emulators/qemu-devel/files/patch-libmath,v 1.4 2007/03/10 17:03:05 nox Exp $")
X+#define fn lrint
X+#endif
X+
X+ENTRY(fn)
X+ cvtsd2si %xmm0, %rax
X+ ret
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/s_lrintf.S qemu-0.7.0/bsd/amd64/s_lrintf.S
X--- qemu-0.7.0/bsd.orig/amd64/s_lrintf.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/s_lrintf.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,36 @@
X+/*-
X+ * Copyright (c) 2005 David Schultz
X+ * All rights reserved.
X+ *
X+ * Redistribution and use in source and binary forms, with or without
X+ * modification, are permitted provided that the following conditions
X+ * are met:
X+ * 1. Redistributions of source code must retain the above copyright
X+ * notice, this list of conditions and the following disclaimer.
X+ * 2. Redistributions in binary form must reproduce the above copyright
X+ * notice, this list of conditions and the following disclaimer in the
X+ * documentation and/or other materials provided with the distribution.
X+ *
X+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
X+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
X+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X+ * SUCH DAMAGE.
X+ */
X+
X+#include
X+
X+#ifndef fn
X+__FBSDID("$FreeBSD: ports/emulators/qemu-devel/files/patch-libmath,v 1.4 2007/03/10 17:03:05 nox Exp $")
X+#define fn lrintf
X+#endif
X+
X+ENTRY(fn)
X+ cvtss2si %xmm0, %rax
X+ ret
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/s_lrintl.S qemu-0.7.0/bsd/amd64/s_lrintl.S
X--- qemu-0.7.0/bsd.orig/amd64/s_lrintl.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/s_lrintl.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1 @@
X+/* Not needed, see s_llrintl.S. */
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/s_rintl.c qemu-0.7.0/bsd/amd64/s_rintl.c
X--- qemu-0.7.0/bsd.orig/amd64/s_rintl.c Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/s_rintl.c Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,18 @@
X+/*
X+ * Written by J.T. Conklin .
X+ * Changes for long double by Ulrich Drepper
X+ * Public domain.
X+ */
X+
X+#include
X+
X+long double
X+__rintl (long double x)
X+{
X+ long double res;
X+
X+ asm ("frndint" : "=t" (res) : "0" (x));
X+ return res;
X+}
X+
X+weak_alias (__rintl, rintl)
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/s_round.c qemu-0.7.0/bsd/amd64/s_round.c
X--- qemu-0.7.0/bsd.orig/amd64/s_round.c Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/s_round.c Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,51 @@
X+/*-
X+ * Copyright (c) 2003, Steven G. Kargl
X+ * All rights reserved.
X+ *
X+ * Redistribution and use in source and binary forms, with or without
X+ * modification, are permitted provided that the following conditions
X+ * are met:
X+ * 1. Redistributions of source code must retain the above copyright
X+ * notice unmodified, this list of conditions, and the following
X+ * disclaimer.
X+ * 2. Redistributions in binary form must reproduce the above copyright
X+ * notice, this list of conditions and the following disclaimer in the
X+ * documentation and/or other materials provided with the distribution.
X+ *
X+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
X+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
X+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
X+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
X+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
X+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
X+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
X+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
X+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
X+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
X+ */
X+
X+#include
X+__FBSDID("$FreeBSD: ports/emulators/qemu-devel/files/patch-libmath,v 1.4 2007/03/10 17:03:05 nox Exp $");
X+
X+#include
X+
X+double
X+round(double x)
X+{
X+ double t;
X+
X+ if (!isfinite(x))
X+ return (x);
X+
X+ if (x >= 0.0) {
X+ t = floor(x);
X+ if (t - x <= -0.5)
X+ t += 1.0;
X+ return (t);
X+ } else {
X+ t = floor(-x);
X+ if (t + x <= -0.5)
X+ t += 1.0;
X+ return (-t);
X+ }
X+}
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/s_sinl.S qemu-0.7.0/bsd/amd64/s_sinl.S
X--- qemu-0.7.0/bsd.orig/amd64/s_sinl.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/s_sinl.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,31 @@
X+/*
X+ * Written by J.T. Conklin .
X+ * Public domain.
X+ *
X+ * Adapted for `long double' by Ulrich Drepper .
X+ * Adapted for x86-64 by Andreas Jaeger .
X+ */
X+
X+#include
X+#include
X+
X+ENTRY(__sinl)
X+ fldt 8(%rsp)
X+ fsin
X+ fnstsw %ax
X+ testl $0x400,%eax
X+ jnz 1f
X+ ret
X+ .align ALIGNARG(4)
X+1: fldpi
X+ fadd %st(0)
X+ fxch %st(1)
X+2: fprem1
X+ fnstsw %ax
X+ testl $0x400,%eax
X+ jnz 2b
X+ fstp %st(1)
X+ fsin
X+ ret
X+END (__sinl)
X+weak_alias (__sinl, sinl)
Xdiff -Nru qemu-0.7.0/bsd.orig/amd64/s_tanl.S qemu-0.7.0/bsd/amd64/s_tanl.S
X--- qemu-0.7.0/bsd.orig/amd64/s_tanl.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/amd64/s_tanl.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,34 @@
X+/*
X+ * Written by J.T. Conklin .
X+ * Public domain.
X+ *
X+ * Adapted for `long double' by Ulrich Drepper .
X+ * Adapted for x86-64 by Andreas Jaeger .
X+ */
X+
X+#include
X+#include
X+
X+RCSID("$NetBSD: $")
X+
X+ENTRY(__tanl)
X+ fldt 8(%rsp)
X+ fptan
X+ fnstsw %ax
X+ testl $0x400,%eax
X+ jnz 1f
X+ fstp %st(0)
X+ ret
X+1: fldpi
X+ fadd %st(0)
X+ fxch %st(1)
X+2: fprem1
X+ fstsw %ax
X+ testl $0x400,%eax
X+ jnz 2b
X+ fstp %st(1)
X+ fptan
X+ fstp %st(0)
X+ ret
X+END (__tanl)
X+weak_alias (__tanl, tanl)
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/e_atan2l.c qemu-0.7.0/bsd/i386/e_atan2l.c
X--- qemu-0.7.0/bsd.orig/i386/e_atan2l.c Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/e_atan2l.c Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,20 @@
X+/*
X+ * Written by J.T. Conklin .
X+ * Public domain.
X+ *
X+ * Adapted for `long double' by Ulrich Drepper .
X+ */
X+
X+#include
X+
X+long double
X+__ieee754_atan2l (long double y, long double x)
X+{
X+ long double res;
X+
X+ asm ("fpatan" : "=t" (res) : "u" (y), "0" (x) : "st(1)");
X+
X+ return res;
X+}
X+
X+weak_alias(__ieee754_atan2l, atan2l)
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/e_logl.S qemu-0.7.0/bsd/i386/e_logl.S
X--- qemu-0.7.0/bsd.orig/i386/e_logl.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/e_logl.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,63 @@
X+/*
X+ * Written by J.T. Conklin .
X+ * Public domain.
X+ *
X+ * Adapted for `long double' by Ulrich Drepper .
X+ */
X+
X+#include
X+#include
X+
X+RCSID("$NetBSD: $")
X+
X+
X+#ifdef __ELF__
X+ .section .rodata
X+#else
X+ .text
X+#endif
X+ .align ALIGNARG(4)
X+ ASM_TYPE_DIRECTIVE(one,@object)
X+one: .double 1.0
X+ ASM_SIZE_DIRECTIVE(one)
X+ /* It is not important that this constant is precise. It is only
X+ a value which is known to be on the safe side for using the
X+ fyl2xp1 instruction. */
X+ ASM_TYPE_DIRECTIVE(limit,@object)
X+limit: .double 0.29
X+ ASM_SIZE_DIRECTIVE(limit)
X+
X+
X+#ifdef PIC
X+#define MO(op) op##@GOTOFF(%edx)
X+#else
X+#define MO(op) op
X+#endif
X+
X+ .text
X+ENTRY(__ieee754_logl)
X+ fldln2 // log(2)
X+ fldt 4(%esp) // x : log(2)
X+#ifdef PIC
X+ call 1f
X+1: popl %edx
X+ addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %edx
X+#endif
X+ fld %st // x : x : log(2)
X+ fsubl MO(one) // x-1 : x : log(2)
X+ fld %st // x-1 : x-1 : x : log(2)
X+ fabs // |x-1| : x-1 : x : log(2)
X+ fcompl MO(limit) // x-1 : x : log(2)
X+ fnstsw // x-1 : x : log(2)
X+ andb $0x45, %ah
X+ jz 2f
X+ fstp %st(1) // x-1 : log(2)
X+ fyl2xp1 // log(x)
X+ ret
X+
X+2: fstp %st(0) // x : log(2)
X+ fyl2x // log(x)
X+ ret
X+END (__ieee754_logl)
X+
X+weak_alias(__ieee754_logl,logl)
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/e_powl.S qemu-0.7.0/bsd/i386/e_powl.S
X--- qemu-0.7.0/bsd.orig/i386/e_powl.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/e_powl.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,341 @@
X+/* ix87 specific implementation of pow function.
X+ Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004
X+ Free Software Foundation, Inc.
X+ This file is part of the GNU C Library.
X+ Contributed by Ulrich Drepper , 1996.
X+
X+ The GNU C Library is free software; you can redistribute it and/or
X+ modify it under the terms of the GNU Lesser General Public
X+ License as published by the Free Software Foundation; either
X+ version 2.1 of the License, or (at your option) any later version.
X+
X+ The GNU C Library is distributed in the hope that it will be useful,
X+ but WITHOUT ANY WARRANTY; without even the implied warranty of
X+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
X+ Lesser General Public License for more details.
X+
X+ You should have received a copy of the GNU Lesser General Public
X+ License along with the GNU C Library; if not, write to the Free
X+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
X+ 02111-1307 USA. */
X+
X+#include
X+#include
X+
X+#ifdef __ELF__
X+ .section .rodata
X+#else
X+ .text
X+#endif
X+
X+ .align ALIGNARG(4)
X+ ASM_TYPE_DIRECTIVE(infinity,@object)
X+inf_zero:
X+infinity:
X+ .byte 0, 0, 0, 0, 0, 0, 0xf0, 0x7f
X+ ASM_SIZE_DIRECTIVE(infinity)
X+ ASM_TYPE_DIRECTIVE(zero,@object)
X+zero: .double 0.0
X+ ASM_SIZE_DIRECTIVE(zero)
X+ ASM_TYPE_DIRECTIVE(minf_mzero,@object)
X+minf_mzero:
X+minfinity:
X+ .byte 0, 0, 0, 0, 0, 0, 0xf0, 0xff
X+mzero:
X+ .byte 0, 0, 0, 0, 0, 0, 0, 0x80
X+ ASM_SIZE_DIRECTIVE(minf_mzero)
X+ ASM_TYPE_DIRECTIVE(one,@object)
X+one: .double 1.0
X+ ASM_SIZE_DIRECTIVE(one)
X+ ASM_TYPE_DIRECTIVE(limit,@object)
X+limit: .double 0.29
X+ ASM_SIZE_DIRECTIVE(limit)
X+ ASM_TYPE_DIRECTIVE(p63,@object)
X+p63: .byte 0, 0, 0, 0, 0, 0, 0xe0, 0x43
X+ ASM_SIZE_DIRECTIVE(p63)
X+
X+#ifdef PIC
X+#define MO(op) op##@GOTOFF(%ecx)
X+#define MOX(op,x,f) op##@GOTOFF(%ecx,x,f)
X+#else
X+#define MO(op) op
X+#define MOX(op,x,f) op(,x,f)
X+#endif
X+
X+ .text
X+ENTRY(__ieee754_powl)
X+ fldt 16(%esp) // y
X+ fxam
X+
X+#ifdef PIC
X+ call 1f
X+1: popl %ecx
X+ addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ecx
X+#endif
X+
X+ fnstsw
X+ movb %ah, %dl
X+ andb $0x45, %ah
X+ cmpb $0x40, %ah // is y == 0 ?
X+ je 11f
X+
X+ cmpb $0x05, %ah // is y == ±inf ?
X+ je 12f
X+
X+ cmpb $0x01, %ah // is y == NaN ?
X+ je 30f
X+
X+ fldt 4(%esp) // x : y
X+
X+ subl $8,%esp
X+
X+ fxam
X+ fnstsw
X+ movb %ah, %dh
X+ andb $0x45, %ah
X+ cmpb $0x40, %ah
X+ je 20f // x is ±0
X+
X+ cmpb $0x05, %ah
X+ je 15f // x is ±inf
X+
X+ fxch // y : x
X+
X+ /* fistpll raises invalid exception for |y| >= 1L<<63. */
X+ fld %st // y : y : x
X+ fabs // |y| : y : x
X+ fcompl MO(p63) // y : x
X+ fnstsw
X+ sahf
X+ jnc 2f
X+
X+ /* First see whether `y' is a natural number. In this case we
X+ can use a more precise algorithm. */
X+ fld %st // y : y : x
X+ fistpll (%esp) // y : x
X+ fildll (%esp) // int(y) : y : x
X+ fucomp %st(1) // y : x
X+ fnstsw
X+ sahf
X+ jne 2f
X+
X+ /* OK, we have an integer value for y. */
X+ popl %eax
X+ popl %edx
X+ orl $0, %edx
X+ fstp %st(0) // x
X+ jns 4f // y >= 0, jump
X+ fdivrl MO(one) // 1/x (now referred to as x)
X+ negl %eax
X+ adcl $0, %edx
X+ negl %edx
X+4: fldl MO(one) // 1 : x
X+ fxch
X+
X+6: shrdl $1, %edx, %eax
X+ jnc 5f
X+ fxch
X+ fmul %st(1) // x : ST*x
X+ fxch
X+5: fmul %st(0), %st // x*x : ST*x
X+ shrl $1, %edx
X+ movl %eax, %ecx
X+ orl %edx, %ecx
X+ jnz 6b
X+ fstp %st(0) // ST*x
X+ ret
X+
X+ /* y is ±NAN */
X+30: fldt 4(%esp) // x : y
X+ fldl MO(one) // 1.0 : x : y
X+ fucomp %st(1) // x : y
X+ fnstsw
X+ sahf
X+ je 31f
X+ fxch // y : x
X+31: fstp %st(1)
X+ ret
X+
X+ .align ALIGNARG(4)
X+2: /* y is a real number. */
X+ fxch // x : y
X+ fldl MO(one) // 1.0 : x : y
X+ fld %st(1) // x : 1.0 : x : y
X+ fsub %st(1) // x-1 : 1.0 : x : y
X+ fabs // |x-1| : 1.0 : x : y
X+ fcompl MO(limit) // 1.0 : x : y
X+ fnstsw
X+ fxch // x : 1.0 : y
X+ sahf
X+ ja 7f
X+ fsub %st(1) // x-1 : 1.0 : y
X+ fyl2xp1 // log2(x) : y
X+ jmp 8f
X+
X+7: fyl2x // log2(x) : y
X+8: fmul %st(1) // y*log2(x) : y
X+ fxam
X+ fnstsw
X+ andb $0x45, %ah
X+ cmpb $0x05, %ah // is y*log2(x) == ±inf ?
X+ je 28f
X+ fst %st(1) // y*log2(x) : y*log2(x)
X+ frndint // int(y*log2(x)) : y*log2(x)
X+ fsubr %st, %st(1) // int(y*log2(x)) : fract(y*log2(x))
X+ fxch // fract(y*log2(x)) : int(y*log2(x))
X+ f2xm1 // 2^fract(y*log2(x))-1 : int(y*log2(x))
X+ faddl MO(one) // 2^fract(y*log2(x)) : int(y*log2(x))
X+ fscale // 2^fract(y*log2(x))*2^int(y*log2(x)) : int(y*log2(x))
X+ addl $8, %esp
X+ fstp %st(1) // 2^fract(y*log2(x))*2^int(y*log2(x))
X+ ret
X+
X+28: fstp %st(1) // y*log2(x)
X+ fldl MO(one) // 1 : y*log2(x)
X+ fscale // 2^(y*log2(x)) : y*log2(x)
X+ addl $8, %esp
X+ fstp %st(1) // 2^(y*log2(x))
X+ ret
X+
X+ // pow(x,±0) = 1
X+ .align ALIGNARG(4)
X+11: fstp %st(0) // pop y
X+ fldl MO(one)
X+ ret
X+
X+ // y == ±inf
X+ .align ALIGNARG(4)
X+12: fstp %st(0) // pop y
X+ fldt 4(%esp) // x
X+ fabs
X+ fcompl MO(one) // < 1, == 1, or > 1
X+ fnstsw
X+ andb $0x45, %ah
X+ cmpb $0x45, %ah
X+ je 13f // jump if x is NaN
X+
X+ cmpb $0x40, %ah
X+ je 14f // jump if |x| == 1
X+
X+ shlb $1, %ah
X+ xorb %ah, %dl
X+ andl $2, %edx
X+ fldl MOX(inf_zero, %edx, 4)
X+ ret
X+
X+ .align ALIGNARG(4)
X+14: fldl MO(one)
X+ ret
X+
X+ .align ALIGNARG(4)
X+13: fldt 4(%esp) // load x == NaN
X+ ret
X+
X+ .align ALIGNARG(4)
X+ // x is ±inf
X+15: fstp %st(0) // y
X+ testb $2, %dh
X+ jz 16f // jump if x == +inf
X+
X+ // We must find out whether y is an odd integer.
X+ fld %st // y : y
X+ fistpll (%esp) // y
X+ fildll (%esp) // int(y) : y
X+ fucompp //
X+ fnstsw
X+ sahf
X+ jne 17f
X+
X+ // OK, the value is an integer, but is it odd?
X+ popl %eax
X+ popl %edx
X+ andb $1, %al
X+ jz 18f // jump if not odd
X+ // It's an odd integer.
X+ shrl $31, %edx
X+ fldl MOX(minf_mzero, %edx, 8)
X+ ret
X+
X+ .align ALIGNARG(4)
X+16: fcompl MO(zero)
X+ addl $8, %esp
X+ fnstsw
X+ shrl $5, %eax
X+ andl $8, %eax
X+ fldl MOX(inf_zero, %eax, 1)
X+ ret
X+
X+ .align ALIGNARG(4)
X+17: shll $30, %edx // sign bit for y in right position
X+ addl $8, %esp
X+18: shrl $31, %edx
X+ fldl MOX(inf_zero, %edx, 8)
X+ ret
X+
X+ .align ALIGNARG(4)
X+ // x is ±0
X+20: fstp %st(0) // y
X+ testb $2, %dl
X+ jz 21f // y > 0
X+
X+ // x is ±0 and y is < 0. We must find out whether y is an odd integer.
X+ testb $2, %dh
X+ jz 25f
X+
X+ fld %st // y : y
X+ fistpll (%esp) // y
X+ fildll (%esp) // int(y) : y
X+ fucompp //
X+ fnstsw
X+ sahf
X+ jne 26f
X+
X+ // OK, the value is an integer, but is it odd?
X+ popl %eax
X+ popl %edx
X+ andb $1, %al
X+ jz 27f // jump if not odd
X+ // It's an odd integer.
X+ // Raise divide-by-zero exception and get minus infinity value.
X+ fldl MO(one)
X+ fdivl MO(zero)
X+ fchs
X+ ret
X+
X+25: fstp %st(0)
X+26: addl $8, %esp
X+27: // Raise divide-by-zero exception and get infinity value.
X+ fldl MO(one)
X+ fdivl MO(zero)
X+ ret
X+
X+ .align ALIGNARG(4)
X+ // x is ±0 and y is > 0. We must find out whether y is an odd integer.
X+21: testb $2, %dh
X+ jz 22f
X+
X+ fld %st // y : y
X+ fistpll (%esp) // y
X+ fildll (%esp) // int(y) : y
X+ fucompp //
X+ fnstsw
X+ sahf
X+ jne 23f
X+
X+ // OK, the value is an integer, but is it odd?
X+ popl %eax
X+ popl %edx
X+ andb $1, %al
X+ jz 24f // jump if not odd
X+ // It's an odd integer.
X+ fldl MO(mzero)
X+ ret
X+
X+22: fstp %st(0)
X+23: addl $8, %esp // Don't use 2 x pop
X+24: fldl MO(zero)
X+ ret
X+
X+END(__ieee754_powl)
X+
X+weak_alias(__ieee754_powl,powl)
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/e_remainderl.S qemu-0.7.0/bsd/i386/e_remainderl.S
X--- qemu-0.7.0/bsd.orig/i386/e_remainderl.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/e_remainderl.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,24 @@
X+/*
X+ * Written by J.T. Conklin .
X+ * Public domain.
X+ *
X+ * Adapted for `long double' by Ulrich Drepper .
X+ */
X+
X+#include
X+#include
X+
X+RCSID("$NetBSD: $")
X+
X+ENTRY(__ieee754_remainderl)
X+ fldt 16(%esp)
X+ fldt 4(%esp)
X+1: fprem1
X+ fstsw %ax
X+ sahf
X+ jp 1b
X+ fstp %st(1)
X+ ret
X+END (__ieee754_remainderl)
X+
X+weak_alias(__ieee754_remainderl,remainderl)
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/e_sqrtl.c qemu-0.7.0/bsd/i386/e_sqrtl.c
X--- qemu-0.7.0/bsd.orig/i386/e_sqrtl.c Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/e_sqrtl.c Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,20 @@
X+/*
X+ * Written by J.T. Conklin .
X+ * Public domain.
X+ *
X+ * Adapted for `long double' by Ulrich Drepper .
X+ */
X+
X+#include
X+
X+long double
X+__ieee754_sqrtl (long double x)
X+{
X+ long double res;
X+
X+ asm ("fsqrt" : "=t" (res) : "0" (x));
X+
X+ return res;
X+}
X+
X+weak_alias(__ieee754_sqrtl,sqrtl)
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/s_ceill.S qemu-0.7.0/bsd/i386/s_ceill.S
X--- qemu-0.7.0/bsd.orig/i386/s_ceill.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/s_ceill.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,27 @@
X+/*
X+ * Based on code written by J.T. Conklin .
X+ * Public domain.
X+ */
X+
X+#include
X+RCSID("$FreeBSD: ports/emulators/qemu-devel/files/patch-libmath,v 1.4 2007/03/10 17:03:05 nox Exp $")
X+
X+ENTRY(ceill)
X+ pushl %ebp
X+ movl %esp,%ebp
X+ subl $8,%esp
X+
X+ fstcw -4(%ebp) /* store fpu control word */
X+ movw -4(%ebp),%dx
X+ orw $0x0800,%dx /* round towards +oo */
X+ andw $0xfbff,%dx
X+ movw %dx,-8(%ebp)
X+ fldcw -8(%ebp) /* load modfied control word */
X+
X+ fldt 8(%ebp) /* round */
X+ frndint
X+
X+ fldcw -4(%ebp) /* restore original control word */
X+
X+ leave
X+ ret
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/s_cosl.S qemu-0.7.0/bsd/i386/s_cosl.S
X--- qemu-0.7.0/bsd.orig/i386/s_cosl.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/s_cosl.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,32 @@
X+/*
X+ * Written by J.T. Conklin .
X+ * Public domain.
X+ *
X+ * Adapted for `long double' by Ulrich Drepper .
X+ */
X+
X+#include
X+#include
X+
X+RCSID("$NetBSD: $")
X+
X+ENTRY(__cosl)
X+ fldt 4(%esp)
X+ fcos
X+ fnstsw %ax
X+ testl $0x400,%eax
X+ jnz 1f
X+ ret
X+ .align ALIGNARG(4)
X+1: fldpi
X+ fadd %st(0)
X+ fxch %st(1)
X+2: fprem1
X+ fnstsw %ax
X+ testl $0x400,%eax
X+ jnz 2b
X+ fstp %st(1)
X+ fcos
X+ ret
X+END (__cosl)
X+weak_alias (__cosl, cosl)
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/s_floorl.S qemu-0.7.0/bsd/i386/s_floorl.S
X--- qemu-0.7.0/bsd.orig/i386/s_floorl.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/s_floorl.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,27 @@
X+/*
X+ * Based on code written by J.T. Conklin .
X+ * Public domain.
X+ */
X+
X+#include
X+RCSID("$FreeBSD: ports/emulators/qemu-devel/files/patch-libmath,v 1.4 2007/03/10 17:03:05 nox Exp $")
X+
X+ENTRY(floorl)
X+ pushl %ebp
X+ movl %esp,%ebp
X+ subl $8,%esp
X+
X+ fstcw -4(%ebp) /* store fpu control word */
X+ movw -4(%ebp),%dx
X+ orw $0x0400,%dx /* round towards -oo */
X+ andw $0xf7ff,%dx
X+ movw %dx,-8(%ebp)
X+ fldcw -8(%ebp) /* load modfied control word */
X+
X+ fldt 8(%ebp) /* round */
X+ frndint
X+
X+ fldcw -4(%ebp) /* restore original control word */
X+
X+ leave
X+ ret
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/s_isnormal.c qemu-0.7.0/bsd/i386/s_isnormal.c
X--- qemu-0.7.0/bsd.orig/i386/s_isnormal.c Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/s_isnormal.c Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,85 @@
X+/*-
X+ * Copyright (c) 2003 Mike Barcroft
X+ * Copyright (c) 2002-2004 David Schultz
X+ * All rights reserved.
X+ *
X+ * Redistribution and use in source and binary forms, with or without
X+ * modification, are permitted provided that the following conditions
X+ * are met:
X+ * 1. Redistributions of source code must retain the above copyright
X+ * notice, this list of conditions and the following disclaimer.
X+ * 2. Redistributions in binary form must reproduce the above copyright
X+ * notice, this list of conditions and the following disclaimer in the
X+ * documentation and/or other materials provided with the distribution.
X+ *
X+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
X+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
X+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X+ * SUCH DAMAGE.
X+ *
X+ * $FreeBSD: ports/emulators/qemu-devel/files/patch-libmath,v 1.4 2007/03/10 17:03:05 nox Exp $
X+ */
X+
X+union IEEEf2bits {
X+ float f;
X+ struct {
X+ unsigned int man :23;
X+ unsigned int exp :8;
X+ unsigned int sign :1;
X+ } bits;
X+};
X+
X+union IEEEd2bits {
X+ double d;
X+ struct {
X+ unsigned int manl :32;
X+ unsigned int manh :20;
X+ unsigned int exp :11;
X+ unsigned int sign :1;
X+ } bits;
X+};
X+
X+union IEEEl2bits {
X+ long double e;
X+ struct {
X+ unsigned int manl :32;
X+ unsigned int manh :32;
X+ unsigned int exp :15;
X+ unsigned int sign :1;
X+ unsigned int junk :16;
X+ } bits;
X+};
X+
X+int
X+__isnormal(double d)
X+{
X+ union IEEEd2bits u;
X+
X+ u.d = d;
X+ return (u.bits.exp != 0 && u.bits.exp != 2047);
X+}
X+
X+int
X+__isnormalf(float f)
X+{
X+ union IEEEf2bits u;
X+
X+ u.f = f;
X+ return (u.bits.exp != 0 && u.bits.exp != 255);
X+}
X+
X+int
X+__isnormall(long double e)
X+{
X+ union IEEEl2bits u;
X+
X+ u.e = e;
X+ return (u.bits.exp != 0 && u.bits.exp != 32767);
X+}
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/s_llrint.S qemu-0.7.0/bsd/i386/s_llrint.S
X--- qemu-0.7.0/bsd.orig/i386/s_llrint.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/s_llrint.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,36 @@
X+/*-
X+ * Copyright (c) 2005 David Schultz
X+ * All rights reserved.
X+ *
X+ * Redistribution and use in source and binary forms, with or without
X+ * modification, are permitted provided that the following conditions
X+ * are met:
X+ * 1. Redistributions of source code must retain the above copyright
X+ * notice, this list of conditions and the following disclaimer.
X+ * 2. Redistributions in binary form must reproduce the above copyright
X+ * notice, this list of conditions and the following disclaimer in the
X+ * documentation and/or other materials provided with the distribution.
X+ *
X+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
X+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
X+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X+ * SUCH DAMAGE.
X+ */
X+
X+#include
X+RCSID("$FreeBSD: ports/emulators/qemu-devel/files/patch-libmath,v 1.4 2007/03/10 17:03:05 nox Exp $");
X+
X+ENTRY(llrint)
X+ fldl 4(%esp)
X+ subl $8,%esp
X+ fistpll (%esp)
X+ popl %eax
X+ popl %edx
X+ ret
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/s_llrintf.S qemu-0.7.0/bsd/i386/s_llrintf.S
X--- qemu-0.7.0/bsd.orig/i386/s_llrintf.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/s_llrintf.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,36 @@
X+/*-
X+ * Copyright (c) 2005 David Schultz
X+ * All rights reserved.
X+ *
X+ * Redistribution and use in source and binary forms, with or without
X+ * modification, are permitted provided that the following conditions
X+ * are met:
X+ * 1. Redistributions of source code must retain the above copyright
X+ * notice, this list of conditions and the following disclaimer.
X+ * 2. Redistributions in binary form must reproduce the above copyright
X+ * notice, this list of conditions and the following disclaimer in the
X+ * documentation and/or other materials provided with the distribution.
X+ *
X+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
X+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
X+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X+ * SUCH DAMAGE.
X+ */
X+
X+#include
X+RCSID("$FreeBSD: ports/emulators/qemu-devel/files/patch-libmath,v 1.4 2007/03/10 17:03:05 nox Exp $")
X+
X+ENTRY(llrintf)
X+ flds 4(%esp)
X+ subl $8,%esp
X+ fistpll (%esp)
X+ popl %eax
X+ popl %edx
X+ ret
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/s_llrintl.S qemu-0.7.0/bsd/i386/s_llrintl.S
X--- qemu-0.7.0/bsd.orig/i386/s_llrintl.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/s_llrintl.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,35 @@
X+/* Round argument to nearest integral value according to current rounding
X+ direction.
X+ Copyright (C) 1997 Free Software Foundation, Inc.
X+ This file is part of the GNU C Library.
X+ Contributed by Ulrich Drepper , 1997.
X+
X+ The GNU C Library is free software; you can redistribute it and/or
X+ modify it under the terms of the GNU Lesser General Public
X+ License as published by the Free Software Foundation; either
X+ version 2.1 of the License, or (at your option) any later version.
X+
X+ The GNU C Library is distributed in the hope that it will be useful,
X+ but WITHOUT ANY WARRANTY; without even the implied warranty of
X+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
X+ Lesser General Public License for more details.
X+
X+ You should have received a copy of the GNU Lesser General Public
X+ License along with the GNU C Library; if not, write to the Free
X+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
X+ 02111-1307 USA. */
X+
X+#include
X+#include
X+
X+ .text
X+ENTRY(__llrintl)
X+ fldt 4(%esp)
X+ subl $8, %esp
X+ fistpll (%esp)
X+ fwait
X+ popl %eax
X+ popl %edx
X+ ret
X+END(__llrintl)
X+weak_alias (__llrintl, llrintl)
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/s_lrint.S qemu-0.7.0/bsd/i386/s_lrint.S
X--- qemu-0.7.0/bsd.orig/i386/s_lrint.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/s_lrint.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,35 @@
X+/*-
X+ * Copyright (c) 2005 David Schultz
X+ * All rights reserved.
X+ *
X+ * Redistribution and use in source and binary forms, with or without
X+ * modification, are permitted provided that the following conditions
X+ * are met:
X+ * 1. Redistributions of source code must retain the above copyright
X+ * notice, this list of conditions and the following disclaimer.
X+ * 2. Redistributions in binary form must reproduce the above copyright
X+ * notice, this list of conditions and the following disclaimer in the
X+ * documentation and/or other materials provided with the distribution.
X+ *
X+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
X+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
X+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X+ * SUCH DAMAGE.
X+ */
X+
X+#include
X+RCSID("$FreeBSD: ports/emulators/qemu-devel/files/patch-libmath,v 1.4 2007/03/10 17:03:05 nox Exp $");
X+
X+ENTRY(lrint)
X+ fldl 4(%esp)
X+ subl $4,%esp
X+ fistpl (%esp)
X+ popl %eax
X+ ret
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/s_lrintf.S qemu-0.7.0/bsd/i386/s_lrintf.S
X--- qemu-0.7.0/bsd.orig/i386/s_lrintf.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/s_lrintf.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,35 @@
X+/*-
X+ * Copyright (c) 2005 David Schultz
X+ * All rights reserved.
X+ *
X+ * Redistribution and use in source and binary forms, with or without
X+ * modification, are permitted provided that the following conditions
X+ * are met:
X+ * 1. Redistributions of source code must retain the above copyright
X+ * notice, this list of conditions and the following disclaimer.
X+ * 2. Redistributions in binary form must reproduce the above copyright
X+ * notice, this list of conditions and the following disclaimer in the
X+ * documentation and/or other materials provided with the distribution.
X+ *
X+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
X+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
X+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X+ * SUCH DAMAGE.
X+ */
X+
X+#include
X+RCSID("$FreeBSD: ports/emulators/qemu-devel/files/patch-libmath,v 1.4 2007/03/10 17:03:05 nox Exp $")
X+
X+ENTRY(lrintf)
X+ flds 4(%esp)
X+ subl $4,%esp
X+ fistpl (%esp)
X+ popl %eax
X+ ret
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/s_lrintl.S qemu-0.7.0/bsd/i386/s_lrintl.S
X--- qemu-0.7.0/bsd.orig/i386/s_lrintl.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/s_lrintl.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,34 @@
X+/* Round argument to nearest integral value according to current rounding
X+ direction.
X+ Copyright (C) 1997 Free Software Foundation, Inc.
X+ This file is part of the GNU C Library.
X+ Contributed by Ulrich Drepper , 1997.
X+
X+ The GNU C Library is free software; you can redistribute it and/or
X+ modify it under the terms of the GNU Lesser General Public
X+ License as published by the Free Software Foundation; either
X+ version 2.1 of the License, or (at your option) any later version.
X+
X+ The GNU C Library is distributed in the hope that it will be useful,
X+ but WITHOUT ANY WARRANTY; without even the implied warranty of
X+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
X+ Lesser General Public License for more details.
X+
X+ You should have received a copy of the GNU Lesser General Public
X+ License along with the GNU C Library; if not, write to the Free
X+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
X+ 02111-1307 USA. */
X+
X+#include
X+#include
X+
X+ .text
X+ENTRY(__lrintl)
X+ fldt 4(%esp)
X+ subl $4, %esp
X+ fistpl (%esp)
X+ fwait
X+ popl %eax
X+ ret
X+END(__lrintl)
X+weak_alias (__lrintl, lrintl)
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/s_rintl.c qemu-0.7.0/bsd/i386/s_rintl.c
X--- qemu-0.7.0/bsd.orig/i386/s_rintl.c Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/s_rintl.c Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,18 @@
X+/*
X+ * Written by J.T. Conklin .
X+ * Changes for long double by Ulrich Drepper
X+ * Public domain.
X+ */
X+
X+#include
X+
X+long double
X+__rintl (long double x)
X+{
X+ long double res;
X+
X+ asm ("frndint" : "=t" (res) : "0" (x));
X+ return res;
X+}
X+
X+weak_alias (__rintl, rintl)
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/s_round.c qemu-0.7.0/bsd/i386/s_round.c
X--- qemu-0.7.0/bsd.orig/i386/s_round.c Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/s_round.c Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,51 @@
X+/*-
X+ * Copyright (c) 2003, Steven G. Kargl
X+ * All rights reserved.
X+ *
X+ * Redistribution and use in source and binary forms, with or without
X+ * modification, are permitted provided that the following conditions
X+ * are met:
X+ * 1. Redistributions of source code must retain the above copyright
X+ * notice unmodified, this list of conditions, and the following
X+ * disclaimer.
X+ * 2. Redistributions in binary form must reproduce the above copyright
X+ * notice, this list of conditions and the following disclaimer in the
X+ * documentation and/or other materials provided with the distribution.
X+ *
X+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
X+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
X+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
X+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
X+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
X+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
X+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
X+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
X+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
X+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
X+ */
X+
X+#include
X+__FBSDID("$FreeBSD: ports/emulators/qemu-devel/files/patch-libmath,v 1.4 2007/03/10 17:03:05 nox Exp $");
X+
X+#include
X+
X+double
X+round(double x)
X+{
X+ double t;
X+
X+ if (!isfinite(x))
X+ return (x);
X+
X+ if (x >= 0.0) {
X+ t = floor(x);
X+ if (t - x <= -0.5)
X+ t += 1.0;
X+ return (t);
X+ } else {
X+ t = floor(-x);
X+ if (t + x <= -0.5)
X+ t += 1.0;
X+ return (-t);
X+ }
X+}
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/s_sinl.S qemu-0.7.0/bsd/i386/s_sinl.S
X--- qemu-0.7.0/bsd.orig/i386/s_sinl.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/s_sinl.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,32 @@
X+/*
X+ * Written by J.T. Conklin .
X+ * Public domain.
X+ *
X+ * Adapted for `long double' by Ulrich Drepper .
X+ */
X+
X+#include
X+#include
X+
X+RCSID("$NetBSD: $")
X+
X+ENTRY(__sinl)
X+ fldt 4(%esp)
X+ fsin
X+ fnstsw %ax
X+ testl $0x400,%eax
X+ jnz 1f
X+ ret
X+ .align ALIGNARG(4)
X+1: fldpi
X+ fadd %st(0)
X+ fxch %st(1)
X+2: fprem1
X+ fnstsw %ax
X+ testl $0x400,%eax
X+ jnz 2b
X+ fstp %st(1)
X+ fsin
X+ ret
X+END (__sinl)
X+weak_alias (__sinl, sinl)
Xdiff -Nru qemu-0.7.0/bsd.orig/i386/s_tanl.S qemu-0.7.0/bsd/i386/s_tanl.S
X--- qemu-0.7.0/bsd.orig/i386/s_tanl.S Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/i386/s_tanl.S Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,33 @@
X+/*
X+ * Written by J.T. Conklin .
X+ * Public domain.
X+ *
X+ * Adapted for `long double' by Ulrich Drepper .
X+ */
X+
X+#include
X+#include
X+
X+RCSID("$NetBSD: $")
X+
X+ENTRY(__tanl)
X+ fldt 4(%esp)
X+ fptan
X+ fnstsw %ax
X+ testl $0x400,%eax
X+ jnz 1f
X+ fstp %st(0)
X+ ret
X+1: fldpi
X+ fadd %st(0)
X+ fxch %st(1)
X+2: fprem1
X+ fstsw %ax
X+ testl $0x400,%eax
X+ jnz 2b
X+ fstp %st(1)
X+ fptan
X+ fstp %st(0)
X+ ret
X+END (__tanl)
X+weak_alias (__tanl, tanl)
Xdiff -Nru qemu-0.7.0/bsd.orig/sysdep.h qemu-0.7.0/bsd/sysdep.h
X--- qemu-0.7.0/bsd.orig/sysdep.h Wed Dec 31 19:00:00 1969
X+++ qemu-0.7.0/bsd/sysdep.h Fri Apr 29 02:11:27 2005
X@@ -0,0 +1,20 @@
X+#ifndef _QEMU_BSD_SYSDEP_H_
X+#define _QEMU_BSD_SYSDEP_H_
X+
X+#include
X+
X+#define HAVE_ELF
X+
X+#ifdef __ASSEMBLER__
X+#define ALIGNARG(log2) 1< X+#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
X+#define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
X+#define END(x)
X+#define strong_alias(sym,alias) .set alias,sym;
X+#define weak_alias(sym,alias) .weak alias; .equ alias,sym;
X+#else
X+#define strong_alias(sym,alias) __strong_reference(sym,alias);
X+#define weak_alias(sym,alias) __weak_reference(sym,alias);
X+#endif
X+
X+#endif
END-of-files/patch-libmath
echo x - files/patch-libmath2
sed 's/^X//' >files/patch-libmath2 << 'END-of-files/patch-libmath2'
XIndex: qemu/bsd/Makefile
X@@ -16,7 +16,8 @@
X ${MACHINE_ARCH}/s_rintl.c \
X ${MACHINE_ARCH}/s_round.c \
X ${MACHINE_ARCH}/s_sinl.S \
X- ${MACHINE_ARCH}/s_tanl.S
X+ ${MACHINE_ARCH}/s_tanl.S \
X+ ${MACHINE_ARCH}/s_ldexpl.c
X
X OBJS= ${SRCS:R:S/$/.o/}
X
XIndex: qemu/bsd/i386/s_ldexpl.c
X@@ -0,0 +1,21 @@
X+#include
X+#include
X+#include
X+
X+long double __ldexpl(long double x, int expn)
X+{
X+ long double res;
X+ if (!isfinite (x) || x == 0.0L)
X+ return x;
X+
X+ __asm__ ("fscale"
X+ : "=t" (res)
X+ : "0" (x), "u" ((long double) expn));
X+
X+ if (!isfinite (res) || res == 0.0L)
X+ errno = ERANGE;
X+
X+ return res;
X+}
X+
X+weak_alias(__ldexpl,ldexpl)
XIndex: qemu/bsd/amd64/s_ldexpl.c
X@@ -0,0 +1,21 @@
X+#include
X+#include
X+#include
X+
X+long double __ldexpl(long double x, int expn)
X+{
X+ long double res;
X+ if (!isfinite (x) || x == 0.0L)
X+ return x;
X+
X+ __asm__ ("fscale"
X+ : "=t" (res)
X+ : "0" (x), "u" ((long double) expn));
X+
X+ if (!isfinite (res) || res == 0.0L)
X+ errno = ERANGE;
X+
X+ return res;
X+}
X+
X+weak_alias(__ldexpl,ldexpl)
END-of-files/patch-libmath2
echo x - files/patch-libmath4
sed 's/^X//' >files/patch-libmath4 << 'END-of-files/patch-libmath4'
XIndex: qemu/bsd/i386/s_ldexpl.c
X@@ -2,6 +2,30 @@
X #include
X #include
X
X+/* 4.x doesnt have isfinite */
X+#ifndef isfinite
X+#define isfinite __isfinitel
X+
X+union IEEEl2bits {
X+ long double e;
X+ struct {
X+ unsigned int manl :32;
X+ unsigned int manh :32;
X+ unsigned int exp :15;
X+ unsigned int sign :1;
X+ unsigned int junk :16;
X+ } bits;
X+};
X+
X+static int __isfinitel(long double x)
X+{
X+ union IEEEl2bits u;
X+
X+ u.e = x;
X+ return (u.bits.exp != 32767);
X+}
X+#endif
X+
X long double __ldexpl(long double x, int expn)
X {
X long double res;
XIndex: qemu/bsd/i386/s_round.c
X@@ -29,6 +29,11 @@
X
X #include
X
X+/* 4.x doesnt have isfinite */
X+#ifndef isfinite
X+#define isfinite(x) (!isnan(x) && !isinf(x))
X+#endif
X+
X double
X round(double x)
X {
END-of-files/patch-libmath4
echo x - files/patch-osdep.c
sed 's/^X//' >files/patch-osdep.c << 'END-of-files/patch-osdep.c'
XIndex: qemu/osdep.c
X@@ -75,8 +75,10 @@
X #include
X #include
X #else
X+#ifndef __FreeBSD__
X #include
X #endif
X+#endif
X
X #include
X #include
X@@ -87,7 +87,7 @@
X static int phys_ram_size = 0;
X void *ptr;
X
X-#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */
X+#if defined(__OpenBSD__) || defined(__FreeBSD__) /* no need (?) for a dummy file on OpenBSD/FreeBSD */
X int map_anon = MAP_ANON;
X #else
X int map_anon = 0;
X@@ -154,7 +154,7 @@
X }
X size = (size + 4095) & ~4095;
X ftruncate(phys_ram_fd, phys_ram_size + size);
X-#endif /* !__OpenBSD__ */
X+#endif /* !(__OpenBSD__ || __FreeBSD__) */
X ptr = mmap(NULL,
X size,
X PROT_WRITE | PROT_READ, map_anon | MAP_SHARED,
END-of-files/patch-osdep.c
echo x - files/patch-qemu-doc.texi
sed 's/^X//' >files/patch-qemu-doc.texi << 'END-of-files/patch-qemu-doc.texi'
XIndex: qemu/qemu-doc.texi
X@@ -985,7 +985,8 @@
X
X @c man begin SEEALSO
X The HTML documentation of QEMU for more precise information and Linux
X-user mode emulator invocation.
X+user mode emulator invocation, as well as the FreeBSD host notes in
X+@file{pkg-message} in the relevant qemu port directory.
X @c man end
X
X @c man begin AUTHOR
END-of-files/patch-qemu-doc.texi
echo x - files/patch-target-i386-translate.c
sed 's/^X//' >files/patch-target-i386-translate.c << 'END-of-files/patch-target-i386-translate.c'
END-of-files/patch-target-i386-translate.c
echo x - files/patch-target-mips-cpu.h
sed 's/^X//' >files/patch-target-mips-cpu.h << 'END-of-files/patch-target-mips-cpu.h'
XIndex: qemu/target-mips/cpu.h
X@@ -8,6 +8,13 @@
X #include "config.h"
X #include "softfloat.h"
X
X+#ifdef __FreeBSD__
X+#if __FreeBSD__ <= 4
X+typedef uint32_t uint_fast8_t;
X+typedef uint32_t uint_fast16_t;
X+#endif
X+#endif
X+
X typedef union fpr_t fpr_t;
X union fpr_t {
X double d;
END-of-files/patch-target-mips-cpu.h
echo x - files/patch-tcg-i386-tcg-target.c
sed 's/^X//' >files/patch-tcg-i386-tcg-target.c << 'END-of-files/patch-tcg-i386-tcg-target.c'
END-of-files/patch-tcg-i386-tcg-target.c
echo x - files/patch-vl.c
sed 's/^X//' >files/patch-vl.c << 'END-of-files/patch-vl.c'
XIndex: qemu/vl.c
X@@ -9850,15 +9850,15 @@
X phys_ram_size += ram_size;
X }
X
X+ /* init the dynamic translator */
X+ cpu_exec_init_all(tb_size * 1024 * 1024);
X+
X phys_ram_base = qemu_vmalloc(phys_ram_size);
X if (!phys_ram_base) {
X fprintf(stderr, "Could not allocate physical memory\n");
X exit(1);
X }
X
X- /* init the dynamic translator */
X- cpu_exec_init_all(tb_size * 1024 * 1024);
X-
X bdrv_init(emulate_aio);
X
X /* we always create the cdrom drive, even if no disk is there */
END-of-files/patch-vl.c
echo x - files/patch-vl.c-ppbus
sed 's/^X//' >files/patch-vl.c-ppbus << 'END-of-files/patch-vl.c-ppbus'
XIndex: qemu/qemu-char.c
X@@ -63,6 +63,8 @@
X #include
X #ifdef __FreeBSD__
X #include
X+#include
X+#include
X #else
X #include
X #endif
X@@ -1268,6 +1270,65 @@
X }
X #endif /* __linux__ */
X
X+#if defined(__FreeBSD__)
X+static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
X+{
X+ int fd = (int)chr->opaque;
X+ uint8_t b;
X+
X+ switch(cmd) {
X+ case CHR_IOCTL_PP_READ_DATA:
X+ if (ioctl(fd, PPIGDATA, &b) < 0)
X+ return -ENOTSUP;
X+ *(uint8_t *)arg = b;
X+ break;
X+ case CHR_IOCTL_PP_WRITE_DATA:
X+ b = *(uint8_t *)arg;
X+ if (ioctl(fd, PPISDATA, &b) < 0)
X+ return -ENOTSUP;
X+ break;
X+ case CHR_IOCTL_PP_READ_CONTROL:
X+ if (ioctl(fd, PPIGCTRL, &b) < 0)
X+ return -ENOTSUP;
X+ *(uint8_t *)arg = b;
X+ break;
X+ case CHR_IOCTL_PP_WRITE_CONTROL:
X+ b = *(uint8_t *)arg;
X+ if (ioctl(fd, PPISCTRL, &b) < 0)
X+ return -ENOTSUP;
X+ break;
X+ case CHR_IOCTL_PP_READ_STATUS:
X+ if (ioctl(fd, PPIGSTATUS, &b) < 0)
X+ return -ENOTSUP;
X+ *(uint8_t *)arg = b;
X+ break;
X+ default:
X+ return -ENOTSUP;
X+ }
X+ return 0;
X+}
X+
X+CharDriverState *qemu_chr_open_pp(const char *filename)
X+{
X+ CharDriverState *chr;
X+ int fd;
X+
X+ fd = open(filename, O_RDWR);
X+ if (fd < 0)
X+ return NULL;
X+
X+ chr = qemu_mallocz(sizeof(CharDriverState));
X+ if (!chr) {
X+ close(fd);
X+ return NULL;
X+ }
X+ chr->opaque = (void *)fd;
X+ chr->chr_write = null_chr_write;
X+ chr->chr_ioctl = pp_ioctl;
X+ return chr;
X+}
X+#endif
X+
X #else /* _WIN32 */
X
X typedef struct {
X@@ -2151,6 +2212,10 @@
X if (strstart(filename, "/dev/parport", NULL)) {
X chr = qemu_chr_open_pp(filename);
X } else
X+#elif defined(__FreeBSD__)
X+ if (strstart(filename, "/dev/ppi", NULL)) {
X+ chr = qemu_chr_open_pp(filename);
X+ } else
X #endif
X #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \
X || defined(__NetBSD__) || defined(__OpenBSD__)
END-of-files/patch-vl.c-ppbus
echo x - files/patch-vl.c-serial
sed 's/^X//' >files/patch-vl.c-serial << 'END-of-files/patch-vl.c-serial'
XIndex: qemu/qemu-char.c
X@@ -1606,10 +1606,13 @@
X cfsetospeed(&tty, spd);
X
X tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
X- |INLCR|IGNCR|ICRNL|IXON);
X- tty.c_oflag |= OPOST;
X+ |INLCR|IGNCR|ICRNL|IXON|IMAXBEL);
X+ tty.c_oflag &= ~OPOST; /* Don't do any output processing! */
X tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN|ISIG);
X tty.c_cflag &= ~(CSIZE|PARENB|PARODD|CRTSCTS|CSTOPB);
X+#ifdef __FreeBSD__
X+ cfmakeraw(&tty);
X+#endif
X switch(data_bits) {
X default:
X case 8:
END-of-files/patch-vl.c-serial
echo x - files/patch-x_keymap.c
sed 's/^X//' >files/patch-x_keymap.c << 'END-of-files/patch-x_keymap.c'
XIndex: qemu/x_keymap.c
X@@ -41,9 +41,9 @@
X 0xb5, /* 112 Divide */
X 0xb8, /* 113 Alt-R */
X 0xc6, /* 114 Break */
X- 0x0, /* 115 */
X- 0x0, /* 116 */
X- 0x0, /* 117 */
X+ 0xdb, /* 115 left windows key */
X+ 0xdc, /* 116 right windows key */
X+ 0xdd, /* 117 right menu key */
X 0x0, /* 118 */
X 0x0, /* 119 */
X 0x0, /* 120 */
END-of-files/patch-x_keymap.c
echo x - files/pcap-patch
sed 's/^X//' >files/pcap-patch << 'END-of-files/pcap-patch'
X--- Makefile.target.orig 2008-07-18 15:18:11.000000000 -0400
X+++ Makefile.target 2008-07-18 15:23:11.000000000 -0400
X@@ -619,6 +619,13 @@
X COCOA_LIBS+=-framework CoreAudio
X endif
X endif
X+ifdef CONFIG_PCAP
X+ifdef CONFIG_WIN32
X+LIBS+=-lwpcap
X+else
X+LIBS+=-lpcap
X+endif
X+endif
X ifdef CONFIG_SLIRP
X CPPFLAGS+=-I$(SRC_PATH)/slirp
X endif
X--- configure.orig 2008-07-18 15:18:42.000000000 -0400
X+++ configure 2008-07-18 15:22:24.000000000 -0400
X@@ -88,6 +88,7 @@
X mingw32="no"
X EXESUF=""
X gdbstub="yes"
X+pcap="no"
X slirp="yes"
X fmod_lib=""
X fmod_inc=""
X@@ -278,6 +279,8 @@
X ;;
X --enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32-" ; linux_user="no"
X ;;
X+ --enable-pcap) pcap="yes"
X+ ;;
X --disable-slirp) slirp="no"
X ;;
X --disable-kqemu) kqemu="no"
X@@ -712,6 +715,28 @@
X fi # -z $sdl
X
X ##########################################
X+# pcap probe
X+
X+if test "$pcap" = "yes" ; then
X+ cat > $TMPC << EOF
X+#include
X+int main(void) { return (pcap_lib_version() == (char *)0 ? 1 : 0); }
X+EOF
X+ if test "$mingw32" = "no" ; then
X+ libpcap=-lpcap
X+ else
X+ libpcap=-lwpcap
X+ fi
X+ if ! $cc $ARCH_CFLAGS -o $TMPE $TMPC $libpcap 2> /dev/null ; then
X+ echo
X+ echo "Error: Could not find pcap"
X+ echo "Make sure to have the pcap libs and headers installed."
X+ echo
X+ exit 1
X+ fi
X+fi # test "$pcap"
X+
X+##########################################
X # VNC TLS detection
X if test "$vnc_tls" = "yes" ; then
X `pkg-config gnutls` || vnc_tls="no"
X@@ -865,6 +890,7 @@
X echo " TLS CFLAGS $vnc_tls_cflags"
X echo " TLS LIBS $vnc_tls_libs"
X fi
X+echo "pcap support $pcap"
X if test -n "$sparc_cpu"; then
X echo "Target Sparc Arch $sparc_cpu"
X fi
X@@ -1034,6 +1060,15 @@
X if test $profiler = "yes" ; then
X echo "#define CONFIG_PROFILER 1" >> $config_h
X fi
X+if test "$pcap" = "yes" ; then
X+ echo "CONFIG_PCAP=yes" >> $config_mak
X+ echo "#define CONFIG_PCAP 1" >> $config_h
X+ if test "$mingw32" = "no" ; then
X+ if test -c /dev/bpf0 ; then
X+ echo "#define HAVE_BPF 1" >> $config_h
X+ fi
X+ fi
X+fi
X if test "$slirp" = "yes" ; then
X echo "CONFIG_SLIRP=yes" >> $config_mak
X echo "#define CONFIG_SLIRP 1" >> $config_h
XIndex: net.c
X@@ -102,6 +102,13 @@
X int inet_aton(const char *cp, struct in_addr *ia);
X #endif
X
X+#if defined(CONFIG_PCAP)
X+#if defined(_WIN32)
X+#define WPCAP 1
X+#endif
X+#include
X+#endif
X+
X #if defined(CONFIG_SLIRP)
X #include "libslirp.h"
X #endif
X@@ -3914,6 +3921,164 @@
X }
X }
X
X+#if defined(CONFIG_PCAP)
X+
X+typedef struct PCAPState {
X+ VLANClientState *vc;
X+ pcap_t *handle;
X+} PCAPState;
X+
X+static void pcap_receive(void *opaque, const uint8_t *buf, int size)
X+{
X+ PCAPState *s = (PCAPState *)opaque;
X+
X+ pcap_sendpacket(s->handle, (u_char*)buf, size);
X+}
X+
X+static void pcap_callback(u_char *user, struct pcap_pkthdr *phdr, u_char *pdata)
X+{
X+ VLANClientState *vc = (VLANClientState *)user;
X+
X+ qemu_send_packet(vc, pdata, phdr->len);
X+}
X+
X+static void pcap_send(void *opaque)
X+{
X+ PCAPState *s = (PCAPState *)opaque;
X+
X+ pcap_dispatch(s->handle, 1, (pcap_handler)&pcap_callback, (u_char *)s->vc);
X+}
X+
X+static int net_pcap_init(VLANState *vlan, char *ifname)
X+{
X+ PCAPState *s = NULL;
X+ struct bpf_program fcode = { 0, NULL };
X+ char pcap_program[64];
X+ char macstr[] = "xx:xx:xx:xx:xx:xx";
X+ char errbuf[PCAP_ERRBUF_SIZE];
X+#if defined(_WIN32)
X+ HANDLE h;
X+#endif
X+ int i;
X+
X+ /* Find guest's MAC address. */
X+ for (i = 0; i < nb_nics; i++)
X+ if (nd_table[i].vlan == vlan) {
X+ u_char *mac = nd_table[i].macaddr;
X+ snprintf(macstr, sizeof(macstr), "%02x:%02x:%02x:%02x:%02x:%02x",
X+ mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
X+ break;
X+ }
X+ if (macstr[0] == 'x') {
X+ fprintf(stderr, "qemu: net_pcap_init: no matching NIC found\n");
X+ return -1;
X+ }
X+
X+ s = qemu_mallocz(sizeof(PCAPState));
X+ if (!s)
X+ return -1;
X+
X+ if (ifname == NULL && (ifname = pcap_lookupdev(errbuf)) == NULL) {
X+ fprintf(stderr, "qemu: pcap_lookupdev: %s\n", errbuf);
X+ goto fail;
X+ }
X+
X+ /* Attempt to connect device. */
X+ s->handle = (void *)pcap_open_live(ifname, 65535, 1, 0, errbuf);
X+ if (!s->handle) {
X+ fprintf(stderr, "qemu: pcap_open_live: %s\n", errbuf);
X+ goto fail;
X+ }
X+
X+ /* Set filter program. */
X+ snprintf(pcap_program, 64, "ether dst %s or multicast", macstr);
X+ if (pcap_compile(s->handle, &fcode, pcap_program, 1, 0) < 0) {
X+ fprintf(stderr, "qemu: pcap_compile failed\n");
X+ goto fail;
X+ }
X+ if (pcap_setfilter(s->handle, &fcode) < 0) {
X+ fprintf(stderr, "qemu: pcap_setfilter failed\n");
X+ goto fail;
X+ }
X+
X+ /* Set non-blocking mode. */
X+ if (pcap_setnonblock(s->handle, 1, errbuf) < 0) {
X+ fprintf(stderr, "qemu: pcap_setnonblock: %s\n", errbuf);
X+ goto fail;
X+ }
X+
X+#if defined(_WIN32)
X+ /*
X+ * Tell the kernel that the packet has to be seen immediately.
X+ */
X+ if (pcap_setmintocopy(s->handle, 0) < 0) {
X+ fprintf(stderr, "qemu: pcap failed to set immediate mode\n");
X+ goto fail;
X+ }
X+#else /* !_WIN32 */
X+#if defined(HAVE_BPF)
X+#if defined(BIOCIMMEDIATE)
X+ /*
X+ * Tell the kernel that the packet has to be seen immediately.
X+ */
X+ {
X+ unsigned int one = 1;
X+ if (ioctl(pcap_fileno(s->handle), BIOCIMMEDIATE, &one) < 0) {
X+ fprintf(stderr, "qemu: pcap failed to set immediate mode\n");
X+ goto fail;
X+ }
X+ }
X+#endif /* BIOCIMMEDIATE */
X+
X+#if defined(BIOCFEEDBACK)
X+ /*
X+ * Tell the kernel that the sent packet has to be fed back.
X+ * This is necessary to connect host and guest.
X+ */
X+ {
X+ unsigned int one = 1;
X+ if (ioctl(pcap_fileno(s->handle), BIOCFEEDBACK, &one) < 0) {
X+ fprintf(stderr, "qemu: pcap failed to set feedback mode\n");
X+ goto fail;
X+ }
X+ }
X+#endif /* BIOCFEEDBACK */
X+#endif /* HAVE_BPF */
X+#endif /* _WIN32 */
X+
X+ s->vc = qemu_new_vlan_client(vlan, pcap_receive, NULL, s);
X+ snprintf(s->vc->info_str, sizeof(s->vc->info_str), "pcap redirector");
X+
X+#if defined(_WIN32)
X+ if ((h = pcap_getevent(s->handle)) == NULL) {
X+ fprintf(stderr, "qemu: pcap_getevent failed\n");
X+ goto fail;
X+ }
X+ qemu_add_wait_object(h, pcap_send, s);
X+#else /* !_WIN32 */
X+ if ((i = pcap_get_selectable_fd(s->handle)) < 0) {
X+ fprintf(stderr, "qemu: pcap_get_selectable_fd failed\n");
X+ goto fail;
X+ }
X+ qemu_set_fd_handler(i, pcap_send, NULL, s);
X+#endif /* _WIN32 */
X+
X+ return 0;
X+
X+fail:
X+ if (s) {
X+ if (s->handle) {
X+ if (fcode.bf_len)
X+ pcap_freecode(&fcode);
X+ pcap_close(s->handle);
X+ }
X+ qemu_free(s);
X+ }
X+
X+ return -1;
X+}
X+#endif /* CONFIG_PCAP */
X+
X #if defined(CONFIG_SLIRP)
X
X /* slirp network adapter */
X@@ -4983,6 +5150,16 @@
X are wanted */
X ret = 0;
X } else
X+#ifdef CONFIG_PCAP
X+ if (!strcmp(device, "pcap")) {
X+ char ifname[64];
X+ vlan->nb_host_devs++;
X+ if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0)
X+ ret = net_pcap_init(vlan, NULL);
X+ else
X+ ret = net_pcap_init(vlan, ifname);
X+ } else
X+#endif
X #ifdef CONFIG_SLIRP
X if (!strcmp(device, "user")) {
X if (get_param_value(buf, sizeof(buf), "hostname", p)) {
X--- vl.c.orig 2008-07-18 15:19:26.000000000 -0400
X+++ vl.c 2008-07-18 15:31:25.000000000 -0400
X@@ -7398,6 +7575,10 @@
X "Network options:\n"
X "-net nic[,vlan=n][,macaddr=addr][,model=type]\n"
X " create a new Network Interface Card and connect it to VLAN 'n'\n"
X+#ifdef CONFIG_PCAP
X+ "-net pcap[,vlan=n][,ifname=name]\n"
X+ " connect the host network interface using PCAP to VLAN 'n'\n"
X+#endif
X #ifdef CONFIG_SLIRP
X "-net user[,vlan=n][,hostname=host]\n"
X " connect the user mode network stack to VLAN 'n' and send\n"
END-of-files/pcap-patch
echo x - files/rtl8139-re-patch
sed 's/^X//' >files/rtl8139-re-patch << 'END-of-files/rtl8139-re-patch'
XIndex: hw/rtl8139.c
X@@ -58,7 +58,7 @@
X //#define RTL8139_CALCULATE_RXCRC 1
X
X /* Uncomment to enable on-board timer interrupts */
X-//#define RTL8139_ONBOARD_TIMER 1
X+#define RTL8139_ONBOARD_TIMER 1
X
X #if defined(RTL8139_CALCULATE_RXCRC)
X /* For crc32 */
END-of-files/rtl8139-re-patch
exit
_______________________________________________
freebsd-emulation@freebsd.org mailing list
http://lists.freebsd.org/mailman/lis...ebsd-emulation
To unsubscribe, send any mail to "freebsd-emulation-unsubscribe@freebsd.org"