[njs] Removed redefinition of isinf() and isnan().

Valentin Bartenev vbart at nginx.com
Fri Nov 4 15:25:17 UTC 2016


details:   http://hg.nginx.org/njs/rev/109932e1d3c8
branches:  
changeset: 238:109932e1d3c8
user:      Valentin Bartenev <vbart at nginx.com>
date:      Fri Nov 04 18:25:55 2016 +0300
description:
Removed redefinition of isinf() and isnan().

diffstat:

 njs/njs_array.c  |   4 +-
 njs/njs_date.c   |  66 ++++++++++++++++++++++++++++----------------------------
 njs/njs_math.c   |   2 +-
 njs/njs_number.c |   8 +++---
 njs/njs_number.h |   8 ------
 njs/njs_string.c |   2 +-
 njs/njs_vm.c     |   6 +---
 njs/njs_vm.h     |   2 +-
 8 files changed, 44 insertions(+), 54 deletions(-)

diffs (429 lines):

diff -r bcd4910c5be9 -r 109932e1d3c8 njs/njs_array.c
--- a/njs/njs_array.c	Fri Nov 04 18:25:55 2016 +0300
+++ b/njs/njs_array.c	Fri Nov 04 18:25:55 2016 +0300
@@ -1131,12 +1131,12 @@ njs_array_prototype_includes(njs_vm_t *v
     start = array->start;
     value = &args[1];
 
-    if (njs_is_number(value) && njs_is_nan(value->data.u.number)) {
+    if (njs_is_number(value) && isnan(value->data.u.number)) {
 
         do {
             value = &start[i];
 
-            if (njs_is_number(value) && njs_is_nan(value->data.u.number)) {
+            if (njs_is_number(value) && isnan(value->data.u.number)) {
                 retval = &njs_value_true;
                 break;
             }
diff -r bcd4910c5be9 -r 109932e1d3c8 njs/njs_date.c
--- a/njs/njs_date.c	Fri Nov 04 18:25:55 2016 +0300
+++ b/njs/njs_date.c	Fri Nov 04 18:25:55 2016 +0300
@@ -114,7 +114,7 @@ njs_date_constructor(njs_vm_t *vm, njs_v
 
                 num = args[i].data.u.number;
 
-                if (njs_is_nan(num)) {
+                if (isnan(num)) {
                     time = num;
                     goto done;
                 }
@@ -193,7 +193,7 @@ njs_date_utc(njs_vm_t *vm, njs_value_t *
 
             num = args[i].data.u.number;
 
-            if (njs_is_nan(num)) {
+            if (isnan(num)) {
                 goto done;
             }
 
@@ -951,7 +951,7 @@ njs_date_string(njs_vm_t *vm, const char
     u_char     buf[NJS_DATE_TIME_LEN];
     struct tm  tm;
 
-    if (!njs_is_nan(time)) {
+    if (!isnan(time)) {
         clock = time / 1000;
         localtime_r(&clock, &tm);
 
@@ -984,7 +984,7 @@ njs_date_prototype_to_utc_string(njs_vm_
 
     time = args[0].data.u.date->time;
 
-    if (!njs_is_nan(time)) {
+    if (!isnan(time)) {
         clock = time / 1000;
         gmtime_r(&clock, &tm);
 
@@ -1016,7 +1016,7 @@ njs_date_prototype_to_iso_string(njs_vm_
 
     time = args[0].data.u.date->time;
 
-    if (!njs_is_nan(time)) {
+    if (!isnan(time)) {
         clock = time / 1000;
 
         gmtime_r(&clock, &tm);
@@ -1049,7 +1049,7 @@ njs_date_prototype_get_full_year(njs_vm_
 
     value = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(value))) {
+    if (nxt_fast_path(!isnan(value))) {
         clock = value / 1000;
         localtime_r(&clock, &tm);
 
@@ -1072,7 +1072,7 @@ njs_date_prototype_get_utc_full_year(njs
 
     value = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(value))) {
+    if (nxt_fast_path(!isnan(value))) {
         clock = value / 1000;
         gmtime_r(&clock, &tm);
 
@@ -1095,7 +1095,7 @@ njs_date_prototype_get_month(njs_vm_t *v
 
     value = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(value))) {
+    if (nxt_fast_path(!isnan(value))) {
         clock = value / 1000;
         localtime_r(&clock, &tm);
 
@@ -1118,7 +1118,7 @@ njs_date_prototype_get_utc_month(njs_vm_
 
     value = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(value))) {
+    if (nxt_fast_path(!isnan(value))) {
         clock = value / 1000;
 
         gmtime_r(&clock, &tm);
@@ -1142,7 +1142,7 @@ njs_date_prototype_get_date(njs_vm_t *vm
 
     value = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(value))) {
+    if (nxt_fast_path(!isnan(value))) {
         clock = value / 1000;
         localtime_r(&clock, &tm);
 
@@ -1165,7 +1165,7 @@ njs_date_prototype_get_utc_date(njs_vm_t
 
     value = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(value))) {
+    if (nxt_fast_path(!isnan(value))) {
         clock = value / 1000;
         gmtime_r(&clock, &tm);
 
@@ -1188,7 +1188,7 @@ njs_date_prototype_get_day(njs_vm_t *vm,
 
     value = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(value))) {
+    if (nxt_fast_path(!isnan(value))) {
         clock = value / 1000;
         localtime_r(&clock, &tm);
 
@@ -1211,7 +1211,7 @@ njs_date_prototype_get_utc_day(njs_vm_t 
 
     value = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(value))) {
+    if (nxt_fast_path(!isnan(value))) {
         clock = value / 1000;
         gmtime_r(&clock, &tm);
 
@@ -1234,7 +1234,7 @@ njs_date_prototype_get_hours(njs_vm_t *v
 
     value = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(value))) {
+    if (nxt_fast_path(!isnan(value))) {
         clock = value / 1000;
 
         localtime_r(&clock, &tm);
@@ -1258,7 +1258,7 @@ njs_date_prototype_get_utc_hours(njs_vm_
 
     value = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(value))) {
+    if (nxt_fast_path(!isnan(value))) {
         clock = value / 1000;
         gmtime_r(&clock, &tm);
 
@@ -1281,7 +1281,7 @@ njs_date_prototype_get_minutes(njs_vm_t 
 
     value = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(value))) {
+    if (nxt_fast_path(!isnan(value))) {
         clock = value / 1000;
 
         localtime_r(&clock, &tm);
@@ -1305,7 +1305,7 @@ njs_date_prototype_get_utc_minutes(njs_v
 
     value = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(value))) {
+    if (nxt_fast_path(!isnan(value))) {
         clock = value / 1000;
         gmtime_r(&clock, &tm);
 
@@ -1326,7 +1326,7 @@ njs_date_prototype_get_seconds(njs_vm_t 
 
     value = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(value))) {
+    if (nxt_fast_path(!isnan(value))) {
         value = (int64_t) (value / 1000) % 60;
     }
 
@@ -1344,7 +1344,7 @@ njs_date_prototype_get_milliseconds(njs_
 
     value = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(value))) {
+    if (nxt_fast_path(!isnan(value))) {
         value = (int64_t) value % 1000;
     }
 
@@ -1364,7 +1364,7 @@ njs_date_prototype_get_timezone_offset(n
 
     value = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(value))) {
+    if (nxt_fast_path(!isnan(value))) {
         clock = value / 1000;
         localtime_r(&clock, &tm);
 
@@ -1385,7 +1385,7 @@ njs_date_prototype_set_time(njs_vm_t *vm
 
     time = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(time))) {
+    if (nxt_fast_path(!isnan(time))) {
 
         if (nargs > 1) {
             time = args[1].data.u.number;
@@ -1410,7 +1410,7 @@ njs_date_prototype_set_milliseconds(njs_
 
     time = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(time))) {
+    if (nxt_fast_path(!isnan(time))) {
 
         if (nargs > 1) {
             time = (int64_t) (time / 1000) * 1000 + args[1].data.u.number;
@@ -1436,7 +1436,7 @@ njs_date_prototype_set_seconds(njs_vm_t 
 
     time = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(time))) {
+    if (nxt_fast_path(!isnan(time))) {
 
         if (nargs > 1) {
             sec = args[1].data.u.number;
@@ -1467,7 +1467,7 @@ njs_date_prototype_set_minutes(njs_vm_t 
 
     time = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(time))) {
+    if (nxt_fast_path(!isnan(time))) {
 
         if (nargs > 1) {
             clock = time / 1000;
@@ -1504,7 +1504,7 @@ njs_date_prototype_set_utc_minutes(njs_v
 
     time = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(time))) {
+    if (nxt_fast_path(!isnan(time))) {
 
         if (nargs > 1) {
             clock = time / 1000;
@@ -1541,7 +1541,7 @@ njs_date_prototype_set_hours(njs_vm_t *v
 
     time = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(time))) {
+    if (nxt_fast_path(!isnan(time))) {
 
         if (nargs > 1) {
             clock = time / 1000;
@@ -1582,7 +1582,7 @@ njs_date_prototype_set_utc_hours(njs_vm_
 
     time = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(time))) {
+    if (nxt_fast_path(!isnan(time))) {
 
         if (nargs > 1) {
             clock = time / 1000;
@@ -1619,7 +1619,7 @@ njs_date_prototype_set_date(njs_vm_t *vm
 
     time = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(time))) {
+    if (nxt_fast_path(!isnan(time))) {
 
         if (nargs > 1) {
             clock = time / 1000;
@@ -1651,7 +1651,7 @@ njs_date_prototype_set_utc_date(njs_vm_t
 
     time = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(time))) {
+    if (nxt_fast_path(!isnan(time))) {
 
         if (nargs > 1) {
             clock = time / 1000;
@@ -1683,7 +1683,7 @@ njs_date_prototype_set_month(njs_vm_t *v
 
     time = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(time))) {
+    if (nxt_fast_path(!isnan(time))) {
 
         if (nargs > 1) {
             clock = time / 1000;
@@ -1719,7 +1719,7 @@ njs_date_prototype_set_utc_month(njs_vm_
 
     time = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(time))) {
+    if (nxt_fast_path(!isnan(time))) {
 
         if (nargs > 1) {
             clock = time / 1000;
@@ -1755,7 +1755,7 @@ njs_date_prototype_set_full_year(njs_vm_
 
     time = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(time))) {
+    if (nxt_fast_path(!isnan(time))) {
 
         if (nargs > 1) {
             clock = time / 1000;
@@ -1795,7 +1795,7 @@ njs_date_prototype_set_utc_full_year(njs
 
     time = args[0].data.u.date->time;
 
-    if (nxt_fast_path(!njs_is_nan(time))) {
+    if (nxt_fast_path(!isnan(time))) {
 
         if (nargs > 1) {
             clock = time / 1000;
diff -r bcd4910c5be9 -r 109932e1d3c8 njs/njs_math.c
--- a/njs/njs_math.c	Fri Nov 04 18:25:55 2016 +0300
+++ b/njs/njs_math.c	Fri Nov 04 18:25:55 2016 +0300
@@ -342,7 +342,7 @@ njs_object_math_sign(njs_vm_t *vm, njs_v
     if (nargs > 1) {
         num = args[1].data.u.number;
 
-        if (!njs_is_nan(num) && num != 0) {
+        if (!isnan(num) && num != 0) {
             num = signbit(num) ? -1 : 1;
         }
 
diff -r bcd4910c5be9 -r 109932e1d3c8 njs/njs_number.c
--- a/njs/njs_number.c	Fri Nov 04 18:25:55 2016 +0300
+++ b/njs/njs_number.c	Fri Nov 04 18:25:55 2016 +0300
@@ -177,10 +177,10 @@ njs_number_to_string(njs_vm_t *vm, njs_v
 
     num = number->data.u.number;
 
-    if (njs_is_nan(num)) {
+    if (isnan(num)) {
         value = &njs_string_nan;
 
-    } else if (njs_is_infinity(num)) {
+    } else if (isinf(num)) {
 
         if (num < 0) {
             value = &njs_string_minus_infinity;
@@ -445,7 +445,7 @@ njs_number_is_nan(njs_vm_t *vm, njs_valu
 
     value = &njs_value_true;
 
-    if (nargs > 1 && !njs_is_nan(args[1].data.u.number)) {
+    if (nargs > 1 && !isnan(args[1].data.u.number)) {
         value = &njs_value_false;
     }
 
@@ -467,7 +467,7 @@ njs_number_is_finite(njs_vm_t *vm, njs_v
     if (nargs > 1) {
         num = args[1].data.u.number;
 
-        if (!njs_is_nan(num) && !njs_is_infinity(num)) {
+        if (!isnan(num) && !isinf(num)) {
             value = &njs_value_true;
         }
     }
diff -r bcd4910c5be9 -r 109932e1d3c8 njs/njs_number.h
--- a/njs/njs_number.h	Fri Nov 04 18:25:55 2016 +0300
+++ b/njs/njs_number.h	Fri Nov 04 18:25:55 2016 +0300
@@ -11,14 +11,6 @@
 #include <math.h>
 
 
-#define njs_is_infinity(n)                                                    \
-    isinf(n)
-
-
-#define njs_is_nan(n)                                                         \
-    isnan(n)
-
-
 double njs_value_to_number(njs_value_t *value);
 double njs_number_parse(const u_char **start, const u_char *end);
 int64_t njs_number_radix_parse(u_char *p, u_char *end, uint8_t radix,
diff -r bcd4910c5be9 -r 109932e1d3c8 njs/njs_string.c
--- a/njs/njs_string.c	Fri Nov 04 18:25:55 2016 +0300
+++ b/njs/njs_string.c	Fri Nov 04 18:25:55 2016 +0300
@@ -1174,7 +1174,7 @@ njs_string_from_char_code(njs_vm_t *vm, 
 
     for (i = 1; i < nargs; i++) {
         num = args[i].data.u.number;
-        if (njs_is_nan(num)) {
+        if (isnan(num)) {
             goto range_error;
         }
 
diff -r bcd4910c5be9 -r 109932e1d3c8 njs/njs_vm.c
--- a/njs/njs_vm.c	Fri Nov 04 18:25:55 2016 +0300
+++ b/njs/njs_vm.c	Fri Nov 04 18:25:55 2016 +0300
@@ -1973,9 +1973,7 @@ njs_values_compare(njs_value_t *val1, nj
         if (nxt_fast_path(njs_is_numeric(val1) && njs_is_numeric(val2))) {
 
             /* NaN and void values are not comparable with anything. */
-            if (njs_is_nan(val1->data.u.number)
-                || njs_is_nan(val2->data.u.number))
-            {
+            if (isnan(val1->data.u.number) || isnan(val2->data.u.number)) {
                 return -1;
             }
 
@@ -2471,7 +2469,7 @@ njs_normalize_args(njs_vm_t *vm, njs_val
 
                 /* Numbers are truncated to fit in 32-bit integers. */
 
-                if (njs_is_nan(args->data.u.number)) {
+                if (isnan(args->data.u.number)) {
                     args->data.u.number = 0;
 
                 } else if (args->data.u.number > 2147483647.0) {
diff -r bcd4910c5be9 -r 109932e1d3c8 njs/njs_vm.h
--- a/njs/njs_vm.h	Fri Nov 04 18:25:55 2016 +0300
+++ b/njs/njs_vm.h	Fri Nov 04 18:25:55 2016 +0300
@@ -376,7 +376,7 @@ typedef njs_ret_t (*njs_vmcode_operation
 /* Testing for NaN first generates a better code at least on i386/amd64. */
 
 #define njs_is_number_true(num)                                               \
-    (!njs_is_nan(num) && num != 0)
+    (!isnan(num) && num != 0)
 
 
 #define njs_is_numeric(value)                                                 \



More information about the nginx-devel mailing list