Welcome! Log In Create A New Profile

Advanced

[njs] A workround for Solaris bugs in acos() and asin().

November 16, 2016 07:24AM
details: http://hg.nginx.org/njs/rev/f402a8c64d7a
branches:
changeset: 261:f402a8c64d7a
user: Igor Sysoev <igor@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;

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] A workround for Solaris bugs in acos() and asin().

Igor Sysoev 660 November 16, 2016 07:24AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 68
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready