OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.9 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../musl/0004-math-fix-expf-NAN-and-exp2f-NAN-to-return-NAN-instea.patch
  5. # Copyright (C) 2016 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. From b023c03b574acdfd73418314a5dcaa83e5cea5a0 Mon Sep 17 00:00:00 2001
  17. From: Szabolcs Nagy <nsz@port70.net>
  18. Date: Fri, 4 Mar 2016 21:23:33 +0000
  19. Subject: [PATCH] math: fix expf(-NAN) and exp2f(-NAN) to return -NAN instead
  20. of 0
  21. expf(-NAN) was treated as expf(-large) which unconditionally
  22. returns +0, so special case +-NAN.
  23. reported by Petr Hosek.
  24. ---
  25. src/math/exp2f.c | 2 ++
  26. src/math/expf.c | 2 ++
  27. 2 files changed, 4 insertions(+)
  28. diff --git a/src/math/exp2f.c b/src/math/exp2f.c
  29. index cf6126e..296b634 100644
  30. --- a/src/math/exp2f.c
  31. +++ b/src/math/exp2f.c
  32. @@ -91,6 +91,8 @@ float exp2f(float x)
  33. /* Filter out exceptional cases. */
  34. ix = u.i & 0x7fffffff;
  35. if (ix > 0x42fc0000) { /* |x| > 126 */
  36. + if (ix > 0x7f800000) /* NaN */
  37. + return x;
  38. if (u.i >= 0x43000000 && u.i < 0x80000000) { /* x >= 128 */
  39. x *= 0x1p127f;
  40. return x;
  41. diff --git a/src/math/expf.c b/src/math/expf.c
  42. index 16e9afe..feee2b0 100644
  43. --- a/src/math/expf.c
  44. +++ b/src/math/expf.c
  45. @@ -39,6 +39,8 @@ float expf(float x)
  46. /* special cases */
  47. if (hx >= 0x42aeac50) { /* if |x| >= -87.33655f or NaN */
  48. + if (hx > 0x7f800000) /* NaN */
  49. + return x;
  50. if (hx >= 0x42b17218 && !sign) { /* x >= 88.722839f */
  51. /* overflow */
  52. x *= 0x1p127f;
  53. --
  54. 2.7.2