Ivan Maidanski [Wed, 11 Jul 2018 06:07:30 +0000 (09:07 +0300)]
Fix 'pointer arithmetic with NULL' code defect in print_callers
* os_dep.c [NEED_CALLINFO && LINUX && !SMALL_CONFIG] (GC_print_callers):
If nl is null then pass result_len (instead of nl-result_buf) to strncmp;
adjust code indentation.
Ivan Maidanski [Thu, 5 Jul 2018 14:38:11 +0000 (17:38 +0300)]
Fix test_cpp failure in case GC_DEBUG is defined
Now GC_bytes_freed is updated even if the real deallocation of the
explicitly freed object is deferred.
* dbg_mlc.c (GC_debug_free): Increment GC_bytes_freed by hhdr->hb_sz
in case of GC_free is not called (when the object is filled with
GC_FREED_MEM_MARKER); add comment.
Ivan Maidanski [Thu, 5 Jul 2018 04:17:09 +0000 (07:17 +0300)]
Remove multi-line macros (ITERATE_DL_HASHTBL_*) in finalize
(code refactoring)
* finalize.c (ITERATE_DL_HASHTBL_BEGIN, ITERATE_DL_HASHTBL_END,
DELETE_DL_HASHTBL_ENTRY): Remove macro.
* finalize.c (GC_make_disappearing_links_disappear): Add
is_remove_dangling argument (true means removal of dangling disappearing
links, false means make the disappearing links disappear); rename curr
and next local variables to curr_dl and next_dl, respectively; expand
ITERATE_DL_HASHTBL_BEGIN, DELETE_DL_HASHTBL_ENTRY and
ITERATE_DL_HASHTBL_END macros; remove real_ptr local variable; reformat
code.
* finalize.c (GC_remove_dangling_disappearing_links): Remove.
Ivan Maidanski [Sat, 30 Jun 2018 04:37:54 +0000 (07:37 +0300)]
Compute GC_CONS arguments just once
(fix of commit 8eb6f8d)
* include/gc_inline.h (GC_CONS): Declare l and r local variables;
compute first and second expression even in case of
GC_MALLOC_WORDS_KIND failure; pass l and r to GC_reachable_here (instead
of first and second).
Ivan Maidanski [Fri, 22 Jun 2018 22:17:46 +0000 (01:17 +0300)]
Fix mark stack overflow checking in push_selected
* mark.c (GC_push_selected): In case of a danger of mark stack overflow
after the first GC_push_all() call then call GC_push_all(bottom, top)
and return; remove redundant checking of GC_mark_stack_top at the end
of the function (overflow is already checked in GC_push_all).
Ivan Maidanski [Fri, 22 Jun 2018 21:42:30 +0000 (00:42 +0300)]
Add GC_reachable_here after GC_dirty in GC source
(fix of commits 73d30d2b4, e5fb574cf)
* README.md (Incremental Collection): Add note about bugs caused by
a missing GC_reachable_here call.
* doc/gcdescr.md (Generational Collection): Mention GC_reachable_here
for MANUAL_VDB mode.
* finalize.c (GC_register_disappearing_link_inner,
GC_register_finalizer_inner): Move GC_dirty(new_dl) call to be before
unlocking (so that to ensure no collection occurs between initialization
of new_dl and GC_dirty() call).
* finalize.c (GC_finalize): Call GC_dirty() immediately after updating
GC_fnlz_roots.fo_head (instead of setting needs_barrier) if
GC_object_finalized_proc is set.
* gcj_mlc.c (GC_gcj_malloc, GC_debug_gcj_malloc,
GC_gcj_malloc_ignore_off_page): Call
REACHABLE_AFTER_DIRTY(ptr_to_struct_containing_descr) after GC_dirty(op).
* include/gc.h (GC_end_stubborn_change): Mention GC_reachable_here
in comment.
* include/gc_inline.h (GC_FAST_MALLOC_GRANS): Call
GC_reachable_here(next) after GC_end_stubborn_change(my_fl); remove
GC_end_stubborn_change() call when a non-pointer is stored to my_fl;
remove GC_end_stubborn_change() after GC_generic_malloc_many() call.
* include/gc_inline.h (GC_CONS): Call GC_reachable_here for the stored
pointers after GC_end_stubborn_change call.
* include/private/gc_priv.h (REACHABLE_AFTER_DIRTY): New macro.
* mallocx.c [MANUAL_VDB] (GC_generic_malloc_many): If
GC_is_heap_ptr(result) then call GC_dirty(result) and
REACHABLE_AFTER_DIRTY(op) after storing op pointer.
* typd_mlc.c (GC_make_sequence_descriptor): Call REACHABLE_AFTER_DIRTY
for the stored pointers after GC_dirty(result).
* typd_mlc.c (GC_malloc_explicitly_typed,
GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed):
Call REACHABLE_AFTER_DIRTY(d) after GC_dirty(op).
* win32_threads.c (GC_CreateThread, GC_beginthreadex,
GC_pthread_create): Call REACHABLE_AFTER_DIRTY for the stored pointer
after GC_dirty.
Ivan Maidanski [Thu, 21 Jun 2018 21:57:09 +0000 (00:57 +0300)]
Add GC_reachable_here after GC_END_STUBBORN_CHANGE in tests
(fix of commits b52c140d3, f72fc9d43, 08a380c3a)
* tests/disclaim_test.c (pair_dct, pair_new): Call GC_reachable_here
for the stored pointers after GC_end_stubborn_change call.
* tests/staticrootslib.c (libsrl_mktree): Call GC_reachable_here for
the stored pointers after GC_END_STUBBORN_CHANGE call.
* tests/test.c (cons, small_cons, small_cons_uncollectable, mktree,
typed_test): Likewise.
* tests/test.c [GC_GCJ_SUPPORT] (gcj_cons): Likewise.
* tests/test.c [!SMALL_CONFIG && !GC_DEBUG] (alloc8bytes): Likewise.
* tests/test_cpp.cc [!DONT_USE_STD_ALLOCATOR] (main): Likewise.
* tests/trace_test.c (mktree): Likewise.
* tests/test.c (reverse_test_inner): Declare tmp local variable; call
GC_END_STUBBORN_CHANGE() and GC_reachable_here() after storing pointers
to f[5], g[799] and h[1999].
* tests/test_cpp.cc (C_INIT_LEFT_RIGHT): New macro (to call
GC_END_STUBBORN_CHANGE and GC_reachable_here).
* tests/test_cpp.cc (C::C): Use C_INIT_LEFT_RIGHT().
* tests/test_cpp.cc (main): Remove GC_end_stubborn_change(c) call after
because GC_END_STUBBORN_CHANGE() is now called for this (in
C_INIT_LEFT_RIGHT) of the heap-allocated objects.
Ivan Maidanski [Thu, 21 Jun 2018 10:38:56 +0000 (13:38 +0300)]
Add GC_reachable_here after GC_END_STUBBORN_CHANGE in cords
(fix of commit e12e820f3)
* cord/cordbscs.c (CORD_cat_char_star, CORD_cat, CORD_from_fn_inner,
CORD_substr_closure): Call GC_END_STUBBORN_CHANGE() instead of
GC_end_stubborn_change().
* cord/cordxtra.c (refill_cache): Likewise.
* cord/tests/de.c (prune_map, add_map, add_hist, replace_line,
generic_init): Likewise.
* cord/cordbscs.c (CORD_cat_char_star, CORD_cat): Mark x and y as
reachable after GC_END_STUBBORN_CHANGE(result).
* cord/cordbscs.c (CORD_from_fn_inner): Mark client_data as reachable
after GC_END_STUBBORN_CHANGE(result).
* cord/cordbscs.c (CORD_substr_closure): Mark x as reachable after
GC_END_STUBBORN_CHANGE(sa).
* cord/tests/de.c (prune_map): Mark saved map->previous->previous as
reachable after GC_END_STUBBORN_CHANGE(map).
* cord/tests/de.c (add_map): Mark saved current_map as reachable after
GC_END_STUBBORN_CHANGE(new_map).
* cord/tests/de.c (replace_line): Mark s as reachable after
GC_END_STUBBORN_CHANGE(screen+i).
Ivan Maidanski [Wed, 20 Jun 2018 08:52:33 +0000 (11:52 +0300)]
Really use C11 static_assert if available (GCC/Clang/MSVC)
(fix of commit 7d34f4e5c)
Issue #223 (bdwgc).
Improve static assertion message as well.
* include/private/gc_priv.h [__STDC_VERSION__>=201112L]: Include
assert.h (to have static_assert defined).
* include/private/gc_priv.h [_MSC_VER>=1700] (GC_STATIC_ASSERT): Define
as static_assert.
* include/private/gc_priv.h [static_assert && __STDC_VERSION__>=201112L]
(GC_STATIC_ASSERT): Pass #expr as the 2nd argument to static_assert
(instead of "").
Ivan Maidanski [Wed, 20 Jun 2018 08:35:55 +0000 (11:35 +0300)]
Add missing type casts in remap and register_my_thread_inner
(fix of commit a825a2d)
Issue #206 (bdwgc).
* os_dep.c [USE_MUNMAP && USE_WINALLOC] (GC_remap): Cast result of
VirtualAlloc to ptr_t.
* win32_threads.c [!GC_NO_THREADS_DISCOVERY]
(GC_register_my_thread_inner): Cast the first argument of
InterlockedExchange() call to word* (instead of void*).
Ivan Maidanski [Wed, 20 Jun 2018 07:56:19 +0000 (10:56 +0300)]
Fix VirtualQuery call in case of malloc failure (Win32)
* os_dep.c [!REDIRECT_MALLOC && USE_WINALLOC]
(GC_add_current_malloc_heap): Do not call GC_get_allocation_base(new_l)
if new_l is null; cast malloc() result to the type of new_l.
Ivan Maidanski [Wed, 20 Jun 2018 07:36:25 +0000 (10:36 +0300)]
Do not include windows.h when compiling gc_cpp.cc
(code refactoring)
* gc_cpp.cc (GC_DONT_INCL_WINDOWS_H): Define macro before include gc.h.
* tests/test_cpp.cc (GC_DONT_INCL_WINDOWS_H): Likewise.
* include/gc.h [GC_WIN32_THREADS && (!GC_PTHREADS || GC_BUILD
|| GC_WINDOWS_H_INCLUDED) && (!GC_NO_THREAD_DECLS || GC_BUILD)]:
If GC_DONT_INCL_WINDOWS_H then do not include process.h, windows.h,
and do not declare GC_CreateThread, GC_ExitThread, GC_DllMain,
GC_beginthreadex, GC_endthreadex.
Ivan Maidanski [Wed, 20 Jun 2018 07:20:22 +0000 (10:20 +0300)]
Fast fail on invalid CPU parameter passed to NT_MAKEFILE
Issue #223 (bdwgc).
* NT_MAKEFILE (OBJS): Move misc.obj and win32_threads.obj to the
beginning of the list.
* NT_MAKEFILE (gctest.exe): Move $(GC_LIB) to the beginning of the list.
Ivan Maidanski [Tue, 19 Jun 2018 09:15:30 +0000 (12:15 +0300)]
Add cpu, make_as_lib, nothreads options to NT_MAKEFILE
The optional cpu=i386 and cpu=AMD64 arguments are now handled properly.
Issue #223 (bdwgc).
* NT_MAKEFILE: Update header comment (document "make_as_lib=1" and
"nothreads=1" options).
* NT_MAKEFILE (CVTRES_CPU): Defined depending on CPU variable value.
* NT_MAKEFILE [!NOTHREADS] (CFLAGS_MT): Define variable.
* NT_MAKEFILE (CFLAGS_GCDLL, GC_LIB, LINK_GC, GC_DLL, LINK_DLL_FLAGS):
Define depending on the value of MAKE_AS_LIB and CPU variables.
* NT_MAKEFILE (CFLAGS_SPECIFIC): Use CFLAGS_GCDLL, CFLAGS_MT.
Ivan Maidanski [Tue, 19 Jun 2018 07:38:55 +0000 (10:38 +0300)]
Do not include 'new' standard header from gc_cpp.h by default
(fix of commit cb1194d17)
* gc_cpp.cc: Include gc.h (before "new") and "new" standard header
(before gc_cpp.h).
* gc_cpp.cc (GC_ALLOCATOR_THROW_OR_ABORT): New macro (the same
definition as in gc_allocator.h).
* gc_cpp.cc (GC_throw_bad_alloc): New API function definition.
* gc_cpp.cc [!GC_NEW_DELETE_THROW_NOT_NEEDED]
(GC_NEW_DELETE_NEED_THROW): Do not define if _MSC_VER or __DMC__.
* gc_cpp.cc [!_MSC_VER && !__DMC__] (new, new[]): Replace
GC_OP_NEW_OOM_CHECK(obj) to if(!obj)GC_ALLOCATOR_THROW_OR_ABORT().
* gc_cpp.h: Include "new" standard header only if GC_INCLUDE_NEW
and !GC_NEW_ABORTS_ON_OOM and !_LIBCPP_NO_EXCEPTIONS.
* gc_cpp.h [!GC_NEW_ABORTS_ON_OOM && !_LIBCPP_NO_EXCEPTIONS
&& !GC_INCLUDE_NEW] (GC_throw_bad_alloc): Declare API function.
* gc_cpp.h [!GC_NEW_ABORTS_ON_OOM && !_LIBCPP_NO_EXCEPTIONS
&& !GC_INCLUDE_NEW] (GC_OP_NEW_OOM_CHECK): Call GC_throw_bad_alloc()
instead of throw std::bad_alloc; do not use do-while(0) (to eliminate
VC++ warning that the expression is always false).
Ivan Maidanski [Mon, 18 Jun 2018 23:35:33 +0000 (02:35 +0300)]
Eliminate 'declaration of var hides global declaration' compiler warning
* cord/tests/de.c (add_map): Rename line argument to line_arg.
* cord/tests/de_win.c (get_line_rect): Likewise.
* cord/tests/de_win.c (WndProc): Rename hwnd argument to hwnd_arg.
* cord/tests/de_win.c (invalidate_line): Rename line local variable to
line_r.
Ivan Maidanski [Mon, 18 Jun 2018 21:50:07 +0000 (00:50 +0300)]
Remove duplicate local variable in reclaim_block
(fix of commit 6c1a92445)
* reclaim.c [ENABLE_DISCLAIM] (GC_reclaim_block): Remove duplicate ok
local variable definition (which hides the one in the outermost block
and has the same value).
Ivan Maidanski [Thu, 14 Jun 2018 23:27:11 +0000 (02:27 +0300)]
Fix large object base computation in PUSH_CONTENTS() if MARK_BIT_PER_OBJ
Issue #177 (bdwgc).
* include/private/gc_pmark.h [MARK_BIT_PER_OBJ] (PUSH_CONTENTS_HDR):
Do not call LONG_MULT() if inv_sz == LARGE_INV_SZ; set base to
hhdr->hb_block if inv_sz == LARGE_INV_SZ regardless of low_prod>>16
value; use EXPECT(FALSE) for inv_sz == LARGE_INV_SZ expression;
remove FIXME about offset; adjust assertion to allow hb_block==current.
Ivan Maidanski [Wed, 13 Jun 2018 23:20:34 +0000 (02:20 +0300)]
Remove unnecessary type casts in n_set_marks
(code refactoring)
* reclaim.c (GC_n_set_marks): Change return type from int to unsigned;
change type of result local variable to unsigned.
* reclaim.c [!USE_MARK_BYTES] (set_bits): Likewise.
* reclaim.c (GC_n_set_marks): Change type of i, offset, limit,
n_mark_words, n_objs local variables to word; remove redundant casts.
Ivan Maidanski [Wed, 13 Jun 2018 21:40:46 +0000 (00:40 +0300)]
Skip typed_test in gctest if NO_TYPED_TEST macro is defined
This is purely for a debugging purpose.
* tests/test.c: Do not include gc_typed.h if NO_TYPED_TEST.
* tests/test.c [GC_AMIGA_FASTALLOC && AMIGA]
(GC_amiga_gctest_malloc_explicitly_typed,
GC_amiga_gctest_calloc_explicitly_typed): Do not define if NO_TYPED_TEST.
* tests/test.c (bm_huge, typed_test): Likewise.
* tests/test.c [!DBG_HDRS_ALL] (run_one_test): Do not call typed_test
if NO_TYPED_TEST.
Ivan Maidanski [Fri, 8 Jun 2018 20:21:38 +0000 (23:21 +0300)]
Fix 'scope of var can be reduced' cppcheck warnings in check_heap_stats
(fix of commit 4e909d2)
Also, print the message about the leak-find mode just once per gctest
execution.
* tests/test.c (INIT_FIND_LEAK): Define macro.
* tests/test.c (GC_COND_INIT): Invoke INIT_FIND_LEAK.
* tests/test.c (run_one_test): Remove print about leak-find mode.
* tests/test.c [!GC_NO_FINALIZATION] (check_heap_stats): Move
still_live and still_long_live local variables to the block of their
usage.
Ivan Maidanski [Fri, 8 Jun 2018 08:34:23 +0000 (11:34 +0300)]
Use noexcept specifier in gc_cpp if C++11
* gc_cpp.cc [!_MSC_VER && !__DMC__] (delete, delete[]): Rename
GC_DECL_DELETE_THROW to GC_NOEXCEPT.
* include/gc_cpp.h: Always include "new" header.
* include/gc_cpp.h [!GC_NEW_DELETE_THROW_NOT_NEEDED]
(GC_NEW_DELETE_NEED_THROW): Do not define if __BORLANDC__ or _MSC_VER,
or __WATCOMC__, or if __cplusplus>=201103L and !__clang__.
* include/gc_cpp.h (GC_DECL_DELETE_THROW): Remove.
* include/gc_cpp.h [!GC_NOEXCEPT] (GC_NOEXCEPT): Define internal macro
to except or throw(), or nothing (same as that in gc_allocator.h).
* include/gc_cpp.h [!GC_NEW_ABORTS_ON_OOM] (GC_NEW_ABORTS_ON_OOM):
Define if GC_NOEXCEPT is defined to nothing.
* include/gc_cpp.h (new(size_t,void*), new[](size_t,void*), delete):
Add GC_NOEXCEPT.
Ivan Maidanski [Thu, 7 Jun 2018 09:09:57 +0000 (12:09 +0300)]
Fix gctest in leak-finding mode
* tests/test.c [!FIND_LEAK] (mktree): Do not call GC_REGISTER_FINALIZER
and GC_GENERAL_REGISTER_DISAPPEARING_LINK if GC_get_find_leak().
* tests/test.c (run_one_test): Replace "ifdef FIND_LEAK" with
if(GC_get_find_leak()).
* tests/test.c (check_heap_stats): Do not fail on unexpected heap
growth if GC_get_find_leak().
Ivan Maidanski [Thu, 7 Jun 2018 08:39:27 +0000 (11:39 +0300)]
Use noexcept in gc_allocator
* include/gc_allocator.h [!GC_NOEXCEPT] (GC_NOEXCEPT): Define internal
macro (to noexcept if C++11, otherwise to throw() or nothing); define
GC_NEW_ABORTS_ON_OOM if GC_NOEXCEPT is defined to nothing.
* include/gc_allocator.h (gc_allocator(), deallocate, operator==,
operator!=, gc_allocator_ignore_off_page()): Add GC_NOEXCEPT.
* include/gc_allocator.h (gc_allocator, gc_allocator_ignore_off_page,
traceable_allocator): Replace throw() to GC_NOEXCEPT.
* include/gc_allocator.h (deallocate): Remove outdated comment that
p should be non-null.
Ivan Maidanski [Wed, 6 Jun 2018 22:08:07 +0000 (01:08 +0300)]
Never return null by C++ GC allocators
Now, in case of the allocation failure, the allocators (defined in
gc_allocator.h or new_gc_alloc.h) throw bad_alloc (or abort the
application if compiled without exceptions support).
* include/gc_allocator.h (GC_ALLOCATOR_THROW_OR_ABORT): New macro
(either throws bad_alloc or calls GC_abort_on_oom).
* include/gc_allocator.h (GC_selective_alloc,
traceable_allocator::allocate): Call GC_ALLOCATOR_THROW_OR_ABORT() if
the allocation failed.
* include/new_gc_alloc.h (GC_ALLOCATOR_THROW_OR_ABORT): New macro
(redirected to GC_abort_on_oom).
* include/new_gc_alloc.h (GC_out_of_line_malloc,
single_client_gc_alloc_template::allocate,
single_client_gc_alloc_template::ptr_free_allocate,
single_client_traceable_alloc_template::allocate,
single_client_traceable_alloc_template::ptr_free_allocate,
gc_alloc_template::allocate, gc_alloc_template::ptr_free_allocate,
traceable_alloc_template::allocate,
traceable_alloc_template::ptr_free_allocate): Call
GC_ALLOCATOR_THROW_OR_ABORT() instead of returning 0.
* include/new_gc_alloc.h (simple_alloc::allocate): If n is 0 then
allocate 1 byte.
* include/new_gc_alloc.h (simple_alloc::deallocate): If n is 0 then
call ptr_free_deallocate for 1-byte object.
Ivan Maidanski [Mon, 4 Jun 2018 20:04:17 +0000 (23:04 +0300)]
Eliminate 'cast between incompatible function types' compiler warning
* cord/cordxtra.c (refill_cache): Add GC_CALLBACK; change return type
from char to void*; change argument type from refill_data* to void*;
add necessary casts to client_data and the return expression.
* cord/cordxtra.c (CORD_lf_func): Do not cast refill_cache.
* os_dep.c [MPROTECT_VDB] (GC_write_fault_handler,
GC_mprotect_dirty_init): Cast SIG_DFL, SIG_IGN and oldact.sa_handler
to SIG_HNDLR_PTR via signed_word type.
* os_dep.c [MPROTECT_VDB && !MSWIN32 && !MSWINCE]
(GC_write_fault_handler): Cast old_handler to PLAIN_HNDLR_PTR via
signed_word type.
Ivan Maidanski [Mon, 4 Jun 2018 07:04:09 +0000 (10:04 +0300)]
Fix new and delete operators definition for DigitalMars compiler
* gc_cpp.cc (new, delete, new[], delete[]): Do not define if __DMC__.
* include/gc_cpp.h (new[], delete[], new, delete): Define also if
__DMC__.
* include/gc_cpp.h [_MSC_VER] (new[], delete[]): Replace _MSC_VER>1020
to defined(GC_OPERATOR_NEW_ARRAY).
Ivan Maidanski [Tue, 29 May 2018 18:01:23 +0000 (21:01 +0300)]
Make subthreadcreate test compilable even without libatomic_ops
(fix of commit 4becbc906)
* tests/subthread_create.c [HAVE_CONFIG_H]: Update comment.
* tests/subthread_create.c: Do not include gc.h and gc_atomic_ops.h
(and do not define AO_REQUIRE_CAS) unless GC_THREADS is defined.
Ivan Maidanski [Tue, 29 May 2018 17:51:48 +0000 (20:51 +0300)]
Eliminate 'comparing signed and unsigned values' compiler warnings (bcc)
* allchblk.c (GC_allochblk_nth): Cast HBLKSIZE to signed_word in
comparison to size_needed.
* reclaim.c (GC_reclaim_all): Cast hhdr->hb_last_reclaimed to word in
comparison to GC_gc_no-1.
Ivan Maidanski [Thu, 24 May 2018 22:08:25 +0000 (01:08 +0300)]
Fix GC_out_of_line_malloc in new_gc_alloc.h for out-of-memory case
* include/new_gc_alloc.h (GC_out_of_line_malloc): Call
GC_generic_malloc_words_small() before the counters update; do not
update the counters if GC_generic_malloc_words_small() returns 0.
Ivan Maidanski [Thu, 24 May 2018 08:41:51 +0000 (11:41 +0300)]
Fix test_cpp for MANUAL_VDB
* tests/test_cpp.cc (C(C&), C::operator=): Call new if and only if
level>0.
* tests/test_cpp.cc (C(C&), C::operator=, C(int), main): Call
GC_end_stubborn_change for the result of new operator.
* tests/test_cpp.cc (main): Call GC_end_stubborn_change after update
of *xptr.
Ivan Maidanski [Wed, 23 May 2018 08:14:44 +0000 (11:14 +0300)]
Fix staticroots and trace tests for MANUAL_VDB
* tests/staticrootslib.c (mktree): Call GC_end_stubborn_change() at the
end of function if GC_NEW() was called.
* tests/trace_test.c (mktree): Likewise.
* os_dep.c [NEED_PROC_MAPS] (READ): Move macro definition inside the
function where it is used; undefine the macro at the function end.
* os_dep.c [PROC_VDB] (READ): Likewise.
* os_dep.c [!GWW_VDB] (GC_GWW_AVAILABLE): Define to FALSE.
* os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_page_was_dirty,
GC_page_was_ever_dirty, GC_remove_protection, GC_read_dirty): Collapse
multiple definitions into a single one; reformat code; replace
GC_ATTR_UNUSED with (void)arg.
* os_dep.c [GWW_VDB && MPROTECT_VDB] (GC_gww_page_was_ever_dirty):
Remove.
* os_dep.c [GWW_VDB && !MPROTECT_VDB] (GC_read_dirty): Rename to
GC_gww_read_dirty; define as GC_INLINE.
* os_dep.c [PROC_VDB] (GC_read_dirty): Rename to GC_proc_read_dirty;
define as GC_INLINE.
Ivan Maidanski [Sat, 19 May 2018 09:02:00 +0000 (12:02 +0300)]
Fix FAST_MALLOC_GRANS and malloc_many for MANUAL_VDB
(fix of commit 73d30d2)
This commit actually disables multiple objects allocation in
GC_generic_malloc_many (if MANUAL_VDB and the incremental mode is on);
the proper implementation would require GC_dirty call for each of the
allocated object (except for the last one).
* include/gc_inline.h (GC_FAST_MALLOC_GRANS): Call
GC_end_stubborn_change(my_fl) after GC_generic_malloc_many().
* mallocx.c [MANUAL_VDB] (GC_generic_malloc_many): Always fall back to
GC_generic_malloc (unless !GC_incremental).
Ivan Maidanski [Sat, 19 May 2018 06:50:23 +0000 (09:50 +0300)]
Enable compilation for Cygwin with MPROTECT_VDB
Note: It just compiles but not working.
* include/private/gc_priv.h [GC_WIN32_THREADS && MPROTECT_VDB]
(GC_set_write_fault_handler): Do not declare if CYGWIN32.
* os_dep.c [MPROTECT_VDB && !DARWIN && !USE_WINALLOC]: Do not include
sys/syscall.h if CYGWIN32.
* os_dep.c [MPROTECT_VDB && CYGWIN32] (CODE_OK): Define (to true).
* os_dep.c [MPROTECT_VDB && GC_WIN32_THREADS]
(GC_set_write_fault_handler): Do not define if CYGWIN32.
* win32_threads.c [MPROTECT_VDB] (GC_register_my_thread_inner): Do not
call GC_gww_dirty_init() and GC_set_write_fault_handler() if CYGWIN32.