[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/3] qemu: Add strtosz_suffix_unit function
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH 1/3] qemu: Add strtosz_suffix_unit function |
Date: |
Fri, 08 Jul 2011 10:00:44 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
Joerg Roedel <address@hidden> writes:
> This function does the same as the strtosz_suffix function
> except that it allows to specify the unit to which the
> k/M/B/T suffixes apply. This function will be used later to
> parse the tsc-frequency from the command-line.
>
> Signed-off-by: Joerg Roedel <address@hidden>
> ---
> cutils.c | 16 +++++++++++-----
> qemu-common.h | 2 ++
> 2 files changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/cutils.c b/cutils.c
> index f9a7e36..28049e0 100644
> --- a/cutils.c
> +++ b/cutils.c
> @@ -322,7 +322,8 @@ int fcntl_setfl(int fd, int flag)
> * value must be terminated by whitespace, ',' or '\0'. Return -1 on
> * error.
> */
> -int64_t strtosz_suffix(const char *nptr, char **end, const char
> default_suffix)
> +int64_t strtosz_suffix_unit(const char *nptr, char **end,
> + const char default_suffix, int64_t unit)
> {
> int64_t retval = -1;
> char *endptr;
> @@ -362,20 +363,20 @@ int64_t strtosz_suffix(const char *nptr, char **end,
> const char default_suffix)
> }
> break;
> case STRTOSZ_DEFSUFFIX_KB:
> - mul = 1 << 10;
> + mul = unit;
> break;
> case 0:
> if (mul_required) {
> goto fail;
> }
> case STRTOSZ_DEFSUFFIX_MB:
> - mul = 1ULL << 20;
> + mul = unit * unit;
> break;
> case STRTOSZ_DEFSUFFIX_GB:
> - mul = 1ULL << 30;
> + mul = unit * unit * unit;
> break;
> case STRTOSZ_DEFSUFFIX_TB:
> - mul = 1ULL << 40;
> + mul = unit * unit * unit * unit;
> break;
> default:
> goto fail;
> @@ -405,6 +406,11 @@ fail:
> return retval;
> }
Why would anyone ever call this function with an unit argument other
than 1000 or 1024?
Without such a use case, I'd rather give strtosz_suffix() a flag
parameter to pick SI prefixes (multiples of 1000) vs. binary prefixes
(multiples of 1024).
[...]
- [Qemu-devel] [PATCH 0/3][uq/master] Basic TSC-Scaling support v2, Joerg Roedel, 2011/07/07
- [Qemu-devel] [PATCH 1/3] qemu: Add strtosz_suffix_unit function, Joerg Roedel, 2011/07/07
- Re: [Qemu-devel] [PATCH 1/3] qemu: Add strtosz_suffix_unit function,
Markus Armbruster <=
- [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu, Joerg Roedel, 2011/07/07
- Re: [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu, Marcelo Tosatti, 2011/07/19
- Re: [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu, Avi Kivity, 2011/07/19
- Re: [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu, Marcelo Tosatti, 2011/07/19
- Re: [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu, Joerg Roedel, 2011/07/19
- Re: [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu, Avi Kivity, 2011/07/19
- Re: [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu, Avi Kivity, 2011/07/19
- Re: [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu, Joerg Roedel, 2011/07/19
- Re: [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu, Avi Kivity, 2011/07/19
[Qemu-devel] [PATCH 3/3] qemu-x86: Set tsc_khz in kvm when supported, Joerg Roedel, 2011/07/07