diff options
author | jistone <jistone> | 2006-12-09 02:03:58 +0000 |
---|---|---|
committer | jistone <jistone> | 2006-12-09 02:03:58 +0000 |
commit | 9ba8c134d15dcf75e42dfaef7f72a6bc492fdbbb (patch) | |
tree | 5def76740609ffd298ee2d558905d535a2072350 /translate.cxx | |
parent | 6a256b03673beeea1c2d6731d5b680b50778b124 (diff) | |
download | systemtap-steved-9ba8c134d15dcf75e42dfaef7f72a6bc492fdbbb.tar.gz systemtap-steved-9ba8c134d15dcf75e42dfaef7f72a6bc492fdbbb.tar.xz systemtap-steved-9ba8c134d15dcf75e42dfaef7f72a6bc492fdbbb.zip |
2006-12-08 Josh Stone <joshua.i.stone@intel.com>
PR 3681.
* staptree.h (struct vardecl): Add a literal 'init' member for the
initialization value of globals.
* staptree.cxx (vardecl::vardecl): Initialize 'init' to NULL.
(vardecl::print): Print global init value during pass-1 output.
* main.cxx (printscript): Print global init values during verbose
pass-2 output.
* parse.cxx (parser::parse_global): Set the initialization literal of
global vardecls.
* translate.cxx (var::init): Don't unconditionally override the value
of numeric globals when the module_param isn't used.
(c_unparser::emit_global_param): Write numeric module_params directly
into the global variable, as an int64_t instead of long.
(c_unparser::emit_global): Add initialization to global declarations.
Don't create a temp module_param long for numeric globals anymore.
runtime/
* runtime.h (param_set_int64_t, param_get_int64_t,
param_check_int64_t): New functions to allow taking module parameters
directly as int64_t values.
testsuite/
* systemtap.base/global_init.exp, systemtap.base/global_init.stp: New
test for checking the timeliness of global initialization.
Diffstat (limited to 'translate.cxx')
-rw-r--r-- | translate.cxx | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/translate.cxx b/translate.cxx index f6214206..d1d21ab9 100644 --- a/translate.cxx +++ b/translate.cxx @@ -344,7 +344,7 @@ public: return qname() + "[0] = '\\0';"; case pe_long: if (! local) - return qname() + " = (int64_t) init_" + qname() + ";"; // module_param + return ""; // module_param else return qname() + " = 0;"; case pe_stats: @@ -918,7 +918,7 @@ c_unparser::emit_global_param (vardecl *v) if (v->arity == 0 && v->type == pe_long) { o->newline() << "module_param_named (" << vn << ", " - << "init_global_" << vn << ", long, 0);"; + << "global_" << vn << ", int64_t, 0);"; } else if (v->arity == 0 && v->type == pe_string) { @@ -936,11 +936,17 @@ c_unparser::emit_global (vardecl *v) string vn = c_varname (v->name); if (v->arity == 0) - o->newline() << "static __cacheline_aligned " - << c_typename (v->type) - << " " - << "global_" << vn - << ";"; + { + o->newline() << "static __cacheline_aligned " + << c_typename (v->type) + << " " << "global_" << vn; + if (v->init) + { + o->line() << " = "; + v->init->visit(this); + } + o->line() << ";"; + } else if (v->type == pe_stats) { o->newline() << "static __cacheline_aligned PMAP global_" @@ -953,15 +959,6 @@ c_unparser::emit_global (vardecl *v) } o->newline() << "static __cacheline_aligned rwlock_t " << "global_" << vn << "_lock;"; - - // Emit module_param helper variable - if (v->arity == 0 && v->type == pe_long) - { - // XXX: moduleparam.h does not have a 64-bit type, so let's just - // take a plain long here, and manually copy/widen during - // initialization. See var::init(). - o->newline() << "long init_global_" << vn << ";"; - } } |