On 2016-05-18 2:20 AM, Jakub Jelinek wrote:
On Tue, May 17, 2016 at 08:31:00PM -0400, John David Anglin wrote:
>r235550 introduced the use of long long, and the macros LLONG_MIN and
LLONG_MAX. These macros
>are not defined by default and we need to include when compiling
with c++ to define them.
IMNSHO we should get rid of those long long uses instead and just use
int64_t and INTTYPE_MINIMUM (int64_t) and INTTYPE_MAXIMUM (int64_t).
There is also another use of long long in libcpp, we should also replace
that.
The attached change implements the above. There is an implicit
assumption that int64_t
is long long if it is not long.
The patch also changes gcov-tool.c. This affects the interface somewhat but
I think consistently using int64_t better.
Tested on hppa2.0w-hp-hpux11.11. Okay for trunk?
Dave
--
John David Anglin dave.ang...@bell.net
2016-05-20 John David Anglin
PR bootstrap/71014
* c-common.c (get_source_date_epoch): Use int64_t instead of long long.
* gcov-tool.c (profile_rewrite): Use int64_t instead of long long.
(do_rewrite): likewise.
* line-map.c (location_adhoc_data_update): Use int64_t instead of
long long.
(get_combined_adhoc_loc): Likewise.
Index: gcc/c-family/c-common.c
===
--- gcc/c-family/c-common.c (revision 236418)
+++ gcc/c-family/c-common.c (working copy)
@@ -12798,7 +12798,7 @@
get_source_date_epoch ()
{
char *source_date_epoch;
- long long epoch;
+ int64_t epoch;
char *endptr;
source_date_epoch = getenv ("SOURCE_DATE_EPOCH");
@@ -12806,8 +12806,13 @@
return (time_t) -1;
errno = 0;
+#if defined(INT64_T_IS_LONG)
+ epoch = strtol (source_date_epoch, &endptr, 10);
+#else
epoch = strtoll (source_date_epoch, &endptr, 10);
- if ((errno == ERANGE && (epoch == LLONG_MAX || epoch == LLONG_MIN))
+#endif
+ if ((errno == ERANGE && (epoch == INTTYPE_MAXIMUM (int64_t)
+ || epoch == INTTYPE_MINIMUM (int64_t)))
|| (errno != 0 && epoch == 0))
fatal_error (UNKNOWN_LOCATION, "environment variable $SOURCE_DATE_EPOCH: "
"strtoll: %s\n", xstrerror(errno));
@@ -12819,7 +12824,7 @@
"trailing garbage: %s\n", endptr);
if (epoch < 0)
fatal_error (UNKNOWN_LOCATION, "environment variable $SOURCE_DATE_EPOCH: "
-"value must be nonnegative: %lld \n", epoch);
+"value must be nonnegative: %" SCNd64 "\n", epoch);
return (time_t) epoch;
}
Index: gcc/gcov-tool.c
===
--- gcc/gcov-tool.c (revision 236418)
+++ gcc/gcov-tool.c (working copy)
@@ -232,7 +232,7 @@
Otherwise, multiply the all counters by SCALE. */
static int
-profile_rewrite (const char *d1, const char *out, long long n_val,
+profile_rewrite (const char *d1, const char *out, int64_t n_val,
float scale, int n, int d)
{
struct gcov_info * d1_profile;
@@ -261,7 +261,7 @@
fnotice (file, "-v, --verbose Verbose mode\n");
fnotice (file, "-o, --output Output directory\n");
fnotice (file, "-s, --scale Scale the profile
counters\n");
- fnotice (file, "-n, --normalize Normalize the
profile\n");
+ fnotice (file, "-n, --normalizeNormalize the
profile\n");
}
static const struct option rewrite_options[] =
@@ -291,11 +291,7 @@
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;
@@ -315,12 +311,10 @@
break;
case 'n':
if (!do_scaling)
-#if defined(HAVE_LONG_LONG)
- normalize_val = strtoll (optarg, (char **)NULL, 10);
-#elif defined(INT64_T_IS_LONG)
+#if defined(INT64_T_IS_LONG)
normalize_val = strtol (optarg, (char **)NULL, 10);
#else
- sscanf (optarg, "%" SCNd64, &normalize_val);
+ normalize_val = strtoll (optarg, (char **)NULL, 10);
#endif
else
fnotice (stderr, "scaling cannot co-exist with normalization,"
Index: libcpp/line-map.c
===
--- libcpp/line-map.c (revision 236418)
+++ libcpp/line-map.c (working copy)
@@ -102,7 +102,7 @@
static int
location_adhoc_data_update (void **slot, void *data)
{
- *((char **) slot) += *((long long *) data);
+ *((char **) slot) += *((int64_t *) data);
return 1;
}
@@ -224,7 +224,7 @@
set->location_adhoc_data_map.allocated)
{
char *orig_data = (char *) set->location_adhoc_data_map.data;
- long long offset;
+ int64_t offset;
/* Cast away extern "C" from the type of xrealloc. */
line_map_realloc reallocator = (set->reallocator