public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Use sscanf instead of atoll in gcov-tool.c
@ 2014-09-07 17:36 John David Anglin
  2014-09-08  9:21 ` Richard Biener
  0 siblings, 1 reply; 7+ messages in thread
From: John David Anglin @ 2014-09-07 17:36 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 207 bytes --]

The attached patch fixes bootstrap on hpux which doesn't have the  
atoll function.

Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.

OK for trunk?

Dave
--
John David Anglin	dave.anglin@bell.net



[-- Attachment #2: gcov-tool.c.d.txt --]
[-- Type: text/plain, Size: 597 bytes --]

2014-09-07  John David Anglin  <danglin@gcc.gnu.org>

	PR gcpv-profile/61790
	* gcov-tool.c (do_rewrite): Use sscanf instead of atoll.

Index: gcov-tool.c
===================================================================
--- gcov-tool.c	(revision 214998)
+++ gcov-tool.c	(working copy)
@@ -308,7 +308,7 @@
           break;
         case 'n':
           if (!do_scaling)
-            normalize_val = atoll (optarg);
+            sscanf (optarg, "%lld", &normalize_val);
           else
             fnotice (stderr, "scaling cannot co-exist with normalization,"
                 " skipping\n");

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Use sscanf instead of atoll in gcov-tool.c
  2014-09-07 17:36 [PATCH] Use sscanf instead of atoll in gcov-tool.c John David Anglin
@ 2014-09-08  9:21 ` Richard Biener
  2014-09-14 19:05   ` [PATCH v2] " John David Anglin
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Biener @ 2014-09-08  9:21 UTC (permalink / raw)
  To: John David Anglin; +Cc: GCC Patches

On Sun, Sep 7, 2014 at 7:36 PM, John David Anglin <dave.anglin@bell.net> wrote:
> The attached patch fixes bootstrap on hpux which doesn't have the atoll
> function.
>
> Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.
>
> OK for trunk?

"ll" is not portable (it's GNU), I think BSD uses "q" and windows may
use sth else.  I think the code shouldn't use 'long long' but int64_t
and the appropriate SCNd64 macros for the sscanf format specifier.

Note that C99 has atoll and only C99 has the SCNd64 stuff
(inttypes.h).   I wonder if hpux11 has a C99 conforming inttypes.h?

Thanks,
Richard.

> Dave
> --
> John David Anglin       dave.anglin@bell.net
>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] Use sscanf instead of atoll in gcov-tool.c
  2014-09-08  9:21 ` Richard Biener
@ 2014-09-14 19:05   ` John David Anglin
  2014-09-15 10:38     ` Richard Biener
  0 siblings, 1 reply; 7+ messages in thread
From: John David Anglin @ 2014-09-14 19:05 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 864 bytes --]

On 8-Sep-14, at 5:21 AM, Richard Biener wrote:

