This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: Global constants
Hi,
On Mon, 2006-02-13 at 15:10 -0500, Frank Ch. Eigler wrote:
> > Also it would be nice to have a way to declare these constants in
> > embedded C [...]
> > something like
> > %{ const_O_CREAT = O_CREAT; %}
> > instead of
> > O_CREAT = 64
>
> One problem with this is that globals, if elided by the optimizer,
> would still have such references within the opaque embedded-C blocks.
> (That's one of the reasons that embedded-C code should not refer to
> systemtap data other than its arguments.)
Yep, that's why I initially was doing this:
In translate.cxx:emit_global()
---
o->newline() << "static rwlock_t "
<< "global_" << c_varname (v->name) << "_lock;";
+ o->newline() << "#define global_"
+ << c_varname(v->name) << "_DEFINED 1";
---
and then
---
global O_CREAT
function init_sys_open_flags () %{
#ifdef global_O_CREAT_DEFINED
global_O_CREAT = 64;
#endif
%}
---
Cheers,
Mark.