NetBSD-Bugs archive

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

kern/46627: ceil() is broken on m68k FPE (FINT emulation is broken)



>Number:         46627
>Category:       kern
>Synopsis:       ceil() is broken on m68k FPE (FINT emulation is broken)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 25 04:45:00 +0000 2012
>Originator:     Tetsuya Isaki
>Release:        NetBSD-current/x68k
>Organization:
>Environment:
NetBSD xxxx 6.99.6 NetBSD 6.99.6 (GENERIC) #11: Mon May  7 22:47:21 JST 2012 
xxxx@xxxx:xxxx/sys/arch/x68k/compile/GENERIC x68k
>Description:
On m68k FPE (= m68k without the FPU, such as XM6i emulator),
ceil() is broken in |x| < 1.

% uname -srm
NetBSD 6.99.6 x68k
% dmesg|grep FPU
X68030 (m68030 CPU/MMU, emulator FPU, 24MHz clock)
% cat a.c
#include <stdio.h>
#include <math.h>
int main()
{
    double list[]={ -1.5, -1.1, -0.5, -0.1, 0, 0.1, 0.5, 1.1, 1.5, };
    unsigned int i;

    for (i = 0; i < sizeof(list)/sizeof(list[0]); i++) {
        printf("ceil(%g) -> %g\n", list[i], ceil(list[i]));
    }
    return 0;
}
% gcc a.c -lm
% ./a.out
ceil(-1.5) -> -1
ceil(-1.1) -> -1
ceil(-0.5) -> -0.5
ceil(-0.1) -> -0
ceil(0) -> 0
ceil(0.1) -> 0
ceil(0.5) -> 1
ceil(1.1) -> 2
ceil(1.5) -> 2
%

ceil() calls FINT (in lib/libm/arch/m68k/s_ceil.S), and
FINT emulation in FPE does not consider FPCR round mode when
|x| < 1 and something is strange in sys/arch/m68k/fpe/fpu_int.c.
>How-To-Repeat:
See above.
>Fix:
I will fix it.



Home | Main Index | Thread Index | Old Index