> On Sun, Sep 7, 2014 at 7:36 PM, John David Anglin <dave.anglin@bell.net 
> > wrote:
>> The attached patch fixes bootstrap on hpux which doesn't have the  
>> atoll
>> function.
>>
>> Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.
>>
>> OK for trunk?
>
> "ll" is not portable (it's GNU), I think BSD uses "q" and windows may
> use sth else.  I think the code shouldn't use 'long long' but int64_t
> and the appropriate SCNd64 macros for the sscanf format specifier.

Attached is an updated version using the SCNd64 macro.  It works fine
on hpux.  The PRI/SCN macrocs are available back to at least hpux10.20.

The other alternative is to use the atoll implementation in read-rtl.c.

Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.

OK for trunk?

Dave
--
John David Anglin	dave.anglin@bell.net



[-- Attachment #2: gcov-tool.c.d.1.txt --]
[-- Type: text/plain, Size: 841 bytes --]

2014-09-14  John David Anglin  <danglin@gcc.gnu.org>

	PR gcov-profile/61790
	* gcov-tool.c (do_rewrite): Change normalize_val to int64_t.  Use
	sscanf instead of atoll.

Index: gcov-tool.c
===================================================================
--- gcov-tool.c	(revision 215242)
+++ gcov-tool.c	(working copy)
@@ -288,7 +288,7 @@
   int opt;
   int ret;
   const char *output_dir = 0;
-  long long normalize_val = 0;
+  int64_t normalize_val = 0;
   float scale = 0.0;
   int numerator = 1;
   int denominator = 1;
@@ -308,7 +308,7 @@
           break;
         case 'n':
           if (!do_scaling)
-            normalize_val = atoll (optarg);
+            sscanf (optarg, "%" SCNd64, &normalize_val);
           else
             fnotice (stderr, "scaling cannot co-exist with normalization,"
                 " skipping\n");

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] Use sscanf instead of atoll in gcov-tool.c
  2014-09-14 19:05   ` [PATCH v2] " John David Anglin
@ 2014-09-15 10:38     ` Richard Biener
  2014-11-25  1:36       ` [PATCH v3] Use strtoll " John David Anglin
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Biener @ 2014-09-15 10:38 UTC (permalink / raw)
  To: John David Anglin; +Cc: GCC Patches

On Sun, Sep 14, 2014 at 9:04 PM, John David Anglin <dave.anglin@bell.net> wrote:
> On 8-Sep-14, at 5:21 AM, Richard Biener wrote:
>
>> On Sun, Sep 7, 2014 at 7:36 PM, John David Anglin <dave.anglin@bell.net>
>> wrote:
>>>
>>> The attached patch fixes bootstrap on hpux which doesn't have the atoll
>>> function.
>>>
>>> Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.
>>>
>>> OK for trunk?
>>
>>
>> "ll" is not portable (it's GNU), I think BSD uses "q" and windows may
>> use sth else.  I think the code shouldn't use 'long long' but int64_t
>> and the appropriate SCNd64 macros for the sscanf format specifier.
>
>
> Attached is an updated version using the SCNd64 macro.  It works fine
> on hpux.  The PRI/SCN macrocs are available back to at least hpux10.20.

Ok, I'd be happy to require all hosts having "proper" inttypes.h.

So if it works this way for SCNd64 maybe we can remove the "hand-crafting"
of PRId64 stuff in hwint.h ... (or we have to hand-craft SCNd64 as well...).
After all atoll is C99 as well...

> The other alternative is to use the atoll implementation in read-rtl.c.

Also a possibility.  Which would ask for a libiberty implementation
I suppose.

> Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.
>
> OK for trunk?

Let's wait for other opinions.

Thanks,
Richard.

> Dave
> --
> John David Anglin       dave.anglin@bell.net
>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] Use strtoll instead of atoll in gcov-tool.c
  2014-09-15 10:38     ` Richard Biener
@ 2014-11-25  1:36       ` John David Anglin
  2014-12-20 23:41         ` John David Anglin
  0 siblings, 1 reply; 7+ messages in thread
From: John David Anglin @ 2014-11-25  1:36 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 411 bytes --]

On 15-Sep-14, at 5:40 AM, Richard Biener wrote:

> Let's wait for other opinions.

We now have implementations of strtol and strtoll in libiberty.  So,  
it's better to use
these than atoll.  As suggested by Jakub, the patch now falls back to  
int64_t if the
host doesn't have long long.

Tested on hppa2.0w-hpux11.11 and hppa64-hp-hpux11.11.

Okay for trunk?

Dave
--
John David Anglin	dave.anglin@bell.net



