-
Notifications
You must be signed in to change notification settings - Fork 406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make CFLAGS=-xc++ #206
Comments
Making the whole code compliant with C++ would not be bad I think. My understanding for "int foo redefinition" is that we should define GC_EXTERN to extern in extra/gc.c if not NO_DEBUGGING. So, I'm OK to accept your patch. Thank you |
Issue #206 (bdwgc). * cord/cordbscs.c (Concatenation, Function, Generic): Define struct outside union (i.e. the union just uses them). * cord/cordbscs.c (CORD_cat_char_star, CORD_from_fn_inner, CORD_substr_checked): Cast GC_MALLOC_ATOMIC() result to char*. * cord/cordprnt.c (CORD_vsprintf): Likewise. * cord/cordxtra.c (CORD_cat_char, CORD_to_char_star, CORD_from_char_star, CORD_ec_flush_buf): Likewise. * cord/cordbscs.c (CORD_substr_checked): Remove register keyword for "result" local variable.
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*.
I've decided to help you with this, I've added some casts some individual .c files can be now compiled by C++ compiler (I have tested with Cygwin only, so probably I missed some casts). See commit a825a2d. |
You are pretty much way ahead of me. I had similar looking stuff, but you did a lot more. |
…ource Issue #206 (bdwgc). * dyn_load.c [DARWIN] (GC_dyld_sections): Provide some name to struct. * finalize.c (GC_fnlz_roots): Likewise. * os_dep.c [MPROTECT_VDB && DARWIN] (GC_ports, GC_mprotect_thread_notify, GC_mprotect_thread): Likewise.
…r_proc Issue #206 (bdwgc). Add const to the variable receiving strchr() result for C++ compatibility. * cord/cordxtra.c (CORD_batched_chr_proc): Change type of occ local variable from char* to const char*; remove register keyword for occ.
Issue #206 (bdwgc). * cord/cordbscs.c (CORD_dump_inner, CORD_cat_char_star, CORD_cat, CORD_from_fn_inner, CORD_index_access_fn, CORD_apply_access_fn, CORD_substr_closure, CORD_substr_checked, CORD_substr, CORD_iter5, CORD_riter4, CORD_init_min_len, CORD_init_forest, CORD_add_forest, CORD_concat_forest, CORD_balance_insert, CORD_balance, CORD__extend_path, CORD__pos_fetch, CORD__next, CORD__prev, CORD_pos_fetch: Remove register keyword for local variables (and function parameters). * cord/cordprnt.c (extract_conv_spec, CORD_vsprintf): Likewise. * cord/cordxtra.c (CORD_cat_char, CORD_catn, CORD_fill_proc, CORD_batched_fill_proc, CORD_cmp, CORD_ncmp, CORD_to_char_star, CORD_put_proc, CORD_batched_put_proc, CORD_chr_proc, CORD_rchr_proc, CORD_batched_chr_proc, CORD_str, CORD_ec_flush_buf, CORD_from_file_eager, refill_cache, CORD_lf_func, CORD_from_file_lazy_inner, CORD_from_file_lazy, CORD_from_file): Likewise. * cord/tests/cordtest.c (test_basics, test_extras): Likewise. * cord/tests/de.c (retrieve_line, redisplay): Likewise. * cord/tests/de_win.c (plain_chars, control_chars, WndProc): Likewise.
Issue #206 (bdwgc). * blacklst.c (GC_number_stack_black_listed, total_stack_black_listed): Remove register keyword for local variables. * dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX] (GC_register_dynamic_libraries): Likewise. * extra/pcr_interface.c [PCR] (GC_enumerate_block): Likewise. * finalize.c (GC_grow_table): Likewise. * headers.c (alloc_hdr, GC_init_headers, GC_remove_counts, GC_prev_block): Likewise. * include/private/gc_pmark.h (PUSH_OBJ): Likewise. * mach_dep.c [!HAVE_PUSH_REGS && !HAVE_BUILTIN_UNWIND_INIT] (GC_with_callee_saves_pushed): Likewise. * mark.c (clear_marks_for_block): Likewise. * mark_rts.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_add_roots_inner): Likewise. * mark_rts.c [!NO_DEBUGGING] (GC_is_tmp_root): Likewise. * os_dep.c [GWW_VDB || MPROTECT_VDB || PROC_VDB || MANUAL_VDB] (GC_page_was_dirty): Likewise. * os_dep.c [CHECKSUMS && GWW_VDB || PROC_VDB] (GC_or_pages, GC_page_was_ever_dirty): Likewise. * os_dep.c (GC_write_fault_handler): Likewise. * os_dep.c [PROC_VDB] (GC_read_dirty): Likewise. * os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise): Likewise. * os_dep.c [SAVE_CALL_CHAIN && NARGS>0] (GC_save_callers): Likewise. * pthread_stop_world.c [!NACL] (GC_start_world): Likewise. * pthread_support.c (GC_delete_thread, GC_delete_gc_thread): Likewise. * typd_mlc.c (GC_push_complex_descriptor): Likewise. * win32_threads.c (GC_delete_gc_thread_no_free, GC_delete_thread): Likewise.
Issue #206 (bdwgc). * headers.c (GC_next_used_block): Replace register keyword to REGISTER. * include/private/gc_hdrs.h [HASH_TL] (GET_BI, GET_HDR_ADDR, GET_HDR, SET_HDR): Likewise. * mark.c (GC_push_all_eager): Likewise. * mark.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager): Likewise. * include/private/gc_priv.h (REGISTER): New macro (defined before include gc_hdrs.h); add comment.
Issue #206 (bdwgc). * darwin_stop_world.c (GC_stack_range_for): Cast pointer which is assinged to lo local variable to ptr_t (instead of void*). * os_dep.c [GC_DARWIN_THREADS && MPROTECT_VDB]: Include darwin_stop_world.h (so that GC_mprotect_stop and GC_mprotect_resume to be declared and later defined as extern "C"). * os_dep.c [MPROTECT_VDB && DARWIN] (exc_server, exception_raise, exception_raise_state): Wrap into extern "C" block; refine comment. * os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise_state, catch_exception_raise_state_identity): Declare as extern "C" (before the definition). * os_dep.c [MPROTECT_VDB && DARWIN && THREADS] (GC_mprotect_state): Initialize to GC_MP_NORMAL (instead of integer 0).
Issue #206 (bdwgc). Specifically: int i; int i = 0; is not valid, but: extern int i; int i = 0; is valid. Adding static would also be desirable here but requires a larger change. * extra/gc.c (GC_INNER, GC_EXTERN): Do not define if __cplusplus; add comment and TODO item.
Issue #206 (bdwgc). * include/private/gc_priv.h [GC_GCJ_SUPPORT] (GC_free_bytes): Declare; update comment.
(code refactoring) Issue #206 (bdwgc). * include/private/darwin_stop_world.h [MPROTECT_VDB && !GC_NO_THREADS_DISCOVERY] (GC_darwin_register_mach_handler_thread): Declare function. * include/private/gc_priv.h [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager): Likewise. * include/private/gc_priv.h [!THREADS && TRACE_BUF] (GC_add_trace_entry): Likewise. * include/private/gc_priv.h (GC_collect_or_expand): Likewise. * include/private/gc_priv.h [MPROTECT_VDB && USE_MUNMAP] (GC_mprotect_dirty_init, GC_has_unmapped_memory): Likewise. * include/private/gc_priv.h [CHECKSUMS && MPROTECT_VDB && !DARWIN] (GC_record_fault): Likewise. * include/private/gc_priv.h [CHECKSUMS] (GC_check_dirty): Likewise. * include/private/gc_priv.h [GC_WIN32_THREADS && WRAP_MARK_SOME && !GC_PTHREADS] (GC_started_thread_while_stopped): Likewise. * include/private/gc_priv.h [SEARCH_FOR_DATA_START || NETBSD && __ELF__] (GC_find_limit): Likewise. * include/private/gc_priv.h [NEED_PROC_MAPS && (IA64 || INCLUDE_LINUX_THREAD_DESCR)] (GC_enclosing_mapping): Likewise. * include/private/pthread_support.h (GC_inner_start_routine): Likewise. * include/private/thread_local_alloc.h [GC_ASSERTIONS] (GC_is_thread_tsd_valid, GC_check_tls_for): Likewise. * include/private/thread_local_alloc.h [GC_ASSERTIONS && USE_CUSTOM_SPECIFIC] (GC_check_tsd_marks): Likewise. * include/private/gc_priv.h [HEURISTIC2 || SEARCH_FOR_DATA_START || !STACKBOTTOM && HEURISTIC2 || (SVR4 || AIX || DGUX || LINUX && SPARC) && !PCR] (NEED_FIND_LIMIT): Collapse multiple definitions. * malloc.c (GC_collect_or_expand): Remove prototype. * mark.c [CHECKSUMS] (GC_check_dirty): Likewise. * mark.c [GC_WIN32_THREADS && !GC_PTHREADS] (GC_started_thread_while_stopped): Likewise. * mark_rts.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager): Likewise. * mark_rts.c [!THREADS && TRACE_BUF] (GC_add_trace_entry): Likewise. * os_dep.c [SEARCH_FOR_DATA_START || NETBSD && __ELF__] (GC_find_limit): Likewise. * os_dep.c [CHECKSUMS && MPROTECT_VDB && !DARWIN] (GC_record_fault): Likewise. * os_dep.c [MPROTECT_VDB && USE_MUNMAP] (GC_has_unmapped_memory, GC_mprotect_dirty_init): Likewise. * os_dep.c [MPROTECT_VDB && !GC_NO_THREADS_DISCOVERY] (GC_darwin_register_mach_handler_thread): Likewise. * pthread_support.c [GC_ASSERTIONS] (GC_check_tls_for): Likewise. * pthread_support.c [GC_ASSERTIONS && USE_CUSTOM_SPECIFIC] (GC_check_tsd_marks): Likewise. * pthread_support.c [INCLUDE_LINUX_THREAD_DESCR] (GC_enclosing_mapping): Likewise. * pthread_support.c [!SN_TARGET_ORBIS && !SN_TARGET_PSP2] (GC_inner_start_routine): Likewise. * thread_local_alloc.c [GC_ASSERTIONS] (GC_is_thread_tsd_valid): Likewise. * win32_threads.c [GC_ASSERTIONS] (GC_check_tls_for): Likewise. * win32_threads.c [GC_ASSERTIONS && USE_CUSTOM_SPECIFIC] (GC_check_tsd_marks): Likewise.
(code refactoring) Issue #206 (bdwgc). Note: EXTERN_C_BEGIN and EXTERN_C_END are not available in the GC public headers. * include/private/darwin_stop_world.h: Replace the conditional extern "C" block begin/end with EXTERN_C_BEGIN and EXTERN_C_END, respectively. * include/private/dbg_mlc.h: Likewise. * include/private/gc_hdrs.h: Likewise. * include/private/gc_locks.h: Likewise. * include/private/gc_pmark.h: Likewise. * include/private/gc_priv.h: Likewise. * include/private/gcconfig.h: Likewise. * include/private/pthread_stop_world.h: Likewise. * include/private/pthread_support.h: Likewise. * include/private/specific.h: Likewise. * include/private/thread_local_alloc.h: Likewise. * os_dep.c [MPROTECT_VDB && DARWIN]: Likewise. * tests/test.c [GC_AMIGA_FASTALLOC && AMIGA]: Likewise. * include/private/gcconfig.h (EXTERN_C_BEGIN, EXTERN_C_END): Define macro.
Issue #206 (bdwgc). The functions should be declared (as extern "C") before the definition. * finalize.c [!GC_NO_FINALIZATION]: Include javaxfc.h. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD]: Likewise.
…sion Issue #206 (bdwgc). * alloc.c (GC_copyright): Declare (inside EXTERN_C_BEGIN/END) before the definition. * alloc.c [!GC_NO_VERSION_VAR] (GC_version): Likewise.
Issue #206 (bdwgc). * os_dep.c [!DARWIN && !MSWIN32 && !MSWINCE] (GC_write_fault_handler): Cast si->si_addr to char* when assigned to addr local variable.
Issue #206 (bdwgc). * Makefile.direct (SRCS): Add include/gc_alloc_ptrs.h. * include/include.am (dist_noinst_HEADERS): Likewise. * include/gc_alloc_ptrs.h: New file. * include/new_gc_alloc.h (GC_objfreelist_ptr, GC_aobjfreelist_ptr, GC_uobjfreelist_ptr, GC_auobjfreelist_ptr, GC_incr_bytes_allocd, GC_incr_bytes_freed): Move to the declarations to gc_alloc_ptrs.h. * include/new_gc_alloc.h: Include gc_alloc_ptrs.h; update comment. * mallocx.c: Likewise.
Issue #206 (bdwgc). * dyn_load.c [SOLARISDL && !USE_PROC_FOR_LIBRARIES] (_DYNAMIC): Move the extern symbol declaration out of a function body. * os_dep.c [!PCR && !MACOS && REDIRECT_MALLOC && GC_SOLARIS_THREADS] (sbrk): Likewise. * dyn_load.c [SOLARISDL && !USE_PROC_FOR_LIBRARIES] (_DYNAMIC): Wrap into EXTERN_C_BEGIN/END block. * dyn_load.c [__ELF__ && LINUX && HOST_ANDROID || HAVE_DL_ITERATE_PHDR] (dl_iterate_phdr): Likewise. * dyn_load.c [!USE_PROC_FOR_LIBRARIES] (_DYNAMIC): Likewise. * dyn_load.c [ALPHA && OSF1 || HPUX] (sys_errlist, sys_nerr, errno): Likewise. * os_dep.c [SEARCH_FOR_DATA_START && (LINUX || HURD)] (__data_start, data_start): Likewise. * os_dep.c [SEARCH_FOR_DATA_START && LINUX && HOST_ANDROID] (_etext, __dso_handle): Likewise. * os_dep.c [NETBSD && __ELF__] (environ): Likewise. * os_dep.c [OPENBSD && THREADS] (__syscall): Likewise. * os_dep.c [LINUX_STACKBOTTOM && USE_LIBC_PRIVATES] (__libc_stack_end): Likewise. * os_dep.c [LINUX_STACKBOTTOM && USE_LIBC_PRIVATES && IA64] (__libc_ia64_register_backing_store_base): Likewise. * os_dep.c [SYMBIAN] (GC_get_main_symbian_stack_base): Likewise. * os_dep.c [!PCR && !MACOS && REDIRECT_MALLOC && GC_SOLARIS_THREADS] (sbrk): Likewise. * os_dep.c [MMAP_SUPPORTED && SYMBIAN] (GC_get_private_path_and_zero_file): Likewise. * pthread_stop_world.c [USE_TKILL_ON_ANDROID] (tkill): Likewise. * pthread_stop_world.c [NACL] (nacl_interface_query): Likewise. * pthread_support.c [PTHREAD_REGISTER_CANCEL_WEAK_STUBS] (__pthread_register_cancel, __pthread_unregister_cancel): Likewise. * pthread_support.c [PTHREAD_REGISTER_CANCEL_WEAK_STUBS] (__pthread_register_cancel, __pthread_unregister_cancel): Use "void" to denote empty arguments list.
Issue #206 (bdwgc). * dyn_load.c [DYNAMIC_LOADING && (SCO_ELF || DGUX || HURD || __ELF__ && (LINUX || FREEBSD || NACL || NETBSD || OPENBSD)) && !HOST_ANDROID]: Put EXTERN_C_BEGIN/END around include link.h; add comment.
Issue #206 (bdwgc). * dbg_mlc.c (GC_get_back_ptr_info): Cast GC_REVEAL_POINTER() result to ptr_t (when assigned to bp local variable). * dbg_mlc.c (GC_generate_random_valid_address): Cast result of GC_generate_random_heap_address() to ptr_t. * dbg_mlc.c (GC_print_backtrace): Cast GC_print_heap_obj() argument to ptr_t.
make CFLAGS=-xc++ has some compilation problems. Interested?
The ones I recall are: ptr_t vs. void*, and extra.c playing games with extern/inner leads to:
int foo;
int foo = 1;
which isn't legal. I can work it through if you are interested. I do not have any grand plan here -- void* and extern "C" was really all.
The text was updated successfully, but these errors were encountered: