- make_COW_* sets flag on the source string [1]
- if that is solved (with a special RO flag, or whatever) we have:
- string_make sets a default type and encoding if these arguments were NULL. These constant strings have NULL for encoding/type so during string_append as the encodings differ transcode is called - next SIGSEGV with NULL encoding pointer.
So using these .rodata-constant STRINGs needs a lot of work.
- COW code (there are problems with COWed stacks anyway)
- transcoding stuff (should be changed to use {strstart, byteidx} and do something about default vs NULL type/encoding.
leo
[1] this was called via string_copy in the spf_vtable code (I don't see the point, why a string should be copied just to print it - removed)
#include "parrot/parrot.h" #include "parrot/embed.h"
#if ! DISABLE_GC_DEBUG # define GC_DEBUG_VERSION ,0 #else # define GC_DEBUG_VERSION #endif
#define PCONCAT(b,c) _Parrot_static_##b##c #define PARROT_DECLARE_STATIC_STRING(name, cstring) \ static const char PCONCAT(name,_cstring) * = cstring; \ static const struct parrot_string_t \ PCONCAT(name,_STRING) = { \ { /* pobj_t */ \ {{ \ (void*)PCONCAT(name,_cstring), \ sizeof(PCONCAT(name,_cstring)) \ }}, \ PObj_constant_FLAG \ GC_DEBUG_VERSION \ }, \ sizeof(PCONCAT(name,_cstring)), \ (void*)PCONCAT(name,_cstring), \ sizeof(PCONCAT(name,_cstring)) - 1, \ NULL, \ NULL, \ 0 \ }, * const name = &PCONCAT(name,_STRING)
int main(int argc, char* argv[]) { int dummy_var; struct Parrot_Interp * interpreter; PARROT_DECLARE_STATIC_STRING(mystr, "some string here");
interpreter = Parrot_new(); Parrot_init(interpreter, (void*) &dummy_var); PIO_printf(interpreter, "%S\n", mystr); return 0; }