summaryrefslogtreecommitdiff
path: root/dyn_load.c
Commit message (Collapse)AuthorAgeFilesLines
* Add assertion about GC lock to GC_add_roots_inner and its callersIvan Maidanski2023-04-121-29/+38
| | | | | | | | | | | | | | | | | | | | (refactoring) Also, add the assertion to GC_roots_present() and COND_DUMP_CHECKS(). * dyn_load.c [HAVE_DL_ITERATE_PHDR && PT_GNU_RELRO] (GC_register_dynlib_callback): Add assertion that GC lock is held. * dyn_load.c [HAVE_DL_ITERATE_PHDR] (GC_register_dynamic_libraries_dl_iterate_phdr): Likewise. * dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_cond_add_roots): Likewise. * dyn_load.c [ALPHA && OSF1 || HPUX || AIX || HAIKU] (GC_register_dynamic_libraries): Likewise. * include/private/gc_priv.h (COND_DUMP_CHECKS): Likewise. * mark_rts.c (GC_roots_present, GC_add_roots_inner): Likewise. * dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_cond_add_roots): Check THREADS instead of GC_WIN32_THREADS; check base==limit before stack_top assignment.
* Remove MAIN_THREAD flag in GC_threadIvan Maidanski2023-03-091-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * darwin_stop_world.c (GC_stack_range_for): Do not check MAIN_THREAD bit of p->flags. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_support.c [!GC_WIN32_THREADS] (GC_set_stackbottom, GC_get_my_stackbottom): Likewise. * pthread_support.c [!GC_WIN32_THREADS] (GC_call_with_gc_active): Likewise. * darwin_stop_world.c (GC_stack_range_for): Do not use GC_stackbottom. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_support.c [!GC_WIN32_THREADS] (GC_get_my_stackbottom): Likewise. * dyn_load.c [(SCO_ELF || DGUX || HURD || NACL || __ELF__ && (LINUX || FREEBSD || NETBSD || OPENBSD)) && USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Do not check GC_stackbottom if THREADS. * include/gc/gc.h (GC_stackbottom): Refine comment (mention that it could be change only before GC initialization if multi-threaded, mention GC_set_stackbottom). * include/private/gcconfig.h [IA64 && (HPUX || LINUX)] (BACKING_STORE_BASE): Remove. * include/private/pthread_support.h [!GC_WIN32_THREADS] (MAIN_THREAD): Likewise. * mark_rts.c [!THREADS && IA64] (GC_push_current_stack): Use GC_register_stackbottom instead of BACKING_STORE_BASE. * pthread_stop_world.c [IA64] (GC_push_all_stacks): Do not use BACKING_STORE_BASE (GC_register_stackbottom). * pthread_support.c [!GC_WIN32_THREADS] (GC_thr_init): Do not set MAIN_THREAD bit of me->flags. * pthread_support.c (GC_set_stackbottom, GC_get_my_stackbottom): Move crtn local variable to outer scope. * pthread_support.c [!GC_WIN32_THREADS] (GC_set_stackbottom): Do not set GC_stackbottom (and GC_register_stackbottom) if GC is initialized. * pthread_support.c [!GC_WIN32_THREADS && IA64] (GC_get_my_stackbottom): Do not use GC_register_stackbottom. * pthread_support.c (GC_call_with_gc_active): Move stack_end local variable to outer scope. * pthread_support.c [!GC_WIN32_THREADS] (GC_call_with_gc_active): Do not use and set GC_stackbottom.
* Remove unused DCL_LOCK_STATEIvan Maidanski2023-01-301-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * alloc.c (GC_set_disable_automatic_collection, GC_set_stop_func, GC_get_disable_automatic_collection, GC_get_stop_func, GC_set_start_callback, GC_get_start_callback, GC_set_on_collection_event, GC_get_on_collection_event, GC_collect_a_little, GC_try_to_collect_general, GC_expand_hp): Remove DCL_LOCK_STATE. * alloc.c [!GC_DISABLE_INCREMENTAL] (GC_start_incremental_collection): Likewise. * dbg_mlc.c (GC_generate_random_backtrace, store_debug_info, GC_debug_register_displacement): Likewise. * dyn_load.c [DARWIN_DEBUG && !NO_DEBUGGING] (GC_dyld_image_add, GC_dyld_image_remove): Likewise. * finalize.c (GC_register_disappearing_link_inner, GC_unregister_disappearing_link, GC_complete_ongoing_collection, GC_set_toggleref_func, GC_get_toggleref_func, GC_toggleref_add, GC_set_await_finalize_proc, GC_get_await_finalize_proc, GC_unregister_long_link, GC_move_disappearing_link, GC_move_long_link, GC_register_finalizer_inner, GC_finalize, GC_invoke_finalizers, GC_notify_or_invoke_finalizers): Likewise. * fnlz_mlc.c (GC_init_finalized_malloc): Likewise. * gc_dlopen.c [!USE_PROC_FOR_LIBRARIES] (disable_gc_for_dlopen): Likewise. * gcj_mlc.c (GC_init_gcj_malloc, maybe_finalize, GC_core_gcj_malloc, GC_debug_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * malloc.c (GC_alloc_large, GC_generic_malloc_inner, GC_generic_malloc_aligned, GC_malloc_kind_global, GC_generic_malloc_uncollectable, GC_free): Likewise. * mallocx.c (GC_realloc, GC_generic_malloc_ignore_off_page, GC_generic_malloc_many): Likewise. * mark.c (GC_print_trace): Likewise. * mark_rts.c (GC_add_roots, GC_clear_roots, GC_remove_roots): Likewise. * misc.c (GC_get_heap_usage_safe, GC_get_heap_usage_safe, GC_is_init_called, GC_init, GC_enable_incremental, GC_start_mark_threads, GC_set_warn_proc, GC_get_warn_proc, GC_set_abort_func, GC_get_abort_func, GC_enable, GC_disable, GC_new_free_list, GC_new_kind, GC_new_proc, GC_call_with_alloc_lock, GC_dump, GC_get_memory_use, GC_alloc_lock, GC_set_on_thread_event, GC_get_on_thread_event, GC_set_oom_fn, GC_get_oom_fn, GC_set_on_heap_resize, GC_get_on_heap_resize, GC_set_finalizer_notifier, GC_get_finalizer_notifier, GC_set_all_interior_pointers): Likewise. * obj_map.c (GC_register_displacement): Likewise. * os_dep.c (GC_get_stack_base, GC_print_callers): Likewise. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread, GC_resume_thread, GC_is_thread_suspended): Likewise. * pthread_support.c (GC_is_thread_tsd_valid, GC_thread_is_registered, GC_register_altstack, GC_wait_for_gc_completion, GC_init_parallel, GC_do_blocking_inner, GC_suspend_self_blocked, GC_get_my_stackbottom, GC_call_with_gc_active, GC_unregister_my_thread, GC_pthread_cancel, GC_pthread_exit, GC_allow_register_threads, GC_register_my_thread, GC_thread_exit_proc, GC_pthread_join, GC_pthread_detach, GC_start_rtn_prepare_thread): Likewise. * ptr_chck.c (GC_set_same_obj_print_proc, GC_get_same_obj_print_proc, GC_set_is_valid_displacement_print_proc, GC_set_is_visible_print_proc, GC_get_is_valid_displacement_print_proc, GC_get_is_visible_print_proc): Likewise. * reclaim.c (GC_print_all_errors): Likewise. * typd_mlc.c (GC_add_ext_descriptor, GC_make_descriptor, GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Likewise. * alloc.c (GC_max_retries): Change type from GC_word to word. * include/private/gc_locks.h: Remove DCL_LOCK_STATE from comment, * include/private/gc_locks.h (DCL_LOCK_STATE): Do not define.
* Define GC_GLIBC_PREREQ internal macroIvan Maidanski2022-10-211-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * dyn_load.c [(SCO_ELF || DGUX || HURD || NACL || __ELF__ && (LINUX || FREEBSD || NETBSD || OPENBSD)) && !USE_PROC_FOR_LIBRARIES && !HAVE_DL_ITERATE_PHDR] (HAVE_DL_ITERATE_PHDR): Replace __GLIBC__>2||__GLIBC__==2&&__GLIBC_MINOR__>2 to GC_GLIBC_PREREQ(2,3). * dyn_load.c [(SCO_ELF || DGUX || HURD || NACL || __ELF__ && (LINUX || FREEBSD || NETBSD || OPENBSD)) && !USE_PROC_FOR_LIBRARIES && __GLIBC__==2 && __GLIBC_MINOR__==2 && DT_CONFIG && !HAVE_DL_ITERATE_PHDR] (HAVE_DL_ITERATE_PHDR): Do not define. * include/private/gcconfig.h [LINUX]: Move include features.h upper (to be before GC_GLIBC_PREREQ); add TODO item; refine comment. * include/private/gcconfig.h (GC_GLIBC_PREREQ): Define macro. * include/private/gcconfig.h [(M68K || I386 || ARM32) && LINUX && __ELF__]: Replace defined(__GLIBC__)&&__GLIBC__>=2 to GC_GLIBC_PREREQ(2,0). * include/private/gcconfig.h [MIPS && LINUX]: Replace __GLIBC__>2||__GLIBC__==2&&__GLIBC_MINOR__>=2 to GC_GLIBC_PREREQ(2,2). * include/private/gcconfig.h [MPROTECT_VDB && __GLIBC__]: Replace __GLIBC__<2||__GLIBC__==2&&__GLIBC_MINOR__<2 to !GC_GLIBC_PREREQ(2,2). * malloc.c [REDIRECT_MALLOC && GC_LINUX_THREADS && __GLIBC__] (GC_init_lib_bounds): Replace __GLIBC__<2||__GLIBC__==2&&__GLIBC_MINOR__<34 to !GC_GLIBC_PREREQ(2,34). * os_dep.c [(I386 && SAVE_CALL_CHAIN || SPARC) && LINUX]: Do not include features.h.
* Fix a typo in comment of dyn_load.c (shortened USE_PROC_FOR_LIBRARIES)Ivan Maidanski2022-09-271-2/+2
| | | | | * dyn_load.c [SOLARISDL || !LINUX]: Rename USE_PROC to USE_PROC_FOR_LIBRARIES in comment.
* Include stdio.h and stdlib.h only from gc_priv.hIvan Maidanski2022-09-261-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * allchblk.c: Do not include stdio.h directly. * alloc.c: Likewise. * dyn_load.c [(DYNAMIC_LOADING || MSWIN32 || MSWINCE || CYGWIN32) && !PCR]: Likewise. * mach_dep.c [!PLATFORM_MACH_DEP && !SN_TARGET_PSP2]: Likewise. * malloc.c: Likewise. * mallocx.c: Likewise. * mark.c: Likewise. * mark_rts.c: Likewise. * misc.c: Likewise. * new_hblk.c: Likewise. * os_dep.c: Likewise. * reclaim.c: Likewise. * tests/disclaim_bench.c: Likewise. * tests/gctest.c: Likewise. * dbg_mlc.c [KEEP_BACK_PTRS && !LINT2]: Do not include stdlib.h directly. * dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32]: Likewise. * os_dep.c [HAIKU]: Likewise. * pthread_support.c [GC_PTHREADS && !GC_WIN32_THREADS]: Likewise. * tests/disclaim_bench.c: Likewise. * tests/gctest.c [!mips || !SYSTYPE_BSD43]: Likewise. * thread_local_alloc.c: Likewise. * include/private/gc_priv.h: Include stdio.h.
* Update copyright information in alloc.c and other modified files (2022)Ivan Maidanski2022-05-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * CMakeLists.txt: Update year in copyright comment (2021 to 2022). * alloc.c: Likewise. * configure.ac: Likewise. * dyn_load.c: Likewise. * include/private/gc_priv.h: Likewise. * include/private/gcconfig.h: Likewise. * mallocx.c: Likewise. * mark.c: Likewise. * mark_rts.c: Likewise. * misc.c: Likewise. * os_dep.c: Likewise. * pthread_support.c: Likewise. * reclaim.c: Likewise. * tests/gctest.c: Likewise. * win32_threads.c: Likewise. * LICENSE: Update year (2021 to 2022). * allchblk.c: Add copyright line in header comment. * darwin_stop_world.c: Likewise. * dbg_mlc.c: Likewise. * gcj_mlc.c: Likewise. * headers.c: Likewise. * include/gc/gc_inline.h: Likewise. * include/gc/gc_mark.h: Likewise. * include/private/gc_locks.h: Likewise. * include/private/gc_pmark.h: Likewise. * include/private/pthread_stop_world.h: Likewise. * include/private/pthread_support.h: Likewise. * mach_dep.c: Likewise. * malloc.c: Likewise. * thread_local_alloc.c: Likewise. * typd_mlc.c: Likewise. * finalize.c: Update year in copyright comment (2020 to 2022). * include/gc/gc.h: Likewise. * pthread_stop_world.c: Likewise.
* Replace comments about GC is held or not with relevant assertionsIvan Maidanski2022-05-111-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * alloc.c (GC_default_stop_func): Refine comment about the allocation lock. * alloc.c (GC_finish_collection): Remove comment that the allocation lock is held because the assertion about it already exists. * finalize.c (GC_grow_table, GC_mark_fo, GC_finalize): Likewise. * finalize.c [!GC_MOVE_DISAPPEARING_LINK_NOT_NEEDED] (GC_move_disappearing_link_inner): Likewise. * mark.c (GC_mark_some_inner): Likewise. * mark.c [PARALLEL_MARK] (GC_do_parallel_mark): Likewise. * os_dep.c [OPENBSD && GC_OPENBSD_UTHREADS] (GC_find_limit_openbsd, GC_skip_hole_openbsd): Likewise. * os_dep.c [NEED_FIND_LIMIT || USE_PROC_FOR_LIBRARIES && THREADS] (GC_find_limit_with_bound): Likewise. * os_dep.c (GC_register_data_segments): Likewise. * os_dep.c [MPROTECT_VDB || PROC_VDB || SOFT_VDB] (GC_dirty_init): Likewise. * pthread_stop_world.c (GC_start_world): Likewise. * pthread_support.c (GC_new_thread): Likewise. * thread_local_alloc.c (return_freelists): Likewise. * win32_threads.c (GC_new_thread, GC_lookup_thread_inner, GC_delete_gc_thread_no_free): Likewise. * blacklst.c (GC_promote_black_lists): Remove comment that the allocation lock is held, and add the corresponding assertion to the beginning of the function. * blacklst.c [!PARALLEL_MARK] (GC_add_to_black_list_normal, GC_add_to_black_list_stack): Likewise. * darwin_stop_world.c (GC_stop_world, GC_start_world): Likewise. * mark_rts.c (GC_remove_root_at_pos, GC_remove_roots_inner, GC_exclude_static_roots_inner): Likewise. * pthread_stop_world.c (GC_push_all_stacks, GC_suspend_all): Likewise. * pthread_support.c (GC_check_finalizer_nested): Likewise. * thread_local_alloc.c (GC_destroy_thread_local): Likewise. * win32_threads.c (GC_check_finalizer_nested, GC_push_all_stacks): Likewise. * blacklst.c (GC_is_black_listed): Refine comment about the allocation lock. * darwin_stop_world.c (GC_push_all_stacks): Add assertion that the lock is held on entrance. * gcj_mlc.c (maybe_finalize): Likewise. * malloc.c [THREADS] (GC_free_inner): Likewise. * dyn_load.c (GC_dyld_image_add, GC_dyld_image_remove, GC_init_dyld): Remove comment the allocation lock should not be held, and add the corresponding assertion to the beginning of the function. * finalize.c (GC_invoke_finalizers): Likewise. * mark.c [PARALLEL_MARK] (GC_help_marker): Likewise. * pthread_support.c (GC_init_parallel): Likewise. * win32_threads.c (GC_lookup_pthread, GC_init_parallel): Likewise. * finalize.c (GC_finalize_all): Remove comment that the lock is not held on entrance. * gcj_mlc.c (GC_init_gcj_malloc): Likewise. * typd_mlc.c (GC_add_ext_descriptor): Likewise. * include/gc/javaxfc.h (GC_finalize_all): Add comment the function acquires the allocation lock. * mallocx.c (GC_generic_malloc_many): Adjust comment about GC lock. * new_hblk.c (GC_build_fl): Likewise. * pthread_support.c (GC_new_thread): Move the assertion about the allocation lock closer to the beginning of the function. * win32_threads.c (GC_new_thread): Likewise.
* Remove extra space after comma in license termsIvan Maidanski2022-05-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (reformatting) * CMakeLists.txt: Remove an extra space after comma in license header comment. * Makefile.am: Likewise. * allchblk.c: Likewise. * alloc.c: Likewise. * backgraph.c: Likewise. * blacklst.c: Likewise. * checksums.c: Likewise. * configure.ac: Likewise. * cord/cordbscs.c: Likewise. * cord/cordprnt.c: Likewise. * cord/cordxtra.c: Likewise. * cord/tests/cordtest.c: Likewise. * cord/tests/de.c: Likewise. * cord/tests/de_cmds.h: Likewise. * cord/tests/de_win.c: Likewise. * cord/tests/de_win.h: Likewise. * cord/tests/de_win.rc: Likewise. * darwin_stop_world.c: Likewise. * dbg_mlc.c: Likewise. * dyn_load.c: Likewise. * extra/gc.c: Likewise. * extra/msvc_dbg.c: Likewise. * extra/pcr_interface.c: Likewise. * extra/real_malloc.c: Likewise. * finalize.c: Likewise. * fnlz_mlc.c: Likewise. * gc_badalc.cc: Likewise. * gc_cpp.cc: Likewise. * gc_dlopen.c: Likewise. * gcj_mlc.c: Likewise. * headers.c: Likewise. * include/gc/cord.h: Likewise. * include/gc/cord_pos.h: Likewise. * include/gc/ec.h: Likewise. * include/gc/gc.h: Likewise. * include/gc/gc_backptr.h: Likewise. * include/gc/gc_config_macros.h: Likewise. * include/gc/gc_disclaim.h: Likewise. * include/gc/gc_gcj.h: Likewise. * include/gc/gc_inline.h: Likewise. * include/gc/gc_mark.h: Likewise. * include/gc/gc_pthread_redirects.h: Likewise. * include/gc/gc_tiny_fl.h: Likewise. * include/gc/gc_typed.h: Likewise. * include/gc/gc_version.h: Likewise. * include/gc/javaxfc.h: Likewise. * include/gc/leak_detector.h: Likewise. * include/include.am: Likewise. * include/private/darwin_semaphore.h: Likewise. * include/private/darwin_stop_world.h: Likewise. * include/private/dbg_mlc.h: Likewise. * include/private/gc_alloc_ptrs.h: Likewise. * include/private/gc_atomic_ops.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. * m4/gc_set_version.m4: Likewise. * mach_dep.c: Likewise. * malloc.c: Likewise. * mallocx.c: Likewise. * mark.c: Likewise. * mark_rts.c: Likewise. * misc.c: Likewise. * new_hblk.c: Likewise. * obj_map.c: Likewise. * os_dep.c: Likewise. * pthread_start.c: Likewise. * pthread_stop_world.c: Likewise. * pthread_support.c: Likewise. * ptr_chck.c: Likewise. * reclaim.c: Likewise. * specific.c: Likewise. * tests/atomicops.c: Likewise. * tests/cpp.cc: Likewise. * tests/disclaim.c: Likewise. * tests/disclaim_bench.c: Likewise. * tests/gctest.c: Likewise. * tests/tests.am: Likewise. * tests/weakmap.c: Likewise. * thread_local_alloc.c: Likewise. * tools/setjmp_t.c: Likewise. * tools/threadlibs.c: Likewise. * typd_mlc.c: Likewise. * win32_threads.c: Likewise. * LICENSE: Remove an extra space after comma in license terms.
* Remove extra parentheses in return statementIvan Maidanski2022-05-011-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) Also, replace 0 to NULL where appropriate. * allchblk.c (setup_header, GC_get_first_part, GC_allochblk_nth): Remove outermost parentheses in the expression of return statement. * alloc.c (GC_never_stop_func, GC_timeout_stop_func, GC_adj_bytes_allocd, GC_try_to_collect_inner, GC_collect_a_little, GC_stopped_mark, GC_try_to_collect_general, GC_expand_hp_inner, GC_collect_or_expand, GC_allocobj): Likewise. * blacklst.c (GC_is_black_listed, GC_number_stack_black_listed, total_stack_black_listed): Likewise. * checksums.c (GC_checksum): Likewise. * cord/cordbscs.c (CORD_cat_char_star, CORD_cat, CORD_len, CORD_index_access_fn, CORD_apply_access_fn, CORD_substr_checked, CORD_substr, CORD_iter5, CORD_iter, CORD_riter4, CORD_riter, CORD_concat_forest, CORD_balance, CORD__pos_fetch, CORD__prev, CORD_prev, CORD_pos_to_cord, CORD_pos_valid): Likewise. * cord/cordprnt.c (extract_conv_spec, CORD_vsprintf, CORD_sprintf, CORD_fprintf, CORD_vfprintf, CORD_printf, CORD_vprintf): 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_from_char_star, CORD_to_const_char_star, CORD_fetch, CORD_put_proc, CORD_batched_put_proc, CORD_put, CORD_chr_proc, CORD_rchr_proc, CORD_batched_chr_proc, CORD_chr, CORD_rchr, CORD_str, CORD_from_file_eager, CORD_lf_func, CORD_from_file_lazy_inner, CORD_from_file_lazy, CORD_from_file): Likewise. * cord/tests/cordtest.c (test_fn, id_cord_fn, test_basics): Likewise. * cord/tests/de.c (line_pos, add_hist, retrieve_line, beep): Likewise. * cord/tests/de_win.c (WinMain, plain_chars, control_chars, WndProc): Likewise. * dbg_mlc.c (store_debug_info, GC_debug_generic_malloc, GC_debug_generic_malloc, GC_debug_realloc, GC_make_closure): Likewise. * dyn_load.c (GC_FirstDLOpenedLinkMap): Likewise. * extra/real_malloc.c (real_malloc): Likewise. * finalize.c (GC_register_disappearing_link, GC_unregister_disappearing_link): Likewise. * gc_dlopen.c (dlopen): Likewise. * gcj_mlc.c (maybe_finalize, GC_debug_gcj_malloc, GC_gcj_malloc_ignore_off_page): Likewise. * headers.c (GC_find_header, alloc_hdr, get_index, GC_install_header, GC_next_block, GC_prev_block): Likewise. * malloc.c (GC_generic_malloc): Likewise. * mallocx.c (GC_realloc, GC_generic_malloc_ignore_off_page): Likewise. * mark.c (GC_collection_in_progress, GC_mark_some, GC_signal_mark_stack_overflow, GC_block_was_dirty, GC_push_next_marked, GC_push_next_marked_dirty, GC_push_next_marked_uncollectable): Likewise. * mark_rts.c (GC_is_static_root, rt_hash, GC_roots_present, GC_remove_tmp_roots, GC_approx_sp): Likewise. * misc.c (GC_default_oom_fn, GC_clear_stack_inner, GC_base, GC_write, GC_get_warn_proc, GC_call_with_alloc_lock): Likewise. * new_hblk.c (GC_build_fl_clear2, GC_build_fl_clear4, GC_build_fl2, GC_build_fl4, GC_build_fl): Likewise. * obj_map.c (GC_register_displacement_inner): Likewise. * os_dep.c (GC_find_limit_openbsd, GC_skip_hole_openbsd, GC_get_writable_length, GC_get_writable_length, GC_get_main_stack_base, GC_FreeBSDGetDataStart, GC_unix_mmap_get_mem, GC_unix_sbrk_get_mem, os2_alloc, GC_wince_get_mem, GC_win32_get_mem, GC_push_thread_stack, GC_push_old_obj, GC_write_fault_handler, catch_exception_raise_state, catch_exception_raise_state_identity): Likewise. * pthread_support.c (GC_new_thread, GC_lookup_thread, GC_get_nprocs, pthread_sigmask, pthread_create): Likewise. * ptr_chck.c (GC_same_obj, GC_default_is_visible_print_proc, GC_default_is_valid_displacement_print_proc, GC_is_visible, GC_pre_incr, GC_post_incr): Likewise. * reclaim.c (GC_block_empty, GC_reclaim_uninit, GC_n_set_marks, GC_reclaim_all): Likewise. * tests/cpp.cc (main): Likewise. * tests/gctest.c (fake_gcj_mark_proc, reverse1, reverse, ints, gcj_reverse1, gcj_reverse, gcj_ints, uncollectable_ints, mktree, alloc8bytes, main, test): Likewise. * tools/if_mach.c (main): Likewise. * tools/if_not_there.c (main): Likewise. * tools/setjmp_t.c (getpagesize, main, g): Likewise. * typd_mlc.c (GC_add_ext_descriptor, GC_add_ext_descriptor, GC_double_descr, GC_make_array_descriptor, GC_make_sequence_descriptor, GC_typed_mark_proc, GC_descr_obj_size, GC_push_complex_descriptor, GC_array_mark_proc, GC_make_descriptor, GC_calloc_explicitly_typed): Likewise. * win32_threads.c (GC_new_thread, GC_lookup_thread_inner, GC_get_stack_min, GC_pthread_create, GC_pthread_start_inner): Likewise. * allchblk.c (GC_get_first_part, GC_allochblk_nth): Replace 0 to NULL where appropriate. * alloc.c (GC_allocobj): Likewise. * blacklst.c (GC_is_black_listed): Likewise. * cord/cordbscs.c (CORD_from_fn_inner, CORD_substr_checked): Likewise. * cord/cordxtra.c (CORD_cat_char, CORD_to_char_star, CORD_from_char_star, CORD_lf_func, CORD_from_file_lazy_inner): Likewise. * dbg_mlc.c (store_debug_info, GC_debug_generic_malloc, GC_debug_generic_malloc): Likewise. * dyn_load.c (GC_FirstDLOpenedLinkMap): Likewise. * gcj_mlc.c (GC_debug_gcj_malloc): Likewise. * headers.c (GC_next_block, GC_prev_block): Likewise. * malloc.c (GC_generic_malloc, strdup): Likewise. * mallocx.c (GC_realloc): Likewise. * misc.c (GC_default_oom_fn, GC_base): Likewise. * os_dep.c (GC_get_main_stack_base, os2_alloc, GC_win32_get_mem): Likewise. * pthread_support.c (GC_new_thread, GC_lookup_thread): Likewise. * ptr_chck.c (GC_same_obj, GC_is_visible, GC_default_is_valid_displacement_print_proc): Likewise. * tests/gctest.c (mktree): Likewise. * typd_mlc.c (GC_make_array_descriptor, GC_push_complex_descriptor, GC_array_mark_proc, GC_calloc_explicitly_typed): Likewise. * win32_threads.c (GC_new_thread, GC_lookup_thread_inner): Likewise. * alloc.c (GC_never_stop_func, GC_timeout_stop_func): Replace 0 and 1 (in return statement) to FALSE and TRUE, respectively. * include/private/gcconfig.h: Remove outermost parentheses in the expression of return statement in comment.
* Adjust indentation in C preprocessor directivesIvan Maidanski2022-04-181-24/+24
| | | | | | | | | | | | | | | | | | | | | | | (reformatting) * cord/tests/de.c: Adjust indentation in directives. * cord/tests/de_win.c: Likewise. * dbg_mlc.c: Likewise. * dyn_load.c: Likewise. * extra/AmigaOS.c: Likewise. * include/gc/ec.h: Likewise. * include/gc/gc_tiny_fl.h: Likewise. * include/private/gc_locks.h: Likewise. * include/private/gc_priv.h: Likewise. * include/private/gcconfig.h: Likewise. * include/private/thread_local_alloc.h: Likewise. * malloc.c: Likewise. * mark.c: Likewise. * os_dep.c: Likewise. * ptr_chck.c: Likewise. * reclaim.c: Likewise. * tests/gctest.c: Likewise. * tools/threadlibs.c: Likewise.
* Fix SIGSEGV while marking some special proc mapping (E2K)Ivan Maidanski2022-02-021-0/+6
| | | | | | | | | Issue #413 (bdwgc). * dyn_load.c [(SCO_ELF || DGUX || HURD || NACL || __ELF__ && (LINUX || FREEBSD || NETBSD || OPENBSD)) && USE_PROC_FOR_LIBRARIES && E2K && __ptr64__] (GC_register_map_entries): Skip c2fffffff000-c30000000000 anonymous writable section; add TODO.
* Discard sections with pseudo-paths except heap in register_map_entriesIvan Maidanski2022-02-021-2/+5
| | | | | | | | | | | If USE_PROC_FOR_LIBRARIES, this commit prevents addition of special writable sections (from proc maps) like stacks. * dyn_load.c [(SCO_ELF || DGUX || HURD || NACL || __ELF__ && (LINUX || FREEBSD || NETBSD || OPENBSD)) && USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Declare path local variable and pass it to GC_parse_map_entry; discard writable section if its path (mapping name) starts with '[' but does not match "[heap]".
* Add I_HOLD_LOCK assertion to scratch_alloc/recycle and their callersIvan Maidanski2022-01-171-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * allchblk.c (setup_header, GC_get_first_part, GC_allochblk_nth): Add assertion that the GC lock is held (I_HOLD_LOCK). * alloc.c (GC_add_to_heap, GC_scratch_recycle_inner): Likewise. * backgraph.c (push_in_progress, backwards_height): Likewise. * blacklst.c (GC_bl_init_no_interiors, GC_bl_init): Likewise. * dyn_load.c (GC_register_dynamic_libraries): Likewise. * finalize.c (push_and_mark_object): Likewise. * finalize.c [!GC_TOGGLE_REFS_NOT_NEEDED] (GC_mark_togglerefs): Likewise. * headers.c (GC_scratch_alloc, alloc_hdr, GC_init_headers, GC_install_header): Likewise. * include/private/gc_pmark.h (GC_MARK_FO): Likewise. * malloc.c (GC_alloc_reclaim_list): Likewise. * mark.c (GC_mark_some_inner, alloc_mark_stack): Likewise. * mark_rts.c [DYNAMIC_LOADING || MSWIN32 || MSWINCE || PCR || CYGWIN32] (GC_remove_tmp_roots): Likewise. * mark_rts.c (GC_cond_register_dynamic_libraries, GC_push_roots): Likewise. * obj_map.c [MARK_BIT_PER_GRANULE] (GC_add_map_entry): Likewise. * os_dep.c [NEED_PROC_MAPS && IA64] (backing_store_base_from_proc): Likewise. * os_dep.c [LINUX_STACKBOTTOM && IA64] (GC_get_register_stack_base): Likewise. * os_dep.c [MSWIN32] (GC_register_root_section): Likewise. * os_dep.c [!OS2 && !MSWIN32 && !MSWINCE && !CYGWIN32] (GC_register_data_segments): Likewise. * os_dep.c [GWW_VDB] (GC_gww_dirty_init, GC_gww_read_dirty): Likewise. * os_dep.c (GC_dirty_init): Likewise. * os_dep.c [PROC_VDB] (GC_proc_read_dirty): Likewise. * os_dep.c [SOFT_VDB] (soft_dirty_init, GC_soft_read_dirty): Likewise. * os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_read_dirty): Likewise. * dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX] (GC_register_dynamic_libraries): Round up size of buf local variable to multiple of 8 bytes. * headers.c (GC_install_header): Use EXPECT(). * malloc.c (GC_alloc_reclaim_list): Likewise. * obj_map.c [MARK_BIT_PER_GRANULE] (GC_add_map_entry): Likewise. * mark_rts.c [DYNAMIC_LOADING || MSWIN32 || MSWINCE || PCR || CYGWIN32] (GC_remove_tmp_roots, GC_push_roots): Remove redundant comment. * misc.c [GC_ASSERTIONS && GC_ALWAYS_MULTITHREADED] (GC_init): Wrap calls of GC_get_main_stack_base(), GC_get_register_stack_base(), GC_init_headers(), GC_dirty_init(), GC_register_data_segments(), GC_bl_init(), GC_mark_init() into LOCK/UNLOCK. * os_dep.c [OPENBSD] (GC_skip_hole_openbsd): Move sysconf() call to be after the assertion that the GC lock is held. * os_dep.c [HPUX_STACKBOTTOM] (GC_get_register_stack_base): Add assertion that GC_stackbottom is set.
* Fix assertion violation in register_dynlib_callback on AndroidIvan Maidanski2021-09-191-1/+5
| | | | | | * dyn_load.c [HAVE_DL_ITERATE_PHDR && PT_GNU_RELRO] (GC_register_dynlib_callback): Round load_segs[j].end up to nearest page boundary in the assertion; add comment.
* Adjust spaces around '=' in printed messagesIvan Maidanski2021-09-151-27/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * checksums.c (GC_check_blocks): Remove space before '=' and add a space (if missing) after '=' in printed message. * darwin_stop_world.c [DEBUG_THREADS_EXTRA] (GC_FindTopOfStack): Likewise. * dbg_mlc.c (GC_print_obj, GC_debug_print_heap_obj_proc): Likewise. * dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX || HPUX] (GC_register_dynamic_libraries): Likewise. [DEBUG_VIRTUALQUERY] (GC_dump_meminfo): Likewise. * os_dep.c [NEED_PROC_MAPS] (GC_get_maps): Likewise. * os_dep.c [PROC_VDB] (GC_proc_read_dirty): Likewise. * os_dep.c [SOFT_VDB] (soft_read_dirty): Likewise. * pthread_support.c (set_marker_thread_name, GC_start_mark_threads_inner): Likewise. * pthread_support.c [DEBUG_THREADS] (GC_delete_thread, GC_unregister_my_thread_inner, GC_unregister_my_thread, GC_thread_exit_proc, GC_start_rtn_prepare_thread): Likewise. * pthread_support.c [GC_LINUX_THREADS] (GC_get_nprocs): Likewise. * tests/disclaim_weakmap_test.c [DEBUG_DISCLAIM_WEAKMAP] (weakmap_add, weakmap_disclaim): Likewise. * tests/subthread_create.c (run_one_test): Likewise. * win32_threads.c (GC_delete_thread, GC_push_stack_for, GC_get_next_stack): Likewise. * darwin_stop_world.c [DEBUG_THREADS] (GC_stack_range_for): Remove '=' in printed message and/or improve message. * mark.c (GC_signal_mark_stack_overflow): Likewise. * mark_rts.c [!NO_DEBUGGING] (GC_print_static_roots): Likewise. * pthread_stop_world.c [DEBUG_THREADS] (GC_push_all_stacks, GC_suspend_all): Likewise. * pthread_support.c (GC_thr_init): Likewise. * tests/disclaim_test.c (pair_dct, pair_new): Likewise. * tests/disclaim_weakmap_test.c (pair_check_rec): Likewise. * tests/initsecondarythread.c (main): Likewise. * tests/subthread_create.c (entry, main): Likewise. * tests/test.c [THREADS] (fork_a_thread, main): Likewise. * tests/test.c [MSWINCE] (thr_window): Likewise. * tests/test.c [NTHREADS>0] (main): Likewise. * tests/threadkey_test.c (main): Likewise. * dyn_load.c [ALPHA && OSF1 && DL_VERBOSE] (GC_register_dynamic_libraries): Reformat printed messages. * tests/disclaim_test.c (main): Remove space after '#' in printed message.
* Update copyright information in alloc.c and other modified files (2021)Ivan Maidanski2021-09-091-0/+1
| | | | | | | | | | | | | | | | | | | | | * README.QUICK (Copyright): Update year (2019 to 2020). * README.md (Copyright): Likewise. * alloc.c (Copyright, GC_copyright): Likewise. * configure.ac (Copyright): Likewise. * include/private/gc_priv.h (Copyright): Likewise. * mark.c (Copyright): Likewise. * misc.c (Copyright): Likewise. * os_dep.c (Copyright): Likewise. * pthread_support.c (Copyright): Likewise. * win32_threads.c (Copyright): Likewise. * CMakeLists.txt: Update (add Ivan Maidanski). * dyn_load.c (Copyright): Likewise. * include/private/gc_alloc_ptrs.h (Copyright): Likewise. * include/private/gcconfig.h (Copyright): Likewise. * mallocx.c (Copyright): Likewise. * mark_rts.c (Copyright): Likewise. * reclaim.c (Copyright): Likewise. * tests/test.c (Copyright): Likewise.
* Remove useless empty statements after block ones (refactoring)Ivan Maidanski2021-09-081-1/+1
| | | | | | | | | * dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX] (GC_register_dynamic_libraries): Remove extra ';' after block statement ('}'). * new_hblk.c [!SMALL_CONFIG] (GC_build_fl_clear2, GC_build_fl_clear4, GC_build_fl2, GC_build_fl4): Likewise. * typd_mlc.c (GC_double_descr): Likewise.
* Add comment about fd caching to GC_register_dynamic_libraries (Irix)Ivan Maidanski2021-09-021-0/+2
| | | | | | * dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX] (GC_register_dynamic_libraries): Add comment (about the need to close fd in forked child if fd is cached when re-enabled).
* Always abort on failure to access /proc/self/maps (Linux)Ivan Maidanski2021-08-041-5/+1
| | | | | | | | | | | | | | | | | | | | | * dyn_load.c [(SCO_ELF || DGUX || HURD || NACL || __ELF__ && (LINUX || FREEBSD || NETBSD || OPENBSD)) && USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Remove map local variable; do not check result of GC_get_maps() for null. * os_dep.c [NEED_PROC_MAPS]: Include errno.h. * os_dep.c [NEED_PROC_MAPS && THREADS] (GC_get_file_len): Add comment that lseek does not work. * os_dep.c [NEED_PROC_MAPS] (GC_get_maps): Remove comment that the implementation could be simplified (if lseek works); update comments about result (it cannot be null) and about lseek (do not mention it); ABORT in case of failure (instead of returning null); report errno in ABORT message where possible. * os_dep.c [NEED_PROC_MAPS && (IA64 || INCLUDE_LINUX_THREAD_DESCR)] (GC_enclosing_mapping): Do not check result of GC_get_maps() for null. * os_dep.c [NEED_PROC_MAPS && REDIRECT_MALLOC] (GC_text_mapping): Likewise. * os_dep.c [LINUX && __ELF__ && !SMALL_CONFIG] (GC_print_address_map): Likewise.
* Mark buffer returned by get_maps as const (code refactoring)Ivan Maidanski2021-08-041-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * dyn_load.c [(SCO_ELF || DGUX || HURD || NACL || __ELF__ && (LINUX || FREEBSD || NETBSD || OPENBSD)) && USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Add const to maps argument and prot local variable; remove buf_ptr local variable (use maps instead). * dyn_load.c [(SCO_ELF || DGUX || HURD || NACL || __ELF__ && (LINUX || FREEBSD || NETBSD || OPENBSD)) && USE_PROC_FOR_LIBRARIES] (GC_register_dynamic_libraries): Add const to maps local variable. * include/private/gc_priv.h [NEED_PROC_MAPS && DYNAMIC_LOADING && USE_PROC_FOR_LIBRARIES] (GC_parse_map_entry): Add const to the return type, and to buf_ptr, prot, mapping_name arguments; rename buf_ptr to maps_ptr argument. * os_dep.c [NEED_PROC_MAPS && (DYNAMIC_LOADING && USE_PROC_FOR_LIBRARIES || IA64 || INCLUDE_LINUX_THREAD_DESCR || REDIRECT_MALLOC)] (GC_parse_map_entry): Likewise. * include/private/gc_priv.h [NEED_PROC_MAPS] (GC_get_maps): Add const to the return type. * os_dep.c [NEED_PROC_MAPS] (GC_get_maps): Likewise. * os_dep.c [NEED_PROC_MAPS && (DYNAMIC_LOADING && USE_PROC_FOR_LIBRARIES || IA64 || INCLUDE_LINUX_THREAD_DESCR || REDIRECT_MALLOC)] (GC_parse_map_entry): Add const to start_start, end_start, maj_dev_start, p local variables; remove duplicate while statement (it does not depend on mapping_name). * os_dep.c [NEED_PROC_MAPS && (IA64 || INCLUDE_LINUX_THREAD_DESCR)] (GC_enclosing_mapping): Add const to prot, buf_ptr local variables; remove maps local variable and rename buf_ptr to maps_ptr. * os_dep.c [NEED_PROC_MAPS && REDIRECT_MALLOC] (GC_text_mapping): Likewise. * os_dep.c [LINUX && __ELF__ && !SMALL_CONFIG] (GC_print_address_map): Add const to maps local variable.
* Replace SN_TARGET_ORBIS to PLATFORM_* and GC_NO_* macrosTim Cannell2021-07-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (cherry-pick of 6a86542, 366aaf6, f3b34f4 from Unity-Technologies/bdwgc) SN_TARGET_ORBIS macro is replaced (almost) with GC_NO_CAN_CALL_ATFORK, GC_NO_FREEBSD, GC_NO_NOSYS, GC_NO_TYPES, PLATFORM_GC_REG_STORAGE_SIZE, PLATFORM_GETMEM, PLATFORM_MACH_DEP, PLATFORM_STOP_WORLD, PLATFORM_WRITE ones. * alloc.c [!MACOS && !MSWINCE && !SN_TARGET_PSP2]: Test GC_NO_TYPES macro instead of SN_TARGET_ORBIS. * misc.c [!MSWIN32 && !MSWINCE && !OS2 && !MACOS && !GC_ANDROID_LOG && !NN_PLATFORM_CTR && !NINTENDO_SWITCH && !SN_TARGET_PSP2 && !AMIGA && !MSWIN32 && !MSWIN_XBOX1 && !__CC_ARM]: Likewise. * dyn_load.c [MACOS && !SN_TARGET_PSP2 && !_WIN32_WCE && !__CC_ARM]: Likewise. * extra/gc.c [PLATFORM_MACH_DEP]: Do not include mach_dep.c file. * extra/gc.c [PLATFORM_STOP_WORLD]: Do not include pthread_stop_world.c file. * include/gc_config_macros.h [__DragonFly__ || __FreeBSD_kernel__ || __FreeBSD__]: Do not define GC_FREEBSD_THREADS if GC_NO_FREEBSD. * include/private/gc_locks.h [GC_PTHREADS]: Do not test SN_TARGET_ORBIS macro. * include/private/gc_priv.h [!HBLKSIZE && (LARGE_CONFIG || !SMALL_CONFIG)]: Likewise. * include/private/gcconfig.h [USE_MUNMAP && !MUNMAP_THRESHOLD] (MUNMAP_THRESHOLD): Likewise. * include/private/gcconfig.h [GC_THREADS] (THREADS): Likewise. * include/private/gcconfig.h [(__FreeBSD__ || __DragonFly__ || __FreeBSD_kernel__) && !FREEBSD] (FREEBSD): Test GC_NO_FREEBSD macro instead of SN_TARGET_ORBIS. * include/private/gcconfig.h [(__arm || __arm__ || __thumb__) && !NACL && !LINUX && !NETBSD && !FREEBSD && !OPENBSD && !DARWIN && !_WIN32 && !__CEGCC__ && !NN_PLATFORM_CTR && !SN_TARGET_PSP2 && !SYMBIAN] (NOSYS): Test GC_NO_NOSYS macro instead of SN_TARGET_ORBIS. * include/private/gcconfig.h [SN_TARGET_ORBIS && (__amd64__ || __x86_64__)] (X86_64): Do not define. * include/private/gcconfig.h [X86_64]: Test PLATFORM_GETMEM macro instead of SN_TARGET_ORBIS. * include/private/gcconfig.h [X86_64 && PLATFORM_GETMEM] (OS_TYPE): Update value. * include/private/gcconfig.h [X86_64 && PLATFORM_GETMEM]: Include pthread.h. * include/private/gcconfig.h [X86_64 && PLATFORM_GETMEM]: Declare platform_get_stack_bottom() instead of ps4_get_stack_bottom(). * include/private/gcconfig.h [X86_64 && PLATFORM_GETMEM] (STACKBOTTOM): Use platform_get_stack_bottom(). * include/private/gcconfig.h [CAN_HANDLE_FORK && !CAN_CALL_ATFORK !HOST_TIZEN && !HURD] (CAN_CALL_ATFORK): Test GC_NO_CAN_CALL_ATFORK macro instead of SN_TARGET_ORBIS. * include/private/gcconfig.h [GC_PRIVATE_H]: Test PLATFORM_GETMEM macro instead of SN_TARGET_ORBIS. * include/private/gcconfig.h [GC_PRIVATE_H && PLATFORM_GETMEM] (platform_get_mem): Declare (instead of ps4_get_mem). * include/private/gcconfig.h [GC_PRIVATE_H && PLATFORM_GETMEM] (GET_MEM): Use platform_get_mem(). * include/private/pthread_stop_world.h [!GC_OPENBSD_UTHREADS && !NACL && !SN_TARGET_PSP2] (thread_stop_info.last_stop_count): Test PLATFORM_STOP_WORLD macro instead of SN_TARGET_ORBIS. * pthread_stop_world.c [GC_PTHREADS && !GC_WIN32_THREADS && !GC_DARWIN_THREADS]: Likewise. * include/private/pthread_stop_world.h [!NACL]: Test PLATFORM_HAVE_GC_REG_STORAGE_SIZE macro instead of SN_TARGET_ORBIS. * include/private/pthread_stop_world.h [!NACL && PLATFORM_HAVE_GC_REG_STORAGE_SIZE] (ORBIS_GC_REG_STORAGE_SIZE): Do not define. * include/private/pthread_stop_world.h [!NACL && PLATFORM_HAVE_GC_REG_STORAGE_SIZE] (thread_stop_info.registers): Use PLATFORM_GC_REG_STORAGE_SIZE instead of ORBIS_GC_REG_STORAGE_SIZE. * mach_dep.c [!SN_TARGET_PSP2]: Test PLATFORM_MACH_DEP macro instead of SN_TARGET_ORBIS. * misc.c [THREADS && !PCR && !SN_TARGET_PSP2] (GC_allocate_ml): Test GC_DEFN_ALLOCATE_ML macro instead of SN_TARGET_ORBIS. * misc.c [!MSWIN32 && !MSWINCE && !OS2 && !MACOS && !GC_ANDROID_LOG && !NN_PLATFORM_CTR && !NINTENDO_SWITCH] (GC_write): Test PLATFORM_WRITE macro instead of SN_TARGET_ORBIS.
* Ensure ELFSIZE is defined in dyn_load.c for OpenBSD (code refactoring)Kurt Miller2021-06-121-1/+3
| | | | | | | Issue #347 (bdwgc). * dyn_load.c [!ElfW && OPENBSD] (ElfW): Define to Elf64_##type only if ELFSIZE==64; issue compile error if ELFSIZE is neither 32 nor 64.
* Include <alloca.h> when using alloca on AIXClement Chigot2021-06-101-1/+1
| | | | | | | | | Issue #355 (bdwgc). Using "#pragma alloca" only works with XLC, in order to enable alloca calls. Including <alloca.h> works for both GCC and XLC. * dyn_load.c [AIX]: Replace "#pragma alloca" by "#include <alloca.h>".
* Collapse multiple includes of windows.hIvan Maidanski2019-09-141-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | (code refactoring) * dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32]: Do not define WIN32_LEAN_AND_MEAN and NOSERVICE macros; do not include windows.h. * include/private/gc_locks.h [GC_WIN32_THREADS && !USE_PTHREAD_LOCKS]: Likewise. * include/private/gc_priv.h [!NO_CLOCK && !BSD_TIME && (MSWIN32 || MSWINCE || WINXP_USE_PERF_COUNTER)]: Likewise. * include/private/thread_local_alloc.h [!USE_PTHREAD_SPECIFIC && !USE_COMPILER_TLS && !USE_WIN32_COMPILER_TLS && USE_WIN32_SPECIFIC]: Likewise. * mallocx.c [MSWINCE]: Likewise. * misc.c [MSWIN32 || MSWINCE || CYGWIN32 && GC_READ_ENV_FILE]: Likewise. * os_dep.c [MSWIN32 || MSWINCE || CYGWIN32]: Likewise. * tests/test.c [MSWIN32 || MSWINCE]: Likewise. * tools/setjmp_t.c [!OS2 && (MSWIN32 || MSWINCE || CYGWIN32)]: Likewise. * win32_threads.c [GC_WIN32_THREADS]: Likewise. * include/private/gc_priv.h [MSWIN32 || MSWINCE || CYGWIN32] (WIN32_LEAN_AND_MEAN, NOSERVICE): Define macro (before include windows.h). * include/private/gc_priv.h [MSWIN32 || MSWINCE || CYGWIN32]: Inclde windows.h and winbase.h before include gc_locks.h (instead of just before GC_sysinfo declaration).
* Remove unnecessary checks of __ELF__ for NaClIvan Maidanski2019-06-111-8/+6
| | | | | | (code refactoring of commit 9738a14a0) * dyn_load.c [NACL]: Assume __ELF__ is always defined.
* Use GC_WORD_MAX macro across all C source filesIvan Maidanski2018-11-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | (code refactoring) * alloc.c (GC_collect_at_heapsize, GC_compute_heap_usage_percent, GC_add_to_heap, GC_expand_hp_inner): Use GC_WORD_MAX instead of (word)-1. * dyn_load.c [DATASTART_IS_FUNC] (GC_register_dynamic_libraries_dl_iterate_phdr): Likewise. * finalize.c [KEEP_BACK_PTRS] (GC_notify_or_invoke_finalizers): Likewise. * headers.c (GC_install_counts): Likewise. * include/private/thread_local_alloc.h [GC_GCJ_SUPPORT] (ERROR_FL): Likewise. * os_dep.c [NEED_FIND_LIMIT || USE_PROC_FOR_LIBRARIES] (GC_find_limit): Likewise. * os_dep.c [MPROTECT_VDB && DARWIN] (GC_mprotect_thread): Likewise. * pthread_support.c [PARALLEL_MARK] (GC_mark_thread): Likewise. * win32_threads.c (ADDR_LIMIT): Likewise. * win32_threads.c [PARALLEL_MARK] (GC_mark_thread): Likewise. * alloc.c (GC_least_plausible_heap_addr): Use GC_WORD_MAX instead of ONES macro. * include/private/gc_priv.h [STACK_GROWS_DOWN] (MAKE_COOLER): Likewise. * mark.c (GC_set_hdr_marks): Likewise. * alloc.c (GC_WORD_MAX): Remove definition (in this file). * headers.c (GC_install_counts): Reformat code. * include/private/gc_priv.h (ONES): Rename to GC_WORD_MAX.
* Fix infinite restarting of mark_some when a static root disappeared (Linux)Ivan Maidanski2018-05-071-0/+4
| | | | | | | | | | | | Issue #218 (bdwgc). * dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Call GC_remove_roots_subregion for each region which has prot starting with "---"; add comment. * include/private/gc_priv.h [USE_PROC_FOR_LIBRARIES] (GC_remove_roots_subregion): Declare function. * mark_rts.c[USE_PROC_FOR_LIBRARIES] (GC_remove_roots_subregion): Implement.
* Remove unnecessary argument casts in add_roots_inner callsIvan Maidanski2018-05-051-14/+9
| | | | | | | | | | | | (code refactoring) * dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Remove unnecessary casting of arguments in GC_add_roots_inner call. * dyn_load.c [PCR && !DYNAMIC_LOADING && !MSWIN32] (GC_register_dynamic_libraries): Likewise. * dyn_load.c [HAVE_DL_ITERATE_PHDR] (GC_register_dynamic_libraries_dl_iterate_phdr): Change type of datastart and dataend local variables from char* to ptr_t.
* Really abort if failed to read /proc for library registration (Linux)Ivan Maidanski2018-05-041-4/+7
| | | | | | | | | * dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Change return type from word to void; remove "return 1". * dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_dynamic_libraries): Call ABORT() if GC_get_maps() returned null. * os_dep.c [NEED_PROC_MAPS] (GC_get_maps): Remove outdated comment (about fn).
* Fix register_dynamic_libraries on Windows 10Naoyuki Sawa2018-05-031-1/+3
| | | | | | | | | | | | | | Issue #219 (bdwgc). In the past (Windows XP, Windows 7, and older Windows 10), VirtualQuery always returned PAGE_READWRITE for the data section. In the April 2018 Update of Windows 10, it seems that PAGE_WRITECOPY is returned sometimes (thus causing GC_register_dynamic_libraries not to call GC_cond_add_roots for the section). * dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_register_dynamic_libraries): Call GC_cond_add_roots() also for PAGE_EXECUTE_WRITECOPY and PAGE_WRITECOPY pages.
* Avoid potential race in print_static_roots called by dyld_image_add/removeIvan Maidanski2018-04-101-2/+9
| | | | | | | | * dyn_load.c [DARWIN && DARWIN_DEBUG && !NO_DEBUGGING] (GC_dyld_image_add, GC_dyld_image_remove): Place LOCK/UNLOCK around GC_print_static_roots() call. * dyn_load.c [DARWIN && DARWIN_DEBUG && !NO_DEBUGGING] (GC_dyld_image_remove): Add DCL_LOCK_STATE.
* Do not declare dl_iterate_phdr as weak for kFreeBSDIvan Maidanski2018-04-061-1/+2
| | | | | * dyn_load.c [!USE_PROC_FOR_LIBRARIES && __FreeBSD_kernel__] (HAVE_DL_ITERATE_PHDR, DL_ITERATE_PHDR_STRONG): Define.
* Workaround missing extern 'C' for _DYNAMIC in link.h on some Linux hostsIvan Maidanski2018-03-021-0/+3
| | | | | | | | | 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.
* Wrap remaining extern symbols in .c files into EXTERN_C_BEGIN/ENDIvan Maidanski2018-03-021-7/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Eliminate C++ warnings about deprecated register keyword (GC source)Jay Krell2018-02-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix 'anonymous type with no linkage used to declare variable' in GC sourceIvan Maidanski2018-02-201-1/+1
| | | | | | | | | 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.
* Convert GC source files to valid C++ codeIvan Maidanski2018-02-161-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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*.
* Initial support of Sony PlayStation Portable 2Jonathan Chambers2018-02-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (part of commit 9379c66 from Unity-Technologies/bdwgc) Issue #173 (bdwgc). * alloc.c [!MACOS && !MSWINCE && !SN_TARGET_ORBIS && !__CC_ARM]: Do not include sys/types.h if SN_TARGET_PSP2. * dyn_load.c [!MACOS && !_WIN32_WCE && !SN_TARGET_ORBIS && !__CC_ARM]: Likewise. * os_dep.c [!OS2 && !PCR && !AMIGA && !MACOS && !MSWINCE && !SN_TARGET_ORBIS && !__CC_ARM]: Likewise. * include/gc_config_macros.h [SN_TARGET_PSP2] (GC_THREADS): Define macro. * include/private/gcconfig.h [SN_TARGET_PSP2] (mach_type_known): Likewise. * include/private/gcconfig.h [ARM32 && SN_TARGET_PSP2] (NO_HANDLE_FORK, DATASTART, DATAEND, STACKBOTTOM): Likewise. * include/private/gcconfig.h [SN_TARGET_PSP2] (THREADS, GET_MEM): Likewise. * include/private/gc_locks.h [GC_PTHREADS && !GC_WIN32_THREADS && !SN_TARGET_ORBIS]: Do not include gc_atomic_ops.h if SN_TARGET_PSP2. * include/private/gc_locks.h [SN_TARGET_PSP2]: Include psp2-support.h. * include/private/gc_locks.h [SN_TARGET_PSP2] (GC_allocate_ml_PSP2): Declare GC_EXTERN variable. * include/private/gc_locks.h [SN_TARGET_PSP2] (UNCOND_LOCK, UNCOND_UNLOCK): Define (using GC_allocate_ml_PSP2 instead of GC_allocate_ml). * include/private/gc_priv.h [!HBLKSIZE && (LARGE_CONFIG || !SMALL_CONFIG) && SN_TARGET_PSP2] (CPP_LOG_HBLKSIZE): Define to 16 (instead of 12). * include/private/gcconfig.h [ARM32] (NOSYS): Do not define if SN_TARGET_PSP2. * os_dep.c (SBRK_ARG_T, OPT_MAP_ANON, GC_unix_mmap_get_mem, GC_unix_sbrk_get_mem, GC_unix_get_mem): Likewise. * pthread_support.c (GC_pthread_join, GC_pthread_detach, GC_pthread_create): Likewise. * include/private/gcconfig.h [ARM32 && SN_TARGET_PSP2] (psp2_get_stack_bottom): Declare external function. * include/private/gcconfig.h [SN_TARGET_PSP2] (psp2_get_mem): Likewise. * include/private/gcconfig.h [USE_MUNMAP && !MUNMAP_THRESHOLD && SN_TARGET_PSP2] (MUNMAP_THRESHOLD): Define to 2. * mach_dep.c: Skip everything in this file if SN_TARGET_PSP2. * pthread_stop_world.c: Likewise. * misc.c [SN_TARGET_PSP2] (GC_allocate_ml_PSP2): Define global varible (instead of GC_allocate_ml). * misc.c [!MSWIN32 && !MSWINCE && !OS2 && !MACOS && !GC_ANDROID_LOG && !NN_PLATFORM_CTR && !NINTENDO_SWITCH && !AMIGA && !SN_TARGET_ORBIS && !__CC_ARM]: Do not include unistd.h if SN_TARGET_PSP2. * misc.c [SN_TARGET_PSP2] (GC_write): Define to no-op. * pthread_support.c: Do not include sys/mman.h if SN_TARGET_PSP2.
* Initial support of Orbis targetJonathan Chambers2018-01-291-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (part of commit 9379c66 from Unity-Technologies/bdwgc) Issue #173 (bdwgc). * alloc.c [!MACOS && !MSWINCE && !__CC_ARM]: Do not include sys/types.h if SN_TARGET_ORBIS. * dyn_load.c [!MACOS && !_WIN32_WCE && !__CC_ARM]: Likewise. * include/gc_config_macros.h [SN_TARGET_ORBIS] (GC_THREADS): Define. * include/gc_config_macros.h [__FreeBSD__] (GC_FREEBSD_THREADS): Do not define if SN_TARGET_ORBIS. * include/private/gcconfig.h [__FreeBSD__ || __DragonFly__ || __FreeBSD_kernel__] (FREEBSD): Likewise. * include/private/gcconfig.h [!LINUX && !NETBSD && !FREEBSD && !OPENBSD && !DARWIN && !_WIN32 && !__CEGCC__ && !NN_PLATFORM_CTR !NN_BUILD_TARGET_PLATFORM_NX && !SYMBIAN] (NOSYS): Likewise. * include/private/gc_locks.h [THREADS && GC_PTHREADS && !GC_WIN32_THREADS]: Do not include gc_atomic_ops.h if SN_TARGET_ORBIS. * include/private/gc_locks.h [SN_TARGET_ORBIS && GC_PTHREADS] (USE_PTHREAD_LOCKS): Define. * include/private/gc_priv.h [SN_TARGET_ORBIS] (CPP_LOG_HBLKSIZE): Define to 16 (instead of 12). * include/private/gcconfig.h [SN_TARGET_ORBIS && (__amd64__ || __x86_64__)] (X86_64): Define. * include/private/gcconfig.h [X86_64] (CACHE_LINE_SIZE): Do not define if already defined. * include/private/gcconfig.h [X86_64 && SN_TARGET_ORBIS] (DATASTART, DATAEND, STACKBOTTOM): Define. * include/private/gcconfig.h [X86_64 && SN_TARGET_ORBIS]: Include pthread.h. * include/private/gcconfig.h [X86_64 && SN_TARGET_ORBIS] (ps4_get_stack_bottom): Declare. * include/private/gcconfig.h [USE_MUNMAP && !MUNMAP_THRESHOLD && SN_TARGET_ORBIS] (MUNMAP_THRESHOLD): Define to 2. * include/private/gcconfig.h [SN_TARGET_ORBIS] (THREADS): Define. * pthread_support.c: Do not include sys/mman.h, sys/time.h, sys/types.h, fcntl.h if SN_TARGET_ORBIS. * pthread_support.c (GC_pthread_join, GC_pthread_detach, GC_pthread_create): Do not define if SN_TARGET_ORBIS.
* Initial support of Haiku/amd64Calvin Buckley2018-01-241-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (port of commit e52f300 from 'mono_libgc') * configure.ac [THREADS=posix && host=*-*-haiku*] (GC_THREADS, _REENTRANT, PARALLEL_MARK, THREAD_LOCAL_ALLOC): Define macro. * include/gc_config_macros.h [GC_THREADS && __HAIKU__] (GC_HAIKU_THREADS): Likewise. * include/private/gcconfig.h [__HAIKU__ && _X86_] (I386, HAIKU, mach_type_known): Likewise. * include/private/gcconfig.h [__HAIKU__ && __amd64__] (X86_64, HAIKU, mach_type_known): Likewise. * include/private/gcconfig.h [I386 && HAIKU] (DYNAMIC_LOADING, MPROTECT_VDB): Likewise. * include/private/gcconfig.h [X86_64 && HAIKU] (OS_TYPE, GETPAGESIZE, DATASTART, DYNAMIC_LOADING, MPROTECT_VDB): Likewise. * include/private/gcconfig.h [HAIKU] (UNIX_LIKE, GET_MEM): Likewise. * os_dep.c [MPROTECT_VDB && !DARWIN && !MSWIN32 && !MSWINCE && HAIKU] (CODE_OK): Likewise. * dyn_load.c [HAIKU] (GC_register_dynamic_libraries): Implement. * os_dep.c [HAIKU] (GC_haiku_get_mem): Likewise. * include/private/gcconfig.h (BEOS): Rename to HAIKU. * os_dep.c (BEOS): Likewise. * include/private/gcconfig.h [I386 && HAIKU] (OS_TYPE): Change value to "HAIKU". * include/private/gcconfig.h [X86_64 && HAIKU]: Include OS.h; declare etext symbol. * include/private/gcconfig.h [HAIKU] (GC_haiku_get_mem): Declare prototype. * os_dep.c [(NEED_FIND_LIMIT || UNIX_LIKE) && HAIKU] (old_segv_act): Define static variable. * os_dep.c [(NEED_FIND_LIMIT || UNIX_LIKE) && HAIKU] (GC_set_and_save_fault_handler): Use old_segv_act; call sigaction(SIGSEGV). * os_dep.c [NEED_FIND_LIMIT || (USE_PROC_FOR_LIBRARIES && THREADS)] (GC_reset_fault_handler): Likewise. * os_dep.c [MPROTECT_VDB && !DARWIN && !USE_WINALLOC && HAIKU]: Do not include sys/syscall.h. * pthread_support.c [GC_HAIKU_THREADS] (GC_get_nprocs): Define function.
* Use HOST_ANDROID define instead of PLATFORM_ANDROIDZoltan Varga2018-01-241-8/+8
| | | | | | | | | | | | | | | | (a cherry-pick of commit 5d819c8 from 'mono_libgc') * doc/README.macros (PLATFORM_ANDROID): Rename to HOST_ANDROID. * dyn_load.c: Rename PLATFORM_ANDROID to HOST_ANDROID. * include/gc.h: Likewise. * include/gc_config_macros.h: Likewise. * include/private/gcconfig.h: Likewise. * include/private/thread_local_alloc.h: Likewise. * os_dep.c: Likewise. * pthread_support.c: Likewise. * tests/initsecondarythread.c: Likewise. * tests/test.c: Likewise. * tools/threadlibs.c: Likewise.
* Do not declare dl_iterate_phdr as weak for DragonFlyIvan Maidanski2018-01-171-1/+1
| | | | | * dyn_load.c [!USE_PROC_FOR_LIBRARIES && __DragonFly__] (HAVE_DL_ITERATE_PHDR, DL_ITERATE_PHDR_STRONG): Define.
* Workaround 'array compared to 0', 'untrusted loop bound' false defectsIvan Maidanski2017-05-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | * dyn_load.c [SOLARISDL && !USE_PROC_FOR_LIBRARIES] (GC_FirstDLOpenedLinkMap): Wrap access to dynStructureAddr (which value obtained from a weak symbol) into COVERT_DATAFLOW() in comparison to 0. * dyn_load.c [HAVE_DL_ITERATE_PHDR && !DL_ITERATE_PHDR_STRONG] (GC_register_main_static_data): Wrap access to dl_iterate_phdr weak symbol into COVERT_DATAFLOW() in comparison to 0. * dyn_load.c [HAVE_DL_ITERATE_PHDR] (GC_FirstDLOpenedLinkMap): Wrap access to _DYNAMIC weak symbol into COVERT_DATAFLOW() in comparison to 0. * include/private/gc_priv.h (TRUSTED_STRING): Pass the argument through COVERT_DATAFLOW. * include/private/gcconfig.h (COVERT_DATAFLOW): New macro. * os_dep.c [SEARCH_FOR_DATA_START] (GC_init_linux_data_start): Wrap access to __data_start and GC_data_start into COVERT_DATAFLOW() in comparison to 0. * tests/disclaim_bench.c: Update comment for include gc_priv.h. * tests/disclaim_bench.c (main): Pass the integer value obtained from command-line argument (and which is used as a loop boundary) through COVERT_DATAFLOW(). * tests/test_cpp.cc (main): Likewise.
* Fix crash in FirstDLOpenedLinkMap if app linked statically (Alpine Linux)Ryan Gonzalez2017-04-131-9/+16
| | | | | | | | | | Issue #154 (bdwgc). * dyn_load.c [SOLARISDL && !USE_PROC_FOR_LIBRARIES] (GC_FirstDLOpenedLinkMap): Do not dereference d_un.d_ptr if it is null. * dyn_load.c [(SCO_ELF || DGUX || HURD || LINUX || FREEBSD || NACL || NETBSD || OPENBSD) && !USE_PROC_FOR_LIBRARIES] (GC_FirstDLOpenedLinkMap): Likewise.
* Remove lint-specific codeIvan Maidanski2017-03-221-6/+0
| | | | | | | | | | | | | | | Note: cppcheck and CSA replace lint tool. * Makefile.direct (lint): Remove. * dyn_load.c [SOLARISDL && !USE_PROC_FOR_LIBRARIES && LINT] (_DYNAMIC): Remove. * dyn_load.c [IRIX5 || (USE_PROC_FOR_LIBRARIES && !LINUX)] (GC_register_dynamic_libraries): Remove comment about a false warning reported by lint. * mach_dep.c [ASM_CLEAR_CODE && LINT] (GC_clear_stack_inner): Remove. * tests/test.c (typed_test): Call GC_make_descriptor unconditionally. * tests/test.c (run_one_test): Set y to fail_proc1 unconditionally. * tests/test.c (main): Do not check whether LINT is defined.
* Allow HAVE_DL_ITERATE_PHDR to be defined by client (musl)Ivan Maidanski2017-03-171-9/+14
| | | | | | | | | | | | Do not redefine HAVE_DL_ITERATE_PHDR macro if already defined. * dyn_load.c [OPENBSD>=200519] (HAVE_DL_ITERATE_PHDR): Do not define if already defined. * dyn_load.c [!USE_PROC_FOR_LIBRARIES && (__GLIBC__>=2 || PLATFORM_ANDROID)] (HAVE_DL_ITERATE_PHDR): Likewise. * dyn_load.c [!USE_PROC_FOR_LIBRARIES && HAVE_DL_ITERATE_PHDR && !DL_ITERATE_PHDR_STRONG] (dl_iterate_phdr): Define as weak symbol (even if HAVE_DL_ITERATE_PHDR is defined outside this file).
* Eliminate 'ISO C forbids object to function pointer conversion' warningIvan Maidanski2017-03-161-1/+1
| | | | | | | * dyn_load.c [SOLARISDL && !USE_PROC_FOR_LIBRARIES && SUNOS53_SHARED_LIB] (GC_FirstDLOpenedLinkMap): Cast result of dlsym() to word type before casting it to a function pointer. * pthread_support.c [GC_USE_DLOPEN_WRAP] (GC_init_real_syms): Likewise.
* Eliminate 'memory leak' code defect for scratch-allocated memoryIvan Maidanski2016-12-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Reuse memory allocated by GC_scratch_alloc and GET_MEM in GC heap if possible. * backgraph.c (push_in_progress): Replace in_progress_size==0 with in_progress_space==NULL (to ensure BCOPY argument is non-NULL); eliminate code duplication regarding GC_add_to_our_memory call; call GC_scratch_recycle_no_gww (for old in_progress_space value) unless GWW_VDB (and remove corresponding FIXME). * dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX] (GC_register_dynamic_libraries): Call GC_scratch_recycle_no_gww (for old addr_map and current_sz values). * include/private/gc_priv.h [!GWW_VDB] (GC_scratch_recycle_no_gww): New internal macro. * include/private/gc_priv.h (GC_scratch_recycle_inner): New prototype. * mark.c (GC_scratch_recycle_inner): New function (move code portion from alloc_mark_stack). * mark.c (alloc_mark_stack): Call GC_scratch_recycle_inner (if recycle_old). * os_dep.c [NEED_PROC_MAPS] (GC_get_maps): Call GC_scratch_recycle_no_gww (for old maps_buf and maps_buf_sz values). * os_dep.c [PROC_VDB] (GC_read_dirty): Call GC_scratch_recycle_no_gww (for old GC_proc_buf and GC_proc_buf_size values).
* Fix (adjust) GC_scratch_alloc actual argument typeIvan Maidanski2016-12-201-1/+1
| | | | | | | | | | * dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX] (GC_register_dynamic_libraries): Do not cast GC_scratch_alloc argument to word type (it should be of size_t). * headers.c (alloc_hdr, GC_init_headers, get_index): Likewise. * os_dep.c [PROC_VDB] (GC_proc_buf_size): Change type from word to size_t. * os_dep.c [PROC_VDB] (GC_read_dirty): Change type of new_size local variable (which is passed to GC_scratch_alloc) from word to size_t.