From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IkdM5-0005d5-8c for qemu-devel@nongnu.org; Wed, 24 Oct 2007 06:20:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IkdM3-0005ch-OA for qemu-devel@nongnu.org; Wed, 24 Oct 2007 06:20:53 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IkdM3-0005ce-KS for qemu-devel@nongnu.org; Wed, 24 Oct 2007 06:20:51 -0400 Received: from miranda.se.axis.com ([193.13.178.8]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IkdM3-0004of-1m for qemu-devel@nongnu.org; Wed, 24 Oct 2007 06:20:51 -0400 Received: from axis.com (edgar.se.axis.com [10.92.151.1]) by miranda.se.axis.com (8.13.4/8.13.4/Debian-3sarge3) with ESMTP id l9OAKdei009054 for ; Wed, 24 Oct 2007 12:20:39 +0200 Date: Wed, 24 Oct 2007 12:20:39 +0200 From: "Edgar E. Iglesias" Subject: Re: [Qemu-devel] qemu-2007-10-24 build error Message-ID: <20071024102039.GC13076@edgar.underground.se.axis.com> References: <20071024003602.0000F11F01F20261@mail6.dreamwiz.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20071024003602.0000F11F01F20261@mail6.dreamwiz.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: hys545@dreamwiz.com, qemu-devel@nongnu.org On Wed, Oct 24, 2007 at 09:36:02AM +0900, Hwang YunSong(??????) wrote: > gcc32 -g -o qemu-system-cris vl.o osdep.o readline.o monitor.o pci.o > console.o loader.o isa_mmio.o cutils.o block.o block-raw.o block-cow.o > block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o > block-vpc.o block-vvfat.o block-qcow2.o block-parallels.o irq.o i2c.o > smbus.o scsi-disk.o cdrom.o lsi53c895a.o usb.o usb-hub.o usb-linux.o > usb-hid.o usb-ohci.o usb-msd.o usb-wacom.o eeprom93xx.o eepro100.o > ne2000.o pcnet.o rtl8139.o etraxfs.o ptimer.o etraxfs_timer.o > etraxfs_ser.o gdbstub.o sdl.o x_keymap.o vnc.o d3des.o slirp/cksum.o > slirp/if.o slirp/ip_icmp.o slirp/ip_input.o slirp/ip_output.o > slirp/slirp.o slirp/mbuf.o slirp/misc.o slirp/sbuf.o slirp/socket.o > slirp/tcp_input.o slirp/tcp_output.o slirp/tcp_subr.o slirp/tcp_timer.o > slirp/udp.o slirp/bootp.o slirp/debug.o slirp/tftp.o libqemu.a -lm -lz > -lgnutls -L/usr/lib -lSDL -lpthread -lrt -lutil > libqemu.a(helper.o): In function `do_interrupt': > /usr/src/Haansoft/BUILD/qemu/target-cris/helper.c:137: undefined > reference to `__builtin_clz' > libqemu.a(translate-op.o): In function `dyngen_code': > /home/hys545/qemu/cris-softmmu/op.h:1566: undefined reference to > `__builtin_clz' > libqemu.a(op.o): In function `op_lz_T0_T1': > /usr/src/Haansoft/BUILD/qemu/target-cris/op.c:1009: undefined reference > to `__builtin_clz' > collect2: ld returned 1 exit status > Linux localhost.localdomain 2.6.19-10hs #1 Tue Apr 3 11:29:42 KST 2007 > i686 i686 i386 GNU/Linux > Configured with: ../configure --prefix=/usr --mandir=/usr/share/man > --infodir=/usr/share/info --enable-shared --enable-threads=posix > --enable-checking=release --with-system-zlib --enable-__cxa_atexit > --disable-libunwind-exceptions --enable-libgcj-multifile > --enable-languages=c,c++,objc,obj-c++,java,fortran,ada > --enable-java-awt=gtk --disable-dssi --enable-plugin > --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre > --with-cpu=generic --host=i386-Haansoft-linux > Thread model: posix > gcc version 4.1.1 20061120 (Haansoft 4.1.1-41) Hello, This patch adds a version of clz that does not rely on the builtin from GCC for GCC versions where it's not expected to be available. Test were done with the cris qemu testsuite with gcc version 4.1.2 (Gentoo 4.1.2) and with gcc version 3.3.6 (Gentoo 3.3.6-r1 p1.4, ssp-3.3.6-1.0, pie-8.7.8). You indicate the use of a GCC 4.1.1 which AFAIK should provide the __builtin_clz. I don't know whats going on but from the cmdline (gcc32) one might guess that a GCC 3.2 was used. Could you verify this? If so, this patch will hopefully solve the build problem you see. Best regards -- Edgar E. Iglesias Axis Communications AB diff --git a/target-cris/op.c b/target-cris/op.c index 3ce9888..fbbae5b 100644 --- a/target-cris/op.c +++ b/target-cris/op.c @@ -1006,7 +1006,34 @@ void OPPROTO op_lz_T0_T1 (void) if (T1 == 0) T0 = 32; else +#if __GNUC__ == 3 && __GNUC_MINOR__ >= 4 || __GNUC__ > 3 + { T0 = __builtin_clz(T1); + } +#else + { + /* Binary search for leading zeros. */ + + T0 = 1; + if ((T1 >> 16) == 0) { + T0 = T0 + 16; + T1 = T1 << 16; + } + if ((T1 >> 24) == 0) { + T0 = T0 + 8; + T1 = T1 << 8; + } + if ((T1 >> 28) == 0) { + T0 = T0 + 4; + T1 = T1 << 4; + } + if ((T1 >> 30) == 0) { + T0 = T0 + 2; + T1 = T1 << 2; + } + T0 = T0 - (T1 >> 31); + } +#endif RETURN(); }