[perl #44729] [PATCH] Various C++ cleanups
# 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] Index: src/gc/smallobject.c === --- src/gc/smallobject.c(revision 20650) +++ src/gc/smallobject.c(working copy) @@ -202,24 +202,24 @@ NOTNULL(Small_Object_Arena *arena)) { UINTVAL i; -void*object; +PObj *object; UINTVAL num_objects = pool-objects_per_alloc; pool-total_objects += num_objects; arena-used = num_objects; /* Move all the new objects into the free list */ -object = (PObj *)((char *)arena-start_objects); +object = ((PObj *)arena-start_objects); for (i = 0; i num_objects; i++) { -PObj_flags_SETTO((PObj *)object, PObj_on_free_list_FLAG); +PObj_flags_SETTO(object, PObj_on_free_list_FLAG); /* * during GC buflen is used to check for objects on the * free_list */ PObj_buflen((PObj*)object) = 0; pool-add_free_object(interp, pool, object); -object = (PObj *)((char *)object + pool-object_size); +object = ((PObj *)object + pool-object_size); } pool-num_free_objects += num_objects; 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 intslot = 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,8 @@ 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/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/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: 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)
Re: [perl #44729] [PATCH] Various C++ cleanups
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 intslot =
Re: [perl #44729] [PATCH] Various C++ cleanups
On Friday 17 August 2007 12:51:21 Steve Peters wrote: 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. I'll look at the smallobject patch. Meanwhile, thanks and applied as of r20663. -- c
Re: [perl #44729] [PATCH] Various C++ cleanups
On Friday 17 August 2007 06:59:27 Steve Peters wrote: The attached patch cleans up some problems with C++ compiling currently with Parrot. This patch has most of the cleanups while not segfaulting, at least on x86 Linux with GCC 4.1.2. -- c === src/gc/smallobject.c == --- src/gc/smallobject.c (revision 5347) +++ src/gc/smallobject.c (local) @@ -202,22 +202,22 @@ NOTNULL(Small_Object_Arena *arena)) { UINTVAL i; -void*object; +PObj*object; UINTVAL num_objects = pool-objects_per_alloc; pool-total_objects += num_objects; arena-used = num_objects; /* Move all the new objects into the free list */ -object = (PObj *)((char *)arena-start_objects); +object = (PObj *)arena-start_objects; for (i = 0; i num_objects; i++) { -PObj_flags_SETTO((PObj *)object, PObj_on_free_list_FLAG); +PObj_flags_SETTO(object, PObj_on_free_list_FLAG); /* * during GC buflen is used to check for objects on the * free_list */ -PObj_buflen((PObj*)object) = 0; +PObj_buflen(object) = 0; pool-add_free_object(interp, pool, object); object = (PObj *)((char *)object + pool-object_size); }