Juergen Boemmels wrote:
> 
> Leopold Toetsch <[EMAIL PROTECTED]> writes:
> 
> > Benjamin Goldberg <[EMAIL PROTECTED]> wrote:
> >
> > > #define PARROT_DECLARE_STATIC_STRING(name, cstring) \
> >
> > [ big snip ]
> >
> > While Juergen's original or your proposal are fine, they don't work
> > (or not as proposed). First there are compiler issues:
> >
[snip]
> > The declaration looks ok at first sight, my gcc 2.95.2 might be wrong, but
> > anyway, a bigger problem is here:
> >
> >      PIO_printf(interpreter, "%S\n", mystr);
> >
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x400f8725 in make_COW_reference (interpreter=0x8049828, s=0x80486e0)
> >     at string.c:95
> > 95              PObj_constant_CLEAR(s);
> > (gdb) bac
> > #0  0x400f8725 in make_COW_reference (interpreter=0x8049828, s=0x80486e0)
> >     at string.c:95
> > #1  0x400f91b6 in string_copy (interpreter=0x8049828, s=0x80486e0)
> >     at string.c:497
> 
> Ah it seems that make_COW_reference wants to change a constant
> string. As my code puts the static strings in .rodata (this was one of
> the targets of my experiments) it is not possible in any way to change
> this item.

The problem is that as far as the COW logic knows, only the *buffer* is
constant.  In this (peciliar?) case, both the string buffer and the
string header are constant.

> I even think PObj_constant_CLEAR(s) is evil. One reason for
> setting a PObj_constant_FLAG is to declare that an object will not
> change. Unsetting this flag means breaking this contract.

It's clearing the constant flag, then making the copy, then turning the
constant flag back on.  If it were only the buffer that were in const
memory, and not the header, this would be perfectly fine.  I think.

> > snippet from objdump:
> >
> >  .rodata        00000011              _Parrot_static_mystr_cstring.15
> >  .rodata        00000024              _Parrot_static_mystr_STRING.16
> >
> > If we get a general compiler independend solution for declaring static
> > STRINGs we still have nothing for static keys.
> 
> The main problem of all this code is the union initialiser. Static
> keys could also created with an initialisier, but i think this needs
> an other union-val to be initialized. There are gcc extension to init
> arbitary members, but ANSI-C allows only the initializiation of the
> first member.

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "[EMAIL PROTECTED]
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}

Reply via email to