Return to BSD News archive
Newsgroups: comp.unix.bsd Path: sserve!manuel!munnari.oz.au!spool.mu.edu!nigel.msen.com!sdd.hp.com!swrinde!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watdragon.uwaterloo.ca!kcwellsc From: kcwellsc@watdragon.uwaterloo.ca (Ken Wellsch) Subject: Re: gcc-2.2.2, BSDI, runtime errors in fixdfsi.o !?!? Message-ID: <Bv1C4D.E9B@watdragon.uwaterloo.ca> Organization: University of Waterloo References: <BuzwJJ.MH0@immd4.informatik.uni-erlangen.de> Date: Wed, 23 Sep 1992 14:26:37 GMT Lines: 31 You can't use gcc to build gcc. At least you can't compile gnulib1.c as it requires a local non-gcc compiler. Otherwise compiling int __fixdfsi(d) double d; { return((int)d); } for example will have gcc produce a call to fixdfsi to do the float to int conversion (recursion occurs obviously). Thus 386bsd provides assembler copies for such built-in operations with gcc-1.39. The copy of __fixdfsi in 386bsd does not switch the '387 to truncate mode so float->int rounds rather than truncates as "defined" in K&R. Here is a copy that I compiled on a Dynix 386 system (some 386/387 wizard can clean up the thing to make it shorter if they like): .globl ___fixdfsi ___fixdfsi: pushl %ebp movl %esp,%ebp subl $12,%esp fstcw -4(%ebp) / stash current '387 control word movw -4(%ebp),%ax orb $12,%ah / set "truncate" mode movw %ax,-2(%ebp) fldcw -2(%ebp) / set control word on '387 fldl 8(%ebp) / load double onto '387 stack fistpl -12(%ebp) / store as int off '387 stack fldcw -4(%ebp) / restore previous '387 control word movl -12(%ebp),%eax leave ret