| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: s_fma.c,v 1.3 2013/02/11 02:45:27 christos Exp $ */ | | 1 | /* $NetBSD: s_fma.c,v 1.4 2013/02/12 08:21:48 martin Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2005-2011 David Schultz <das@FreeBSD.ORG> | | 4 | * Copyright (c) 2005-2011 David Schultz <das@FreeBSD.ORG> |
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. |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
26 | * SUCH DAMAGE. | | 26 | * SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | #if 0 | | 30 | #if 0 |
31 | __FBSDID("$FreeBSD: src/lib/msun/src/s_fma.c,v 1.8 2011/10/21 06:30:43 das Exp $"); | | 31 | __FBSDID("$FreeBSD: src/lib/msun/src/s_fma.c,v 1.8 2011/10/21 06:30:43 das Exp $"); |
32 | #else | | 32 | #else |
33 | __RCSID("$NetBSD: s_fma.c,v 1.3 2013/02/11 02:45:27 christos Exp $"); | | 33 | __RCSID("$NetBSD: s_fma.c,v 1.4 2013/02/12 08:21:48 martin Exp $"); |
34 | #endif | | 34 | #endif |
35 | | | 35 | |
36 | #include <machine/ieee.h> | | 36 | #include <machine/ieee.h> |
37 | #include <fenv.h> | | 37 | #include <fenv.h> |
38 | #include <float.h> | | 38 | #include <float.h> |
39 | #include <math.h> | | 39 | #include <math.h> |
40 | | | 40 | |
41 | #include "math_private.h" | | 41 | #include "math_private.h" |
42 | | | 42 | |
43 | /* | | 43 | /* |
44 | * A struct dd represents a floating-point number with twice the precision | | 44 | * A struct dd represents a floating-point number with twice the precision |
45 | * of a double. We maintain the invariant that "hi" stores the 53 high-order | | 45 | * of a double. We maintain the invariant that "hi" stores the 53 high-order |
46 | * bits of the result. | | 46 | * bits of the result. |
| @@ -279,15 +279,15 @@ fma(double x, double y, double z) | | | @@ -279,15 +279,15 @@ fma(double x, double y, double z) |
279 | fesetround(oround); | | 279 | fesetround(oround); |
280 | adj = r.lo + xy.lo; | | 280 | adj = r.lo + xy.lo; |
281 | return (ldexp(r.hi + adj, spread)); | | 281 | return (ldexp(r.hi + adj, spread)); |
282 | } | | 282 | } |
283 | | | 283 | |
284 | adj = add_adjusted(r.lo, xy.lo); | | 284 | adj = add_adjusted(r.lo, xy.lo); |
285 | if (spread + ilogb(r.hi) > -1023) | | 285 | if (spread + ilogb(r.hi) > -1023) |
286 | return (ldexp(r.hi + adj, spread)); | | 286 | return (ldexp(r.hi + adj, spread)); |
287 | else | | 287 | else |
288 | return (add_and_denormalize(r.hi, adj, spread)); | | 288 | return (add_and_denormalize(r.hi, adj, spread)); |
289 | } | | 289 | } |
290 | | | 290 | |
291 | #ifndef __HAVE_LONG_DOUBLE | | 291 | #ifndef __HAVE_LONG_DOUBLE |
292 | __weak_reference(fma, fmal); | | 292 | __weak_alias(fma, fmal) |
293 | #endif | | 293 | #endif |