summaryrefslogtreecommitdiff
path: root/typd_mlc.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2018-02-16 21:05:21 +0300
committerIvan Maidanski <ivmai@mail.ru>2018-02-16 21:05:21 +0300
commita825a2d612e749c08c24fca0f11eb2a523ce3b6b (patch)
tree55ba2113473a73bd83f96269747a1c0622e8f4ff /typd_mlc.c
parentc59a2ecc4588c76c986850363aa59252a96b0d67 (diff)
downloadbdwgc-a825a2d612e749c08c24fca0f11eb2a523ce3b6b.tar.gz
Convert GC source files to valid C++ code
Issue #206 (bdwgc). * alloc.c (GC_copyright): Change type from char* const to const char* const. * alloc.c (GC_set_fl_marks, GC_clear_fl_marks, GC_finish_collection, GC_allocobj): Add missing explicit casts from void* to ptr_t. * backgraph.c [MAKE_BACK_GRAPH] (add_back_edges): Likewise. * blacklst.c (GC_default_print_heap_obj_proc, GC_print_blacklisted_ptr): Likewise. * dbg_mlc.c (GC_get_back_ptr_info, GC_store_debug_info_inner, GC_store_debug_info, GC_debug_malloc, GC_debug_malloc_ignore_off_page, GC_debug_malloc_atomic_ignore_off_page, GC_debug_generic_malloc, GC_debug_malloc_stubborn, GC_debug_malloc_atomic, GC_debug_malloc_uncollectable, GC_debug_malloc_atomic_uncollectable, GC_debug_free, GC_debug_free_inner, GC_debug_register_finalizer, GC_debug_register_finalizer_no_order, GC_debug_register_finalizer_unreachable, GC_debug_register_finalizer_ignore_self): Likewise. * finalize.c (GC_grow_table, push_and_mark_object, ensure_toggleref_capacity, GC_dump_finalization_links, GC_dump_finalization, GC_make_disappearing_links_disappear, GC_remove_dangling_disappearing_links, GC_finalize): Likewise. * gcj_mlc.c (GC_gcj_malloc, GC_debug_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * include/private/gc_pmark.h (PUSH_CONTENTS_HDR): Likewise. * mallocx.c (GC_memalign): Likewise. * mark.c (GC_mark_from, GC_mark_and_push, GC_push_all_eager, GC_push_all_stack, GC_push_marked1, GC_push_marked2, GC_push_marked4): Likewise. * mark_rts.c (GC_exclude_static_roots_inner): Likewise. * misc.c (GC_base): Likewise. * new_hblk.c (GC_new_hblk): Likewise. * pthread_support.c (GC_register_altstack, GC_thr_init, GC_record_stack_base): Likewise. * ptr_chck.c (GC_is_visible): Likewise. * reclaim.c (GC_reclaim_small_nonempty_block, GC_disclaim_and_reclaim_or_free_small_block): Likewise. * thread_local_alloc.c (GC_mark_thread_local_fls_for): Likewise. * typd_mlc.c (GC_typed_mark_proc, GC_malloc_explicitly_typed_ignore_off_page): Likewise. * win32_threads.c (GC_record_stack_base, GC_get_stack_min, GC_push_stack_for): Likewise. * blacklst.c (GC_copy_bl): Rename "new" argument to "dest". * dbg_mlc.c (GC_store_debug_info_inner, GC_print_smashed_obj): Change type of p argument from ptr_t to void*. * include/private/gc_priv.h (GC_is_heap_base, GC_is_static_root): Likewise. * mark_rts.c [!THREADS] (GC_is_static_root): Likewise. * os_dep.c (GC_is_malloc_heap_base, GC_is_heap_base): Likewise. * ptr_chck.c (GC_on_stack): Likewise. * dbg_mlc.c (GC_print_obj): Change type of kind_str local variable from char* to const char*. * dbg_mlc.c (GC_debug_strdup, GC_debug_strndup): Cast result of GC_debug_malloc_atomic() to char*. * mallocx.c (GC_strdup, GC_strndup): Likewise. * dbg_mlc.c (GC_debug_wcsdup): Cast result of GC_debug_malloc_atomic() to wchar_t*. * mallocx.c (GC_wcsdup): Likewise. * dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_register_dynamic_libraries): Cast p local variable to char*. * os_dep.c (GC_register_data_segments): Likewise. * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_disclaim): Cast masked fc_word to struct GC_finalizer_closure* (instead of void*). * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_malloc): Cast result of GC_malloc_kind() to word*. * typd_mlc.c (GC_malloc_explicitly_typed, GC_calloc_explicitly_typed): Likewise. * include/private/gc_priv.h (WARN): Cast away const qualifier for msg (and the string literal). * misc.c (GC_default_on_abort): Remove cast to void* for WRITE() buf argument. * misc.c (GC_new_free_list_inner): Cast result local variable to void**. * misc.c (GC_new_free_list): Change type of result local variable from void* to void**. * pthread_support.c (GC_start_rtn_prepare_thread): Cast arg to struct start_info*. * win32_threads.c [GC_PTHREADS] (GC_pthread_start_inner): Likewise. * reclaim.c (GC_print_free_list): Replace ptr_t flh to void *flh_next local variable; remove redundant casts. * tools/if_mach.c (EXECV_ARGV_T): New macro; add comment. * tools/if_not_there.c (EXECV_ARGV_T): Likewise. * tools/if_mach.c (main): Use EXECV_ARGV_T instead of void* for execvp() argument. * tools/if_not_there.c (main): Likewise. * typd_mlc.c (LeafDescriptor, ComplexArrayDescriptor, SequenceDescriptor): Move struct definition out of union ComplexDescriptor. * typd_mlc.c (GC_add_ext_descriptor): Rename "new" local variable to newExtD. * win32_threads.c (GC_CreateThread, GC_beginthreadex): Cast result of GC_malloc_uncollectable() to thread_args*. * win32_threads.c [PARALLEL_MARK && !MSWINCE && __cplusplus] (GC_thr_init): Do not cast GetProcessAffinityMask() arguments to void*.
Diffstat (limited to 'typd_mlc.c')
-rw-r--r--typd_mlc.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/typd_mlc.c b/typd_mlc.c
index 05079f14..b5e2c612 100644
--- a/typd_mlc.c
+++ b/typd_mlc.c
@@ -62,28 +62,35 @@ typedef struct {
/* We may eventually need to add provisions for headers and */
/* trailers. Hence we provide for tree structured descriptors, */
/* though we don't really use them currently. */
-typedef union ComplexDescriptor {
+
struct LeafDescriptor { /* Describes simple array */
word ld_tag;
# define LEAF_TAG 1
- size_t ld_size; /* bytes per element */
- /* multiple of ALIGNMENT */
- size_t ld_nelements; /* Number of elements. */
+ size_t ld_size; /* bytes per element */
+ /* multiple of ALIGNMENT. */
+ size_t ld_nelements; /* Number of elements. */
GC_descr ld_descriptor; /* A simple length, bitmap, */
/* or procedure descriptor. */
} ld;
+
struct ComplexArrayDescriptor {
word ad_tag;
# define ARRAY_TAG 2
size_t ad_nelements;
union ComplexDescriptor * ad_element_descr;
} ad;
+
struct SequenceDescriptor {
word sd_tag;
# define SEQUENCE_TAG 3
union ComplexDescriptor * sd_first;
union ComplexDescriptor * sd_second;
} sd;
+
+typedef union ComplexDescriptor {
+ struct LeafDescriptor ld;
+ struct ComplexArrayDescriptor ad;
+ struct SequenceDescriptor sd;
} complex_descriptor;
#define TAG ad.ad_tag
@@ -129,7 +136,7 @@ STATIC signed_word GC_add_ext_descriptor(const word * bm, word nbits)
LOCK();
while (GC_avail_descr + nwords >= GC_ed_size) {
- ext_descr * new;
+ ext_descr * newExtD;
size_t new_size;
word ed_size = GC_ed_size;
@@ -143,16 +150,17 @@ STATIC signed_word GC_add_ext_descriptor(const word * bm, word nbits)
new_size = 2 * ed_size;
if (new_size > MAX_ENV) return(-1);
}
- new = (ext_descr *) GC_malloc_atomic(new_size * sizeof(ext_descr));
- if (new == 0) return(-1);
+ newExtD = (ext_descr *)GC_malloc_atomic(new_size * sizeof(ext_descr));
+ if (NULL == newExtD)
+ return -1;
LOCK();
if (ed_size == GC_ed_size) {
if (GC_avail_descr != 0) {
- BCOPY(GC_ext_descriptors, new,
+ BCOPY(GC_ext_descriptors, newExtD,
GC_avail_descr * sizeof(ext_descr));
}
GC_ed_size = new_size;
- GC_ext_descriptors = new;
+ GC_ext_descriptors = newExtD;
} /* else another thread already resized it in the meantime */
}
result = GC_avail_descr;
@@ -363,8 +371,8 @@ STATIC mse * GC_typed_mark_proc(word * addr, mse * mark_stack_ptr,
word bm = GC_ext_descriptors[env].ed_bitmap;
word * current_p = addr;
word current;
- ptr_t greatest_ha = GC_greatest_plausible_heap_addr;
- ptr_t least_ha = GC_least_plausible_heap_addr;
+ ptr_t greatest_ha = (ptr_t)GC_greatest_plausible_heap_addr;
+ ptr_t least_ha = (ptr_t)GC_least_plausible_heap_addr;
DECLARE_HDR_CACHE;
INIT_HDR_CACHE;
@@ -591,7 +599,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_explicitly_typed(size_t lb,
GC_ASSERT(GC_explicit_typing_initialized);
lb = SIZET_SAT_ADD(lb, TYPD_EXTRA_BYTES);
- op = GC_malloc_kind(lb, GC_explicit_kind);
+ op = (word *)GC_malloc_kind(lb, GC_explicit_kind);
if (EXPECT(NULL == op, FALSE))
return NULL;
/* It is not safe to use GC_size_map[lb] to compute lg here as the */
@@ -627,7 +635,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL
/* See the comment in GC_malloc_explicitly_typed. */
lg = BYTES_TO_GRANULES(GC_size(op));
} else {
- GC_eobjfreelist[lg] = obj_link(op);
+ GC_eobjfreelist[lg] = (ptr_t)obj_link(op);
obj_link(op) = 0;
GC_bytes_allocd += GRANULES_TO_BYTES((word)lg);
UNLOCK();
@@ -640,7 +648,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL
((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d;
}
}
- return((void *) op);
+ return op;
}
GC_API GC_ATTR_MALLOC void * GC_CALL GC_calloc_explicitly_typed(size_t n,
@@ -672,7 +680,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_calloc_explicitly_typed(size_t n,
lb = SIZET_SAT_ADD(lb, TYPD_EXTRA_BYTES);
break;
}
- op = GC_malloc_kind(lb, GC_array_kind);
+ op = (word *)GC_malloc_kind(lb, GC_array_kind);
if (EXPECT(NULL == op, FALSE))
return NULL;
lg = BYTES_TO_GRANULES(GC_size(op));