summaryrefslogtreecommitdiffstats
path: root/translate.cxx
diff options
context:
space:
mode:
authorgraydon <graydon>2005-12-07 01:47:31 +0000
committergraydon <graydon>2005-12-07 01:47:31 +0000
commit1b9cc5b658bbc69627dcc288913189674c05bbc1 (patch)
treee3331e5ce2359a47a283457ed633e0e5b24a75ec /translate.cxx
parent29e64872aaaf83106315b4fabe72983f73b0dfd2 (diff)
downloadsystemtap-steved-1b9cc5b658bbc69627dcc288913189674c05bbc1.tar.gz
systemtap-steved-1b9cc5b658bbc69627dcc288913189674c05bbc1.tar.xz
systemtap-steved-1b9cc5b658bbc69627dcc288913189674c05bbc1.zip
2005-12-06 Graydon Hoare <graydon@redhat.com>
* translate.cxx (visit_print_format): Explicitly Cast int64_t (pe_long) args to (long long) in generated code, for portability.
Diffstat (limited to 'translate.cxx')
-rw-r--r--translate.cxx14
1 files changed, 13 insertions, 1 deletions
diff --git a/translate.cxx b/translate.cxx
index ee1eff41..e84f9373 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -3154,7 +3154,19 @@ c_unparser::visit_print_format (print_format* e)
for (unsigned i = 0; i < tmp.size(); ++i)
{
- o->line() << ", " << tmp[i].qname();
+ // We must cast our pe_long type (which is int64_t) to "long
+ // long" here, because the format string type we are using
+ // is %ll. We use this format string because, at the back
+ // end of vsnprintf, linux actually implements it using the
+ // "long long" type as well, not a particular 32 or 64 bit
+ // width, and it *also* fails to provide any inttype.h-like
+ // macro machinery to figure out how many bits exist in a
+ // long long. Using %ll and always casting the argument is
+ // the most portable target-sensitive solution.
+ if (tmp[i].type() == pe_long)
+ o->line() << ", ((long long)(" << tmp[i].qname() << "))";
+ else
+ o->line() << ", " << tmp[i].qname();
}
o->line() << ");";
o->newline() << res.qname() << ";";