Sat Apr 20 07:33:06 2013 UTC ()
Support sinh(-0.0) and tanh(-0.0).


(isaki)
diff -r1.14 -r1.15 src/sys/arch/m68k/fpe/fpu_hyperb.c

cvs diff -r1.14 -r1.15 src/sys/arch/m68k/fpe/fpu_hyperb.c (expand / switch to unified diff)

--- src/sys/arch/m68k/fpe/fpu_hyperb.c 2013/04/20 05:27:05 1.14
+++ src/sys/arch/m68k/fpe/fpu_hyperb.c 2013/04/20 07:33:05 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: fpu_hyperb.c,v 1.14 2013/04/20 05:27:05 isaki Exp $ */ 1/* $NetBSD: fpu_hyperb.c,v 1.15 2013/04/20 07:33:05 isaki Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1995 Ken Nakata 4 * Copyright (c) 1995 Ken Nakata
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -47,27 +47,27 @@ @@ -47,27 +47,27 @@
47 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 47 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
48 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 48 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
49 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 49 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
50 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 50 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
51 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 51 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
52 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 52 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
53 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 53 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
54 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 54 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 55 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 * SUCH DAMAGE. 56 * SUCH DAMAGE.
57 */ 57 */
58 58
59#include <sys/cdefs.h> 59#include <sys/cdefs.h>
60__KERNEL_RCSID(0, "$NetBSD: fpu_hyperb.c,v 1.14 2013/04/20 05:27:05 isaki Exp $"); 60__KERNEL_RCSID(0, "$NetBSD: fpu_hyperb.c,v 1.15 2013/04/20 07:33:05 isaki Exp $");
61 61
62#include <machine/ieee.h> 62#include <machine/ieee.h>
63 63
64#include "fpu_emulate.h" 64#include "fpu_emulate.h"
65 65
66/* The number of items to terminate the Taylor expansion */ 66/* The number of items to terminate the Taylor expansion */
67#define MAX_ITEMS (2000) 67#define MAX_ITEMS (2000)
68 68
69/* 69/*
70 * fpu_hyperb.c: defines the following functions 70 * fpu_hyperb.c: defines the following functions
71 * 71 *
72 * fpu_atanh(), fpu_cosh(), fpu_sinh(), and fpu_tanh() 72 * fpu_atanh(), fpu_cosh(), fpu_sinh(), and fpu_tanh()
73 */ 73 */
@@ -223,43 +223,51 @@ fpu_cosh(struct fpemu *fe) @@ -223,43 +223,51 @@ fpu_cosh(struct fpemu *fe)
223} 223}
224 224
225struct fpn * 225struct fpn *
226fpu_sinh(struct fpemu *fe) 226fpu_sinh(struct fpemu *fe)
227{ 227{
228 struct fpn s0; 228 struct fpn s0;
229 struct fpn *r; 229 struct fpn *r;
230 230
231 if (ISNAN(&fe->fe_f2)) 231 if (ISNAN(&fe->fe_f2))
232 return &fe->fe_f2; 232 return &fe->fe_f2;
233 if (ISINF(&fe->fe_f2)) 233 if (ISINF(&fe->fe_f2))
234 return &fe->fe_f2; 234 return &fe->fe_f2;
235 235
 236 /* if x is +0/-0, return +0/-0 */
 237 if (ISZERO(&fe->fe_f2))
 238 return &fe->fe_f2;
 239
236 CPYFPN(&s0, &fe->fe_f2); 240 CPYFPN(&s0, &fe->fe_f2);
237 r = __fpu_sinhcosh_taylor(fe, &s0, 2); 241 r = __fpu_sinhcosh_taylor(fe, &s0, 2);
238 242
239 return r; 243 return r;
240} 244}
241 245
242struct fpn * 246struct fpn *
243fpu_tanh(struct fpemu *fe) 247fpu_tanh(struct fpemu *fe)
244{ 248{
245 struct fpn x; 249 struct fpn x;
246 struct fpn s; 250 struct fpn s;
247 struct fpn *r; 251 struct fpn *r;
248 int sign; 252 int sign;
249 253
250 if (ISNAN(&fe->fe_f2)) 254 if (ISNAN(&fe->fe_f2))
251 return &fe->fe_f2; 255 return &fe->fe_f2;
252 256
 257 /* if x is +0/-0, return +0/-0 */
 258 if (ISZERO(&fe->fe_f2))
 259 return &fe->fe_f2;
 260
253 if (ISINF(&fe->fe_f2)) { 261 if (ISINF(&fe->fe_f2)) {
254 sign = fe->fe_f2.fp_sign; 262 sign = fe->fe_f2.fp_sign;
255 fpu_const(&fe->fe_f2, FPU_CONST_1); 263 fpu_const(&fe->fe_f2, FPU_CONST_1);
256 fe->fe_f2.fp_sign = sign; 264 fe->fe_f2.fp_sign = sign;
257 return &fe->fe_f2; 265 return &fe->fe_f2;
258 } 266 }
259 267
260 CPYFPN(&x, &fe->fe_f2); 268 CPYFPN(&x, &fe->fe_f2);
261 269
262 /* sinh(x) */ 270 /* sinh(x) */
263 CPYFPN(&fe->fe_f2, &x); 271 CPYFPN(&fe->fe_f2, &x);
264 r = fpu_sinh(fe); 272 r = fpu_sinh(fe);
265 CPYFPN(&s, r); 273 CPYFPN(&s, r);