[PATCH 4/7] GCOV: add -j argument (human readable format).
Martin Liška
mliska@suse.cz
Tue Oct 31 14:04:00 GMT 2017
On 10/31/2017 01:05 PM, Nathan Sidwell wrote:
> On 10/31/2017 07:49 AM, Martin Liška wrote:
>> On 10/30/2017 01:35 PM, Nathan Sidwell wrote:
>
>> Is the patch fine to be installed?
> not quite ...
>
>
> +Â gcov_type divisor = 1;
> +Â for (unsigned i = 0; i < strlen (units); i++)
> +Â Â Â {
> +Â Â Â Â Â if (v < (1000 * divisor))
> +Â Â Â {
> +Â Â Â Â Â gcov_type r = (gcov_type)roundf (v / divisor);
> +Â Â Â Â Â sprintf (buffer, "%" PRId64 "%c", r, units[i]);
> +Â Â Â Â Â return buffer;
> +Â Â Â }
> +Â Â Â Â Â divisor *= 1000;
> +Â Â Â }
>
> This doesn't deal with rounding to 1000, which will look a bit odd. It'll also overflow if we ever get 10^24 counts (yeah, like that'll ever happen in this universe). We may as well not use floats either.
Hi.
Do you mean numbers a bit smaller than 1000 or bit bigger? Do you have an example that will
be handled in a different way?
>
> Excuse the poor formatting
>
> Â unsigned i;
> Â for (i = 0; units[i+1]; i++, divisor *= 1000) {
> Â Â Â if (count + divisor / 2 < 1000 * divisor)
> Â Â Â Â Â Â break;
> Â }
>  gcov_type r = (count + divisor / 2) / divisor;
> Â sprintf (buffer, "%" PRId64 "%c", r, units[i]);
> Â return buffer;
>
I've adapted your code snippet.
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-GCOV-add-j-argument-human-readable-format-v3.patch
Type: text/x-patch
Size: 7507 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20171031/9f092081/attachment.bin>
More information about the Gcc-patches
mailing list