parse: use MIN/MAXDOUBLE instead of some representation of NAN
[fio.git] / parse.c
diff --git a/parse.c b/parse.c
index d15d22ba3f7ed03a68e77614a02b44616d64daa5..144794aa09b34d903e2e44969ba788adc70de25f 100644 (file)
--- a/parse.c
+++ b/parse.c
 #include <limits.h>
 #include <stdlib.h>
 #include <math.h>
+#include <values.h>
 
 #include "parse.h"
 #include "debug.h"
 #include "options.h"
 #include "minmax.h"
+#include "lib/ieee754.h"
 
 static struct fio_option *fio_options;
 extern unsigned int fio_get_kb_base(void *);
@@ -49,11 +51,11 @@ static void show_option_range(struct fio_option *o,
                                int (*logger)(const char *format, ...))
 {
        if (o->type == FIO_OPT_FLOAT_LIST){
-               if (isnan(o->minfp) && isnan(o->maxfp))
+               if (o->minfp == MINDOUBLE && o->maxfp == MAXDOUBLE)
                        return;
 
                logger("%20s: min=%f", "range", o->minfp);
-               if (!isnan(o->maxfp))
+               if (o->maxfp != MAXDOUBLE)
                        logger(", max=%f", o->maxfp);
                logger("\n");
        } else {
@@ -362,7 +364,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                           int first, int more, int curr)
 {
        int il, *ilp;
-       double* flp;
+       fio_fp64_t *flp;
        long long ull, *ullp;
        long ul1, ul2;
        double uf;
@@ -500,12 +502,6 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                break;
        }
        case FIO_OPT_FLOAT_LIST: {
-
-               if (first) {
-                       ul2 = 1;
-                       ilp = td_var(data, o->off2);
-                       *ilp = ul2;
-               }
                if (curr >= o->maxlen) {
                        log_err("the list exceeding max length %d\n",
                                        o->maxlen);
@@ -515,19 +511,19 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
                        log_err("not a floating point value: %s\n", ptr);
                        return 1;
                }
-               if (!isnan(o->maxfp) && uf > o->maxfp) {
+               if (uf > o->maxfp) {
                        log_err("value out of range: %f"
                                " (range max: %f)\n", uf, o->maxfp);
                        return 1;
                }
-               if (!isnan(o->minfp) && uf < o->minfp) {
+               if (uf < o->minfp) {
                        log_err("value out of range: %f"
                                " (range min: %f)\n", uf, o->minfp);
                        return 1;
                }
 
                flp = td_var(data, o->off1);
-               flp[curr] = uf;
+               flp[curr].u.f = uf;
 
                break;
        }
@@ -1096,11 +1092,8 @@ void option_init(struct fio_option *o)
                        o->maxval = UINT_MAX;
        }
        if (o->type == FIO_OPT_FLOAT_LIST) {
-#ifndef NAN
-#define NAN __builtin_nanf("")
-#endif
-               o->minfp = NAN;
-               o->maxfp = NAN;
+               o->minfp = MINDOUBLE;
+               o->maxfp = MAXDOUBLE;
        }
        if (o->type == FIO_OPT_STR_SET && o->def) {
                log_err("Option %s: string set option with"