[njs] A workround for Solaris bugs in acos() and asin().
Igor Sysoev
igor at sysoev.ru
Wed Nov 16 12:22:09 UTC 2016
details: http://hg.nginx.org/njs/rev/f402a8c64d7a
branches:
changeset: 261:f402a8c64d7a
user: Igor Sysoev <igor at sysoev.ru>
date: Wed Nov 16 15:21:07 2016 +0300
description:
A workround for Solaris bugs in acos() and asin().
diffstat:
njs/njs_math.c | 22 ++++++++++++++++++++--
1 files changed, 20 insertions(+), 2 deletions(-)
diffs (39 lines):
diff -r 73e4b9ddb4df -r f402a8c64d7a njs/njs_math.c
--- a/njs/njs_math.c Wed Nov 16 15:21:03 2016 +0300
+++ b/njs/njs_math.c Wed Nov 16 15:21:07 2016 +0300
@@ -47,7 +47,16 @@ njs_object_math_acos(njs_vm_t *vm, njs_v
double num;
if (nargs > 1) {
- num = acos(args[1].data.u.number);
+ num = args[1].data.u.number;
+
+#if (NXT_SOLARIS)
+ /* On Solaris acos(x) returns 0 for x > 1. */
+ if (fabs(num) > 1.0) {
+ num = NAN;
+ }
+#endif
+
+ num = acos(num);
} else {
num = NAN;
@@ -66,7 +75,16 @@ njs_object_math_asin(njs_vm_t *vm, njs_v
double num;
if (nargs > 1) {
- num = asin(args[1].data.u.number);
+ num = args[1].data.u.number;
+
+#if (NXT_SOLARIS)
+ /* On Solaris asin(x) returns 0 for x > 1. */
+ if (fabs(num) > 1.0) {
+ num = NAN;
+ }
+#endif
+
+ num = asin(num);
} else {
num = NAN;
More information about the nginx-devel
mailing list