NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-amd64/44293: fpsetround(3) doesn't work



>Number:         44293
>Category:       port-amd64
>Synopsis:       fpsetround(3) doesn't work
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    port-amd64-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 29 16:25:00 +0000 2010
>Originator:     Paul Goyette
>Release:        NetBSD 5.99.39
>Organization:
-------------------------------------------------------------------------
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com    |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |                          | pgoyette at netbsd.org  |
-------------------------------------------------------------------------
>Environment:
        
        
System: NetBSD quicky.whooppee.com 5.99.39 NetBSD 5.99.39 (WHOOPPEE (shared) 
2010-10-28 23:55:07) #48: Thu Oct 28 16:58:51 PDT 2010 
paul%speedy.whooppee.com@localhost:/build-out/netbsd-local/obj/amd64/sys/arch/amd64/compile/WHOOPPEE
 amd64
Architecture: x86_64
Machine: amd64
>Description:
On port-amd64 (at least), fpsetround() appears to be a no-op.  The code
for fpsetround() appears to attempt to set both the x87 control word and
the SSE mxcsr, and fpgetround() reads only the x87 state.  Regardless of
what value is passed to fpsetround(), fpgetround() always returns FP_RN.
>How-To-Repeat:

{101} cat t_round.c
#include <stdlib.h>
#include <stdio.h>
#include <ieeefp.h>
#include <float.h>

int
main(int argc, void *argv[])
{
        fp_rnd old, new;

#define TEST(mode)                                                      \
        old = fpsetround(mode);                                         \
        new = fpgetround();                                             \
        printf("%s = %d: old %d new %d\n", ___STRING(mode), mode, old, new);

        TEST(FP_RN)
        TEST(FP_RP)
        TEST(FP_RM)
        TEST(FP_RZ)
        TEST(FP_RN)
}
{102} cc t_round.c -o t_round
{103} ./t_round 
FP_RN = 0: old 0 new 0
FP_RP = 2048: old 0 new 0
FP_RM = 1024: old 0 new 0
FP_RZ = 3072: old 0 new 0
FP_RN = 0: old 0 new 0
{104}
>Fix:
        

>Unformatted:
        
        


Home | Main Index | Thread Index | Old Index