projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Include juggling
[fio.git]
/
parse.c
diff --git
a/parse.c
b/parse.c
index 29f444b40ba1d6589a2d1a9813ab0bfb058d73f1..78218615b79246a50c02107b7907ef747dd95476 100644
(file)
--- a/
parse.c
+++ b/
parse.c
@@
-14,6
+14,7
@@
#include "debug.h"
static struct fio_option *fio_options;
#include "debug.h"
static struct fio_option *fio_options;
+extern unsigned int fio_get_kb_base(void *);
static int vp_cmp(const void *p1, const void *p2)
{
static int vp_cmp(const void *p1, const void *p2)
{
@@
-112,30
+113,39
@@
static unsigned long get_mult_time(char c)
}
}
}
}
-static unsigned long
get_mult_bytes(char c
)
+static unsigned long
long get_mult_bytes(char c, void *data
)
{
{
+ unsigned int kb_base = fio_get_kb_base(data);
+ unsigned long long ret = 1;
+
switch (c) {
switch (c) {
- case 'k':
- case 'K':
- return 1024;
- case 'm':
- case 'M':
- return 1024 * 1024;
+ default:
+ break;
+ case 'p':
+ case 'P':
+ ret *= (unsigned long long) kb_base;
+ case 't':
+ case 'T':
+ ret *= (unsigned long long) kb_base;
case 'g':
case 'G':
case 'g':
case 'G':
- return 1024 * 1024 * 1024;
- case 'e':
- case 'E':
- return 1024 * 1024 * 1024 * 1024UL;
- default:
- return 1;
+ ret *= (unsigned long long) kb_base;
+ case 'm':
+ case 'M':
+ ret *= (unsigned long long) kb_base;
+ case 'k':
+ case 'K':
+ ret *= (unsigned long long) kb_base;
+ break;
}
}
+
+ return ret;
}
/*
* convert string into decimal value, noting any size suffix
*/
}
/*
* convert string into decimal value, noting any size suffix
*/
-int str_to_decimal(const char *str, long long *val, int kilo)
+int str_to_decimal(const char *str, long long *val, int kilo
, void *data
)
{
int len, base;
{
int len, base;
@@
-153,21
+163,21
@@
int str_to_decimal(const char *str, long long *val, int kilo)
return 1;
if (kilo)
return 1;
if (kilo)
- *val *= get_mult_bytes(str[len - 1]);
+ *val *= get_mult_bytes(str[len - 1]
, data
);
else
*val *= get_mult_time(str[len - 1]);
return 0;
}
else
*val *= get_mult_time(str[len - 1]);
return 0;
}
-static int check_str_bytes(const char *p, long long *val)
+static int check_str_bytes(const char *p, long long *val
, void *data
)
{
{
- return str_to_decimal(p, val, 1);
+ return str_to_decimal(p, val, 1
, data
);
}
static int check_str_time(const char *p, long long *val)
{
}
static int check_str_time(const char *p, long long *val)
{
- return str_to_decimal(p, val, 0);
+ return str_to_decimal(p, val, 0
, NULL
);
}
void strip_blank_front(char **p)
}
void strip_blank_front(char **p)
@@
-200,7
+210,7
@@
void strip_blank_end(char *p)
*(s + 1) = '\0';
}
*(s + 1) = '\0';
}
-static int check_range_bytes(const char *str, long *val)
+static int check_range_bytes(const char *str, long *val
, void *data
)
{
char suffix;
{
char suffix;
@@
-208,7
+218,7
@@
static int check_range_bytes(const char *str, long *val)
return 1;
if (sscanf(str, "%lu%c", val, &suffix) == 2) {
return 1;
if (sscanf(str, "%lu%c", val, &suffix) == 2) {
- *val *= get_mult_bytes(suffix);
+ *val *= get_mult_bytes(suffix
, data
);
return 0;
}
return 0;
}
@@
-309,7
+319,7
@@
static int __handle_option(struct fio_option *o, const char *ptr, void *data,
if (is_time)
ret = check_str_time(ptr, &ull);
else
if (is_time)
ret = check_str_time(ptr, &ull);
else
- ret = check_str_bytes(ptr, &ull);
+ ret = check_str_bytes(ptr, &ull
, data
);
if (ret)
break;
if (ret)
break;
@@
-376,8
+386,8
@@
static int __handle_option(struct fio_option *o, const char *ptr, void *data,
p1 = tmp;
ret = 1;
p1 = tmp;
ret = 1;
- if (!check_range_bytes(p1, &ul1) &&
- !check_range_bytes(p2, &ul2)) {
+ if (!check_range_bytes(p1, &ul1
, data
) &&
+ !check_range_bytes(p2, &ul2
, data
)) {
ret = 0;
if (ul1 > ul2) {
unsigned long foo = ul1;
ret = 0;
if (ul1 > ul2) {
unsigned long foo = ul1;
@@
-547,7
+557,7
@@
static int opt_cmp(const void *p1, const void *p2)
o1 = get_option(s1, fio_options, &foo);
o2 = get_option(s2, fio_options, &foo);
o1 = get_option(s1, fio_options, &foo);
o2 = get_option(s2, fio_options, &foo);
-
+
prio1 = prio2 = 0;
if (o1)
prio1 = o1->prio;
prio1 = prio2 = 0;
if (o1)
prio1 = o1->prio;