summaryrefslogtreecommitdiff
path: root/misc.c
Commit message (Collapse)AuthorAgeFilesLines
* Do not do unnecessary GC_read_dirty() from GC_enable_incrementalIvan Maidanski2023-05-031-3/+8
| | | | | | | | | * misc.c [!GC_DISABLE_INCREMENTAL && !KEEP_BACK_PTRS] (GC_enable_incremental): Do not call GC_read_dirty() if GC_bytes_allocd is non-zero. * misc.c [!GC_DISABLE_INCREMENTAL && !KEEP_BACK_PTRS && !CHECKSUMS] (GC_enable_incremental): Pass TRUE (output_unneeded) to GC_read_dirty().
* Ensure that GC_init does not allocate any object itselfIvan Maidanski2023-04-061-0/+11
| | | | | | | | | | | | | | | (refactoring) Because the client might call GC_enable_incremental after GC_init and in case of GWW_VDB any object allocation should be generally avoided before GC_enable_incremental is called. * misc.c [DYNAMIC_LOADING && DARWIN] (GC_init): Add assertion before GC_gcollect_inner() call that no bytes are allocated yet. * misc.c [GWW_VDB && !KEEP_BACK_PTRS] (GC_init): Add assertion at the end of the function that no bytes were allocated; add comment. * misc.c (GC_deinit): Reset GC_bytes_allocd_before_gc and GC_bytes_allocd.
* Fix signals delivery fail in find-leak mode if init from non-main threadIvan Maidanski2023-04-061-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #542 (bdwgc). The scenario of the failure (on Linux): - Find-leak mode is on - pthread_create/join primitives are not redirected - GC is initialized from a thread other than primordial - that thread is terminated (but not unregistered as the 1st one in GC) - the primordial thread exits and launches GC_exit_check - GC_gcollect tries to suspend the terminated thread by sending a signal - the signal is not delivered but pthread_kill just returns zero - the signal sending is retried until aborting with the proper message. The proposed solution (workaround) is not to call GC_gcollect at the process exit (in the find-leak mode) if GC_init was called from a thread other than primordial one. Check in GC_exit_check() (which is called if GC_find_leak) that the thread executing at-exit functions is the same as the one performed the GC initialization, otherwise the latter thread might already be dead but still registered and this, as a consequence, might cause a signal delivery fail when suspending the threads on platforms that do not guarantee ESRCH returned if the signal is not delivered (as observed on Ubuntu 22). * include/private/gc_priv.h [THREADS && !DONT_USE_ATEXIT] (GC_is_main_thread): Declare GC_INNER function. * include/private/pthread_support.h [GC_WIN32_THREADS && !DONT_USE_ATEXIT] (GC_main_thread_id): Declare variable. * include/private/pthread_support.h [GC_WIN32_THREADS && !GC_NO_THREADS_DISCOVERY] (GC_main_thread_id): Do not depend on GC_ASSERTIONS. * misc.c [!DONT_USE_ATEXIT && THREADS] (GC_exit_check): If not GC_is_main_thread() or not GC_thread_is_registered() then do not call GC_gcollect(); add comment; do not set and clear GC_in_thread_creation. * pthread_support.c [!GC_NO_THREADS_DISCOVERY && GC_WIN32_THREADS || !DONT_USE_ATEXIT] (GC_main_thread_id): Define variable. * pthread_support.c [!DONT_USE_ATEXIT] (GC_is_main_thread): Implement. * pthread_support.c [!GC_WIN32_THREADS] (GC_thr_init): Define self_id local variable. * pthread_support.c [!GC_WIN32_THREADS && !DONT_USE_ATEXIT] (GC_thr_init): Set GC_main_thread_id. * win32_threads.c [!DONT_USE_ATEXIT] (GC_thr_init): Likewise. * win32_threads.c [!GC_NO_THREADS_DISCOVERY] (GC_main_thread_id): Do not define variable.
* Rename ROUNDED_UP_GRANULES macro to ALLOC_REQUEST_GRANSIvan Maidanski2023-03-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * include/gc/gc_tiny_fl.h (GC_RAW_BYTES_FROM_INDEX): Update comment (rename ROUNDED_UP_GRANULES to ALLOC_REQUEST_GRANS). * include/private/gc_priv.h (ADD_SLOP): Rename to ADD_EXTRA_BYTES; move definition upper (to be before ALLOC_REQUEST_GRANS). * include/private/gc_priv.h (ROUNDED_UP_GRANULES): Rename to ALLOC_REQUEST_GRANS; refine comment. * include/private/gc_priv.h (SMALL_OBJ): Remove extra parentheses; add comment. * include/private/gc_priv.h (_GC_arrays._size_map): Refine comment. * malloc.c (GC_extend_size_map, GC_generic_malloc_aligned): Rename ROUNDED_UP_GRANULES to ALLOC_REQUEST_GRANS. * misc.c (GC_init_size_map): Likewise. * thread_local_alloc.c [THREAD_LOCAL_ALLOC] (GC_malloc_kind): Likewise. * thread_local_alloc.c [THREAD_LOCAL_ALLOC && GC_GCJ_SUPPORT] (GC_gcj_malloc): Likewise. * malloc.c (GC_generic_malloc_inner): Rename ADD_SLOP to ADD_EXTRA_BYTES. * mallocx.c (GC_realloc): Likewise. * mallocx.c (GC_malloc_many): Define lg local variable; use ALLOC_REQUEST_GRANS() and GRANULES_TO_BYTES(); remove comment.
* Define GC_print_stats as GC_INNERIvan Maidanski2023-03-161-1/+1
| | | | | | | | | | | | | | (refactoring) * extra/MacOS.c [USE_TEMPORARY_MEMORY && !SHARED_LIBRARY_BUILD] (GC_MacFreeTemporaryMemory): Do not use GC_print_stats (assume it is always zero). * include/private/gc_priv.h [!NO_CLOCK || !SMALL_CONFIG] (GC_print_stats): Declared as GC_EXTERN; refine comment. * misc.c [!NO_CLOCK || !SMALL_CONFIG] (GC_print_stats): Define as GC_INNER. * tests/gctest.c [!GC_PRINT_VERBOSE_STATS && !GCTEST_PRINT_VERBOSE] (GC_print_stats): Update comment.
* Remove unused DCL_LOCK_STATEIvan Maidanski2023-01-301-37/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* Fix DCL_LOCK_STATE placement in GC_set_oom_fnIvan Maidanski2023-01-281-1/+2
| | | | | | (fix of commit c7047ca9e) * misc.c (GC_set_oom_fn): Move GC_ASSERT() to be after DCL_LOCK_STATE.
* Avoid code duplication between pthread_support.c and win32_threads.cIvan Maidanski2022-12-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * CMakeLists.txt [CMAKE_USE_PTHREADS_INIT || CMAKE_USE_WIN32_THREADS_INIT] (SRC): Include pthread_start.c and pthread_support.c for Win32 platform. * Makefile.am [THREADS] (libgc_la_SOURCES): Likewise. * NT_MAKEFILE [ENABLE_STATIC] (OBJS): Add pthread_start.obj, pthread_support.obj. * include/private/gc_locks.h [LINT2 || GC_WIN32_THREADS] (NO_PTHREAD_TRYLOCK): Do not define if already defined; add comment. * include/private/gcconfig.h [GC_PTHREADS && !GC_PTHREADS_PARAMARK && !__MINGW32__] (GC_PTHREADS_PARAMARK): Do not define unless PARALLEL_MARK. * include/private/pthread_support.h (thread_id_self, THREAD_ID_EQUAL, ADDR_LIMIT, MAX_MARKERS, GC_PTHREAD_PTRVAL): Define macro. * include/private/pthread_support.h (GC_win32_dll_threads, GC_available_markers_m1, GC_required_markers_cnt, GC_marker_sp, GC_marker_last_stack_min, GC_marker_Id): Declare global variable. * include/private/pthread_support.h (GC_init_win32_thread_naming, GC_mark_thread, GC_new_thread, GC_record_stack_base, GC_register_my_thread_inner, GC_lookup_by_pthread, GC_setup_atfork, GC_win32_cache_self_pthread, GC_delete_gc_thread_no_free, GC_win32_dll_lookup_thread, GC_delete_thread, GC_win32_unprotect_thread, GC_wait_for_gc_completion): Declare. * include/private/pthread_support.h [GC_PTHREADS] (GC_pthread_start_inner, GC_start_rtn_prepare_thread): Declare even for GC_WIN32_THREADS. * misc.c [!THREADS] (GC_call_with_gc_active, GC_do_blocking_inner): Update comment to refer to pthread_support.c. * pthread_start.c [GC_PTHREADS] (GC_pthread_start_inner): Define even for GC_WIN32_THREADS. * pthread_support.c: Do not skip this file for GC_WIN32_THREADS; adjust includes for Win32. * pthread_support.c (GC_INNER_WIN32THREAD): New macro. * pthread_support.c (GC_init_win32_thread_naming, GC_win32_unprotect_thread): New function. * pthread_support.c (setThreadDescription_fn, set_marker_thread_name): Move from win32_threads.c. * pthread_support.c (available_markers_m1): Rename to GC_available_markers_m1. * win32_threads.c (available_markers_m1): Likewise. * pthread_support.c (required_markers_cnt): Rename to GC_required_markers_cnt. * win32_threads.c (required_markers_cnt): Likewise. * pthread_support.c (GC_mark_thread, GC_start_mark_threads_inner, GC_push_thread_structures, GC_count_threads, GC_new_thread, GC_delete_thread, GC_delete_gc_thread_no_free, GC_lookup_thread, GC_reset_finalizer_nested, GC_check_finalizer_nested, GC_is_thread_tsd_valid, GC_thread_is_registered, GC_register_altstack, GC_segment_is_thread_stack, GC_wait_for_gc_completion, GC_remove_all_threads_but_me, fork_child_proc, GC_record_stack_base, GC_init_parallel, GC_pthread_sigmask, GC_set_stackbottom, GC_get_my_stackbottom, GC_call_with_gc_active, GC_unregister_my_thread, GC_unregister_my_thread_inner, GC_thread_exit_proc, GC_pthread_join, GC_pthread_detach, GC_pthread_sigmask, GC_pthread_create): Adjust function for Win32. * win32_threads.c (GC_lock_holder, GC_win32_dll_threads, IE_t, GC_thr_initialized, GC_need_to_lock, ADDR_LIMIT, GC_thread, GC_vthread, GC_threads, first_thread, GC_new_thread, GC_in_thread_creation, GC_record_stack_base, GC_lookup_thread, CHECK_LOOKUP_MY_THREAD, GC_reset_finalizer_nested, GC_check_finalizer_nested, GC_is_thread_tsd_valid, GC_thread_is_registered, GC_register_altstack, UNPROTECT_THREAD, GC_PTHREAD_PTRVAL, GC_delete_gc_thread_no_free, GC_delete_thread, GC_allow_register_threads, GC_register_my_thread, GC_set_stackbottom, GC_wait_for_gc_completion, GC_unregister_my_thread, GC_do_blocking_inner, GC_call_with_gc_active, GC_get_my_stackbottom, GC_remove_all_threads_but_me, fork_prepare_proc, fork_parent_proc, fork_child_proc, GC_atfork_prepare, GC_atfork_parent, GC_atfork_child, GC_setup_atfork, GC_push_thread_structures, marker_sp, set_marker_thread_name, setThreadDescription_fn, GC_mark_thread, required_markers_cnt, GC_set_markers_count, START_MARK_THREADS, start_info, GC_pthread_join, GC_pthread_create, GC_pthread_start_inner, GC_pthread_start, GC_thread_exit_proc, GC_pthread_detach, GC_check_tls, GC_init_parallel, GC_lock, GC_mark_thread_local_free_lists): Remove. * win32_threads.c [GC_PTHREADS_PARAMARK] (mark_cv, GC_start_mark_threads_inner, GC_mark_lock_holder, SET_MARK_LOCK_HOLDER, UNSET_MARK_LOCK_HOLDER, mark_mutex, builder_cv, GC_acquire_mark_lock, GC_release_mark_lock, GC_wait_builder, GC_wait_for_reclaim, GC_notify_all_builder, GC_wait_marker, GC_notify_all_marker, * win32_threads.c [GC_PTHREADS] (pthread_create, pthread_join, pthread_detach, pthread_sigmask): Do not undefine. * win32_threads.c [CAN_CALL_ATFORK]: Do not include unistd.h. * win32_threads.c (GC_register_my_thread_inner): Change type of me local variable from GC_vthread to GC_thread. * win32_threads.c (GC_win32_dll_lookup_thread, GC_win32_cache_self_pthread): New GC_INNER function. * win32_threads.c (GC_suspend, GC_start_world, GC_push_stack_for): Use GC_win32_unprotect_thread() instead of UNPROTECT_THREAD(). * win32_threads.c (marker_last_stack_min): Rename to GC_marker_last_stack_min. * win32_threads.c (GC_thr_init): Call GC_init_win32_thread_naming().
* Remove trailing dot in WARN messagesIvan Maidanski2022-11-011-6/+7
| | | | | | | | | | | | | | | | | (refactoring) Also, polish some WARN messages in GC_init. * allchblk.c (GC_allochblk_nth): Place space at the beginning of the 2nd half of the WARN message string literal (instead of the end of the 1st half). * misc.c (GC_init): Likewise. * os_dep.c [GWW_VDB] (GC_gww_read_dirty): Likewise. * misc.c (GC_init): Remove trailing dot in WARN message; adjust (make uniform) WARN message about ignoring the value. * os_dep.c [MPROTECT_VDB && DARWIN && BROKEN_EXCEPTION_HANDLING] (GC_dirty_init): No not break WARN message string literal into two parts unnecessarily.
* Fix negative heap size values reported in WARNIvan Maidanski2022-11-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #496 (bdwgc). WARN_PRIuPTR is now used to print unsigned values in WARN() calls. Also, byte values are replaced with KiB ones in some WARN() calls. * allchblk.c (GC_allochblk_nth): Use WARN_PRIuPTR specifier instead of WARN_PRIdPTR. * alloc.c (GC_expand_hp_inner, GC_collect_or_expand): Likewise. * headers.c (GC_scratch_alloc): Likewise. * mark.c (alloc_mark_stack): Likewise. * misc.c (GC_enable): Likewise. * os_dep.c [NEED_PROC_MAPS] (GC_get_maps): Likewise. * os_dep.c [PROC_VDB] (GC_proc_read_dirty): Likewise. * win32_threads.c (GC_delete_thread): Likewise. * allchblk.c (GC_allochblk_nth): Print KiB value instead of in bytes in WARN message. * alloc.c (GC_expand_hp_inner): Likewise. * misc.c (GC_enable): Likewise. * alloc.c (GC_expand_hp_inner): Remove unneeded cast of bytes to word. * headers.c (GC_scratch_alloc): Likewise. * alloc.c [(!AMIGA || !GC_AMIGA_FASTALLOC) && USE_MUNMAP] (GC_collect_or_expand): Add assertion to indicate that there is no underflow in GC_heapsize-GC_unmapped_bytes. * include/private/gc_priv.h (WARN): Update comment. * include/private/gc_priv.h [!WARN_PRIdPTR] (WARN_PRIuPTR): Define.
* Workaround 'returning pointer to local variable base' cppcheck FP in miscIvan Maidanski2022-10-201-1/+1
| | | | | * misc.c (GC_call_with_stack_base): Change fn(&base,arg) to (*fn)(&base,arg).
* Fix missing lock while updating GC_in_thread_creation in GC_exit_checkIvan Maidanski2022-10-031-3/+11
| | | | | | | | (fix of commit 8e6460052) * misc.c [!DONT_USE_ATEXIT && THREADS] (GC_exit_check): Wrap each update of GC_in_thread_creation into LOCK/UNLOCK (but not GC_gcollect call); add comment.
* Include stdio.h and stdlib.h only from gc_priv.hIvan Maidanski2022-09-261-1/+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.
* Adjust naming of Win32/64 and x86/64 words in comments and documentationIvan Maidanski2022-09-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ChangeLog: Replace i386 and X86 to x86; replace x86_64 and amd64 to x64; replace "Win32 pthreads" to pthreads-win32; lower case win32s, x86, x64; replace win32 to Win32; replace "MS Windows" to Windows (in documentation and comments). * NT_MAKEFILE: Likewise. * README.md: Likewise. * configure.ac: Likewise. * cord/tests/de_win.c: Likewise. * doc/README.macros: Likewise. * doc/README.solaris2: Likewise. * doc/README.win32: Likewise. * doc/README.win64: Likewise. * doc/debugging.md: Likewise. * doc/leak.md: Likewise. * doc/overview.md: Likewise. * doc/porting.md: Likewise. * extra/msvc_dbg.c: Likewise. * finalize.c: Likewise. * include/gc/cord.h: Likewise. * include/gc/gc.h: Likewise. * include/private/gc_priv.h: Likewise. * include/private/gcconfig.h: Likewise. * include/private/pthread_stop_world.h: Likewise. * mach_dep.c: Likewise. * mark.c: Likewise. * mark_rts.c: Likewise. * misc.c: Likewise. * os_dep.c: Likewise. * tools/threadlibs.c: Likewise. * win32_threads.c: Likewise. * cord/tests/de.c (WIN32): Remove misleading comment. * misc.c (GC_enable_incremental): Change comment about win32s to TODO item.
* Use cast to void instead of the attribute to indicate unused argumentsIvan Maidanski2022-09-151-13/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * CMakeLists.txt [BORLAND] (add_compile_options): Remove "/w-par"; reorder options. * CMakeLists.txt [!BORLAND && MSVC] (add_compile_options): Remove "/wd4100"; update comment. * NT_MAKEFILE (.c.obj): Likewise. * allchblk.c [!NO_DEBUGGING || GC_ASSERTIONS] (add_hb_sz): Use UNUSED_ARG() instead of GC_ATTR_UNUSED. * allchblk.c [USE_MUNMAP] (GC_adjust_num_unmapped): Likewise. * backgraph.c [MAKE_BACK_GRAPH] (pop_in_progress, reset_back_edge, update_max_height): Likewise. * checksums.c [CHECKSUMS] (GC_add_block): Likewise. * darwin_stop_world.c (GC_stack_range_for): Likewise. * dbg_mlc.c (GC_store_debug_info_inner, GC_debug_change_stubborn, GC_check_heap_block): Likewise. * finalize.c [!GC_NO_FINALIZATION] (GC_null_finalize_mark_proc): Likewise. * gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcj_fake_mark_proc): Likewise. * mallocx.c [!CPPCHECK] (GC_change_stubborn): Likewise. * mark.c (GC_noop6, clear_marks_for_block): Likewise. * mark.c [WRAP_MARK_SOME && (MSWIN32 || MSWINCE) && __GNUC__] (mark_ex_handler): Likewise. * mark.c [GC_DISABLE_INCREMENTAL] (GC_push_conditional): Likewise. * mark_rts.c (GC_push_current_stack, GC_push_roots): Likewise. * misc.c (GC_default_oom_fn, GC_set_handle_fork): Likewise. * misc.c [THREADS && !SIGNAL_BASED_STOP_WORLD] (GC_set_suspend_signal, GC_set_thr_restart_signal): Likewise. * misc.c [THREADS && UNIX_LIKE && !NO_GETCONTEXT] (callee_saves_pushed_dummy_fn): Likewise. * misc.c [!THREADS] (GC_do_blocking_inner): Likewise. * misc.c [!PARALLEL_MARK] (GC_set_markers_count): Likewise. * os_dep.c [OPENBSD] (GC_fault_handler_openbsd): Likewise. * os_dep.c [NEED_FIND_LIMIT || WRAP_MARK_SOME && !MSWIN32 && !MSWINCE || USE_PROC_FOR_LIBRARIES && THREADS] (GC_fault_handler): Likewise. * os_dep.c [!HAVE_GET_STACK_BASE && !NEED_FIND_LIMIT] (GC_get_stack_base): Likewise. * os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise_state, catch_exception_raise_state_identity, catch_exception_raise): Likewise. * pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS && !SUSPEND_HANDLER_NO_CONTEXT] (GC_suspend_sigaction): Likewise. * pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS] (GC_suspend_handler_inner): Likewise. * pthread_support.c (GC_do_blocking_inner): Likewise. * pthread_support.c [GC_ENABLE_SUSPEND_THREAD && SIGNAL_BASED_STOP_WORLD] (GC_suspend_self_blocked): Likewise. * tests/gctest.c [!DBG_HDRS_ALL] (fail_proc1): Likewise. * tests/gctest.c [(MSWIN32 && !__MINGW32__ || MSWINCE) && !NO_WINMAIN_ENTRY] (WinMain): Likewise. * tests/gctest.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && CPPCHECK && RTEMS] (Init): Likewise. * tests/gctest.c [GC_WIN32_THREADS && !GC_PTHREADS] (thr_run_one_test): Likewise. * tests/gctest.c [MSWINCE] (thr_window): Likewise. * tests/gctest.c [GC_PTHREADS] (thr_run_one_test): Likewise. * typd_mlc.c (GC_array_mark_proc): Likewise. * win32_threads.c (GC_register_altstack, GC_do_blocking_inner): Likewise. * win32_threads.c [!GC_PTHREADS && !GC_NO_THREADS_DISCOVERY] (GC_DllMain): Likewise. * cord/cordxtra.c (CORD_ATTR_UNUSED): Remove. * include/private/gc_priv.h [!GC_ATTR_UNUSED] (GC_ATTR_UNUSED): Likewise. * cord/cordxtra.c (CORD_nul_func): Cast unused argument to void instead of using CORD_ATTR_UNUSED. * cord/cordxtra.c [!GC_NO_FINALIZATION] (CORD_lf_close_proc): Likewise. * include/private/gc_priv.h [!UNUSED_ARG] (UNUSED_ARG): Define macro.
* Add missing cast in GC_is_init_calledIvan Maidanski2022-09-141-1/+1
| | | | | | | (refactoring) * misc.c (GC_is_init_called): Cast GC_is_initialized (of GC_bool type) to int explicitly.
* Fix 'overflow in conversion from word' g++ warning in GC_initIvan Maidanski2022-09-101-1/+2
| | | | | | | * include/private/gcconfig.h [POINTER_SHIFT && !POINTER_MASK] (POINTER_MASK): Covert -1 to word type thru signed_word. * misc.c [ALIGNMENT>GC_DS_TAGS] (GC_init): Change (word)-ALIGNMENT to (~(word)ALIGNMENT)+1.
* Fix 'passing arg 1 of GC_apply_to_all_blocks from incompatible type' errorIvan Maidanski2022-08-051-1/+1
| | | | | | | | | | | | | | | | | | (fix of commit e717f1191) Issue #460 (bdwgc). * backgraph.c [MAKE_BACK_GRAPH] (per_object_helper): Add GC_CALLBACK modifier; change 2nd argument type from word to GC_word. * checksums.c [CHECKSUMS] (GC_add_block): Likewise. * dbg_mlc.c [!SHORT_DBG_HDRS] (GC_check_heap_block): Likewise. * mark.c (clear_marks_for_block): Likewise. * misc.c (block_add_size): Likewise. * reclaim.c (GC_reclaim_block, GC_print_block_descr, GC_do_enumerate_reachable_objects): Likewise. * checksums.c [CHECKSUMS] (GC_check_blocks): Remove unnecessary cast of zero to word. * include/gc/gc_mark.h (GC_apply_to_all_blocks): Add GC_ATTR_NONNULL(1).
* New API function (GC_get_hblk_size) to get HBLKSIZE valueIvan Maidanski2022-08-031-0/+5
| | | | | | | | | Issue #460 (bdwgc). * include/gc/gc_mark.h (GC_get_hblk_size): New API function (declared as const). * misc.c (GC_get_hblk_size): Implement (returns HBLKSIZE). * tests/gctest.c [GC_PTHREADS] (main): Call GC_get_hblk_size().
* Use modHBLKSZ where possibleIvan Maidanski2022-08-031-2/+2
| | | | | | | | | | | | | | | | | | | | | (refactoring) * allchblk.c (GC_remove_from_fl_at, GC_add_to_fl, GC_get_first_part): Replace v&(HBLKSIZE-1) to modHBLKSZ(v). * allchblk.c [!GC_DISABLE_INCREMENTAL] (GC_allochblk_nth): Likewise. * include/private/gc_priv.h (HBLKDISPL): Likewise. * include/private/gc_hdrs.h (MAX_JUMP): Remove spaces in HBLKSIZE-1 (to match similar expressions). * include/private/gc_priv.h (OBJ_SZ_TO_BLOCKS_CHECKED): Likewise. * misc.c (block_add_size): Likewise. * os_dep.c [!MSWIN_XBOX1 && !MSWINCE && (USE_WINALLOC || CYGWIN32)] (GC_win32_get_mem): Likewise. * include/private/gc_priv.h (HBLKMASK): Remove. * include/private/gc_priv.h (obj_link): Remove extra space in the expression. * malloc.c (GC_generic_malloc_uncollectable): Replace (word)op&(HBLKSIZE-1) to HBLKDISPL(op). * mallocx.c (GC_realloc): Replace HBLKMASK to (HBLKSIZE-1).
* Prevent (fix) parallel custom mark procs run in single-threaded clientsIvan Maidanski2022-06-011-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the collector is built with parallel marker support then marking is performed in parallel on multi-core targets. Thus, if the client provides custom mark procedures, then they could be executed in parallel. In case of a single-threaded client (developed for the older libgc version with the parallel mark support off), its custom mark procedures might not be prepared to be launched in parallel. Now, the parallel mark threads are not launched, even if available, until the client starts a (user) thread (e.g. calls pthread_create or GC_allow_register_threads) or tells the collector explicitly to start the mark threads (by calling GC_start_mark_threads). * doc/README.macros (GC_ALWAYS_MULTITHREADED): Update documentation. * doc/scale.md (Options for enhanced scalability): Likewise. * include/gc/gc.h [GC_THREADS] (GC_parallel, GC_allow_register_threads): Update comment. * include/gc/gc.h (GC_set_markers_count, GC_start_mark_threads): Likewise. * include/gc/gc_mark.h (GC_mark_proc): Likewise. * include/gc/gc_mark.h (GC_PROC_BYTES, GC_ms_entry): Move upper to be before the comment belonging to GC_mark_proc. * misc.c [THREADS && PARALLEL_MARK] (GC_init): Do not call GC_start_mark_threads_inner(). * misc.c [PARALLEL_MARK] (GC_start_mark_threads): Call GC_start_mark_threads_inner() even if THREAD_SANITIZER or no CAN_HANDLE_FORK. * misc.c [THREADS] (GC_get_parallel): Remove comment. * pthread_support.c [PARALLEL_MARK && !CAN_HANDLE_FORK] (available_markers_m1): Define as a variable. * win32_threads.c [PARALLEL_MARK && !CAN_HANDLE_FORK] (available_markers_m1): Likewise. * pthread_support.c [PARALLEL_MARK && !CAN_HANDLE_FORK] (GC_wait_for_gc_completion): Declare. * pthread_support.c [PARALLEL_MARK && !CAN_HANDLE_FORK] (GC_start_mark_threads_inner): If GC_parallel then return; call GC_wait_for_gc_completion(); set GC_markers_m1 value from available_markers_m1. * win32_threads.c [PARALLEL_MARK && (!GC_PTHREADS_PARAMARK || !CAN_HANDLE_FORK)] (GC_start_mark_threads_inner): Likewise. * pthread_support.c [CAN_HANDLE_FORK && PARALLEL_MARK && THREAD_SANITIZER] (fork_child_proc): Set available_markers_m1 to 0. * pthread_support.c [CAN_HANDLE_FORK]: Move GC_remove_all_threads_but_me() call to be after setting available_markers_m1. * pthread_support.c (GC_allow_register_threads): Call GC_start_mark_threads(). * tests/middle.c (main): Likewise. * win32_threads.c (GC_allow_register_threads): Likewise. * pthread_support.c [PARALLEL_MARK] (pthread_create): Call GC_start_mark_threads() unless GC_parallel or available_markers_m1<=0. * win32_threads.c (START_MARK_THREADS): Define macro (to call GC_start_mark_threads() if PARALLEL_MARK). * win32_threads.c (GC_CreateThread): Call START_MARK_THREADS() (right before set_need_to_lock). * win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1 && !NO_CRT] (GC_beginthreadex): Likewise. * win32_threads.c [GC_PTHREADS] (GC_pthread_create): Likewise.
* Call GC_init_parallel only from GC_initIvan Maidanski2022-05-311-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * darwin_stop_world.c [!GC_NO_THREADS_DISCOVERY && !DARWIN_DONT_PARSE_STACK] (GC_use_threads_discovery): Call GC_init() instead of GC_init_parallel(). * pthread_support.c (pthread_create): Likewise. * win32_threads.c [!GC_NO_THREADS_DISCOVERY] (GC_use_threads_discovery): Likewise. * win32_threads.c (GC_CreateThread): Likewise. * win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1 && !NO_CRT] (GC_beginthreadex): Likewise. * win32_threads.c [GC_PTHREADS] (GC_pthread_create): Likewise. * include/private/gc_priv.h [THREADS] (GC_init, GC_init_parallel): Add comment. * misc.c (GC_init): Replace GC_PTHREADS||GC_WIN32_THREADS with THREADS. * misc.c [THREADS] (GC_init): Call GC_init_parallel() even if no parallel marker support or thread-local allocations; update comment. * pthread_support.c (parallel_initialized): Remove. * win32_threads.c (parallel_initialized): Likewise. * pthread_support.c (GC_init_parallel): Update comment; do not use parallel_initialized; do not call GC_init(); * win32_threads.c (GC_init_parallel): Likewise. * pthread_support.c [THREAD_LOCAL_ALLOC] (GC_init_parallel): Declare and use me local variable. * pthread_support.c [THREAD_LOCAL_ALLOC] (GC_init_parallel): Remove assertion that the GC lock is not hold; add assertion that GC_is_initialized is set. * win32_threads.c [THREAD_LOCAL_ALLOC] (GC_init_parallel): Likewise. * pthread_support.c [THREAD_LOCAL_ALLOC] (GC_register_my_thread, GC_start_rtn_prepare_thread): Remove redundant parentheses in GC_init_thread_local() argument. * win32_threads.c [THREAD_LOCAL_ALLOC] (GC_register_my_thread): Likewise. * win32_threads.c [!GC_NO_THREADS_DISCOVERY] (GC_use_threads_discovery): Check GC_is_initialized value instead of parallel_initialized one. * win32_threads.c (GC_CreateThread): Likewise. * win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1 && !NO_CRT] (GC_beginthreadex): Likewise. * win32_threads.c [GC_PTHREADS] (GC_pthread_create): Likewise. * win32_threads.c [!GC_PTHREADS && !GC_NO_THREADS_DISCOVERY] (GC_DllMain): Likewise. * win32_threads.c [THREAD_LOCAL_ALLOC] (GC_register_my_thread_inner): Add comment. * win32_threads.c [!GC_ALWAYS_MULTITHREADED && !PARALLEL_MARK && !GC_NO_THREADS_DISCOVERY] (GC_allow_register_threads): Do not set parallel_initialized. * win32_threads.c (GC_init_parallel): Call set_need_to_lock() after GC_init_thread_local().
* Fix comment in GC_init regarding GC_init_parallel callIvan Maidanski2022-05-301-3/+2
| | | | | | | | | (fix of commits ffa0c9ea3) * misc.c [PARALLEL_MARK || THREAD_LOCAL_ALLOC || GC_ALWAYS_MULTITHREADED && GC_WIN32_THREADS && !GC_NO_THREADS_DISCOVERY] (GC_init): Fix comment describing GC_init_parallel() call.
* 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.
* Eliminate 'possible loss of data' compiler warning in GC_envfile_getenvIvan Maidanski2022-05-251-1/+2
| | | | | | | (fix of commit 176d5bda1) * misc.c [GC_READ_ENV_FILE] (GC_envfile_getenv): Change type of namelen from unsigned to size_t.
* Define GC_get_parallel and GC_set_markers_count in single-threaded GCIvan Maidanski2022-05-201-3/+14
| | | | | | | | | | | | | | | | | | These are no-op definitions in case of the collector is built as a single-threaded one. This is useful for single threaded clients to be able to call these functions regardless of the collector is multi-threaded or not. * include/gc/gc.h [GC_THREADS] (GC_parallel): Reformat comment. * include/gc/gc.h (GC_get_parallel, GC_set_markers_count): Declare unconditionally. * misc.c [!PARALLEL_MARK] (GC_set_markers_count): Define (as no-op). * misc.c [!THREADS] (GC_get_parallel): Define (return 0). * pthread_support.c (GC_set_markers_count): Define only if PARALLEL_MARK; remove GC_ATTR_UNUSED. * win32_threads.c (GC_set_markers_count): Likewise. * tests/initfromthread.c (main): Call GC_get_suspend_signal() instead of GC_get_parallel().
* Allow to start marker threads in child of single-threaded clientIvan Maidanski2022-05-201-5/+3
| | | | | | | | | | | | Now GC_start_mark_threads() is present even if the collector is single-threaded (the function does nothing in this case). * include/gc/gc.h (GC_start_mark_threads): Declare unconditionally (i.e. even w/o GC_THREADS). * misc.c (GC_start_mark_threads): Define unconditionally (no-op in case of GC_THREADS is not defined). * tests/gctest.c [!NO_TEST_HANDLE_FORK && !GC_THREADS] (run_one_test): Call GC_start_mark_threads().
* Fix potential race if start_mark_threads called from threads in childIvan Maidanski2022-05-191-6/+3
| | | | | | | | | | | | | | | | | | | | | | There should be no race in setting GC_markers_m1 value even in case of a client calls GC_start_mark_threads() from multiple threads in a child process. * include/gc/gc.h (GC_start_mark_threads): Add comment that the allocation lock is acquired internally. * mark.c [PARALLEL_MARK] (GC_wait_for_markers_init): Change assertion from I_DONT_HOLD_LOCK to I_HOLD_LOCK. * pthread_support.c [PARALLEL_MARK] (GC_start_mark_threads_inner): Likewise. * win32_threads.c [PARALLEL_MARK] (GC_start_mark_threads_inner): Likewise. * mark.c [PARALLEL_MARK] (GC_wait_for_markers_init): Remove LOCK/UNLOCK around GC_add_to_our_memory() call. * misc.c [PARALLEL_MARK && GC_ASSERTIONS && GC_ALWAYS_MULTITHREADED] (GC_init): Remove UNLOCK/LOCK around GC_start_mark_threads_inner call. * misc.c [THREADS && PARALLEL_MARK && CAN_HANDLE_FORK && !THREAD_SANITIZER] (GC_start_mark_threads): Wrap GC_start_mark_threads_inner() call into LOCK/UNLOCK.
* Ensure GC_our_memory is updated while holding GC lockIvan Maidanski2022-05-191-4/+6
| | | | | | | | | | | | | | | | | | (refactoring) * alloc.c [USE_PROC_FOR_LIBRARIES] (GC_add_to_our_memory): Add assertion that the GC lock is held. * backgraph.c (new_back_edges): Likewise. * misc.c [GC_READ_ENV_FILE] (GC_envfile_init): Likewise. * mark.c [PARALLEL_MARK] (GC_wait_for_markers_init): Add assertion that the GC lock is not hold on entrance; wrap GC_add_to_our_memory() call into LOCK/UNLOCK. * mark.c [PARALLEL_MARK] (GC_do_parallel_mark): Move assertion about the GC lock to be the first statement. * misc.c [GC_ASSERTIONS && GC_ALWAYS_MULTITHREADED] (GC_init): Move the first call of LOCK() upper to be before GC_envfile_init(). * misc.c [LINT2] (GC_init): Set GC_dont_gc directly (instead of GC_disable() call) if GC_ASSERTIONS and GC_ALWAYS_MULTITHREADED.
* Fix I_HOLD_LOCK assertion violation in GC_exclude_static_roots_innerIvan Maidanski2022-05-121-3/+3
| | | | | | | | (fix of commit 8f72b3545) * misc.c [GC_ASSERTIONS && GC_ALWAYS_MULTITHREADED] (GC_init): Move first LOCK() upper to be before the first call of GC_exclude_static_roots_inner().
* 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-18/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* Define and use SIGNAL_BASED_STOP_WORLD macro internallyIvan Maidanski2022-03-271-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * include/private/gc_priv.h [!SIG_SUSPEND]: Check SIGNAL_BASED_STOP_WORLD macro instead of GC_PTHREADS, GC_WIN32_THREADS, NACL, GC_DARWIN_THREADS, GC_OPENBSD_UTHREADS, SN_TARGET_PSP2. * include/private/gcconfig.h [E2K || HP_PA || IA64 || M68K || NO_SA_SIGACTION] (SUSPEND_HANDLER_NO_CONTEXT): Likewise. * include/private/pthread_stop_world.h (thread_stop_info.last_stop_count): Likewise. * include/private/pthread_stop_world.h [GC_ENABLE_SUSPEND_THREAD] (suspend_self_inner): Likewise. * include/private/pthread_support.h [GC_ENABLE_SUSPEND_THREAD] (GC_Thread_Rep.suspended_ext): Likewise. * misc.c [THREADS] (GC_set_suspend_signal, GC_set_thr_restart_signal, GC_get_suspend_signal, GC_get_thr_restart_signal): Likewise. * os_dep.c [MPROTECT_VDB && !DARWIN && !MSWIN32 && !MSWINCE] (GC_dirty_init): Likewise. * pthread_support.c [PARALLEL_MARK && !NO_MARKER_SPECIAL_SIGMASK] (GC_start_mark_threads_inner): Likewise. * pthread_support.c [BASE_ATOMIC_OPS_EMULATED] (GC_thr_init): Likewise. * pthread_support.c [GC_ENABLE_SUSPEND_THREAD] (GC_register_my_thread): Likewise. * tests/gctest.c [GC_PTHREADS && GC_ENABLE_SUSPEND_THREAD && !GC_OSF1_THREADS] (fork_a_thread): Likewise. * include/private/gcconfig.h [GC_PTHREADS && !GC_DARWIN_THREADS && !GC_WIN32_THREADS && !PLATFORM_STOP_WORLD && !SN_TARGET_PSP2] (PTHREAD_STOP_WORLD_IMPL): Define. * include/private/gcconfig.h [PTHREAD_STOP_WORLD_IMPL && !NACL && !GC_OPENBSD_UTHREADS] (SIGNAL_BASED_STOP_WORLD): Likewise. * include/private/pthread_support.h [!GC_DARWIN_THREADS]: Include pthread_stop_world.h only if PTHREAD_STOP_WORLD_IMPL. * pthread_stop_world.c: Check PTHREAD_STOP_WORLD_IMPL macro instead of GC_PTHREADS, GC_WIN32_THREADS, GC_DARWIN_THREADS, PLATFORM_STOP_WORLD, SN_TARGET_PSP2.
* Update next_random_no state using AO primitiveIvan Maidanski2022-03-201-3/+9
| | | | | | | | | | * misc.c [THREADS] (next_random_no): Remove GC_ATTR_NO_SANITIZE_THREAD. * misc.c [THREADS && AO_HAVE_fetch_and_add1] (next_random_no): Define random_no static variable as volatile AO_t; use AO_fetch_and_add1() to update random_no. * misc.c [THREADS && !AO_HAVE_fetch_and_add1] (next_random_no): Replace pre-increment of random_no to post-increment (to match that of AO_HAVE_fetch_and_add1 variant).
* Output finalization information by GC_dumpIvan Maidanski2022-03-161-2/+5
| | | | | | | | | | * misc.c [!NO_DEBUGGING] (GC_dump_named): Print a new line first (before "***GC Dump"). * misc.c [!NO_DEBUGGING && !GC_NO_FINALIZATION] (GC_dump_named): Call GC_dump_finalization(). * tests/gctest.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && CPPCHECK && !GC_NO_FINALIZATION && !NO_DEBUGGING] (main): Remove UNTESTED(GC_dump_finalization).
* Do not probe to find main data root start if dl_iterate_phdr existsIvan Maidanski2022-03-101-3/+6
| | | | | | | | | | | | Issue #432 (bdwgc). This avoids invocation of GC_find_limit to get GC_data_start value in case of GC_register_data_segments is not called. * misc.c [SEARCH_FOR_DATA_START] (GC_init): Call GC_init_linux_data_start() only if GC_REGISTER_MAIN_STATIC_DATA(); move GC_init_linux_data_start() call down (to be close but precede GC_dirty_init call); add comment.
* Replace GC_init_netbsd_elf with GC_init_linux_data_start on NetBSDIvan Maidanski2022-03-101-4/+1
| | | | | | | | | | | | | | | | | | | | | (refactoring) * include/private/gc_priv.h [NETBSD && __ELF__] (GC_init_netbsd_elf, GC_find_limit): Do not declare. * include/private/gcconfig.h [NETBSD && __ELF__] (GC_data_start): Likewise. * include/private/gcconfig.h [NETBSD && __ELF__] (DATASTART): Do not define. * include/private/gcconfig.h [NETBSD && __ELF__] (SEARCH_FOR_DATA_START): Define. * misc.c [NETBSD && __ELF__] (GC_init): Do not call GC_init_netbsd_elf. * os_dep.c [NETBSD] (environ): Declare C extern variable only if SEARCH_FOR_DATA_START (regardless of __ELF__). * os_dep.c [SEARCH_FOR_DATA_START && NETBSD] (GC_init_linux_data_start): Pass &environ to GC_find_limit (as in deleted GC_init_netbsd_elf) instead of data_end. * os_dep.c [NETBSD && __ELF__] (GC_data_start, GC_init_netbsd_elf): Do not define.
* Change minimum heap growth to one block if requested explicitlyIvan Maidanski2022-03-021-3/+2
| | | | | | | | | | | | | | | | | | | | Previously GC_expand_hp caused heap growth by MINHINCR*HBLKSIZE bytes or more, now the minimum growth is HBLKSIZE. Also, add minimal testing of GC_expand_hp(). * alloc.c (GC_expand_hp_inner): Update comment; if n is less 1 then set it to 1 (unlike comparing and setting to MINHINCR). * alloc.c (GC_collect_or_expand): Ensure the computed blocks_to_get value is not less than MINHINCR (before comparing blocks_to_get to max_get_blocks). * misc.c (GC_init): Do not warn for initial_heap_sz values (obtained from "GC_INITIAL_HEAP_SIZE" environment variable) smaller than MINHINCR*HBLKSIZE. * tests/gctest.c (run_single_threaded_test): Call GC_expand_hp(0) before GC_enable. * tests/gctest.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && CPPCHECK] (main): Remove UNTESTED(GC_expand_hp).
* Really ignore bad GC_INITIAL/MAXIMUM_HEAP_SIZE valuesIvan Maidanski2022-03-021-5/+8
| | | | | | | * misc.c (GC_init): Do not modify initial_heap_sz value if WARN() about the value is called; do not modify GC_max_retries value and do not call GC_set_max_heap_size() if WARN() is called about max_heap_sz value.
* Allow to skip heap expansion in GC_initIvan Maidanski2022-02-281-32/+32
| | | | | | | | | | | Now, if GC_INITIAL_HEAP_SIZE macro or environment variable is set to zero, then GC_init does not call GC_expand_hp_inner. * misc.c (GC_parse_mem_size_arg): Return -1 (GC_WORD_MAX) in case of a bad input string; reformat code. * misc.c (GC_init): Do not WARN if GC_INITIAL_HEAP_SIZE environment variable is 0 or the value is equal to MINHINCR * HBLKSIZE; do not call GC_expand_hp_inner() if initial_heap_sz is 0.
* Warn if heap has grown while GC was disabledIvan Maidanski2022-02-231-0/+5
| | | | | | | | | | | | * alloc.c (GC_expand_hp): Increment GC_heapsize_on_gc_disable by the corresponding size if GC disabled and the heap is expanded. * include/private/gc_priv.h (GC_arrays._heapsize_on_gc_disable): Declare field. * misc.c (GC_enable): Call WARN with the appropriate message if going from GC disabled to enabled mode and the heap size is greater than GC_heapsize_on_gc_disable. * misc.c (GC_disable): Store the current heap size value to GC_heapsize_on_gc_disable if going from GC enabled to disabled mode.
* Add I_HOLD_LOCK assertion to scratch_alloc/recycle and their callersIvan Maidanski2022-01-171-9/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* Declare GC_register_stackbottom symbol as internal (IA64)Ivan Maidanski2022-01-121-2/+2
| | | | | | | | | | | (refactoring) * include/private/gc_priv.h [IA64] (GC_register_stackbottom): Declare variable (as GC_EXTERN). * include/private/gcconfig.h [IA64 && (HPUX || LINUX)] (GC_register_stackbottom): Do not declare. * misc.c [IA64] (GC_register_stackbottom): Define as GC_INNER. * misc.c [IA64] (GC_call_with_stack_base): Outline TODO item.
* Support Elbrus 2000 (Linux/e2k)Ilya Kurdyukov2022-01-121-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (a port of altlinux libgc-e2k.patch (8ed786c)) Issue #411 (bdwgc). * include/gc/gc.h [__GNUC__ && !__INTEL_COMPILER && __e2k__] (GC_reachable_here): Specify "r" contraint for ptr. * include/gc/gc.h [__e2k__] (GC_stack_base): Declare reg_base field. * include/private/gc_priv.h [E2K] (GC_push_all_register_sections, GC_save_regs_in_stack, GC_get_procedure_stack): Declare. * include/private/gc_priv.h [E2K && __ptr64__] (LOAD_TAGGED_VALUE): Define macro. * include/private/gc_priv.h (LOAD_WORD_OR_CONTINUE): Likewise. * include/private/gcconfig.h [LINUX && __e2k__] (E2K, mach_type_known): Likewise. * include/private/gcconfig.h [E2K] (MACH_TYPE, CPP_WORDSZ, ALIGNMENT, HBLKSIZE): Likewise. * include/private/gcconfig.h [E2K && LINUX] (DATASTART): Likewise. * mach_dep.c [E2K] (VA_SIZE, E2K_PSHTP_SIZE, get_stack_index): Likewise. * include/private/gcconfig.h [GC_GNUC_PREREQ(2,8)] (HAVE_BUILTIN_UNWIND_INIT): Do not define if E2K. * include/private/gcconfig.h [E2K && LINUX] (__dso_handle): Declare extern variable. * include/private/pthread_support.h [E2K] (GC_Thread_Rep): Declare backing_store_end and backing_store_ptr fields. * mach_dep.c [E2K]: Include errno.h, sys/syscall.h, asm/e2k_syswork.h. * mach_dep.c [E2K] (e2k_rwap_lo_fields, e2k_rwap_hi_fields): Declare struct. * mach_dep.c [E2K] (e2k_rwap_lo_u, e2k_rwap_hi_u): Declare union. * mach_dep.c [E2K] (GC_get_procedure_stack, GC_save_regs_in_stack): Implement. * mach_dep.c [E2K] (GC_with_callee_saves_pushed): Call GC_save_regs_in_stack() (not saving the result). * mark.c (GC_mark_from, GC_push_all_eager): Use LOAD_WORD_OR_CONTINUE() instead of direct dereference of current_p. * mark.c [!SMALL_CONFIG] (GC_mark_from): Do not prefetch if E2K. * mark_rts.c [E2K] (GC_push_all_register_sections): Implement but ignore traced_stack_sect (add TODO item). * mark_rts.c [!THREADS && E2K] (GC_push_current_stack): Call GC_get_procedure_stack() and GC_push_all_register_sections(). * misc.c [E2K] (GC_call_with_stack_base): Initialize reg_base to 0. * misc.c [!THREADS && E2K] (GC_do_blocking_inner, GC_get_my_stackbottom): Likewise. * os_dep.c [((HAVE_PTHREAD_ATTR_GET_NP || HAVE_PTHREAD_GETATTR_NP) && THREADS || !HAVE_GET_STACK_BASE) && E2K] (GC_get_stack_base): Likewise. * pthread_support.c [E2K] (GC_get_my_stackbottom): Likewise. * pthread_stop_world.c [E2K] (GC_suspend_handler): Call GC_with_callee_saves_pushed(). * pthread_stop_world.c [E2K] (GC_store_stack_ptr): Call GC_save_regs_in_stack() and GC_get_procedure_stack(). * pthread_stop_world.c [E2K] (GC_suspend_handler_inner): Call free(me->backing_store_end) before return. * pthread_stop_world.c [E2K] (GC_push_all_stacks): Declare bs_lo, bs_hi, stack_size local variables; call GC_save_regs_in_stack() and GC_get_procedure_stack() (and free() at the end) for self thread; call GC_push_all_register_sections(). * pthread_support.c [E2K] (GC_do_blocking_inner): Call GC_save_regs_in_stack(); add FIXME.
* Fix lock assertion violation in GC_find_limit if always multi-threadedIvan Maidanski2021-12-051-0/+8
| | | | | | | | | Issue #399 (bdwgc). * misc.c [GC_ASSERTIONS && GC_ALWAYS_MULTITHREADED && (SEARCH_FOR_DATA_START || NETBSD)] (GC_init): Wrap GC_init_linux_data_start() and GC_init_netbsd_elf() calls into LOCK/UNLOCK.
* Fix missing write() declaration if CONSOLE_LOG (Watcom)Ivan Maidanski2021-12-051-1/+1
| | | | | * misc.c [CONSOLE_LOG && MSWIN32]: Include io.h unless __GNUC__ (regardless of _MSC_VER).
* Fix GC_allocate_ml incorrect cleanup in GC_deinit if pthreads (MinGW)Ivan Maidanski2021-12-031-1/+3
| | | | | | | | | (fix of commit 72ba00903) Issue #397 (bdwgc). * misc.c [GC_WIN32_THREADS && (MSWIN32 || MSWINCE)] (GC_deinit): Do not call DeleteCriticalSection(&GC_allocate_ml) if GC_PTHREADS.
* Declare API function and print amount of memory obtained from OSIvan Maidanski2021-09-221-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | Public GC_get_obtained_from_os_bytes() is introduced. * alloc.c [USE_MUNMAP] (GC_stopped_mark): Add assertion that GC_heapsize is not less than GC_unmapped_bytes. * alloc.c (GC_stopped_mark): Add assertion that GC_our_mem_bytes is not less than GC_heapsize; print GC_our_mem_bytes-GC_heapsize value (using GC_DBGLOG_PRINTF). * alloc.c [USE_PROC_FOR_LIBRARIES] (GC_add_to_our_memory): Update comment; increment GC_our_mem_bytes value (by bytes). * include/private/gc_priv.h (GC_add_to_our_memory): Likewise. * include/gc.h (GC_get_obtained_from_os_bytes): New API function declaration. * include/gc.h (GC_prof_stats_s.obtained_from_os_bytes): Declare new field. * include/private/gc_priv.h (_GC_arrays._our_mem_bytes): Likewise. * misc.c (GC_get_obtained_from_os_bytes): Implement. * misc.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (fill_prof_stats): Set obtained_from_os_bytes field. * tests/test.c (check_heap_stats): Print value returned by GC_get_obtained_from_os_bytes(). * tests/test.c [USE_MUNMAP] (check_heap_stats): Print value returned by GC_get_unmapped_bytes().
* Call add_to_our_memory in envfile_initIvan Maidanski2021-09-221-2/+8
| | | | | | | | | (refactoring) * misc.c [GC_READ_ENV_FILE && (MSWIN32 || MSWINCE || CYGWIN32)] (GC_envfile_init): Declare and use bytes_to_get local variable; call GC_add_to_our_memory() for content if non-null; add TODO item about recycling of content area if read operation failed.
* Remove misleading comment for GC_atfork_prepare in misc.cIvan Maidanski2021-09-181-2/+0
| | | | | * misc.c [!CAN_HANDLE_FORK && !HAVE_NO_FORK] (GC_atfork_prepare): Remove comment.