benchmark silo added
[c11concurrency-benchmarks.git] / silo / masstree / misc.cc
1 /* Masstree
2  * Eddie Kohler, Yandong Mao, Robert Morris
3  * Copyright (c) 2012-2013 President and Fellows of Harvard College
4  * Copyright (c) 2012-2013 Massachusetts Institute of Technology
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, subject to the conditions
9  * listed in the Masstree LICENSE file. These conditions include: you must
10  * preserve this copyright notice, and you cannot mention the copyright
11  * holders in advertising related to the Software without their permission.
12  * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This
13  * notice is a summary of the Masstree LICENSE file; the license in that file
14  * is legally binding.
15  */
16 #include "misc.hh"
17 #include <unistd.h>
18 #include "kvthread.hh"
19
20 int clp_parse_suffixdouble(Clp_Parser *clp, const char *vstr,
21                            int complain, void *)
22 {
23     const char *post;
24     if (*vstr == 0 || isspace((unsigned char) *vstr))
25         post = vstr;
26     else
27         clp->val.d = strtod(vstr, (char **) &post);
28     if (vstr != post && (*post == 'K' || *post == 'k'))
29         clp->val.d *= 1000, ++post;
30     else if (vstr != post && (*post == 'M' || *post == 'm'))
31         clp->val.d *= 1000000, ++post;
32     else if (vstr != post && (*post == 'B' || *post == 'b' || *post == 'G' || *post == 'g'))
33         clp->val.d *= 1000000000, ++post;
34     if (*vstr != 0 && *post == 0)
35         return 1;
36     else if (complain)
37         return Clp_OptionError(clp, "%<%O%> expects a real number, not %<%s%>", vstr);
38     else
39         return 0;
40 }