summaryrefslogtreecommitdiff
path: root/tests/test.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'master' into add-long-weakrefadd-long-weakrefIvan Maidanski2012-12-091-14/+43
|\ | | | | | | | | Conflicts: finalize.c
| * Fix GC_CreateThread 'dwStackSize' argument type for Win64Ivan Maidanski2012-11-251-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | * include/gc.h (GC_uintptr_t): Define (for Win32/CE) even if GC_NO_THREAD_DECLS; move definition upper than GC_CreateThread. * include/gc.h (GC_WIN32_SIZE_T): New macro (defined as GC_uintptr_t, Win32 threads only). * include/gc.h (GC_CreateThread): Use GC_WIN32_SIZE_T instead of DWORD type for "dwStackSize" argument (Win32 threads only). * win32_threads.c (GC_CreateThread): Likewise. * tests/test.c (fork_a_thread): Verify types of GC_CreateThread arguments by explicit casts (only if GC_WIN32_THREADS).
| * Add manual POSIX fork handling support (Android)Ivan Maidanski2012-11-211-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * include/gc.h (GC_set_handle_fork): Update comment. * include/gc.h (GC_atfork_prepare, GC_atfork_parent, GC_atfork_child): New API proto. * include/private/gc_priv.h (GC_handle_fork): Change type from GC_bool to int (to hold a value of -1). * misc.c (GC_handle_fork): Likewise. * include/private/gc_priv.h (GC_handle_fork): Add comment. * misc.c (GC_set_handle_fork): Likewise. * include/private/gcconfig.h (CAN_HANDLE_FORK): Define also for HURD and PLATFORM_ANDROID; do not define if HAVE_NO_FORK already defined. * include/private/gcconfig.h (CAN_CALL_ATFORK): New macro (defined if CAN_HANDLE_FORK but not HURD or PLATFORM_ANDROID). * include/private/gcconfig.h (HAVE_NO_FORK): New macro (defined for Win32, OS/2 and others). * misc.c (GC_atfork_prepare, GC_atfork_parent, GC_atfork_child): New API function definition (only if not CAN_HANDLE_FORK and not HAVE_NO_FORK). * misc.c (GC_handle_fork): Map all negative values of argument except for -1 to a positive one stored to GC_handle_fork; call GC_init to initialize GC_stderr before ABORT invocation (only if not SMALL_CONFIG). * pthread_support.c (GC_atfork_prepare, GC_atfork_parent, GC_atfork_child): New API function definition (only if CAN_HANDLE_FORK). * win32_threads.c (GC_atfork_prepare, GC_atfork_parent, GC_atfork_child): Likewise. * pthread_support.c (GC_thr_init): No pthread_atfork call if not CAN_CALL_ATFORK; adjust GC_handle_fork value if pthread_atfork succeeds; do not about in case of pthread_atfork failure provided GC_handle_fork is -1 (only if CAN_HANDLE_FORK). * win32_threads.c (GC_thr_init): Likewise. * tests/test.c (TEST_FORK_WITHOUT_ATFORK): Recognize new macro (do not define NO_TEST_HANDLE_FORK in this case and set INIT_FORK_SUPPORT to no-op). * tests/test.c (INIT_FORK_SUPPORT): Define to GC_set_handle_fork(-1) unless HANDLE_FORK, or NO_TEST_HANDLE_FORK or TEST_FORK_WITHOUT_ATFORK. * tests/test.c (run_one_test): Surround fork() invocation with GC_atfork_prepare, GC_atfork_parent, GC_atfork_child calls. * win32_threads.c: Include unistd.h if CAN_CALL_ATFORK defined (instead of CAN_HANDLE_FORK) to get pthread_atfork prototype.
| * Improve fork test logging in gctestIvan Maidanski2012-11-201-18/+24
| | | | | | | | | | | | | | * tests/test.c (run_one_test): Move fork testing block upper (so that other tests run in parallel in parent process). * tests/test.c (run_one_test): Log "fork performed" and "child started" events (only if not NO_TEST_HANDLE_FORK).
| * Add public GC_start_mark_threads() to allow parallel marker in fork childIvan Maidanski2012-11-191-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * include/gc.h (GC_start_mark_threads): New API function prototype. * misc.c (GC_start_mark_threads): New API function definition (empty) if THREADS but not PARALLEL_MARK or not CAN_HANDLE_FORK. * pthread_support.c (available_markers_m1): New static variable or macro (redirecting to GC_markers_m1) depending on CAN_HANDLE_FORK (only if PARALLEL_MARK). * win32_threads.c (available_markers_m1): Likewise. * pthread_support.c (start_mark_threads): Redirect to GC_start_mark_threads (and decorate with GC_API/GC_CALL) if CAN_HANDLE_FORK (and PARALLEL_MARK); skip start if parallel markers are disabled or already started if CAN_HANDLE_FORK; iterate up to available_markers_m1 (instead of GC_markers_m1); always set GC_markers_m1 value. * win32_threads.c (start_mark_threads): Likewise. * pthread_support.c (GC_thr_init): Set (and test) available_markers_m1 value instead of GC_markers_m1/GC_parallel (only if PARALLEL_MARK). * win32_threads.c (GC_thr_init): Likewise. * tests/test.c (NO_TEST_HANDLE_FORK): Do not define if TEST_HANDLE_FORK. * tests/test.c (run_one_test): Invoke GC_start_mark_threads (and additional GC_gcollect) in forked child (only if THREADS but not NO_TEST_HANDLE_FORK); do not call tiny_reverse_test if not THREADS. * win32_threads.c (start_mark_threads): Add assertion that the caller is not holding the allocation lock (to match that in pthread_support.c) if GC_PTHREADS_PARAMARK.
* | Add tests for GC_register/move/unregister_long_linkIvan Maidanski2012-12-091-0/+49
|/ | | | | | | | | | | | * tests/test.c (live_long_refs): New global variable (only if not GC_LONG_REFS_NOT_NEEDED and not MACOS). * tests/test.c (mktree): Test GC_REGISTER_LONG_LINK, GC_move_long_link, GC_unregister_long_link (using live_long_refs) unless GC_LONG_REFS_NOT_NEEDED. * tests/test.c (check_heap_stats): Define "still_long_live" local variable, count non-null elements of live_long_refs, print number of non-null elements of live_long_refs (if any) unless GC_LONG_REFS_NOT_NEEDED.
* Add 'bytes reclaimed' counters to public GC_prof_stats_sIvan Maidanski2012-11-071-0/+13
| | | | | | | | | | | | | | | | | * alloc.c (GC_finish_collection): Add GC_bytes_found value to GC_reclaimed_bytes_before_gc (if the former is non-negative and not GC_GET_HEAP_USAGE_NOT_NEEDED) before reseting GC_bytes_found. * include/gc.h (GC_prof_stats_s): Add bytes_reclaimed_since_gc and reclaimed_bytes_before_gc fields. * include/private/gc_priv.h (GC_reclaimed_bytes_before_gc): Declare new GC inner variable (only if not GC_GET_HEAP_USAGE_NOT_NEEDED). * misc.c (GC_reclaimed_bytes_before_gc): Define new variable (only if not GC_GET_HEAP_USAGE_NOT_NEEDED). * misc.c (fill_prof_stats): Fill in bytes_reclaimed_since_gc and reclaimed_bytes_before_gc fields. * tests/test.c (check_heap_stats): Invoke GC_get_heap_usage_safe, GC_get_prof_stats, GC_get_prof_stats_unsafe (only if not GC_GET_HEAP_USAGE_NOT_NEEDED).
* Specify GC_malloc result is unused in some testsIvan Maidanski2012-10-191-3/+3
| | | | | | * tests/middle.c (main): Explicitly cast result of GC_malloc[_atomic] to void (to outline that the result is unused intentionally). * tests/test.c (run_one_test): Likewise.
* Remove dummy GC_noop call from code visible to Lint tool onlyIvan Maidanski2012-09-091-15/+0
| | | | | | | (Minor code refactoring.) * misc.c (GC_init): Remove dummy GC_noop call from Lint-only code. * tests/test.c (main): Likewise.
* Include "config.h" instead of "private/config.h" on HAVE_CONFIG_HIvan Maidanski2012-08-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | (Change the behavior of HAVE_CONFIG_H macro to the standard one which assumes that no folder is specified in #include "config.h".) * configure.ac (AM_CONFIG_HEADER): Replace include/private/config.h to include/config.h. * cord/cordbscs.c: Include "config.h" (instead of "private/config.h") if HAVE_CONFIG_H defined. * cord/cordprnt.c: Likewise. * cord/cordxtra.c: Likewise. * gc_cpp.cc: Likewise. * include/private/gc_pmark.h: Likewise. * include/private/gc_priv.h: Likewise. * real_malloc.c: Likewise. * tests/disclaim_test.c: Likewise. * tests/initsecondarythread.c: Likewise. * tests/subthread_create.c: Likewise. * tests/test.c: Likewise. * tests/test_cpp.cc: Likewise. * tests/thread_leak_test.c: Likewise. * tests/threadkey_test.c: Likewise.
* Add public GC_set_handle_fork to control forked child handling supportIvan Maidanski2012-04-021-8/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * include/gc.h (GC_set_handle_fork): New API function. * misc.c (GC_set_handle_fork): Likewise. * include/private/gc_priv.h (GC_handle_fork): New internal variable declaration (only if CAN_HANDLE_FORK). * misc.c (GC_handle_fork): New internal variable (defined only if CAN_HANDLE_FORK); initialize to TRUE if HANDLE_FORK. * include/private/gcconfig.h (HANDLE_FORK): Replace with CAN_HANDLE_FORK. * pthread_support.c (HANDLE_FORK): Likewise. * win32_threads.c (HANDLE_FORK): Likewise. * include/private/gcconfig.h (CAN_HANDLE_FORK): Always define macro if HANDLE_FORK. * pthread_support.c (GC_thr_init): Replace HANDLE_FORK with CAN_HANDLE_FORK; call pthread_atfork only if GC_handle_fork; update the comment. * win32_threads.c (GC_thr_init): Likewise. * tests/test.c (NO_TEST_HANDLE_FORK): Define new macro if fork handling is not supported (or is a no-op) on the target. * tests/test.c (INIT_FORK_SUPPORT): New macro (invoke GC_set_handle_fork unless NO_TEST_HANDLE_FORK). * tests/test.c (GC_OPT_INIT): New macro (defined to GC_INIT or empty). * tests/test.c (GC_COND_INIT): Use INIT_FORK_SUPPORT and GC_OPT_INIT. * tests/test.c (run_one_test): Test NO_TEST_HANDLE_FORK (instead of target-specific macros). * win32_threads.c (GC_remove_all_threads_but_me, GC_fork_prepare_proc, GC_fork_parent_proc, GC_fork_child_proc): Do not test GC_PTHREADS. * configure.ac (HANDLE_FORK, NO_HANDLE_FORK): Update message.
* Fix GC_ALPHA_VERSION comparison in gctest and tools filesIvan Maidanski2012-03-191-0/+4
| | | | | | | * tests/test.c (GC_ALPHA_VERSION): Define to GC_TMP_ALPHA_VERSION if not defined by gc_version.h. * tools/add_gc_prefix.c (GC_ALPHA_VERSION): Likewise. * tools/gcname.c (GC_ALPHA_VERSION): Likewise.
* Fix gctest (for Win32) to avoid GC_print_stats internal variable usageIvan Maidanski2012-03-061-16/+27
| | | | | | | | | | | | * include/private/gc_priv.h (GC_print_stats): Update the comment. * tests/test.c (GC_print_stats, run_one_test, check_heap_stats): Rename GC_print_stats to print_stats (since the former is used internally by GC and not exported). * tests/test.c (print_stats): Always define (either as a macro or a static int variable) regardless of GC_DLL and SMALL_CONFIG. * tests/test.c (INIT_PRINT_STATS): New macro (used to initialize print_stats if needed); GETENV is used if needed and available. * tests/test.c (GC_COND_INIT): Invoke INIT_PRINT_STATS.
* Replace pointer relational comparisons with non-pointer onesIvan Maidanski2012-03-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * allchblk.c (GC_dump_regions, GC_allochblk_nth): Cast pointers to word type in relational (less-greater) comparisons. * alloc.c (GC_add_to_heap, GC_print_heap_sects, GC_expand_hp_inner): Likewise. * backgraph.c (ensure_struct, add_back_edges): Likewise. * blacklst.c (GC_number_stack_black_listed): Likewise. * checksums.c (GC_checksum, GC_check_dirty): Likewise. * darwin_stop_world.c (GC_push_all_stacks): Likewise. * dbg_mlc.c (GC_get_back_ptr_info, GC_print_smashed_obj, GC_check_heap_block): Likewise. * dyn_load.c (sort_heap_sects, GC_register_map_entries, GC_register_dynlib_callback, GC_register_dynamic_libraries_dl_iterate_phdr, GC_register_dynamic_libraries, GC_cond_add_roots): Likewise. * finalize.c (GC_ignore_self_finalize_mark_proc): Likewise. * headers.c (GC_scratch_alloc, GC_install_counts, GC_remove_counts): Likewise. * include/private/gc_pmark.h (PUSH_OBJ, PUsH_CONTENTS_HDR, GC_PUSH_ONE_STACK, GC_PUSH_ONE_HEAP, GC_mark_stack_empty): Likewise. * include/private/gc_priv.h (MAKE_COOLER, COOLER_THAN): Likewise. * mach_dep.c (GC_with_callee_saves_pushed): Likewise. * malloc.c (calloc, free): Likewise. * mark.c (GC_mark_some_inner, GC_mark_from, GC_steal_mark_stack, GC_return_mark_stack, GC_do_local_mark, GC_mark_local, GC_push_all, GC_push_selected, GC_push_all_eager, GC_push_marked1, GC_push_marked2, GC_push_marked4, GC_push_marked, GC_push_unconditionally): Likewise. * mark_rts.c (GC_is_static_root, GC_add_roots_inner, GC_remove_roots_inner, GC_is_tmp_root, GC_exclude_static_roots_inner, GC_push_conditional_with_exclusions, GC_push_all_register_sections, GC_push_all_stack_sections, GC_push_all_stack_partially_eager, GC_push_all_stack_part_eager_sections, GC_push_current_stack): Likewise. * misc.c (GC_clear_stack_inner, GC_clear_stack, GC_base, GC_call_with_gc_active): Likewise. * new_hblk.c (GC_build_fl_clear2, GC_build_fl_clear4, GC_build_fl2, GC_build_fl4, GC_build_fl): Likewise. * os_dep.c (GC_enclosing_mapping, GC_text_mapping, tiny_sbrk, GC_find_limit_openbsd, GC_skip_hole_openbsd, GC_find_limit_with_bound, GC_get_main_stack_base, GC_get_stack_base, GC_least_described_address, GC_register_root_section, GC_register_data_segments, GC_unmap_start, GC_gww_read_dirty, GC_remove_protection, GC_protect_heap, GC_unprotect_range, GC_read_dirty, GC_page_was_dirty, GC_save_callers, GC_print_callers): Likewise. * pcr_interface.c (GC_enumerate_block): Likewise. * pthread_support.c (GC_is_thread_tsd_valid, GC_segment_is_thread_stack, GC_greatest_stack_base_below, GC_call_with_gc_active): Likewise. * ptr_chck.c (GC_same_obj, GC_is_valid_displacement, GC_on_stack, GC_is_visible): Likewise. * reclaim.c (GC_reclaim_clear, GC_reclaim_uninit, GC_disclaim_and_reclaim, GC_reclaim_check, GC_start_reclaim): Likewise. * tests/test.c (cons): Likewise. * tools/setjmp_t.c (main): Likewise. * typd_mlc.c (GC_typed_mark_proc): Likewise. * win32_threads.c (GC_is_thread_tsd_valid, GC_call_with_gc_active, GC_push_stack_for, GC_get_next_stack): Likewise. * extra/msvc_dbg.c (GetDescriptionFromAddress, GetDescriptionFromStack): Cast pointers to GC_ULONG_PTR in relational comparisons. * include/gc.h (GC_DATASTART, GC_DATAEND): Cast pointers to GC_word in relational comparisons. * misc.c (GC_init): Remove static assertion on ((ptr_t)-1 > 0) since no longer required; add the comment. * pcr_interface.c: Expand tabs to spaces.
* Fix fork() handling for Darwin partiallyIvan Maidanski2012-02-241-1/+5
| | | | | | | | | | | | | | (still not handled well for Darwin if GC incremental mode is on) * os_dep.c (GC_dirty_init): Add FIXME regarding fork (Darwin). * pthread_support.c (GC_remove_all_threads_but_me): Update mach_thread for "me" (Darwin). * pthread_support.c (GC_fork_prepare_proc): Output warning if GC_dirty_maintained (if DARWIN and MPROTECT_VDB). * pthread_support.c (GC_fork_prepare_proc, GC_fork_child_proc): Add FIXME (for Darwin). * tests/test.c (run_one_test): Do not test fork() for Darwin with incremental mode on (if HANDLE_FORK); add FIXME.
* Fix gctest to include unistd.h if HANDLE_FORKIvan Maidanski2012-02-211-0/+4
| | | | | * tests/test.c: Include unistd.h for fork() declaration if HANDLE_FORK (and THREADS).
* Allow to exclude finalization support by GC_NO_FINALIZATION macroIvan Maidanski2012-02-061-20/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/README.macros (GC_NO_FINALIZATION): Document. * alloc.c (GC_finish_collection): Do not call GC_finalize and GC_print_finalization_stats if GC_NO_FINALIZATION. * dbg_mlc.c (closure, GC_make_closure, GC_debug_invoke_finalizer, OFN_UNSET, store_old, GC_debug_register_finalizer, GC_debug_register_finalizer_no_order, GC_debug_register_finalizer_unreachable, GC_debug_register_finalizer_ignore_self): Do not define if GC_NO_FINALIZATION. * finalize.c: Skip all definitions if GC_NO_FINALIZATION. * finalize.c (GC_call_with_alloc_lock): Move to misc.c. * include/private/gc_priv.h (GC_INVOKE_FINALIZERS): Define to empty if GC_NO_FINALIZATION. * include/private/gc_priv.h (GC_notify_or_invoke_finalizers, GC_push_finalizer_structures, GC_finalize, GC_print_finalization_stats): Do not declare if GC_NO_FINALIZATION. * mark_rts.c (GC_push_gc_structures): Do not call GC_push_finalizer_structures if GC_NO_FINALIZATION. * misc.c (GC_call_with_alloc_lock): Move from "finalize" module. * tests/test.c (mktree): Do not declare "my_index" and "new_link" local variables, do not update live_indicators_count, do not call GC_REGISTER_FINALIZER, GC_GENERAL_REGISTER_DISAPPEARING_LINK, GC_move_disappearing_link, GC_unregister_disappearing_link if GC_NO_FINALIZATION. * tests/test.c (check_heap_stats): Do not declare "still_live", "late_finalize_count" local variables and do not check finalization for failures if GC_NO_FINALIZATION.
* gctest: Avoid use of deprecated GC_dont_gc and GC_stackbottomIvan Maidanski2012-02-011-6/+11
| | | | | | | | | * tests/test.c (GC_amiga_gctest_malloc_explicitly_typed, GC_amiga_gctest_calloc_explicitly_typed): Do not unnecessarily check GC_dont_gc value. * tests/test.c (check_heap_stats): Get stack base via GC_get_stack_base() (report error if failed) instead of accessing GC_stackbottom.
* gctest: Output marker threads count at endIvan Maidanski2012-01-281-3/+6
| | | | | | | * tests/test.c (run_one_test): Adjust printf format specifier. * tests/test.c (main): Move printf for completed collections number to check_heap_stats(). * tests/test.c (check_heap_stats): Print number of marker threads.
* Fix static data roots registration on Android (if GC is sharedIvan Maidanski2012-01-261-1/+1
| | | | | | | | | | | library) by defining GC_INIT_CONF_ROOTS * include/gc.h (GC_INIT_CONF_ROOTS): Define to register static data root in range from "__data_start" to "_end" on Android (unless explicitly prohibited by client via GC_NOT_DLL macro) since the client data root is not registered automatically if GC is build as a shared library. * tests/test.c (GC_COND_INIT): Invoke GC_INIT also on Android.
* Add 'const' qualifier to pointer argument of GC_clear/set_mark_bit,Ivan Maidanski2012-01-171-7/+5
| | | | | | | | | | | | | | | | | | | | | GC_finalized_malloc, GC_general_register_disappearing_link * dbg_mlc.c (GC_debug_change_stubborn, GC_debug_end_stubborn_change): Make argument pointer const. * finalize.c (GC_general_register_disappearing_link): Likewise. * fnlz_mlc.c (GC_core_finalized_malloc, GC_finalized_malloc): Likewise. * include/gc.h (GC_change_stubborn, GC_end_stubborn_change, GC_debug_change_stubborn, GC_debug_end_stubborn_change, GC_general_register_disappearing_link): Likewise. * include/gc_disclaim.h (GC_finalized_malloc): Likewise. * include/gc_mark.h (GC_clear_mark_bit, GC_set_mark_bit): Likewise. * mark.c (GC_set_mark_bit, GC_clear_mark_bit): Likewise. * stubborn.c (GC_end_stubborn_change, GC_change_stubborn): Likewise. * finalize.c (GC_general_register_disappearing_link): Remove redundant pointer type casts. * tests/test.c (cons, print_int_list, mktree): Likewise. * include/gc.h (GC_GENERAL_REGISTER_DISAPPEARING_LINK): Add cast removing potential 'const' qualifier.
* Improve GC_thread_is_registered implementation and testingIvan Maidanski2012-01-121-0/+6
| | | | | | | | | | | * pthread_support.c (GC_thread_is_registered): Call pthread_self outside LOCK; add DCL_LOCK_STATE declaration; replace "ptr" local variable with "GC_thread me" (and remove cast). * win32_threads.c (GC_thread_is_registered): Fix implementation by calling GC_lookup_thread_inner (now works the same as in pthread_support.c). * tests/test.c (run_one_test): Test GC_thread_is_registered (only if THREADS).
* Add 'const' qualifier for GC_make_descriptor bitmap argumentIvan Maidanski2012-01-101-1/+1
| | | | | | | | * include/gc_typed.h (GC_make_descriptor): Make bm pointer const (replace GC_bitmap type with "const GC_word*"). * typd_mlc.c (GC_add_ext_descriptor, GC_make_descriptor): Likewise. * tests/test.c (bm_huge): Make array const to test updated GC_make_descriptor declaration.
* Add GC_is_heap_ptr() to GC APIIvan Maidanski2011-12-291-0/+12
| | | | | | * include/gc.h (GC_is_heap_ptr): New API function declaration. * misc.c (GC_is_heap_ptr): New function. * tests/test.c (run_one_test): Add GC_is_heap_ptr tests.
* Resolve minor warnings in tests (reported by GCC with '-pedantic' option)Ivan Maidanski2011-11-111-11/+12
| | | | | | | * tests/disclaim_test.c (pair_dct, pair_new): Explicitly cast a pointer argument of GC_printf to void* to match %p format specifier. * tests/test.c (cons, print_int_list, run_one_test, check_heap_stats): Likewise.
* Refactor GC_move_disappearing_link() code;Ivan Maidanski2011-11-071-3/+18
| | | | | | | | | | | | | | | | | | | | | | | | | make GC_move_disappearing_link(link,link) return GC_SUCCESS * finalize.c (GC_move_disappearing_link): Rename "from", "to" arguments to "link" and "new_link", respectively. * include/gc.h (GC_move_disappearing_link): Likewise. * finalize.c (GC_move_disappearing_link): Rename "to_curr_dl", "from_index", "to_index" local variables to "new_dl", "curr_index", "new_index", respectively. * finalize.c (GC_move_disappearing_link): Add curr_hidden_link, new_hidden_link local variables to evaluate GC_HIDE_POINTER(link) and GC_HIDE_POINTER(new_link) only once. * finalize.c (GC_move_disappearing_link): Reformat code. * finalize.c (GC_move_disappearing_link): Do not ABORT in case of unaligned "link", return GC_NOT_FOUND instead (similar to GC_unregister_disappearing_link behavior). * finalize.c (GC_move_disappearing_link): If new_link is equal to link then return GC_SUCCESS instead of GC_DUPLICATE. * include/gc.h (GC_move_disappearing_link, GC_NOT_FOUND): Refine and update documentation comment. * tests/test.c (mktree): Add "new_link" local variable; add GC_move_disappearing_link invocations; apply GC_unregister_disappearing_link to "new_link".
* tests: Add missing checks of GC_malloc result (for out-of-memory)Ivan Maidanski2011-09-301-1/+4
| | | | | | | | * tests/test.c (mktree): Insert CHECK_OUT_OF_MEMORY to report mktree() out-of-memory failures. * tests/trace_test.c (mktree): Test whether GC_MALLOC_ATOMIC returns NULL (exit with an error code and the appropriate message printed in this case).
* Add missing GC_ATTR_UNUSED annotation to some functions in gctestIvan Maidanski2011-09-221-8/+13
| | | | | * tests/test.c (tiny_reverse_test, WinMain, thr_run_one_test, thr_window): Tag the arguments with GC_ATTR_UNUSED.
* Replace ARGSUSED comment-based annotation with GCC 'unused' attribute.Ivan Maidanski2011-09-141-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Turn on unused-parameter checking for GCC. * alloc.c (GC_try_to_collect_general): Add GC_ATTR_UNUSED attribute to an argument. * tests/test.c (tiny_reverse_test, thr_run_one_test): Likewise. * backgraph.c (reset_back_edge, update_max_height): Replace ARGSUSED annotation with GC_ATTR_UNUSED attribute for some arguments. * checksums.c (GC_add_block): Likewise. * dbg_mlc.c (GC_debug_change_stubborn, GC_debug_end_stubborn_change, GC_check_heap_block): Likewise. * finalize.c (GC_null_finalize_mark_proc): Likewise. * gcj_mlc.c (GC_gcj_fake_mark_proc): Likewise. * mark.c (GC_noop, clear_marks_for_block, GC_mark_and_push): Likewise. * mark_rts.c (GC_push_conditional_with_exclusions, GC_push_current_stack): Likewise. * misc.c (GC_default_oom_fn, GC_do_blocking_inner): Likewise. * os_dep.c (GC_fault_handler_openbsd, GC_fault_handler, GC_remove_protection, GC_page_was_dirty, GC_page_was_ever_dirty): Likewise. * pthread_stop_world.c (GC_suspend_handler, GC_suspend_handler_inner): Likewise. * pthread_support.c (GC_do_blocking_inner): Likewise. * stubborn.c (GC_change_stubborn, GC_end_stubborn_change): Likewise. * tests/test.c (fail_proc1): Likewise. * typd_mlc.c (GC_array_mark_proc): Likewise. * win32_threads.c (GC_do_blocking_inner, DllMain): Likewise. * include/private/gc_priv.h (GC_ATTR_UNUSED): Define new macro. * cordxtra.c (CORD_ATTR_UNUSED): Likewise. * cordxtra.c (CORD_nul_func, CORD_lf_close_proc): Replace ARGSUSED annotation with CORD_ATTR_UNUSED attribute for an argument. * mach_dep.c (GC_clear_stack_inner): Remove ARGSUSED annotation and use "limit" argument in the function (to suppress compiler warning). * misc.c (GC_clear_stack_inner): Remove ARGSUSED. * tests/threadkey_test.c (on_thread_exit_inner, on_thread_exit): Use all function arguments (to suppress compiler warning). * configure.ac (CFLAGS): Remove "-Wno-unused-parameter" option.
* Increase tests/test.c max heap size limit (required for Cygwin)Ivan Maidanski2011-09-131-1/+1
| | | | | | * tests/test.c (check_heap_stats): Increase max_heap_sz value (for 32-bit targets) from 15M by 1M (as the former is hit sometimes on Cygwin).
* Support multi-threading for RTEMS target.Jie Liu2011-08-091-1/+5
| | | | | | | | | | | | | | | | | | | | | * configure.ac: Add GC_RTEMS_PTHREADS AH_TEMPLATE and configure for rtems. * os_dep.c: Add GC_get_stack_base if GC_RTEMS_PTHREADS for rtems. * pthread_stop_world.c (GC_stop_init): Add ifdef SA_RESTART. * pthread_stop_world.c (GC_stop_init): Use sigprocmask for rtems when defined GC_RTEMS_PTHREADS. * pthread_support.c: Exclude sys/mman.h for rtems. * pthread_support.c (GC_thr_init): Set default GC_nprocs (1) for rtems. * include/gc_config_macros.h: Define GC_RTEMS_PTHREADS for rtems pthread and define GC_NO_DLOPEN for rtems. * include/private/gc_locks.h: Define USE_PTHREAD_LOCKS for rtems. * include/private/gcconfig.h: Use rtems_get_stack_bottom() for InitStackBottom; and use SIGUSR1 for SIG_SUSPEND, SIGUSR2 for SIG_THR_RESTART on rtems. * include/private/thread_local_alloc.h: Use USE_PTHREAD_SPECIFIC for rtems. * tests/test.c (Init): Use exit(0) for rtems instead of return.
* 2011-07-14 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-2/+2
| | | | | | | | * new_hblk.c (GC_build_fl): Adjust "h" local variable cast type when setting obj_link (to prevent compiler warning); reformat the comment. * tests/test.c (reverse_test_inner): Use proper type when touching "b" and "c" local variables (to prevent compiler warning).
* 2011-07-01 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-35/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * win32_threads.c (CHECK_LOOKUP_MY_THREAD): New macro definition. * win32_threads.c (GC_reset_finalizer_nested, GC_check_finalizer_nested, GC_unregister_my_thread, GC_do_blocking_inner, GC_call_with_gc_active, GC_init_parallel): Insert CHECK_LOOKUP_MY_THREAD before dereferencing thread descriptor pointer (to instruct a LINT-like tool that it is ok to dereference the pointer). * win32_threads.c (GC_get_next_stack): Assert plast_stack_min is non-NULL if current_min is not ADDR_LIMIT (for a LINT-like tool). * win32_threads.c (GC_init_parallel): Define and use "me" local variable. * cord/cordtest.c (test_basics): Test CORD_substr() result is non-NULL. * cord/cordtest.c (test_extras): Test fopen() result is non-NULL. * cord/cordtest.c (test_basics, test_extras, test_printf, main): Replace the K&R-style function definition with the ANSI C one. * cord/cordtest.c: Expand all tabs to spaces; remove trailing spaces at EOLn. * include/private/gc_priv.h (ABORT): Define as abort() when checking the code with a LINT-like tool (Win32 only). * tests/test.c (FAIL): Ditto. * tests/test.c (CHECH_GCLIB_VERSION): New macro (to check that the version of libgc.so used at runtime matches that at compile time). * tests/test.c (GC_COND_INIT): Use CHECH_GCLIB_VERSION. * tests/test.c (CHECK_OUT_OF_MEMORY): New macro (to test malloc result for out of memory). * tests/test.c (cons, small_cons, small_cons_uncollectable, gcj_cons, reverse_test_inner, mktree, alloc8bytes, typed_test, run_one_test): Use CHECK_OUT_OF_MEMORY.
* 2011-05-31 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-1/+1
| | | | | | | * win32_threads.c (GC_unregister_my_thread): Use KNOWN_FINISHED() instead of FINISHED macro. * tests/test.c (check_heap_stats): Round up max_heap_sz value for Win32 (same as for USE_MMAP).
* 2011-05-31 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-2/+2
| | | | | * tests/test.c (check_heap_stats): Adjust printf format specifier for max_heap_sz; cast max_heap_sz accordingly.
* 2011-05-19 Ivan Maidanski <ivmai@mail.ru> (really Jie Liu)ivmai2011-07-261-1/+1
| | | | | | | | | | | * include/private/gcconfig.h (end, InitStackBottom): Declare extern variable for RTEMS. * include/private/gcconfig.h (DATASTART, DATAEND, STACKBOTTOM): Update (for RTEMS). * include/private/gcconfig.h (DATAEND): Fix a typo in the macro name (for RTEMS). * tests/test.c (CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER): Replace with CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER (for RTEMS).
* 2011-05-18 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-2/+11
| | | | | | | | | * include/private/gcconfig.h (MPROTECT_VDB): Undefine if PROC_VDB. * tests/test.c (NUMBER_ROUND_UP): New macro. * tests/test.c (check_heap_stats): Round up total expected heap size to the nearest 4 MiB bound. * tests/test.c (check_heap_stats): Print the current and expected heap sizes in case of failure.
* 2011-04-11 Ivan Maidanski <ivmai@mail.ru> (really Jie Liu)ivmai2011-07-261-3/+12
| | | | | | | | | * mach_dep.c (NO_GETCONTEXT); Define for RTEMS. * mach_dep.c (GC_with_callee_saves_pushed): Don't call __builtin_unwind_init() for RTEMS; use setjmp() without the leading underscore (for RTEMS). * tests/test.c (BIG): Use smaller value for RTEMS. * tests/test.c (main): Customize for RTEMS.
* 2011-04-10 Ivan Maidanski <ivmai@mail.ru> (mostly really Iain Sandoe)ivmai2011-07-261-16/+12
| | | | | * tests/test.c (reverse_test): Modify count (BIG) for ppc64-darwin.
* 2011-04-04 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-8/+9
| | | | | | | * tests/test.c (reverse_test_inner): Undo one of the previous patches which shifts "c" and "d" pointers only if ALL_INTERIOR_POINTERS (since interior pointers are always recognized in stacks).
* 2011-04-03 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-89/+88
| | | | | | | | * tests/test.c (cons, small_cons, gcj_cons, check_ints, check_uncollectable_ints, print_int_list, check_marks_int_list, fork_a_thread, finalizer, mktree, chktree, alloc8bytes, alloc_small, tree_test, typed_test, check_heap_stats, WinMain, test, main): Remove unnecessary casts of GC_printf calls to void.
* 2011-04-02 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * allchblk.c (GC_print_hblkfreelist): Adjust (make uniform across BDWGC) printed message (adjust letters case, terminating dot and new line symbols). * alloc.c (GC_check_fl_marks): Ditto. * backgraph.c (new_back_edges): Ditto. * checksums.c (GC_check_dirty): Ditto. * darwin_stop_world.c (GC_push_all_stacks, GC_suspend_thread_list): Ditto. * dbg_mlc.c (GC_print_type, GC_debug_free, GC_debug_realloc, store_old): Ditto. * dyn_load.c (GC_register_dynamic_libraries): Ditto. * mark.c (GC_initiate_gc, GC_mark_some, GC_mark_from, GC_push_all, GC_push_selected, GC_push_next_marked_dirty): Ditto. * mark_rts.c (GC_exclude_static_roots_inner): Ditto. * os_dep.c (GC_remap, GC_default_push_other_roots, GC_push_thread_structures, GC_dirty_init, GC_read_dirty, catch_exception_raise_state, catch_exception_raise_state_identity, GC_mprotect_thread_notify, GC_mprotect_thread, catch_exception_raise): Ditto. * pthread_stop_world.c (GC_print_sig_mask, GC_push_all_stacks, GC_stop_world, GC_stop_init): Ditto. * pthread_support.c (GC_thr_init, GC_register_my_thread_inner, GC_start_routine): Ditto. * win32_threads.c (GC_register_my_thread_inner, GC_push_all_stacks, GC_win32_start_inner, GC_pthread_join, GC_pthread_start_inner): Ditto. * alloc.c (GC_expand_hp_inner): Realign the code. * mark.c (GC_mark_from, GC_mark_local, GC_do_parallel_mark): Ditto. * misc.c (GC_init): Ditto. * os_dep.c (GC_dirty_init, GC_read_dirty): Ditto. * include/private/gc_pmark.h (PUSH_CONTENTS_HDR): Ditto. * tests/test.c (run_one_test): Ditto. * misc.c (GC_err_puts): Document. * misc.c (GC_err_write): Remove. * os_dep.c (dump_maps): Ditto. * include/private/gc_priv.h (GC_err_write): Ditto. * os_dep.c (GC_print_address_map): Call GC_err_puts() instead of dump_maps() and GC_err_write(). * os_dep.c (GC_read_dirty): Remove redundant brackets.
* 2011-04-02 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-7/+7
| | | | | | | | | | * tests/test.c (reverse_test_inner): Test interior pointer recognition only if ALL_INTERIOR_POINTERS. * tests/test.c (run_one_test): Replace GC_all_interior_pointers with GC_get_all_interior_pointers(); simplify the expression. * tests/test.c (check_heap_stats): Replace GC_bytes_allocd and GC_bytes_allocd_before_gc with GC_get_total_bytes(). * tests/test.c (main): Replace GC_gc_no with GC_get_gc_no().
* 2011-02-10 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-0/+4
| | | | | | | | | | | | | * NT_MAKEFILE: Define _CRT_SECURE_NO_DEPRECATE for C++ files as well. * NT_STATIC_THREADS_MAKEFILE: Ditto. * doc/README.macros (USE_GET_STACKBASE_FOR_MAIN): Refine. * include/gc.h (GC_INIT): Document. * include/private/gc_priv.h (GC_MACH_HEADER, GC_MACH_SECTION, GC_GETSECTBYNAME): Define depending only on the word size (i.e., define these macros also for ARM). * tests/test.c (check_heap_stats): Print main thread stack bottom as well (only if verbose mode is on).
* 2010-11-25 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-0/+2
| | | | | | * tests/test.c (main): Print the relevant message if GWW_VDB. * include/private/gcconfig.h: Don't define MPROTECT_VDB for Win32 on x64 if compiled by GCC.
* 2010-10-22 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * CMakeLists.txt: Check enable_parallel_mark on Darwin. * configure.ac: Ditto. * darwin_stop_world.c (DARWIN_SUSPEND_GC_THREADS, DARWIN_QUERY_TASK_THREADS): Rename to GC_NO_THREADS_DISCOVERY and GC_DISCOVER_TASK_THREADS, respectively. * os_dep.c (DARWIN_SUSPEND_GC_THREADS): Ditto. * pthread_support.c (DARWIN_SUSPEND_GC_THREADS): Ditto. * darwin_stop_world.c (DARWIN_QUERY_TASK_THREADS): Don't define (and remove FIXME). * darwin_stop_world.c (GC_use_threads_discovery): Add GC_API; comment; remove FIXME. * win32_threads.c (GC_NO_DLLMAIN): Rename to GC_NO_THREADS_DISCOVERY. * tests/test.c (GC_NO_DLLMAIN): Ditto. * doc/README.macros (GC_NO_DLLMAIN): Ditto. * doc/README.win32 (GC_NO_DLLMAIN): Ditto. * doc/README.macros (GC_NO_THREADS_DISCOVERY): Update the comment. * win32_threads.c (GC_win32_dll_threads): Define as macro to true if GC_DISCOVER_TASK_THREADS (and not GC_NO_THREADS_DISCOVERY); update the comment. * win32_threads.c (GC_use_DllMain): Rename to GC_use_threads_discovery; do not set GC_win32_dll_threads if GC_DISCOVER_TASK_THREADS. * win32_threads.c (GC_started_thread_while_stopped, GC_lookup_thread_inner, UNPROTECT_THREAD, GC_lookup_pthread, GC_thr_init, GC_pthread_create, DllMain): Rewrite some expressions which use GC_win32_dll_threads to minimize the possibility of an "unreachable code" compiler warning when GC_win32_dll_threads is defined as a macro. * win32_threads.c (GC_unregister_my_thread): Don't call GC_delete_thread() if GC_win32_dll_threads and THREAD_LOCAL_ALLOC (since can't happen); use "t" local variable only if not GC_win32_dll_threads. * win32_threads.c (GC_register_my_thread_inner): Reformat the comment. * doc/README.macros (GC_DISCOVER_TASK_THREADS): Document. * include/gc.h (GC_use_DllMain): Rename to GC_use_threads_discovery but keep old name as a macro definition. * include/gc.h (GC_use_threads_discovery): Declare also for Darwin; update the comment. * tests/test.c (main): Call GC_use_threads_discovery for Darwin (to test the mode if possible). * configure: Regenerate.
* 2010-07-28 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-1/+1
| | | | | | * tests/test.c (check_heap_stats): Increase max_heap_sz by 20% for 64-bit CPUs (to prevent "Unexpected heap growth" failure on Win64, at least).
* 2010-07-14 Ivan Maidanski <ivmai@mail.ru>ivmai2011-07-261-1/+1
| | | | | * tests/test.c (check_heap_stats): Increase max_heap_sz by 25% for 32-bit CPUs (to prevent "Unexpected heap growth" failure).
* 2009-12-18 Ivan Maidanski <ivmai@mail.ru> (with input fromivmai2011-07-261-0/+3
| | | | | | | | | | | | | | | | | | | | Jean-Claude Beaudoin) * include/gc.h (GC_unregister_my_thread): Fix a typo; update the comment. * pthread_support.c (GC_delete_thread): Allow to delete the main thread (don't call GC_INTERNAL_FREE for it); update the comment. * win32_threads.c (GC_delete_thread): Ditto. * pthread_support.c (GC_unregister_my_thread): Add an assertion for FINISHED flag is unset. * tests/test.c (check_heap_stats): Test the main thread unregistering (only if THREADS). * win32_threads.c (GC_register_my_thread_inner): Set flags to DETACHED (only if GC_PTHREADS). * win32_threads.c (GC_unregister_my_thread): Add FIXME (for GC_wait_for_gc_completion). * win32_threads.c (GC_pthread_start_inner): Clear flags detached state if needed; set pthread_id and flags while holding the lock.
* 2009-12-10 Hans-J. Boehm <Hans.Boehm@hp.com>hboehm2011-07-261-3/+2
| | | | | | * test.c (main, WinMain): Consistently don't invoke GC_enable_incremental() if MAKE_BACKGRAPH is defined, but do invoke it even if parallel marking is enabled.