NetBSD Problem Report #47810

From www@NetBSD.org  Thu May  9 05:29:44 2013
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id 7042A63F609
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  9 May 2013 05:29:44 +0000 (UTC)
Message-Id: <20130509052942.EE3F863F609@www.NetBSD.org>
Date: Thu,  9 May 2013 05:29:42 +0000 (UTC)
From: isaki@pastel-flower.jp
Reply-To: isaki@pastel-flower.jp
To: gnats-bugs@NetBSD.org
Subject: FREM emulation of m68k FPE is wrong
X-Send-Pr-Version: www-1.0

>Number:         47810
>Category:       kern
>Synopsis:       FREM emulation of m68k FPE is wrong
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 09 05:30:00 +0000 2013
>Closed-Date:    Sat May 11 12:56:47 +0000 2013
>Last-Modified:  Sat May 11 12:56:47 +0000 2013
>Originator:     Tetsuya Isaki
>Release:        NetBSD/x68k
>Organization:
>Environment:
NetBSD 6.99.19 x68k
>Description:
The FREM emulation of m68k FPE is wrong at several values.
>How-To-Repeat:
% dmesg | grep FPU
X68030 (m68030 CPU/MMU, emulator FPU, 29MHz clock) on XM6i v0.41
% cat main.c
#include<stdio.h>
extern double my_frem(double, double);
int main()
{
        double x;
        double y = 4.0;

        for (x = 0.0; x > -5.0; x -= 1.0) {
                printf("FREM(%g, %g) = %g\n", x, y, my_frem(x, y));
        }
}
% cat frem_s.s 
        .text
        .even
        .globl  my_frem
        .type   my_frem,@function
my_frem:
        fmoved  %sp@(4),%fp0
        fremd   %sp@(12),%fp0
        rts
% gcc -o frem main.c frem_s.s
% ./frem
FREM(0, 4) = -4     <-- NG!
FREM(-1, 4) = -1
FREM(-2, 4) = -2
FREM(-3, 4) = -7    <-- NG!
FREM(-4, 4) = -0
%

FREM(0, 4) should be 0 but it returns -4,
FREM(-3,4) should be 1 but it returns -7.
>Fix:
I have and I will commit it soon.
This PR is just for a record.

>Release-Note:

>Audit-Trail:
From: "Tetsuya Isaki" <isaki@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/47810 CVS commit: src/sys/arch/m68k/fpe
Date: Sat, 11 May 2013 12:52:43 +0000

 Module Name:	src
 Committed By:	isaki
 Date:		Sat May 11 12:52:43 UTC 2013

 Modified Files:
 	src/sys/arch/m68k/fpe: fpu_rem.c

 Log Message:
 Revise the algorithm after Step3.
 almost written by Y.Sugahara and minor modify by me.
 This works for all input of FMOD/FREM and of course solves PR/47810.


 To generate a diff of this commit:
 cvs rdiff -u -r1.15 -r1.16 src/sys/arch/m68k/fpe/fpu_rem.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: isaki@NetBSD.org
State-Changed-When: Sat, 11 May 2013 12:56:47 +0000
State-Changed-Why:
Fixed.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.