summaryrefslogtreecommitdiff
path: root/include/gc
Commit message (Collapse)AuthorAgeFilesLines
* Make comparisons to the lowest heap boundary strictIvan Maidanski2023-05-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | * alloc.c (GC_expand_hp_inner): Subtract sizeof(word) from new_limit (for the case when comparing to GC_least_plausible_heap_addr). * backgraph.c [MAKE_BACK_GRAPH] (add_back_edges): Compare current to GC_least_real_heap_addr and GC_greatest_real_heap_addr (instead of GC_least_plausible_heap_addr and GC_greatest_plausible_heap_addr). * malloc.c [GC_ASSERTIONS] (GC_malloc_kind_global): Likewise. * include/gc/gc_mark.h (GC_MARK_AND_PUSH): Replace greater-or-equal to strictly greater when comparing to GC_least_plausible_heap_addr. * include/private/gc_pmark.h (GC_PUSH_ONE_STACK, GC_PUSH_ONE_HEAP): Likewise. * include/private/gc_priv.h [MAKE_BACK_GRAPH] (SET_REAL_HEAP_BOUNDS, GC_least_real_heap_addr, GC_greatest_real_heap_addr): Define. * mark.c (GC_mark_from, GC_push_all): Add dummy "| GC_DS_LENGTH" when storing length to mse_descr.w. * mark.c (GC_mark_from): Replace greater-or-equal to strictly greater when comparing to least_ha variable. * typd_mlc.c (GC_typed_mark_proc): Likewise. * mark.c [GC_DS_TAGS>ALIGNMENT-1] (GC_push_all): Simplify code to round up length.
* Fix comparisons to heap boundary in GC_get_back_ptr_info and GC_mark_fromIvan Maidanski2023-05-131-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The region delimited by GC_least_plausible_heap_addr and GC_greatest_plausible_heap_addr might contain part of static data roots or stacks (in addition to potential heap expansion areas). Certain comparisons in GC_get_back_ptr_info (when ALIGNMENT is 1) and in GC_mark_from (in assertions) expect the real heap boundaries. * alloc.c [SET_REAL_HEAP_BOUNDS] (GC_add_to_heap): Update GC_least_real_heap_addr and GC_greatest_real_heap_addr variables. * dbg_mlc.c [KEEP_BACK_PTRS && ALIGNMENT == 1] (GC_get_back_ptr_info): Compare alternate_target and target to GC_least_real_heap_addr and GC_greatest_real_heap_addr (instead of GC_least_plausible_heap_addr and GC_greatest_plausible_heap_addr). * include/gc/gc_mark.h (GC_greatest_plausible_heap_addr): Refine comment. * include/private/gc_priv.h [GC_ASSERTIONS || KEEP_BACK_PTRS && ALIGNMENT == 1] (SET_REAL_HEAP_BOUNDS): Define macro. * include/private/gc_priv.h [GC_ASSERTIONS || KEEP_BACK_PTRS && ALIGNMENT == 1] (GC_least_real_heap_addr, GC_greatest_real_heap_addr): Define (as macro). * include/private/gc_priv.h [GC_ASSERTIONS || KEEP_BACK_PTRS && ALIGNMENT == 1] (_GC_arrays._least_real_heap_addr, _GC_arrays._greatest_real_heap_addr): New field; add comment. * mark.c (GC_mark_from): Use GC_greatest_real_heap_addr and GC_least_real_heap_addr instead of GC_least_plausible_heap_addr and GC_greatest_plausible_heap_addr, respectively, in assertions.
* Add API to get total stopped-world marking timeIvan Maidanski2023-05-041-2/+8
| | | | | | | | | | | | | | | | | | | | New public function is GC_get_stopped_mark_total_time(). * alloc.c [!NO_CLOCK] (stopped_mark_total_time, stopped_mark_total_ns_frac): New static variable. * alloc.c [!NO_CLOCK] (GC_get_stopped_mark_total_time): New API function definition. * alloc.c [!NO_CLOCK] (GC_stopped_mark): Define start_time_valid, ns_frac_diff local variables; call GET_TIME() also if measure_performance; add TODO item (about code duplication); update stopped_mark_total_time and stopped_mark_total_ns_frac values. * alloc.c (GC_stopped_mark): Move logging of "Marking for collection" upper to be before GET_TIME(start_time). * include/gc/gc.h (GC_get_full_gc_total_time): Refine documentation. * include/gc/gc.h (GC_get_stopped_mark_total_time): New API prototype. * tests/gctest.c [!NO_CLOCK] (check_heap_stats): Call GC_get_stopped_mark_total_time() to report total stopped-world marking time.
* New API for more optimal usage of GC_calloc_explicitly_typedIvan Maidanski2023-04-261-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the client needs to allocate many typed object arrays of same layout and amount of elements, then "calloc" descriptor could be created once (by GC_calloc_prepare_explicitly_typed) followed by multiple allocations (by GC_calloc_do_explicitly_typed) referring to the same descriptor. * include/gc/gc_typed.h (GC_CALLOC_TYPED_DESCR_WORDS): New macro. * include/gc/gc_typed.h (GC_calloc_typed_descr_s): New struct type. * include/gc/gc_typed.h (GC_calloc_prepare_explicitly_typed, GC_calloc_do_explicitly_typed): New function declaration. * tests/gctest.c [!NO_TYPED_TEST && !GC_DEBUG] (typed_test): Define ctd_l local variable; call GC_calloc_prepare_explicitly_typed() before loop; call GC_calloc_do_explicitly_typed() instead of GC_CALLOC_EXPLICITLY_TYPED(1001). * typd_mlc.c (GC_calloc_typed_descr_s.alloc_lb): Change type from size_t to word. * typd_mlc.c (GC_calloc_typed_descr_s.descr_type): Change type from int to signed_word. * typd_mlc.c (GC_calloc_prepare_explicitly_typed, GC_calloc_do_explicitly_typed): Change from STATIC to GC_API; add ctd_sz argument; check ctd_sz in assertion; add casts for alloc_lb field. * typd_mlc.c (GC_calloc_prepare_explicitly_typed): Add static assertion about size of GC_calloc_typed_descr_s and GC_CALLOC_TYPED_DESCR_WORDS; change return type from void to it. * typd_mlc.c (GC_calloc_explicitly_typed): Pass sizeof(ctd) to GC_calloc_prepare_explicitly_typed(), GC_calloc_do_explicitly_typed().
* Do incremental mark some in GC_collect_a_little even if GC is disabledIvan Maidanski2023-04-251-1/+3
| | | | | | | | | | | | | | | | | | | | Previous behavior was not documented but this API function did nothing in this case. That might cause a deadlock in the client code if the incremental collection was ongoing and the client called GC_collect_a_little() repeatedly (while the result is true). The new behavior, for the cause of disabled garbage collection, is to perform some amount of marking if the incremental collection is ongoing (but not stopping the world and, thus, not causing the memory reclaim to start), returning true if there is something more to mark. * alloc.c (GC_try_to_collect_inner): Change a loop to do-while one. * alloc.c (GC_collect_a_little): Do not check GC_dont_gc (i.e. call GC_collect_a_little_inner() unconditionally); add comment. * include/gc/gc.h (GC_collect_a_little): Update comment (describe the case when GC is disabled). * tests/gctest.c (check_heap_stats): Do not call GC_is_disabled(); add comment.
* Provide global non-throwing operator new/delete in gccpp libraryIvan Maidanski2023-04-201-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note: this might require define GC_INCLUDE_NEW by client before include gc_cpp.h on Windows hosts (to have nothrow_t declared before the global inline operator new and delete are defined). * gc_cpp.cc [(!_MSC_VER && !__DMC__ || GC_NO_INLINE_STD_NEW) && !GC_INLINE_STD_NEW && GC_OPERATOR_NEW_NOTHROW] (operator new, operator delete): Define with nothrow_t argument. * gc_cpp.cc [(!_MSC_VER && !__DMC__ || GC_NO_INLINE_STD_NEW) && !GC_INLINE_STD_NEW && GC_OPERATOR_NEW_ARRAY && !CPPCHECK && GC_OPERATOR_NEW_NOTHROW] (operator new[], operator delete[]): Likewise. * include/gc/gc_cpp.h [GC_INLINE_STD_NEW && GC_OPERATOR_NEW_ARRAY && GC_OPERATOR_NEW_NOTHROW] (operator new[], operator delete[]): Likewise. * include/gc/gc_cpp.h [GC_INLINE_STD_NEW && GC_OPERATOR_NEW_NOTHROW] (operator new, operator delete): Likewise. * include/gc/gc_cpp.h [!GC_OPERATOR_NEW_NOTHROW && !GC_NO_OPERATOR_NEW_NOTHROW && (GC_INCLUDE_NEW && (__cplusplus>=201103L || _MSVC_LANG>=201103L) || __NOTHROW_T_DEFINED)] (GC_OPERATOR_NEW_NOTHROW): Define macro; add comment. * include/gc/gc_cpp.h [!GC_INLINE_STD_NEW && GC_NO_INLINE_STD_NEW && _MSC_VER && GC_OPERATOR_NEW_ARRAY && GC_OPERATOR_NEW_NOTHROW] (operator new[], operator delete[]): Add prototype with nothrow_t argument (with commented out GC_ATTR_MALLOC). * include/gc/gc_cpp.h [!GC_INLINE_STD_NEW && GC_NO_INLINE_STD_NEW && _MSC_VER && GC_OPERATOR_NEW_NOTHROW] (operator new, operator delete): Likewise.
* Define sized delete operator in 'gc' classIvan Maidanski2023-04-201-36/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gc_cpp.cc [!_MSC_VER && !__DMC__ || GC_NO_INLINE_STD_NEW] (operator delete): Replace __cplusplus>=201703L||_MSVC_LANG>=201703L to defined(GC_OPERATOR_SIZED_DELETE). * include/gc/gc_cpp.h [GC_INLINE_STD_NEW]: Likewise. * gc_cpp.cc [!_MSC_VER && !__DMC__ || GC_NO_INLINE_STD_NEW] (GC_ALLOCATOR_THROW_OR_ABORT, operator new, operator delete, operator new[], operator delete[]): Do not define if GC_INLINE_STD_NEW. * gc_cpp.cc (operator new, operator delete): Reformat code. * include/gc/gc_cpp.h [!GC_NO_INLINE_STD_NEW && !GC_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL)] (GC_INLINE_STD_NEW): Define macro. * include/gc/gc_cpp.h [!GC_NO_OPERATOR_SIZED_DELETE && !GC_OPERATOR_SIZED_DELETE && (__cplusplus>=201402L || _MSVC_LANG>=201402L)] (GC_OPERATOR_SIZED_DELETE): Likewise. * include/gc/gc_cpp.h [!GC_NO_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL)]: Check GC_INLINE_STD_NEW instead. * include/gc/gc_cpp.h [GC_OPERATOR_SIZED_DELETE] (gc::operator delete(void*,GC_SIZE_T)): Declare. * include/gc/gc_cpp.h [GC_OPERATOR_NEW_ARRAY && GC_OPERATOR_SIZED_DELETE] (gc::operator delete[](void*,GC_SIZE_T)): Likewise. * include/gc/gc_cpp.h [GC_NO_INLINE_STD_NEW && _MSC_VER && GC_OPERATOR_NEW_ARRAY && GC_OPERATOR_SIZED_DELETE] (operator delete[](void*,GC_SIZE_T)): Likewise. * include/gc/gc_cpp.h [GC_NO_INLINE_STD_NEW && _MSC_VER && GC_OPERATOR_SIZED_DELETE] (operator delete(void*,GC_SIZE_T)): Likewise. * include/gc/gc_cpp.h [GC_OPERATOR_SIZED_DELETE] (gc::operator delete(void*,GC_SIZE_T)): Define inline function. * include/gc/gc_cpp.h [GC_OPERATOR_NEW_ARRAY && GC_OPERATOR_SIZED_DELETE] (gc::operator delete[](void*,GC_SIZE_T)): Likewise.
* Specify throw and noexcept for operator new/delete in gc_cpp.h for MS VCIvan Maidanski2023-04-191-5/+8
| | | | | | | | | | | | | | | | (fix of commit eb571cb86) * include/gc/gc_cpp.h [GC_NO_INLINE_STD_NEW && _MSC_VER && GC_OPERATOR_NEW_ARRAY] (operator new[]): Add GC_DECL_NEW_THROW. * include/gc/gc_cpp.h [GC_NO_INLINE_STD_NEW && _MSC_VER] (operator new): Likewise. * include/gc/gc_cpp.h [GC_NO_INLINE_STD_NEW && _MSC_VER && GC_OPERATOR_NEW_ARRAY] (operator delete[]): Add GC_NOEXCEPT. * include/gc/gc_cpp.h [GC_NO_INLINE_STD_NEW && _MSC_VER] (operator delete): Likewise. * include/gc/gc_cpp.h [GC_NO_INLINE_STD_NEW && _MSC_VER && GC_OPERATOR_NEW_ARRAY] (operator new[](size_t,int,const char*,int)): New prototype.
* Fix 'C++17 does not allow dynamic exc spec' warn if GC_NO_INLINE_STD_NEWIvan Maidanski2023-04-191-8/+14
| | | | | | | | | | | | | | | | | | | | (fix of commit 17364f061) * gc_cpp.cc: Do not include <new> directly. * gc_cpp.cc [!GC_INCLUDE_NEW] (GC_INCLUDE_NEW): Define macro. * gc_cpp.cc (GC_DECL_NEW_THROW): Move definition to gc_cpp.h. * include/gc/gc_cpp.h [!GC_NO_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL)] (GC_DECL_INLINE_NEW_THROW): Do not define. * include/gc/gc_cpp.h [GC_NEW_DELETE_NEED_THROW && !(__cplusplus>=201703L || _MSVC_LANG>=201703L) && !GC_INCLUDE_NEW] (GC_DECL_NEW_THROW): Define to empty. * include/gc/gc_cpp.h [!GC_NO_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL)] (operator new, operator new[]): Replace GC_DECL_INLINE_NEW_THROW attribute to GC_DECL_NEW_THROW.
* Fix 'size_t not found in namespace std' dmc error in gc_allocator.hIvan Maidanski2023-04-172-17/+33
| | | | | | | | | | | | | | | | | | | | | (fix of commit 08eb0da6f) * gc_cpp.cc (operator new, operator delete): Use GC_SIZE_T instead of std::size_t. * include/gc/gc_allocator.h (GC_ALCTR_PTRDIFF_T, GC_ALCTR_SIZE_T): Define macro (and undefine it at the end of file). * include/gc/gc_allocator.h (GC_selective_alloc, gc_allocator.size_type, gc_allocator.max_size, gc_allocator_ignore_off_page.size_type, gc_allocator_ignore_off_page.max_size, traceable_allocator.size_type, traceable_allocator.max_size): Use GC_ALCTR_SIZE_T instead of std::size_t. * include/gc/gc_allocator.h (gc_allocator.difference_type, gc_allocator_ignore_off_page.difference_type, traceable_allocator.difference_type): Use GC_ALCTR_PTRDIFF_T instead of std::ptrdiff_t. * include/gc/gc_cpp.h [GC_INCLUDE_NEW] (GC_PTRDIFF_T, GC_SIZE_T): Do not use std:: prefix unless __cplusplus>=201103L.
* Fix 'operator new is missing throw(bad_alloc)' clang warning in gc_cpp.hIvan Maidanski2023-04-171-2/+14
| | | | | | | | | | | | | | | | | The warning was reported on Window and only if __cplusplus < 201103L. * gc_cpp.cc [GC_NEW_DELETE_THROW_NOT_NEEDED && !GC_NEW_DELETE_NEED_THROW && GC_GNUC_PREREQ(4,2) && (__cplusplus<201103L || __clang__)] (GC_NEW_DELETE_NEED_THROW): Move definition to gc_cpp.h. * include/gc/gc_cpp.h [!GC_NO_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL)] (GC_DECL_INLINE_NEW_THROW): New macro. * include/gc/gc_cpp.h [!GC_NO_INLINE_STD_NEW && (_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__ || __CYGWIN32__ || __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL)] (operator new): Add GC_DECL_INLINE_NEW_THROW attribute.
* Prefix size_t and ptrdiff_t with namespace 'std' in C++ filesIvan Maidanski2023-04-172-128/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note: this affects gc_cpp.h only if GC_INCLUDE_NEW is defined (i.e. "new" header is included). * gc_cpp.cc (operator new, operator delete): Use std::size_t instead of size_t. * include/gc/gc_allocator.h (GC_selective_alloc, gc_allocator.size_type, gc_allocator.max_size, gc_allocator_ignore_off_page.size_type, gc_allocator_ignore_off_page.max_size, traceable_allocator.size_type, traceable_allocator.max_size): Likewise. * gc_cpp.cc (operator delete): Remove name of unused argument (and cast to void). * include/gc/gc_cpp.h (operator new, operator delete): Likewise. * gc_cpp.cc: Reformat code. * include/gc/gc_cpp.h: Likewise. * include/gc/gc_allocator.h (gc_allocator.difference_type, gc_allocator_ignore_off_page.difference_type, traceable_allocator.difference_type): Use std::ptrdiff_t instead of ptrdiff_t. * include/gc/gc_cpp.h (GC_PTRDIFF_T, GC_SIZE_T): New macro (depending on GC_INCLUDE_NEW). * include/gc/gc_cpp.h (operator new, operator delete): Use GC_SIZE_T instead of size_t. * include/gc/gc_cpp.h (gc_cleanup): Reformat comments. * include/gc/gc_cpp.h (gc_cleanup::cleanup): Use GC_PTRDIFF_T instead of ptrdiff_t. * include/gc/gc_cpp.h [!GC_NO_INLINE_STD_NEW && _MSC_VER] (operator new): Remove duplicate code.
* Ensure 'new' system header is included by gc_cpp.h if GC_INCLUDE_NEWIvan Maidanski2023-04-171-1/+4
| | | | | | * include/gc/gc_cpp.h [GC_INCLUDE_NEW]: Include <new> right after include gc.h (regardless of GC_NEW_ABORTS_ON_OOM and _LIBCPP_NO_EXCEPTIONS).
* Allow gc_allocator<T> and friends to be defined in namespace boehmgcIvan Maidanski2023-04-171-0/+9
| | | | | | | | | | | | | | | | The client should define GC_NAMESPACE_ALLOCATOR before include gc_allocator.h to have all symbols of the latter to be defined in namespace boehmgc. * docs/README.macros (GC_NAMESPACE_ALLOCATOR): Document. * include/gc/gc_allocator.h [GC_NAMESPACE_ALLOCATOR] (GC_true_type, GC_false_type, GC_type_traits, GC_DECLARE_PTRFREE, GC_selective_alloc, gc_allocator, gc_allocator_ignore_off_page, traceable_allocator): Define symbols (all) in boehmgc namespace. * tests/cpp.cc (GC_NAMESPACE_ALLOCATOR): Define macro (before include gc_allocator.h). * tests/cpp.cc (gc_allocator, gc_allocator_ignore_off_page, traceable_allocator): Using the symbol of namespace boehmgc.
* Replace C style comments to C++ ones in gc_allocator.hIvan Maidanski2023-04-171-19/+14
| | | | | * include/gc/gc_allocator.h (GC_true_type, GC_selective_alloc, traceable_allocator): Transform comment style to a C++ one.
* Allow align argument of GC_memalign to be smaller than pointer sizeIvan Maidanski2023-04-171-4/+6
| | | | | | | | | | | | (fix of commit ba137368d) This is largely to match the standard requirements on aligned_alloc(). * include/gc/gc.h (GC_memalign): Update comment. * mallocx.c (GC_memalign): Allow align to be less than a pointer size (provided it is non-zero). * mallocx.c (GC_memalign, GC_posix_memalign): Do not expect align argument is invalid.
* Redirect _aligned_malloc/free() in leak_detector.hIvan Maidanski2023-04-171-0/+5
| | | | | | | | | | * include/gc/leak_detector.h (_aligned_malloc, _aligned_free): Redefine macro. * include/gc/leak_detector.h (_aligned_free): Use GC_base (because GC_memalign might return a pointer inside the allocated object to ensure the requested alignment). * tests/leak.c (main): Call _aligned_malloc() and _aligned_free(); print error and exit in case of _aligned_malloc() failure.
* Do not add extra byte to large ignore-off-page objectsIvan Maidanski2023-04-121-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For ignore-off-page objects the client should guarantee the pointer within the first heap block of the object, thus no need to add an extra byte for such objects if the object size of at least one heap block. * allchblk.c (setup_header): Add assertion that byte_sz is not less than ALIGNMENT. * allchblk.c [ALIGNMENT>GC_DS_TAGS] (setup_header): Modify descr local variable to make it zero if IGNORE_OFF_PAGE flag is set and kind is NORMAL (and object size is not less than HBLKSIZE); add comment. * mallocx.c [ALIGNMENT>GC_DS_TAGS] (GC_realloc): Likewise. * include/gc/gc.h (GC_all_interior_pointers): Update comment. * include/private/gc_priv.h [MAX_EXTRA_BYTES==0] (ADD_EXTRA_BYTES): Define as no-op. * malloc.c (GC_generic_malloc_inner): Define lb_adjusted local variable; pass lb_adjusted to GC_alloc_large_and_clear(). * malloc.c [MAX_EXTRA_BYTES>0] (GC_generic_malloc_inner): Set lb_adjusted to lb if IGNORE_OFF_PAGE flag is set and lb is not less than HBLKSIZE. * malloc.c [MAX_EXTRA_BYTES>0] (GC_generic_malloc_aligned): Set lb_rounded without EXTRA_BYTES added (and compute lg based on lb_rounded) if IGNORE_OFF_PAGE is set and lb is not less than HBLKSIZE. * mallocx.c (GC_realloc): Define ok local variable. * typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Remove lb_adjusted local variable; call GC_malloc_explicitly_typed() if lb is smaller than HBLKSIZE-sizeof(word), otherwise pass lb plus sizeof(word) (instead of lb plus TYPD_EXTRA_BYTES) to GC_generic_malloc_aligned; add comment.
* Acquire GC lock in GC_is_tmp_rootIvan Maidanski2023-04-111-0/+2
| | | | | | | | | | * include/gc/gc_mark.h (GC_is_tmp_root): Document function. * include/gc/gc_mark.h (GC_is_tmp_root): Add comment that the function acquires the GC lock. * mark_rts.c [!NO_DEBUGGING] (GC_is_tmp_root): Likewise. * mark_rts.c [!NO_DEBUGGING] (GC_is_tmp_root): Define res local variable; change code to have only single return statement; wrap code into LOCK/UNLOCK.
* Document assumption about GC lock for GC_clear_exclusion_tableIvan Maidanski2023-04-111-0/+1
| | | | | | | * include/gc/gc.h (GC_clear_exclusion_table): Add comment about GC lock. * mark_rts.c (GC_clear_exclusion_table): Likewise. * mark_rts.c (GC_clear_exclusion_table): Copy comment from gc.h.
* Refine comment of GC_print_free_list regarding GC lockIvan Maidanski2023-04-101-2/+3
| | | | | | | | (documentation) * include/gc/gc_inline.h (GC_print_free_list): Add comment about assumption about the GC lock. * reclaim.c (GC_print_free_list): Likewise.
* Refine documentation of GC_register_disclaim_proc and GC_finalized_mallocIvan Maidanski2023-04-101-21/+21
| | | | | * include/gc/gc_disclaim.h (GC_register_disclaim_proc, GC_finalized_malloc): Refine comment.
* Do not prohibit zero proc argument in GC_register_disclaim_procIvan Maidanski2023-04-101-1/+1
| | | | | | | | | | | (fix of commit 1d3675499) * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_register_disclaim_proc): Do not check that proc is non-zero. * include/gc/gc_disclaim.h (GC_register_disclaim_proc): Remove GC_ATTR_NONNULL(2) attribute. * reclaim.c [ENABLE_DISCLAIM] (GC_disclaim_and_reclaim): Add assertion that disclaim is non-zero.
* Acquire lock in GC_register_disclaim_procIvan Maidanski2023-04-101-1/+1
| | | | | | | | | GC_obj_kinds should be updated with the allocation lock held. * fnlz_mlc.c [ENABLE_DISCLAIM] (GC_register_disclaim_proc): Wrap the code into LOCK/UNLOCK. * include/gc/gc_disclaim.h (GC_register_disclaim_proc): Add comment that the function acquires the lock.
* Refine comparisons to GC_greatest_plausible_heap_addrIvan Maidanski2023-04-091-4/+5
| | | | | | | | | | | | | | | | | | GC_greatest_plausible_heap_addr should always be greater (strictly) than any address of a heap object. * backgraph.c (add_back_edges): Check that pointer is strictly less than GC_greatest_plausible_heap_addr (instead of less or equal). * dbg_mlc.c [KEEP_BACK_PTRS && ALIGNMENT==1] (GC_get_back_ptr_info): Likewise. * include/gc/gc_mark.h (GC_MARK_AND_PUSH): Likewise. * malloc.c (GC_malloc_kind_global): Likewise. * typd_mlc.c (GC_typed_mark_proc): Likewise. * include/gc/gc_mark.h (GC_greatest_plausible_heap_addr): Refine comment (that any object address is strictly less). * mark.c (GC_mark_from): Allow descr in assertions to be equal to GC_greatest_plausible_heap_addr-GC_least_plausible_heap_addr; reformat comment.
* Do not add extra byte to non-small uncollectible objectsIvan Maidanski2023-03-251-1/+2
| | | | | | | | | | | | Previously EXTRA_BYTES value was not added to the allocation size only for small uncollectible objects. * include/gc/gc.h (GC_all_interior_pointers): Refine comment (regarding uncollectible objects). * malloc.c (GC_generic_malloc_uncollectable): Define lb_orig local variable; decrement lb before if(SMALL_OBJ(lb)); do not expect original lb is zero; pass lb_orig (instead of lb) to GC_DBG_COLLECT_AT_MALLOC() and to oom_fn().
* 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.
* Fix description of client promise for IGNORE_OFF_PAGE allocated objectsIvan Maidanski2023-03-203-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | (documentation) The client should keep a pointer within the first heap block for such an allocated object. Previously, it was mentioned in the documentation and comments that such a pointer should be within the first 256 or 512 bytes. * README.md (The C Interface to the Allocator): Fix the description (comment) of GC_malloc_ignore_off_page (the client promises to keep a pointer within the first hblk of the object instead of 256 or 512 bytes, or a page). * docs/gcinterface.md (GC_MALLOC_IGNORE_OFF_PAGE): Likewise. * gc.man (GC_malloc_atomic_ignore_off_page): Likewise. * include/gc/gc.h (GC_malloc_ignore_off_page): Likewise. * include/gc/gc_mark.h (GC_generic_malloc_ignore_off_page): Likewise. * include/private/gc_priv.h (IGNORE_OFF_PAGE): Likewise. * include/private/gc_priv.h [DBG_HDRS_ALL || GC_GCJ_SUPPORT || !GC_NO_FINALIZATION] (GC_generic_malloc_inner_ignore_off_page): Likewise. * malloc.c [DBG_HDRS_ALL || GC_GCJ_SUPPORT || !GC_NO_FINALIZATION] (GC_generic_malloc_inner_ignore_off_page): Likewise. * include/gc/gc_gcj.h (GC_gcj_malloc_ignore_off_page): Refine comment.
* New API for disappearing links registration accepting interior pointersIvan Maidanski2023-03-181-3/+11
| | | | | | | | | | | | | | GC_GENERAL_REGISTER_DISAPPEARING_LINK_SAFE() and GC_REGISTER_LONG_LINK_SAFE() macros are provided. * include/gc/gc.h (GC_GENERAL_REGISTER_DISAPPEARING_LINK_SAFE, GC_REGISTER_LONG_LINK_SAFE): New API macros. * include/gc/gc.h [GC_DEBUG] (GC_GENERAL_REGISTER_DISAPPEARING_LINK): Use GC_GENERAL_REGISTER_DISAPPEARING_LINK_SAFE() instead of GC_general_register_disappearing_link() and GC_base() directly. * include/gc/gc.h [GC_DEBUG] (GC_REGISTER_LONG_LINK): Use GC_REGISTER_LONG_LINK_SAFE() instead of GC_register_long_link() and GC_base() directly.
* Fix mistyped GC_register_finalizer[_unreachable] in commentsIvan Maidanski2023-03-181-1/+1
| | | | | | | | (fix of commits 074de161d, f69ca1a96) * dbg_mlc.c (store_old): Fix name in comment ("GC_register_finalizer"). * include/gc/gc.h (GC_java_finalization): Fix name in comment ("GC_register_finalizer_unreachable").
* Better document link argument of GC_general_register_disappearing_linkIvan Maidanski2023-03-181-4/+5
| | | | | * include/gc/gc.h (GC_general_register_disappearing_link): Improve comment to outline that link could be in any memory.
* Fix GC_thread_is_registered for finished threadsIvan Maidanski2023-03-101-0/+2
| | | | | | | | | | | | | (fix of commit 83c1eecd0) A finished thread may still stay in GC_threads, but it is no longer considered during a garbage collection phase, thus GC_thread_is_registered() should return false in such a case. * include/gc/gc.h [GC_THREADS] (GC_thread_is_registered): Refine comment (describe the case when the thread is marked as finished). * pthread_support.c (GC_thread_is_registered): Define and set me local variable; return FALSE if KNOWN_FINISHED(me).
* Remove MAIN_THREAD flag in GC_threadIvan Maidanski2023-03-091-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * darwin_stop_world.c (GC_stack_range_for): Do not check MAIN_THREAD bit of p->flags. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_support.c [!GC_WIN32_THREADS] (GC_set_stackbottom, GC_get_my_stackbottom): Likewise. * pthread_support.c [!GC_WIN32_THREADS] (GC_call_with_gc_active): Likewise. * darwin_stop_world.c (GC_stack_range_for): Do not use GC_stackbottom. * pthread_stop_world.c (GC_push_all_stacks): Likewise. * pthread_support.c [!GC_WIN32_THREADS] (GC_get_my_stackbottom): Likewise. * dyn_load.c [(SCO_ELF || DGUX || HURD || NACL || __ELF__ && (LINUX || FREEBSD || NETBSD || OPENBSD)) && USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Do not check GC_stackbottom if THREADS. * include/gc/gc.h (GC_stackbottom): Refine comment (mention that it could be change only before GC initialization if multi-threaded, mention GC_set_stackbottom). * include/private/gcconfig.h [IA64 && (HPUX || LINUX)] (BACKING_STORE_BASE): Remove. * include/private/pthread_support.h [!GC_WIN32_THREADS] (MAIN_THREAD): Likewise. * mark_rts.c [!THREADS && IA64] (GC_push_current_stack): Use GC_register_stackbottom instead of BACKING_STORE_BASE. * pthread_stop_world.c [IA64] (GC_push_all_stacks): Do not use BACKING_STORE_BASE (GC_register_stackbottom). * pthread_support.c [!GC_WIN32_THREADS] (GC_thr_init): Do not set MAIN_THREAD bit of me->flags. * pthread_support.c (GC_set_stackbottom, GC_get_my_stackbottom): Move crtn local variable to outer scope. * pthread_support.c [!GC_WIN32_THREADS] (GC_set_stackbottom): Do not set GC_stackbottom (and GC_register_stackbottom) if GC is initialized. * pthread_support.c [!GC_WIN32_THREADS && IA64] (GC_get_my_stackbottom): Do not use GC_register_stackbottom. * pthread_support.c (GC_call_with_gc_active): Move stack_end local variable to outer scope. * pthread_support.c [!GC_WIN32_THREADS] (GC_call_with_gc_active): Do not use and set GC_stackbottom.
* Add callback API to support ephemeron markingJonathan Chambers2023-02-141-0/+10
| | | | | | | | | | | | | | | | | | | | | | (cherry-pick of 1a65adc, bb5ba42, 6f41d8d from Unity-Technologies/bdwgc) When ephemerons marking results in pushing a large number of objects, the mark stack may overflow. While the processing could be batched, the simplest approach is to allow the callback to return false to indicate a failure and increasing the mark stack size. * include/gc/gc_mark.h (GC_on_mark_stack_empty_proc): New public type. * include/gc/gc_mark.h (GC_set_on_mark_stack_empty, GC_get_on_mark_stack_empty): New public function declaration. * mark.c (GC_on_mark_stack_empty): New static variable. * mark.c (GC_set_on_mark_stack_empty, GC_get_on_mark_stack_empty): New function implementation. * mark.c (GC_mark_some_inner): If GC_on_mark_stack_empty is non-zero then call it and break if pushed new items or overflowed. * tests/gctest.c [GC_PTHREADS] (main): Call GC_set_on_mark_stack_empty and GC_get_on_mark_stack_empty. Co-authored-by: Ivan Maidanski <ivmai@mail.ru>
* Ensure GC_NO_PTHREAD_SIGMASK defined if no GC_pthread_sigmask prototypeIvan Maidanski2023-02-121-0/+2
| | | | | | | | | (fix of commit 155429702) * include/gc/gc_pthread_redirects.h [!GC_PTHREAD_REDIRECTS_ONLY && !GC_NO_PTHREAD_SIGMASK && !(GC_PTHREAD_SIGMASK_NEEDED || _BSD_SOURCE || _GNU_SOURCE || _POSIX_C_SOURCE>=199506L || _XOPEN_SOURCE>=500)] (GC_NO_PTHREAD_SIGMASK): Define macro.
* Document GC_print_free_list shortly in gc_inline.hIvan Maidanski2023-02-121-0/+2
| | | | | * include/gc/gc_inline.h (GC_print_free_list): Add comment; specify that the function is not defined if NO_DEBUGGING.
* Generalize finalizers interruption APIIvan Maidanski2023-02-081-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (fix of commit e71a7d653) * finalize.c (GC_interrupt_finalizers): Move definition upper (to be before GC_enqueue_all_finalizers); change type from GC_bool to unsigned; update comment. * finalize.c [!JAVA_FINALIZATION_NOT_NEEDED] (GC_finalize_all): Set GC_interrupt_finalizers to 0 after GC_enqueue_all_finalizers() call. * finalize.c (GC_set_interrupt_finalizers): Add unsigned argument; set GC_interrupt_finalizers to the argument value. * finalize.c (GC_set_interrupt_finalizers, GC_invoke_finalizers): Wrap access to GC_interrupt_finalizers into LOCK/UNLOCK. * finalize.c (GC_get_interrupt_finalizers): New public function definition. * finalize.c (GC_invoke_finalizers): Do not break the loop (because of non-zero GC_interrupt_finalizers) on the first iteration or if iteration number is smaller than GC_interrupt_finalizers value. * finalize.c (GC_notify_or_invoke_finalizers): Update comment for the reset of *pnested. * finalize.c [!THREADS] (GC_notify_or_invoke_finalizers): Allow finalize_now to be non-null in the assertion in case of a non-zero value of GC_interrupt_finalizers. * include/gc/gc.h (GC_set_interrupt_finalizers): Update comment; add unsigned argument. * include/gc/gc.h (GC_get_interrupt_finalizers): New public function declaration. * tests/gctest.c [GC_PTHREADS && !GC_NO_FINALIZATION] (main): Call GC_set_interrupt_finalizers() and GC_get_interrupt_finalizers().
* New API function (GC_set_interrupt_finalizers) to break finalizer loopBill Holmes2023-02-041-0/+4
| | | | | | | | | | | | | | | | (cherry-pick of b8a4d0d from Unity-Technologies/bdwgc) GC_invoke_finalizers() can take a long period of time to complete. The client might need a way to safely stop the finalization of objects (e.g., during the shutdown of client's runtime). * finalize.c (GC_interrupt_finalizers): New static variable. * finalize.c (GC_set_interrupt_finalizers): New API function definition. * finalize.c (GC_invoke_finalizers): Break from the loop if GC_interrupt_finalizers. * include/gc/gc.h (GC_set_interrupt_finalizers): New API function declaration.
* Better document missing debugging version for aligned allocation routinesIvan Maidanski2023-01-311-0/+5
| | | | | | | | * dbg_mlc.c (GC_debug_free): Add TODO item to suppress a GC warning. * include/gc/leak_detector.h (aligned_alloc): Add comment that the debugging version is missing. * mallocx.c (GC_memalign): Add TODO item about the missing debugging version.
* Fix store-and-dirty call in GC_CONSIvan Maidanski2023-01-311-1/+2
| | | | | | | | | | | | | | (fix of commit 2e7daad62) GC_PTR_STORE_AND_DIRTY() might be expanded to a debugging version of the store-and-dirty function, thus the former should not be used for pointers returned from the non-debugging version of a GC allocation routine like GC_FAST_MALLOC_GRANS(). * include/gc/gc_inline.h: Add comment that the debugging version of this API is missing. * include/gc/gc_inline.h (GC_CONS): Use GC_ptr_store_and_dirty() instead of GC_PTR_STORE_AND_DIRTY().
* Do not mix debug and non-debug allocations in disclaim testsIvan Maidanski2023-01-311-0/+1
| | | | | | | | | | | | | | | * include/gc/gc_disclaim.h (GC_finalized_malloc): Add comment that the debugging version of the function is missing. * tests/disclaim_bench.c (testobj_new): Use GC_malloc() instead of GC_NEW(). * tests/weakmap.c (weakmap_add, weakmap_new): Likewise. * tests/disclaim_bench.c (testobj_new): Use GC_register_finalizer_no_order() instead of GC_REGISTER_FINALIZER_NO_ORDER(). * tests/disclaim_bench.c (main): Use GC_malloc() instead of GC_MALLOC(). * tests/weakmap.c (weakmap_add, weakmap_new): Use GC_ptr_store_and_dirty() instead of GC_PTR_STORE_AND_DIRTY().
* Define public GC_MALLOC_EXPLICITLY_TYPED_IGNORE_OFF_PAGE()Ivan Maidanski2023-01-311-0/+4
| | | | | | * include/gc/gc_typed.h (GC_MALLOC_EXPLICITLY_TYPED_IGNORE_OFF_PAGE): New macro (defined either to GC_MALLOC_EXPLICITLY_TYPED() or to GC_malloc_explicitly_typed_ignore_off_page()).
* Export setter and getter for pointer checking print proceduresIvan Maidanski2023-01-301-6/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Direct access to GC_same_obj_print_proc, GC_is_visible_print_proc and GC_is_valid_displacement_print_proc is now deprecated. * include/gc/gc.h (GC_same_obj_print_proc, GC_is_valid_displacement_print_proc, GC_is_visible_print_proc): Move the declaration upper (to be right after GC_get_finalizer_notifier); improve comment; add GC_ATTR_DEPRECATED attribute. * include/gc/gc.h (GC_valid_ptr_print_proc_t, GC_same_obj_print_proc_t): New public type. * include/gc/gc.h (GC_same_obj_print_proc): Use GC_same_obj_print_proc_t type. * ptr_chck.c (GC_same_obj_print_proc): Likewise. * include/gc/gc.h (GC_is_valid_displacement_print_proc, GC_is_visible_print_proc): Use GC_valid_ptr_print_proc_t type. * ptr_chck.c (GC_is_valid_displacement_print_proc, GC_is_visible_print_proc): Likewise. * include/gc/gc.h (GC_set_same_obj_print_proc, GC_get_same_obj_print_proc, GC_set_is_valid_displacement_print_proc, GC_get_is_valid_displacement_print_proc, GC_set_is_visible_print_proc, GC_get_is_visible_print_proc): New public function declaration. * ptr_chck.c (GC_set_same_obj_print_proc, GC_get_same_obj_print_proc, GC_set_is_valid_displacement_print_proc, GC_get_is_valid_displacement_print_proc, GC_set_is_visible_print_proc, GC_get_is_visible_print_proc): New function definition. * tests/gctest.c [!DBG_HDRS_ALL] (set_print_procs): Use GC_set_is_valid_displacement_print_proc() and GC_set_is_visible_print_proc() instead of setting GC_is_valid_displacement_print_proc and GC_set_is_visible_print_proc variables. * tests/gctest.c [GC_PTHREADS] (main): Call GC_get_is_valid_displacement_print_proc(), GC_get_is_visible_print_proc(), GC_get_same_obj_print_proc() and GC_set_same_obj_print_proc().
* Better document preprocessor-related pointer checking routines in gc.hIvan Maidanski2023-01-301-26/+29
| | | | | | | | | | | | | | More detailed documentation of GC_same_obj, GC_is_visible and GC_is_valid_displacement in gc.h (by moving it from ptr_chck.c). * include/gc/gc.h (GC_oom_fn): Refine comment. * include/gc/gc.h (GC_same_obj): Move declaration down to be (near GC_is_visible). * include/gc/gc.h (GC_same_obj, GC_is_visible, GC_is_valid_displacement): Copy comment from ptr_chck.c; refine comment. * ptr_chck.c (GC_same_obj, GC_is_valid_displacement, GC_is_visible): Remove comment.
* Support GC_memalign with alignments greater than HBLKSIZEIvan Maidanski2023-01-241-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #510 (bdwgc). * allchblk.c (GC_allochblk_nth, GC_allochblk, next_hblk_fits_better, find_nonbl_hblk): Add align_m1 argument. * include/private/gc_priv.h (GC_allochblk, GC_alloc_large): Likewise. * malloc.c (GC_alloc_large): Likewise. * allchblk.c (GC_allochblk): Check that there is no overflow in blocks*HBLKSIZE+align_m1; pass align_m1 to GC_allochblk_nth; try start_list again (with may_split) if non-zero align_m1. * allchblk.c (ALIGN_PAD_SZ): New macro. * allchblk.c (next_hblk_fits_better): Define and use next_ofs local variable; adjust next_hbp passed to GC_is_black_listed(). * allchblk.c (find_nonbl_hblk): Adjust search_end and last_hbp based on align_m1 value. * allchblk.c (GC_allochblk_nth): Add assertion that align_m1+1 is a power of two and that align_m1+1 is 1 or a multiple of HBLKSIZE; define and use align_ofs local variable; add assertion that last_hbp (before GC_install_header() call) is multiple of align_m1+1. * include/gc/gc.h (GC_memalign): Update comment to mention the restriction on align value (should be a power of two and not less than size of a pointer). * include/private/gc_priv.h (GC_allochblk, GC_alloc_large): Update comment (to mention align_m1 argument). * include/private/gc_priv.h (GC_generic_malloc_aligned): Declare function. * include/private/gcconfig.h [(NACL || I386 && (EMSCRIPTEN || WASI)) && !HBLKSIZE && !GC_NO_VALLOC] (HBLKSIZE): Do not define (to 65536 or GETPAGESIZE()); remove TODO item. * malloc.c (GC_alloc_large): Add alignment to n_blocks value (but not to GC_large_allocd_bytes); pass align_m1 to GC_allochblk(); add assertion that result is aligned to align_m1+1. * malloc.c (GC_alloc_large_and_clear): Pass zero align_m1 to GC_alloc_large(). * mallocx.c (GC_generic_malloc_ignore_off_page): Likewise. * malloc.c (GC_generic_malloc_aligned): Move code from GC_generic_malloc; adjust align_m1 to be either zero or not less than HBLKSIZE-1, and pass it to GC_alloc_large(); add comment that the result of GC_oom_fn(lb) might be unaligned. * malloc.c (GC_generic_malloc): Call GC_generic_malloc_aligned() with zero align_m1. * mallocx.c (GC_generic_malloc_ignore_off_page): Expect result of GC_alloc_large() is unlikely to be NULL. * mallocx.c (GC_generic_malloc_many): Pass zero align_m1 to GC_allochblk(). * new_hblk.c (GC_new_hblk): Likewise. * mallocx.c: Do not include limits.h. * mallocx.c (GC_memalign): Remove new_lb local variable; define and use align_m1 local variable; if align is smaller than sizeof(void*) or is not a power of two than return NULL; call GC_generic_malloc_aligned and GC_clear_stack (instead of GC_oom_fn() or GC_malloc()) if align or lb is at least HBLKSIZE/2; replace result%align to result&align_m1; do not result+=offset if offset is zero. * new_hblk.c (GC_new_hblk): Expect result of GC_allochblk() is unlikely to be NULL. * tests/gctest.c (run_one_test): Call GC_memalign() also for bigger alignment values (up to HBLKSIZE*4).
* Document that GC_unregister_my_thread result value is dummyIvan Maidanski2022-12-191-1/+1
| | | | | | | | | | * include/gc/gc.h [GC_THREADS] (GC_unregister_my_thread): Refine comment (mention that GC_SUCCESS is always returned). * tests/gctest.c [THREADS] (check_heap_stats): Cast call of GC_unregister_my_thread() to void. * win32_threads.c (GC_win32_start_inner, GC_ExitThread): Likewise. * win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1 && !NO_CRT] (GC_endthreadex): Likewise.
* Redirect aligned_alloc() in leak_detector.hIvan Maidanski2022-11-021-0/+2
| | | | | | Issue #494 (bdwgc). * include/gc/leak_detector.h (aligned_alloc): Redefine to GC_memalign.
* Redirect reallocarray() in leak_detector.hIvan Maidanski2022-11-021-0/+2
| | | | | | | | | Issue #491 (bdwgc). * doc/leak.md: Mention reallocarray function; reorder redirected functions list. * include/gc/leak_detector.h (reallocarray): Redefine to GC_REALLOC(). * tests/leak.c (main): Call reallocarray() in a loop.
* Define public GC_[p]valloc() and redirect to them in leak_detector.hIvan Maidanski2022-10-282-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #495 (bdwgc). * doc/README.macros (GC_NO_VALLOC): Document. * doc/leak.md: Mention GNU valloc and pvalloc functions. * include/gc/gc.h (GC_memalign): Remove comment that it is not tested; add comment describing the functionality and a note. * include/gc/gc.h [!GC_NO_VALLOC] (GC_valloc, GC_pvalloc): Declare new API function. * include/gc/leak_detector.h [!GC_NO_VALLOC] (valloc, pvalloc): Redefine to the corresponding GC_ function. * include/private/gc_priv.h (GC_page_size): Add comment. * include/private/gc_priv.h (GC_real_page_size): Declare new variable (or as a macro). * include/private/gcconfig.h [NACL] (GETPAGESIZE): Add TODO item. * mallocx.c (GC_memalign): Likewise. * tests/gctest.c (run_one_test): Likewise. * include/private/gcconfig.h [CYGWIN32 && (MPROTECT_VDB || USE_MUNMAP) || !MSWIN32 && !MSWINCE && !CYGWIN32 && (GC_DISABLE_INCREMENTAL || DEFAULT_VDB) && !USE_MMAP] (ALT_PAGESIZE_USED): Define macro. * include/private/gcconfig.h [CYGWIN32 && (MPROTECT_VDB || USE_MUNMAP) || !MSWIN32 && !MSWINCE && !CYGWIN32 && (GC_DISABLE_INCREMENTAL || DEFAULT_VDB) && !USE_MMAP && !GC_NO_VALLOC] (REAL_PAGESIZE_NEEDED): Likewise. * mallocx.c (GC_strdup): Reformat comment. * mallocx.c [!GC_NO_VALLOC] (GC_valloc, GC_pvalloc): Implement. * os_dep.c [REAL_PAGESIZE_NEEDED] (GC_real_page_size): Define variable. * os_dep.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_setpagesize): Replace CYGWIN32&&(MPROTECT_VDB||USE_MUNMAP) to ALT_PAGESIZE_USED; remove comment that a separate variable could be added; reformat comment; assert about GC_pagesize only if REAL_PAGESIZE_NEEDED. * os_dep.c [ALT_PAGESIZE_USED && REAL_PAGESIZE_NEEDED] (GC_setpagesize): Set GC_real_page_size. * os_dep.c [!MSWIN32 && !MSWINCE && !CYGWIN32] (GC_setpagesize): Replace MPROTECT_VDB||PROC_VDB||SOFT_VDB||USE_MMAP to !ALT_PAGESIZE_USED. * tests/gctest.c [!GC_NO_VALLOC] (run_one_test): Call GC_valloc() and GC_pvalloc().
* Replace C-style casts in C++ headersIvan Maidanski2022-10-202-9/+12
| | | | | | | | | | | | (refactoring) * include/gc/gc_allocator.h (gc_allocator::max_size, gc_allocator_ignore_off_page::max_size, traceable_allocator::max_size): Use static_cast<> instead of C-style cast. * include/gc/gc_cpp.h (gc_cleanup::cleanup, gc_cleanup::gc_cleanup): Use reinterpret_cast<> instead of C-style cast. * include/gc/gc_cpp.h [!GC_NO_FINALIZATION] (gc_cleanup::gc_cleanup): Replace NULL to 0.