[patch] Avoid using strtoll

Rainer Orth ro@CeBiTec.Uni-Bielefeld.DE
Thu Nov 19 10:20:00 GMT 2009


Rafael Espindola <espindola@google.com> writes:

> The attached patch avoids using strtoll in gcc code. It also fixes the
> assumption that long long is 64 bits.
>
> If I understand it correctly, the configure system does its best to
> give us a 64 bit type, so this patch should be portable.
>
> OK if it boostraps and tests are OK?
>
> gcc/lto
> 2009-11-18  Rafael Avila de Espindola  <espindola@google.com>
>
> 	PR42096

This is wrong: it should be PR bootstrap/42096 instead.

diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c
index 8cbafbc..4a8a0ff 100644
--- a/lto-plugin/lto-plugin.c
+++ b/lto-plugin/lto-plugin.c
@@ -551,7 +551,7 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed)
       Elf *archive;
       off_t offset;
       /* We pass the offset of the actual file, not the archive header. */
-      int t = asprintf (&objname, "%s@%" PRId64, file->name,
+      int t = asprintf (&objname, "%s@0x%" PRIx64, file->name,

Unconditional use of PRI* is problematic, either: older platforms lack
it, although I'm not sure if this affects ELF platforms at the moment
(IRIX 5, probably).

cf. intl/loadmsgcat.c for a workaround, although that doesn't work as is
because you cannot use constructs like

# define PRId64 (sizeof (long) == 8 ? "ld" : "lld")

with string concatenation.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University



More information about the Gcc-patches mailing list