On Fri, Aug 17, 2007 at 06:59:27AM -0700, Steve Peters wrote: > # New Ticket Created by Steve Peters > # Please include the string: [perl #44729] > # in the subject line of all future correspondence about this issue. > # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=44729 > > > > The attached patch cleans up some problems with C++ compiling currently > with Parrot. > > Steve Peters > [EMAIL PROTECTED]
The changes to src/gc/smallobject.c seems to be causing some coredumps. The attached patch backs out that change and adds a few additional ones. Enjoy! Steve Peters [EMAIL PROTECTED]
Index: src/stm/waitlist.c =================================================================== --- src/stm/waitlist.c (revision 20650) +++ src/stm/waitlist.c (working copy) @@ -56,7 +56,7 @@ if (!txlog->waitlist_data) { txlog->waitlist_data = - mem_sys_allocate_zeroed(sizeof (*txlog->waitlist_data)); + (waitlist_thread_data*)mem_sys_allocate_zeroed(sizeof (*txlog->waitlist_data)); MUTEX_INIT(txlog->waitlist_data->signal_mutex); txlog->waitlist_data->signal_cond = &interp->thread_data->interp_cond; #if WAITLIST_DEBUG @@ -84,12 +84,12 @@ thr = get_thread(interp); if (!thr->entries) { - thr->entries = mem_sys_allocate_zeroed(sizeof (*thr->entries) * 4); + thr->entries = (waitlist_entry**)mem_sys_allocate_zeroed(sizeof (*thr->entries) * 4); thr->entry_count = 4; } if (thr->used_entries >= thr->entry_count) { - thr->entries = mem_sys_realloc_zeroed(thr->entries, + thr->entries = (waitlist_entry**)mem_sys_realloc_zeroed(thr->entries, sizeof (*thr->entries) * thr->entry_count * 2, sizeof (*thr->entries) * thr->entry_count); thr->entry_count *= 2; @@ -97,7 +97,7 @@ i = thr->used_entries++; if (!thr->entries[i]) - thr->entries[i] = mem_sys_allocate_zeroed(sizeof (**thr->entries)); + thr->entries[i] = (waitlist_entry*)mem_sys_allocate_zeroed(sizeof (**thr->entries)); PARROT_ASSERT(thr->entries[i]->head == NULL); PARROT_ASSERT(thr->entries[i]->next == NULL); @@ -111,9 +111,11 @@ add_entry(NOTNULL(STM_waitlist *waitlist), NOTNULL(struct waitlist_entry *entry)) { int successp = -1; + void *result; PARROT_ASSERT(entry->next == NULL); do { - PARROT_ATOMIC_PTR_GET(entry->next, waitlist->first); + PARROT_ATOMIC_PTR_GET(result, waitlist->first); + entry->next = (waitlist_entry *)result; PARROT_ASSERT(successp != -1 || entry->next != entry); PARROT_ASSERT(entry->next != entry); PARROT_ATOMIC_PTR_CAS(successp, waitlist->first, entry->next, entry); @@ -143,12 +145,14 @@ waitlist_remove(STM_waitlist *waitlist, struct waitlist_entry *what) { struct waitlist_entry *cur; + void *result; if (!waitlist) return; LOCK(waitlist->remove_mutex); - PARROT_ATOMIC_PTR_GET(cur, waitlist->first); + PARROT_ATOMIC_PTR_GET(result, waitlist->first); + cur = (waitlist_entry *)result; /* if we became the first entry while we were acquiring the mutex */ while (cur == what) { @@ -158,7 +162,8 @@ what->next = NULL; return; } - PARROT_ATOMIC_PTR_GET(cur, waitlist->first); + PARROT_ATOMIC_PTR_GET(result, waitlist->first); + cur = (waitlist_entry *)result; } if (!cur) { @@ -225,11 +230,13 @@ { int successp; struct waitlist_entry *cur; + void *result; /* make sure we are not interrupted by a concurrent removal */ LOCK(list->remove_mutex); do { - PARROT_ATOMIC_PTR_GET(cur, list->first); + PARROT_ATOMIC_PTR_GET(result, list->first); + cur = (waitlist_entry *)result; PARROT_ATOMIC_PTR_CAS(successp, list->first, cur, NULL); } while (!successp); Index: src/pbc_merge.c =================================================================== --- src/pbc_merge.c (revision 20650) +++ src/pbc_merge.c (working copy) @@ -175,7 +175,7 @@ str_dup(NOTNULL(const char *old)) { const size_t bytes = strlen(old) + 1; - char * const copy = mem_sys_allocate(bytes); + char * const copy = (char *)mem_sys_allocate(bytes); memcpy(copy, old, bytes); #ifdef MEMDEBUG debug(interp, 1,"line %d str_dup %s [%x]\n", line, old, copy); Index: src/gc/register.c =================================================================== --- src/gc/register.c (revision 20650) +++ src/gc/register.c (working copy) @@ -298,7 +298,7 @@ CONTEXT(interp->ctx) = ctx; ctx->regs_mem_size = reg_alloc; - ctx->n_regs_used = mem_sys_allocate(sizeof (INTVAL) * 4); + ctx->n_regs_used = (INTVAL *)mem_sys_allocate(sizeof (INTVAL) * 4); ctx->n_regs_used[REGNO_INT] = old->n_regs_used[REGNO_INT]; ctx->n_regs_used[REGNO_NUM] = old->n_regs_used[REGNO_NUM]; ctx->n_regs_used[REGNO_STR] = old->n_regs_used[REGNO_STR]; @@ -395,7 +395,7 @@ const int slot = CALCULATE_SLOT_NUM(reg_alloc); /* this gets attached to the context, which should free it */ - INTVAL *n_regs_used = mem_sys_allocate(sizeof (INTVAL) * 4); + INTVAL *n_regs_used = (INTVAL *)mem_sys_allocate(sizeof (INTVAL) * 4); n_regs_used[REGNO_INT] = number_regs_used[REGNO_INT]; n_regs_used[REGNO_NUM] = number_regs_used[REGNO_NUM]; n_regs_used[REGNO_STR] = number_regs_used[REGNO_STR]; Index: src/list.c =================================================================== --- src/list.c (revision 20650) +++ src/list.c (working copy) @@ -1278,7 +1278,7 @@ multi_key = VTABLE_get_pmc_keyed_int(interp, init, val); break; case 2: - type = VTABLE_get_integer_keyed_int(interp, init, val); + type = (PARROT_DATA_TYPE)VTABLE_get_integer_keyed_int(interp, init, val); break; case 3: item_size = VTABLE_get_integer_keyed_int(interp, init, val); Index: src/charset/tables.h =================================================================== --- src/charset/tables.h (revision 20650) +++ src/charset/tables.h (working copy) @@ -4,7 +4,7 @@ * DO NOT EDIT THIS FILE DIRECTLY! * please update the tools/dev/gen_charset_tables.pl script instead. * - * Created by gen_charset_tables.pl 17580 2007-03-17 22:53:00Z paultcochrane + * Created by gen_charset_tables.pl 19534 2007-07-02 02:12:08Z petdance * Overview: * This file contains various charset tables. * Data Structure and Algorithms: @@ -19,12 +19,13 @@ #ifndef PARROT_CHARSET_TABLES_H_GUARD #define PARROT_CHARSET_TABLES_H_GUARD #include "parrot/cclass.h" +#include "parrot/parrot.h" #define WHITESPACE enum_cclass_whitespace #define WORDCHAR enum_cclass_word #define PUNCTUATION enum_cclass_punctuation #define DIGIT enum_cclass_numeric -extern const PARROT_CCLASS_FLAGS Parrot_iso_8859_1_typetable[256]; -extern const PARROT_CCLASS_FLAGS Parrot_ascii_typetable[256]; +extern const INTVAL Parrot_iso_8859_1_typetable[256]; +extern const INTVAL Parrot_ascii_typetable[256]; #endif /* PARROT_CHARSET_TABLES_H_GUARD */ /* * Local variables: Index: src/charset/tables.c =================================================================== --- src/charset/tables.c (revision 20650) +++ src/charset/tables.c (working copy) @@ -4,7 +4,7 @@ * DO NOT EDIT THIS FILE DIRECTLY! * please update the tools/dev/gen_charset_tables.pl script instead. * - * Created by gen_charset_tables.pl 17580 2007-03-17 22:53:00Z paultcochrane + * Created by gen_charset_tables.pl 19534 2007-07-02 02:12:08Z petdance * Overview: * This file contains various charset tables. * Data Structure and Algorithms: @@ -17,7 +17,7 @@ #include "tables.h" -const PARROT_CCLASS_FLAGS Parrot_iso_8859_1_typetable[256] = { +const INTVAL Parrot_iso_8859_1_typetable[256] = { 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, /* 0-7 */ 0x0200, 0x0320, 0x1220, 0x0220, 0x1220, 0x1220, 0x0200, 0x0200, /* 8-15 */ 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, /* 16-23 */ @@ -51,7 +51,7 @@ 0x28c6, 0x28c6, 0x28c6, 0x28c6, 0x28c6, 0x28c6, 0x28c6, 0x04c0, /* 240-247 */ 0x28c6, 0x28c6, 0x28c6, 0x28c6, 0x28c6, 0x28c6, 0x28c6, 0x28c6, /* 248-255 */ }; -const PARROT_CCLASS_FLAGS Parrot_ascii_typetable[256] = { +const INTVAL Parrot_ascii_typetable[256] = { 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, /* 0-7 */ 0x0200, 0x0320, 0x1220, 0x0220, 0x1220, 0x1220, 0x0200, 0x0200, /* 8-15 */ 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, /* 16-23 */ Index: src/pmc/class.pmc =================================================================== --- src/pmc/class.pmc (revision 20650) +++ src/pmc/class.pmc (working copy) @@ -357,12 +357,12 @@ } PMC * -find_vtable_override(PARROT_INTERP, PMC *class, STRING *name) +find_vtable_override(PARROT_INTERP, PMC *parrot_class, STRING *name) { - Parrot_Class * const _class = PARROT_CLASS(class); + Parrot_Class * const _class = PARROT_CLASS(parrot_class); /* Walk and search for the vtable method. */ const int num_classes = VTABLE_elements(interp, _class->all_parents); - const int all_in_universe = !PObj_HasAlienParents_TEST(class); + const int all_in_universe = !PObj_HasAlienParents_TEST(parrot_class); const int alien_parents_pos = VTABLE_elements(interp, _class->attrib_metadata); int i; for (i = 0; i < num_classes; i++) { @@ -555,15 +555,15 @@ STRING *get_string() { Parrot_Class * const _class = PARROT_CLASS(SELF); - PMC *namespace = _class->_namespace; + PMC *_namespace = _class->_namespace; PMC *names; - if (!PMC_IS_NULL(namespace)) { + if (!PMC_IS_NULL(_namespace)) { /* Call the 'get_name' method on the class's associated namespace * to retrieve a fully qualified list of names, then join the list * with a semicolon. */ - names = Parrot_NameSpace_nci_get_name(interp, namespace); + names = Parrot_NameSpace_nci_get_name(interp, _namespace); if (!PMC_IS_NULL(names)) return string_join(interp, CONST_STRING(interp, ";"), names); @@ -1332,12 +1332,12 @@ PCCMETHOD find_method(STRING *name) { Parrot_Class * const _class = PARROT_CLASS(SELF); - PMC *namespace = _class->_namespace; + PMC *_namespace = _class->_namespace; int num_classes, i; - if ( ! PMC_IS_NULL(namespace) - && VTABLE_exists_keyed_str(interp, namespace, name)) { - PMC *ret = VTABLE_get_pmc_keyed_str(interp, namespace, name); + if ( ! PMC_IS_NULL(_namespace) + && VTABLE_exists_keyed_str(interp, _namespace, name)) { + PMC *ret = VTABLE_get_pmc_keyed_str(interp, _namespace, name); PCCRETURN(PMC *ret); } Index: src/pmc/object.pmc =================================================================== --- src/pmc/object.pmc (revision 20650) +++ src/pmc/object.pmc (working copy) @@ -118,8 +118,8 @@ */ STRING *name() { - PMC * const class = VTABLE_get_class(interp, SELF); - STRING * const class_name = VTABLE_get_string(interp, class); + PMC * const _class = VTABLE_get_class(interp, SELF); + STRING * const class_name = VTABLE_get_string(interp, _class); return class_name; } @@ -291,13 +291,13 @@ */ INTVAL isa(STRING *classname) { - PMC *class; + PMC *_class; if (SUPER(classname)) return 1; - class = VTABLE_get_class(interp, SELF); - return VTABLE_isa(interp, class, classname); + _class = VTABLE_get_class(interp, SELF); + return VTABLE_isa(interp, _class, classname); } } Index: src/packfile.c =================================================================== --- src/packfile.c (revision 20650) +++ src/packfile.c (working copy) @@ -724,7 +724,7 @@ else if (header->uuid_type == 1) { /* Read in the UUID. We'll put it in a NULL-terminated string, just in * case pepole use it that way. */ - header->uuid_data = mem_sys_allocate(header->uuid_size + 1); + header->uuid_data = (unsigned char *)mem_sys_allocate(header->uuid_size + 1); memcpy(header->uuid_data, packed + PACKFILE_HEADER_BYTES, header->uuid_size); header->uuid_data[header->uuid_size] = 0; /* NULL terminate */ Index: src/io/io.c =================================================================== --- src/io/io.c (revision 20650) +++ src/io/io.c (working copy) @@ -249,7 +249,7 @@ if (interp->piodata == NULL) real_exception(interp, NULL, PIO_ERROR, "PIO alloc piodata failure."); interp->piodata->default_stack = NULL; - interp->piodata->table = mem_sys_allocate_zeroed(PIO_NR_OPEN * sizeof(ParrotIO *)); + interp->piodata->table = (PMC **)mem_sys_allocate_zeroed(PIO_NR_OPEN * sizeof(ParrotIO *)); if (interp->piodata->table == NULL) real_exception(interp, NULL, PIO_ERROR, "PIO alloc table failure."); Index: src/spf_render.c =================================================================== --- src/spf_render.c (revision 20650) +++ src/spf_render.c (working copy) @@ -311,7 +311,7 @@ HUGEINTVAL sharedint = 0; /* Storage for flags, etc. */ - SpfInfo info = { 0, 0, 0, 0, 0 }; + SpfInfo info = { 0, 0, 0, 0, (PHASE)0 }; /* Reset temporaries */ tc[0] = '\0'; Index: tools/dev/gen_charset_tables.pl =================================================================== --- tools/dev/gen_charset_tables.pl (revision 20650) +++ tools/dev/gen_charset_tables.pl (working copy) @@ -107,7 +107,7 @@ my ($name) = @_; my $len = 8; - print "const PARROT_CCLASS_FLAGS ${name}[256] = {\n"; + print "const INTVAL ${name}[256] = {\n"; foreach my $char ( 0 .. 255 ) { printf "0x%.4x, ", classify($char); print "/* @{[$char-$len+1]}-$char */\n" if $char % $len == $len - 1; @@ -146,13 +146,14 @@ #ifndef PARROT_CHARSET_TABLES_H_GUARD #define PARROT_CHARSET_TABLES_H_GUARD #include "parrot/cclass.h" +#include "parrot/parrot.h" #define WHITESPACE enum_cclass_whitespace #define WORDCHAR enum_cclass_word #define PUNCTUATION enum_cclass_punctuation #define DIGIT enum_cclass_numeric END foreach my $name ( sort keys %table ) { - print "extern const PARROT_CCLASS_FLAGS ${table{$name}}[256];\n"; + print "extern const INTVAL ${table{$name}}[256];\n"; } print <<"EOF"; #endif /* PARROT_CHARSET_TABLES_H_GUARD */ Index: include/parrot/dod.h =================================================================== --- include/parrot/dod.h (revision 20650) +++ include/parrot/dod.h (working copy) @@ -136,7 +136,7 @@ void parrot_gc_gms_wb( PARROT_INTERP, NOTNULL(PMC *agg), NOTNULL(void *old), - NOTNULL(void *new) ) + NOTNULL(void *_new) ) __attribute__nonnull__(1) __attribute__nonnull__(2) __attribute__nonnull__(3) @@ -146,7 +146,7 @@ NOTNULL(PMC *agg), NOTNULL(void *old), NOTNULL(void *old_key), - NOTNULL(void *new), + NOTNULL(void *_new), NOTNULL(void *new_key) ) __attribute__nonnull__(1) __attribute__nonnull__(2) Index: include/parrot/thr_pthread.h =================================================================== --- include/parrot/thr_pthread.h (revision 20650) +++ include/parrot/thr_pthread.h (working copy) @@ -19,8 +19,8 @@ # include <pthread.h> # define PARROT_SYNC_PRIMITIVES_DEFINED -# define LOCK(m) pthread_mutex_lock(&m) -# define UNLOCK(m) pthread_mutex_unlock(&m) +# define LOCK(m) pthread_mutex_lock((pthread_mutex_t*)&m) +# define UNLOCK(m) pthread_mutex_unlock((pthread_mutex_t*)&m) # define COND_WAIT(c,m) pthread_cond_wait(&c, &m) # define COND_TIMED_WAIT(c,m,t) pthread_cond_timedwait(&c, &m, t) # define COND_SIGNAL(c) pthread_cond_signal(&c) Index: config/auto/gcc.pm =================================================================== --- config/auto/gcc.pm (revision 20650) +++ config/auto/gcc.pm (working copy) @@ -153,6 +153,8 @@ # us -Wpadded may prove interesting, or even noisy. # -Wunreachable-code might be useful in a non debugging version 4.0 => "-fvisibility=hidden", + # Needed to prevent C++ compatability issues + 4.1 => " -Wc++-compat", ); my @cage_opt_and_vers = (