[-- Attachment #2: gcov-tool.c.d.3 --]
[-- Type: application/octet-stream, Size: 1183 bytes --]

2014-11-24  John David Anglin  <danglin@gcc.gnu.org>

	PR gcov-profile/61790
	* gcov-tool.c (do_rewrite): Use strtoll instead of atoll if host has
	long long.  Fallback to int64_t if host doesn't have long long and
	use strtol if int64_t is long.  Otherwise, use sscanf for conversion.

Index: gcov-tool.c
===================================================================
--- gcov-tool.c	(revision 217745)
+++ gcov-tool.c	(working copy)
@@ -289,7 +289,11 @@
   int opt;
   int ret;
   const char *output_dir = 0;
+#ifdef HAVE_LONG_LONG
   long long normalize_val = 0;
+#else
+  int64_t normalize_val = 0;
+#endif
   float scale = 0.0;
   int numerator = 1;
   int denominator = 1;
@@ -309,7 +313,13 @@
           break;
         case 'n':
           if (!do_scaling)
-            normalize_val = atoll (optarg);
+#if defined(HAVE_LONG_LONG)
+	    normalize_val = strtoll (optarg, (char **)NULL, 10);
+#elif defined(INT64_T_IS_LONG)
+	    normalize_val = strtol (optarg, (char **)NULL, 10);
+#else
+	    sscanf (optarg, "%" SCNd64, &normalize_val);
+#endif
           else
             fnotice (stderr, "scaling cannot co-exist with normalization,"
                 " skipping\n");

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] Use strtoll instead of atoll in gcov-tool.c
  2014-11-25  1:36       ` [PATCH v3] Use strtoll " John David Anglin
@ 2014-12-20 23:41         ` John David Anglin
  2015-01-08 12:27           ` Richard Biener
  0 siblings, 1 reply; 7+ messages in thread
From: John David Anglin @ 2014-12-20 23:41 UTC (permalink / raw)
  To: John David Anglin; +Cc: Richard Biener, GCC Patches

Ping.

On 24-Nov-14, at 7:38 PM, John David Anglin wrote:

> On 15-Sep-14, at 5:40 AM, Richard Biener wrote:
>
>> Let's wait for other opinions.
>
> We now have implementations of strtol and strtoll in libiberty.  So,  
> it's better to use
> these than atoll.  As suggested by Jakub, the patch now falls back  
> to int64_t if the
> host doesn't have long long.
>
> Tested on hppa2.0w-hpux11.11 and hppa64-hp-hpux11.11.
>
> Okay for trunk?
>
> Dave
> --
> John David Anglin	dave.anglin@bell.net
>
>
> <gcov-tool.c.d.3>


Dave
--
John David Anglin	dave.anglin@bell.net



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] Use strtoll instead of atoll in gcov-tool.c
  2014-12-20 23:41         ` John David Anglin
@ 2015-01-08 12:27           ` Richard Biener
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Biener @ 2015-01-08 12:27 UTC (permalink / raw)
  To: John David Anglin; +Cc: GCC Patches

On Sat, Dec 20, 2014 at 11:51 PM, John David Anglin
<dave.anglin@bell.net> wrote:
> Ping.

Ok.

Thanks,
Richard.

>
> On 24-Nov-14, at 7:38 PM, John David Anglin wrote:
>
>> On 15-Sep-14, at 5:40 AM, Richard Biener wrote:
>>
>>> Let's wait for other opinions.
>>
>>
>> We now have implementations of strtol and strtoll in libiberty.  So, it's
>> better to use
>> these than atoll.  As suggested by Jakub, the patch now falls back to
>> int64_t if the
>> host doesn't have long long.
>>
>> Tested on hppa2.0w-hpux11.11 and hppa64-hp-hpux11.11.
>>
>> Okay for trunk?
>>
>> Dave
>> --
>> John David Anglin       dave.anglin@bell.net
>>
>>
>> <gcov-tool.c.d.3>
>
>
>
> Dave
> --
> John David Anglin       dave.anglin@bell.net
>
>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-01-08 12:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-07 17:36 [PATCH] Use sscanf instead of atoll in gcov-tool.c John David Anglin
2014-09-08  9:21 ` Richard Biener
2014-09-14 19:05   ` [PATCH v2] " John David Anglin
2014-09-15 10:38     ` Richard Biener
2014-11-25  1:36       ` [PATCH v3] Use strtoll " John David Anglin
2014-12-20 23:41         ` John David Anglin
2015-01-08 12:27           ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).