From: Ingo Molnar <mingo@elte.hu>
To: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
Cc: linux-kernel@vger.kernel.org,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>,
Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH v3] perf tools: New function to parse string representing size in bytes
Date: Sun, 15 Nov 2009 11:28:59 +0100 [thread overview]
Message-ID: <20091115102859.GA24931@elte.hu> (raw)
In-Reply-To: <1258280343-4359-1-git-send-email-mitake@dcl.info.waseda.ac.jp>
* Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp> wrote:
> + * bytesexp2int()
i suspect this could be named 'bytestring2ll' ? Is 'bytesexp' an
existing naming in other libraries?
> + * Parse (\d+)(b|B|kb|KB|mb|MB|gb|GB|tb|TB) (e.g. "256MB")
> + * and return its numeric value
> + */
> +long long int bytesexp2int(const char *str)
we have type shortcuts for 'long long': s64.
> +{
> + unsigned int i;
> + long long int length = -1, unit = 1;
s64 too i suspect.
> +tera:
> + unit = (long long int)K * K * K * K;
Note, you can probably avoid this type cast if you define the 'K'
literal as 1024LL or so.
> + length = atoll(str) * unit;
we might want to take a naming clue here and name this new function as
atoll_exp(), to signal that it works like atoll, just with an extension
for KB/MB/GB/etc. expressions?
Ingo
next prev parent reply other threads:[~2009-11-15 10:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-15 3:50 [PATCH] perf tools: New function to parse string representing size in bytes Hitoshi Mitake
2009-11-15 5:11 ` Frederic Weisbecker
2009-11-15 8:08 ` Ingo Molnar
2009-11-15 8:15 ` Hitoshi Mitake
2009-11-15 8:17 ` [PATCH v2] " Hitoshi Mitake
2009-11-15 8:57 ` Ingo Molnar
2009-11-15 9:52 ` Hitoshi Mitake
2009-11-15 10:19 ` [PATCH v3] " Hitoshi Mitake
2009-11-15 10:28 ` Ingo Molnar [this message]
2009-11-15 10:57 ` Hitoshi Mitake
2009-11-15 11:04 ` Ingo Molnar
2009-11-15 11:32 ` Hitoshi Mitake
2009-11-15 11:36 ` [PATCH v4] " Hitoshi Mitake
2009-11-15 14:18 ` [tip:perf/core] perf tools: Add new perf_atoll() " tip-bot for Hitoshi Mitake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091115102859.GA24931@elte.hu \
--to=mingo@elte.hu \
--cc=a.p.zijlstra@chello.nl \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mitake@dcl.info.waseda.ac.jp \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.