Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 May 2005 17:25:04 -0400 (EDT)
From:      Daniel Eischen <deischen@freebsd.org>
To:        Marc Olzheim <marcolz@stack.nl>
Cc:        freebsd-threads@freebsd.org
Subject:   Re: Floating point exceptions with -pthread
Message-ID:  <Pine.GSO.4.43.0505041631550.498-100000@sea.ntplx.net>
In-Reply-To: <20050504202200.GD76171@stack.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 4 May 2005, Marc Olzheim wrote:

> On Wed, May 04, 2005 at 09:51:53PM +0200, Marc Olzheim wrote:
> > On Wed, May 04, 2005 at 03:15:06PM -0400, Daniel Eischen wrote:
> > > > It seems to me like something about the floorf() assembly might have
> > > > something to do with it.
> > >
> > > Yeah, I was just trying to narrow down the problem a bit more.
> >
> > I've attached one that's built very tight around floorf().
>
> Replacing floorf() in the program by:
> fabs()
> rintf()
> sqrt()
> expf()
> log10f()
> logf()
> cosf()
> powf(,)
>
> doesn't crash.
>
> The only two functions I found to crash are floorf() and ceilf().
>
> Replacing all floats by doubles and using floor() or ceil() doesn't
> crash either.

floorf() seems to fiddle with the FP control word.  The kernel
and libpthread use fxsave and fxrstor respectively.  These
save and restore the control word, but something may not be
working correctly.

ENTRY(floorf)
        pushl   %ebp
        movl    %esp,%ebp
        subl    $8,%esp

        fstcw   -12(%ebp)               /* store fpu control word */
        movw    -12(%ebp),%dx
        orw     $0x0400,%dx             /* round towards -oo */
        andw    $0xf7ff,%dx
        movw    %dx,-16(%ebp)
        fldcw   -16(%ebp)               /* load modfied control word */

        flds    8(%ebp);                /* round */
        frndint

        fldcw   -12(%ebp)               /* restore original control word */

        leave
        ret

-- 
DE



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.43.0505041631550.498-100000>