]> granicus.if.org Git - gc/log
gc
6 years agoUpdate AUTHORS file (add Michael DeRoy)
Ivan Maidanski [Sun, 29 Jul 2018 07:21:04 +0000 (10:21 +0300)]
Update AUTHORS file (add Michael DeRoy)

6 years agoNew configure --disable-threads-discovery option
Michael DeRoy [Sat, 28 Jul 2018 15:09:06 +0000 (18:09 +0300)]
New configure --disable-threads-discovery option
(part of commit 7b2813c from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* configure.ac (threads-discovery): New AC_ARG_ENABLE.
* configure.ac [$enable_threads_discovery=no]
(GC_NO_THREADS_DISCOVERY): Define macro.

6 years agoTravis CI: Output content of disclaim_bench.log
Ivan Maidanski [Sat, 28 Jul 2018 08:45:10 +0000 (11:45 +0300)]
Travis CI: Output content of disclaim_bench.log

6 years agoExport stop/start_world_external only for multi-threaded builds
Ivan Maidanski [Fri, 27 Jul 2018 21:29:59 +0000 (00:29 +0300)]
Export stop/start_world_external only for multi-threaded builds
(fix of commit bb91f03)

Issue #173 (bdwgc).

Also, update GC_world_stopped value in GC_stop_world_external and
GC_start_world_external.

* include/gc.h (GC_stop_world_external, GC_start_world_external): Do not
declare unless GC_THREADS; add comment.
* misc.c (GC_stop_world_external, GC_start_world_external): Do not
define unless THREADS; add assertion that GC is initialized.
* misc.c [THREADS && THREAD_LOCAL_ALLOC] (GC_stop_world_external): Set
GC_world_stopped to true after STOP_WORLD; add assertion that the
world is not stopped.
* misc.c [THREADS && THREAD_LOCAL_ALLOC] (GC_start_world_external): Set
GC_world_stopped to false before START_WORLD; add assertion that the
world is stopped.
* tests/test.c [GC_PTHREADS && CPPCHECK] (main): Add UNTESTED for
GC_stop_world_external and GC_start_world_external.

6 years agoFix UNTESTED for multi-threaded API functions in gctest
Ivan Maidanski [Fri, 27 Jul 2018 21:21:18 +0000 (00:21 +0300)]
Fix UNTESTED for multi-threaded API functions in gctest
(fix of commits c5d4ef9c1857bb8ad6)

* tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && CPPCHECK
&& THREADS] (main): Remove UNTESTED for GC_allow_register_threads,
GC_get_on_thread_event, GC_register_altstack, GC_set_on_thread_event.
* tests/test.c [GC_PTHREADS && CPPCHECK] (main): Add UNTESTED for
GC_allow_register_threads, GC_get_on_thread_event,
GC_register_altstack, GC_set_on_thread_event.

6 years agoNew API to stop and start the GC world externally
Jonas Echterhoff [Fri, 27 Jul 2018 15:11:03 +0000 (18:11 +0300)]
New API to stop and start the GC world externally
(part of commits 39e14be05e3377 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* include/gc.h (GC_stop_world_external, GC_start_world_external):
Declare new API function.
* misc.c (GC_stop_world_external, GC_start_world_external): Implement.

6 years agoUpdate AUTHORS file (add Jonas Echterhoff)
Ivan Maidanski [Fri, 27 Jul 2018 12:44:39 +0000 (15:44 +0300)]
Update AUTHORS file (add Jonas Echterhoff)

6 years agoFix the BDWGC build on XboxOne
Jonas Echterhoff [Thu, 14 Jun 2018 18:56:18 +0000 (20:56 +0200)]
Fix the BDWGC build on XboxOne
(fix of commit d16debf)

Issue #173 (bdwgc).

This fixes durango_get_mem() definition.

* os_dep.c [MSWIN_XBOX1] (durango_get_mem): Define even if
MMAP_SUPPORTED is not defined.

6 years agoFix suspend_thread_list in case of thread_suspend is interrupted
Ivan Maidanski [Fri, 27 Jul 2018 10:01:19 +0000 (13:01 +0300)]
Fix suspend_thread_list in case of thread_suspend is interrupted
(fix of commit e8cdc7c)

* darwin_stop_world.c [!GC_NO_THREADS_DISCOVERY]
(GC_suspend_thread_list): Retry thread_suspend if failed with
KERN_ABORTED.

6 years agoPerform thread_suspend in loop as it may be interrupted (Darwin)
Jonathan Chambers [Tue, 24 Jul 2018 20:46:52 +0000 (16:46 -0400)]
Perform thread_suspend in loop as it may be interrupted (Darwin)

* darwin_stop_world.c (GC_stop_world): Retry thread_suspend() on
KERN_ABORTED.

6 years agoRemove PUSH_CONTENTS_HDR multi-line macro
Ivan Maidanski [Thu, 26 Jul 2018 05:07:46 +0000 (08:07 +0300)]
Remove PUSH_CONTENTS_HDR multi-line macro
(code refactoring)

* include/private/gc_pmark.h (PUSH_CONTENTS): Use GC_push_contents_hdr
instead of PUSH_CONTENTS_HDR.
* mark.c (GC_mark_and_push, GC_mark_and_push_stack): Likewise.
* include/private/gc_pmark.h (PUSH_CONTENTS_HDR): Replace macro
definitions with a unified inline function (GC_push_contents_hdr);
return updated value of mark_stack_top; remove unnecessary type casts
and parentheses.
* include/private/gc_priv.h [!KEEP_BACK_PTRS] (GC_STORE_BACK_PTR): Cast
source argument to void (to avoid "unused argument" compiler warning).

6 years agoUpdate copyright information in alloc.c and gc.c
Ivan Maidanski [Thu, 26 Jul 2018 04:51:50 +0000 (07:51 +0300)]
Update copyright information in alloc.c and gc.c
(fix of commit 3bd265a)

* README.md (Copyright & Warranty): Adjust copyright date.
* alloc.c: Update header copyright (add Ivan Maidanski).
* extra/gc.c: Likewise.
* alloc.c (GC_copyright): Update copyright string value.

6 years agoAdd outermost parentheses to HCE definition
Ivan Maidanski [Wed, 25 Jul 2018 09:28:40 +0000 (12:28 +0300)]
Add outermost parentheses to HCE definition
(code refactoring)

* include/private/gc_hdrs.h [COUNT_HDR_CACHE_HITS] (HC_HIT, HC_MISS):
Cast result to void.
* include/private/gc_hdrs.h (HCE): Wrap the whole expression into
parentheses.

6 years agoUpdate copyright information in the documentation and gc.h files
Ivan Maidanski [Sun, 22 Jul 2018 09:17:42 +0000 (12:17 +0300)]
Update copyright information in the documentation and gc.h files

* AUTHORS: Add info about the maintainer.
* README.QUICK: Update header copyright (add Ivan Maidanski).
* include/gc.h: Likewise.
* README.md (Copyright & Warranty): Update copyright (add the
missing copyrights from the source code files).
* doc/gc.man (.TH): Update modification date.
* doc/gc.man (.SH AUTHOR): Update; add reference to AUTHORS file.

6 years agoRemove libatomic_ops license information
Ivan Maidanski [Sun, 22 Jul 2018 08:34:34 +0000 (11:34 +0300)]
Remove libatomic_ops license information

atomic_ops library is not included in BDWGC distribution since v7.4.

* README.md (Copyright & Warranty): Remove libatomic_ops license
information.

6 years agowindows-untested: Update copyright in gc.ver
Ivan Maidanski [Fri, 20 Jul 2018 21:14:20 +0000 (00:14 +0300)]
windows-untested: Update copyright in gc.ver

6 years agoRemove info how to send bugs from README.cords
Ivan Maidanski [Fri, 20 Jul 2018 21:07:17 +0000 (00:07 +0300)]
Remove info how to send bugs from README.cords

* doc/README.cords: Remove information about sending bugs from this
file (clients should refer to the base README regarding bugs
submission).

6 years agoDo not use NULL in gc_inline.h
Ivan Maidanski [Fri, 20 Jul 2018 20:44:50 +0000 (23:44 +0300)]
Do not use NULL in gc_inline.h
(fix of commits 64bed186f0ff8f033c)

* include/gc_inline.h (GC_FAST_MALLOC_GRANS, GC_CONS): Replace NULL
to 0.

6 years agoUpdate ChangeLog file
Ivan Maidanski [Fri, 20 Jul 2018 20:30:22 +0000 (23:30 +0300)]
Update ChangeLog file

6 years agoUpdate ChangeLog file (v7.6 changes only)
Ivan Maidanski [Thu, 19 Jul 2018 21:46:27 +0000 (00:46 +0300)]
Update ChangeLog file (v7.6 changes only)
(a cherry-pick of commit 0584756c from 'release-7_6')

6 years agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Thu, 19 Jul 2018 08:40:18 +0000 (11:40 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)
(a cherry-pick of commit d46e0fda from 'release-7_4')

6 years agoUpdate NT_MAKEFILE usage information in README files for Win32 and Win64
Ivan Maidanski [Thu, 12 Jul 2018 07:40:41 +0000 (10:40 +0300)]
Update NT_MAKEFILE usage information in README files for Win32 and Win64

Issue #223 (bdwgc).

* doc/README.win32 (Microsoft Tools): Provide a sample how to build
static library without threads support.
* doc/README.win64: Likewise.
* doc/README.win32 (Threads): Provide a sample how to build dynamic
collector with threads support using NT_MAKEFILE.
* doc/README.win64: Likewise.

6 years agoFix Borland version in documentation to match that in BCC_MAKEFILE
Ivan Maidanski [Thu, 12 Jul 2018 06:26:45 +0000 (09:26 +0300)]
Fix Borland version in documentation to match that in BCC_MAKEFILE

* doc/README.win32: Rename "Borland 4.5" to "Borland C++ Builder".
* doc/README.win32 (Borland Tools): Change version from 4.5 to 5.5.

6 years agoFix GC_is_valid_displacement and GC_is_visible for non-small objects
Ivan Maidanski [Wed, 11 Jul 2018 20:09:00 +0000 (23:09 +0300)]
Fix GC_is_valid_displacement and GC_is_visible for non-small objects

* ptr_chck.c (GC_is_valid_displacement): Remove redundant
IS_FORWARDING_ADDR_OR_NIL(hhdr) call if GC_all_interior_pointers.
* ptr_chck.c (GC_is_valid_displacement): Do not goto fail if
p+sz-offset > h+1 but IS_FORWARDING_ADDR_OR_NIL(HDR(h+1)).
* ptr_chck.c (GC_is_visible): Transform comment about GC_base to
a TODO item; set hhdr to HDR(base) instead of HDR(p)
if HBLKPTR(base)!=HBLKPTR(p).

6 years agoFix build for Android after enabling handle-fork by default
Ivan Maidanski [Wed, 11 Jul 2018 08:42:12 +0000 (11:42 +0300)]
Fix build for Android after enabling handle-fork by default
(fix of commit 686a667)

Issue #174 (bdwgc).

* CMakeLists.txt [CMAKE_USE_PTHREADS_INIT]: Do not define HANDLE_FORK
macro for android host.
* configure.ac [$enable_handle_fork!=yes/no/manual && THREADS=xposix]:
Likewise.

6 years agoUpdate AUTHORS file (add woollybah)
Ivan Maidanski [Wed, 11 Jul 2018 07:41:36 +0000 (10:41 +0300)]
Update AUTHORS file (add woollybah)

6 years agoFix build for Nintendo platform
Bruce A Henderson [Wed, 11 Jul 2018 07:39:28 +0000 (10:39 +0300)]
Fix build for Nintendo platform
(fix of commit 9718229)

Issue #228 (bdwgc).

The NINTENDO_SWITCH defines in gcconfig.h were in the wrong section
(under ARM32).  Now they are under AARCH64 instead.

* include/private/gcconfig.h (__arm__): Remove checking of
NN_BUILD_TARGET_PLATFORM_NX.
* include/private/gcconfig.h [AARCH64 && NINTENDO_SWITCH] (__bss_end,
NO_HANDLE_FORK, DATASTART, DATAEND, switch_get_stack_bottom,
STACKBOTTOM): Move from ARM32 section.

6 years agoFix 'pointer arithmetic with NULL' code defect in print_callers
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.

6 years agoEliminate 'ptr arithmetic with NULL' cppcheck warning in alloc_mark_stack
Ivan Maidanski [Tue, 10 Jul 2018 21:41:33 +0000 (00:41 +0300)]
Eliminate 'ptr arithmetic with NULL' cppcheck warning in alloc_mark_stack

* mark.c (alloc_mark_stack): Wrap GC_mark_stack_limit (and
GC_mark_stack, GC_mark_stack_size) assignment into "else" block (after
EXIT).

6 years agoEliminate 'condition is always true' cppcheck warning in init_gcj_malloc
Ivan Maidanski [Tue, 10 Jul 2018 21:22:20 +0000 (00:22 +0300)]
Eliminate 'condition is always true' cppcheck warning in init_gcj_malloc

* gcj_mlc.c (GC_init_gcj_malloc): Define ignore_gcj_info as macro
if GC_IGNORE_GCJ_INFO; undefine ignore_gcj_info at the end of the
function.

6 years agoEliminate 'scope of var can be reduced' cppcheck warning in pthread_join
Ivan Maidanski [Tue, 10 Jul 2018 21:15:49 +0000 (00:15 +0300)]
Eliminate 'scope of var can be reduced' cppcheck warning in pthread_join

* win32_threads.c [GC_PTHREADS && GC_WIN32_PTHREADS] (GC_pthread_join):
Declare t local variable in the block where the variable is used.

6 years agoFix missing dirty and reachable_here calls in typed_test
Ivan Maidanski [Tue, 10 Jul 2018 05:58:08 +0000 (08:58 +0300)]
Fix missing dirty and reachable_here calls in typed_test
(fix of commits b52c140d3263ffbbfd2e7daad62)

* tests/test.c [!NO_TYPED_TEST] (typed_test): Call GC_PTR_STORE_AND_DIRTY
to store old value to newP[1].

6 years agoRemove PUSH_OBJ multi-line macro
Ivan Maidanski [Thu, 5 Jul 2018 17:00:49 +0000 (20:00 +0300)]
Remove PUSH_OBJ multi-line macro
(code refactoring)

* finalize.c (GC_normal_finalize_mark_proc): Call GC_push_obj instead
of PUSH_OBJ.
* include/private/gc_pmark.h (PUSH_CONTENTS_HDR): Likewise.
* mark.c (GC_push_marked): Likewise.
* mark.c [ENABLE_DISCLAIM] (GC_push_unconditionally): Likewise.
* finalize.c (GC_normal_finalize_mark_proc): Remove hhdr local
variable.
* include/private/gc_pmark.h (PUSH_OBJ): Transform macro to inline
function; rename to GC_push_obj; update comment; return mark_stack_top.

6 years agoFix test_cpp failure in case GC_DEBUG is defined
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.

6 years agoRemove multi-line macros (ITERATE_DL_HASHTBL_*) in finalize
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.

6 years agoEliminate duplicate clear_mark_bit call when removing disappearing link
Ivan Maidanski [Wed, 4 Jul 2018 14:33:52 +0000 (17:33 +0300)]
Eliminate duplicate clear_mark_bit call when removing disappearing link
(fix of commit 8d13d52b6)

* finalize.c (GC_make_disappearing_links_disappear,
GC_remove_dangling_disappearing_links): Remove GC_clear_mark_bit call.

6 years agoRemove multi-line macro (FOR_EACH_PRED) in backgraph
Ivan Maidanski [Tue, 3 Jul 2018 14:10:26 +0000 (17:10 +0300)]
Remove multi-line macro (FOR_EACH_PRED) in backgraph
(code refactoring)

This change simplifies stepping thru backgraph code in gdb.

* backgraph.c (FOR_EACH_PRED): Remove macro.
* backgraph.c (add_edge): Rename old_back_ptr local variable to pred.
* backgraph.c (add_edge, backwards_height, update_max_height): Expand
FOR_EACH_PRED macro.
* backgraph.c (backwards_height): Rename back_ptr local variable to
pred.
* backgraph.c (backwards_height, update_max_height): Rename q local
variable to pred.
* backgraph.c (update_max_height): Rename q_height local variable to
this_height.

6 years agoTravis CI: Test with explicit -D GC_DEBUG
Ivan Maidanski [Sun, 1 Jul 2018 14:28:13 +0000 (17:28 +0300)]
Travis CI: Test with explicit -D GC_DEBUG

6 years agoNew public API (PTR_STORE_AND_DIRTY) to simplify store-and-dirty operation
Ivan Maidanski [Sun, 1 Jul 2018 13:53:15 +0000 (16:53 +0300)]
New public API (PTR_STORE_AND_DIRTY) to simplify store-and-dirty operation

* cord/cordbscs.c (CORD_cat_char_star, CORD_cat, CORD_from_fn_inner,
CORD_substr_closure): Replace the last store to the heap-allocated
object, GC_END_STUBBORN_CHANGE() and GC_reachable_here() with
GC_PTR_STORE_AND_DIRTY() call.
* cord/tests/de.c (prune_map, add_map, replace_line): Likewise.
* include/gc_inline.h (GC_CONS): Likewise.
* tests/disclaim_test.c (pair_dct, pair_new): Likewise.
* tests/test.c [!VERY_SMALL_CONFIG] (cons): Likewise.
* tests/test.c (small_cons, small_cons_uncollectable,
reverse_test_inner, mktree): Likewise.
* tests/test.c [GC_GCJ_SUPPORT] (gcj_cons): Likewise.
* tests/test.c [GC_PTHREADS && !SMALL_CONFIG && !GC_DEBUG]
(alloc8bytes): Likewise.
* tests/test.c [!NO_TYPED_TEST] (typed_test): Likewise.
* tests/test_cpp.cc (main): Likewise.
* dbg_mlc.c (GC_debug_ptr_store_and_dirty): Implement.
* mallocx.c (GC_ptr_store_and_dirty): Likewise.
* include/gc.h (GC_PTR_STORE_AND_DIRTY): New public macro.
* include/gc.h (GC_debug_ptr_store_and_dirty, GC_ptr_store_and_dirty):
Declare new public API function; add comment.
* tests/test.c (reverse_test_inner): Remove tmp local variable.
* tests/test.c (mktree): Remove right_left local variable.

6 years agoEliminate 'language extension used' Clang warning in gc.h
Ivan Maidanski [Sat, 30 Jun 2018 19:31:13 +0000 (22:31 +0300)]
Eliminate 'language extension used' Clang warning in gc.h

* include/gc.h [GC_DEBUG && __GNUC__] (GC_PTR_ADD, GC_PRE_INCR,
GC_POST_INCR, GC_POST_DECR): Replace typeof to __typeof__.

6 years agoEliminate 'GC_DEBUG redefined' compiler warning in smashtest
Ivan Maidanski [Sat, 30 Jun 2018 04:45:32 +0000 (07:45 +0300)]
Eliminate 'GC_DEBUG redefined' compiler warning in smashtest

* tests/smash_test.c (GC_DEBUG): Do not define if already done.

6 years agoCompute GC_CONS arguments just once
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).

6 years agoSame type casts for GC_PTR_STORE arguments regardless of GC_DEBUG
Ivan Maidanski [Fri, 29 Jun 2018 11:42:14 +0000 (14:42 +0300)]
Same type casts for GC_PTR_STORE arguments regardless of GC_DEBUG

* include/gc.h [GC_DEBUG] (GC_PTR_STORE): Cast p and q to void*.
* include/gc.h [!GC_DEBUG] (GC_PTR_STORE): Cast p to void**, cast q to
void*.

6 years agoWorkaround 'condition is always false' VC++ warning in test_cpp
Ivan Maidanski [Mon, 25 Jun 2018 04:00:21 +0000 (07:00 +0300)]
Workaround 'condition is always false' VC++ warning in test_cpp
(fix of commit 5524a425d)

* tests/test_cpp.cc (GC_CHECKED_DELETE): Remove "do" and "while (0)".

6 years agoFix mark stack overflow checking in push_selected
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).

6 years agoAdd GC_reachable_here after GC_dirty in GC source
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 73d30d2b4e5fb574cf)

* 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.

6 years agoAdd GC_reachable_here after GC_END_STUBBORN_CHANGE in tests
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 b52c140d3f72fc9d4308a380c3a)

* 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.

6 years agoAdd GC_reachable_here after GC_END_STUBBORN_CHANGE in cords
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).

6 years agoTurn on GC assertions in NT_MAKEFILE for debug builds
Ivan Maidanski [Wed, 20 Jun 2018 12:31:08 +0000 (15:31 +0300)]
Turn on GC assertions in NT_MAKEFILE for debug builds

* NT_MAKEFILE [!NODEBUG] (CFLAGS_DEBUG): Define variable (set to
-D GC_ASSERTIONS).
* NT_MAKEFILE (CFLAGS_SPECIFIC): Add $(CFLAGS_DEBUG).

6 years agoFix NT_MAKEFILE for VS 2017
Ivan Maidanski [Wed, 20 Jun 2018 09:15:59 +0000 (12:15 +0300)]
Fix NT_MAKEFILE for VS 2017

Issue #223 (bdwgc).

Do not include ntwin32.mak anymore.

* NT_MAKEFILE: Do not include ntwin32.mak.
* NT_MAKEFILE (cc, link, rc, cflags, cvarsmt, cdebug, rcvars, ldebug):
Define variable.
* NT_MAKEFILE [!NMAKE_WINVER] (NMAKE_WINVER): Likewise.
* NT_MAKEFILE (CPU): Adjust the value (to be either "i386" or "AMD64").
* NT_MAKEFILE (gctest.exe, cord\de.exe, test_cpp.exe): Pass
"/INCREMENTAL:NO", "$(lflags)", "user32.lib", "gdi32.lib" arguments;
remove "$(guiflags)", "$(guilibs)" arguments.

6 years agoReally use C11 static_assert if available (GCC/Clang/MSVC)
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 "").

6 years agoAdd missing type casts in remap and register_my_thread_inner
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*).

6 years agoFix VirtualQuery call in case of malloc failure (Win32)
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.

6 years agoEliminate 'switch statement contains no case label' compiler warning
Ivan Maidanski [Wed, 20 Jun 2018 07:43:25 +0000 (10:43 +0300)]
Eliminate 'switch statement contains no case label' compiler warning

* mark.c [!USE_PUSH_MARKED_ACCELERATORS] (GC_push_marked): Add a dummy
case label before default; add comment.

6 years agoDo not include windows.h when compiling gc_cpp.cc
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.

6 years agoFast fail on invalid CPU parameter passed to NT_MAKEFILE
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.

6 years agoConsistently define WIN32_LEAN_AND_MEAN/NOSERVICE before include windows.h
Ivan Maidanski [Wed, 20 Jun 2018 07:10:17 +0000 (10:10 +0300)]
Consistently define WIN32_LEAN_AND_MEAN/NOSERVICE before include windows.h
(code refactoring)

Note: these macros are not (and should not be) defined in the public
headers (gc.h).

* cord/tests/de.c [WIN32] (WIN32_LEAN_AND_MEAN, NOSERVICE): Define
macro before include windows.h.
* cord/tests/de_win.c (WIN32_LEAN_AND_MEAN, NOSERVICE): Likewise.
* extra/msvc_dbg.c (WIN32_LEAN_AND_MEAN, NOSERVICE): Likewise.
* tests/initsecondarythread.c [!GC_PTHREADS] (WIN32_LEAN_AND_MEAN,
NOSERVICE): Likewise.
* tests/subthread_create.c [!GC_PTHREADS] (WIN32_LEAN_AND_MEAN,
NOSERVICE): Likewise.
* tests/test.c [MSWIN32 || MSWINCE] (WIN32_LEAN_AND_MEAN,
NOSERVICE): Likewise.
* tests/test_cpp.cc [MSWIN32] (WIN32_LEAN_AND_MEAN, NOSERVICE):
Likewise.
* tests/thread_leak_test.c [!GC_PTHREADS] (WIN32_LEAN_AND_MEAN,
NOSERVICE): Likewise.
* tools/setjmp_t.c [MSWIN32 || MSWINCE || CYGWIN32]
(WIN32_LEAN_AND_MEAN, NOSERVICE): Likewise.
* cord/tests/de_win.c: Replace include "windows.h" to
include <windows.h>.

6 years agoTravis CI: Test compilation with -std=gnu11 option (clang and gcc)
Ivan Maidanski [Tue, 19 Jun 2018 21:49:27 +0000 (00:49 +0300)]
Travis CI: Test compilation with -std=gnu11 option (clang and gcc)

6 years ago.gitignore: Ignore '.vs' folders
Ivan Maidanski [Tue, 19 Jun 2018 21:45:12 +0000 (00:45 +0300)]
.gitignore: Ignore '.vs' folders

6 years agoAdd cpu, make_as_lib, nothreads options to NT_MAKEFILE
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.

6 years agoSuppress 'non-member operator new/delete may not be inline' VC++ warning
Ivan Maidanski [Tue, 19 Jun 2018 07:44:30 +0000 (10:44 +0300)]
Suppress 'non-member operator new/delete may not be inline' VC++ warning

* include/gc_cpp.h [_MSC_VER]: Add pragma to disable W4595; add TODO
item.

6 years agoDo not include 'new' standard header from gc_cpp.h by default
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).

6 years agoEliminate 'declaration of var hides global declaration' compiler warning
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.

6 years agoEliminate 'variable might be uninitialized' warning in win32_start_inner
Ivan Maidanski [Mon, 18 Jun 2018 21:59:23 +0000 (00:59 +0300)]
Eliminate 'variable might be uninitialized' warning in win32_start_inner

* win32_threads.c [!__GNUC__] (GC_win32_start_inner): Initialize ret
local variable (to null) before try-finally block; add comment.

6 years agoRemove duplicate local variable in reclaim_block
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).

6 years agoDelete log files produced by gctest and test_cpp on clean in DMC Makefile
Ivan Maidanski [Mon, 18 Jun 2018 21:37:08 +0000 (00:37 +0300)]
Delete log files produced by gctest and test_cpp on clean in DMC Makefile

* digimars.mak (clean): Remove also *.log files.

6 years agoFix dependency on gc_cpp source in BCC_MAKEFILE and NT_MAKEFILE
Ivan Maidanski [Mon, 18 Jun 2018 21:30:33 +0000 (00:30 +0300)]
Fix dependency on gc_cpp source in BCC_MAKEFILE and NT_MAKEFILE

* BCC_MAKEFILE (gc_cpp.obj): Add dependency on gc_cpp.cc.
* NT_MAKEFILE (gc_cpp.obj): Likewise.
* BCC_MAKEFILE (clean): Delete cord\*.tds.

6 years agoDo not specify throw(bad_alloc) in gc_cpp.h
Ivan Maidanski [Fri, 15 Jun 2018 08:20:42 +0000 (11:20 +0300)]
Do not specify throw(bad_alloc) in gc_cpp.h
(fix of commit cb1194d17)

* gc_cpp.cc (GC_NEW_DELETE_NEED_THROW, GC_DECL_NEW_THROW): Move from
gc_cpp.h.
* include/gc_cpp.h (gc::new, new): Remove GC_DECL_NEW_THROW specifier.
* include/gc_cpp.h [GC_OPERATOR_NEW_ARRAY] (gc::new[], new[]):
Likewise.

6 years agoFix large object base computation in PUSH_CONTENTS() if MARK_BIT_PER_OBJ
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.

6 years agoUse atomic allocation for leafs in reverse_test (gctest)
Ivan Maidanski [Thu, 14 Jun 2018 22:57:54 +0000 (01:57 +0300)]
Use atomic allocation for leafs in reverse_test (gctest)

* tests/test.c [NO_CONS_ATOMIC_LEAF] (small_cons_leaf): Redirect to
small_cons.
* tests/test.c [!NO_CONS_ATOMIC_LEAF] (small_cons_leaf): Define function
(which uses GC_MALLOC_ATOMIC).
* tests/test.c (small_cons_uncollectable, uncollectable_ints): Replace
small_cons(INT_TO_SEXPR(low),nil) to small_cons_leaf(low).

6 years agoFix typos in ChangeLog and generic_malloc
Ivan Maidanski [Thu, 14 Jun 2018 21:00:12 +0000 (00:00 +0300)]
Fix typos in ChangeLog and generic_malloc

* ChangeLog: Fix typos ("pointerful", "configure", "sections",
"variable", "determining", "config", "initialize", "getting").
* include/gc_mark.h (GC_generic_malloc): Fix a logical typo in comment
("pointerful" instead of pointer-free).

6 years agoFix comment about inv_sz computation in setup_header
Ivan Maidanski [Thu, 14 Jun 2018 08:50:03 +0000 (11:50 +0300)]
Fix comment about inv_sz computation in setup_header

* allchblk.c [MARK_BIT_PER_OBJ] (setup_header): Fix comment
(sz*inv_sz>=2**32).
* allchblk.c [MARK_BIT_PER_OBJ && INV_SZ_COMPUTATION_CHECK]
(setup_header): Add assertion to check the computation of inv_sz.

6 years agoFix result computation in n_set_marks
Ivan Maidanski [Thu, 14 Jun 2018 08:26:41 +0000 (11:26 +0300)]
Fix result computation in n_set_marks

* reclaim.c [!USE_MARK_BYTES] (GC_n_set_marks): Do not decrement the
result variable on return; add comment.

6 years agoRemove unnecessary type casts in n_set_marks
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.

6 years agoFix multi-threaded gctest for the case of NTHREADS is set to zero
Ivan Maidanski [Wed, 13 Jun 2018 22:11:49 +0000 (01:11 +0300)]
Fix multi-threaded gctest for the case of NTHREADS is set to zero
(fix of commit 347c1f0d0)

* tests/test.c [THREADS] (run_one_test): If !GC_thread_is_registered()
then FAIL only if GC_is_init_called().

6 years agoSkip typed_test in gctest if NO_TYPED_TEST macro is defined
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.

6 years agoUpdate AUTHORS file (add Jared McNeill and Leonardo Taccari)
Ivan Maidanski [Wed, 13 Jun 2018 06:47:33 +0000 (09:47 +0300)]
Update AUTHORS file (add Jared McNeill and Leonardo Taccari)

6 years agoAdd support for NetBSD/aarch64
Leonardo Taccari [Sun, 10 Jun 2018 09:49:37 +0000 (11:49 +0200)]
Add support for NetBSD/aarch64

Originally added by Jared McNeill (@jaredmcneill).

* include/private/gcconfig.h [NETBSD && __aarch64__] (AARCH64,
mach_type_known): Define macro.
* include/private/gcconfig.h [NETBSD && AARCH64] (OS_TYPE, HEURISTIC2,
DATASTART, ELF_CLASS, DYNAMIC_LOADING): Likewise.
* include/private/gcconfig.h [NETBSD && AARCH64] (GC_data_start):
Declare variable.

6 years agoFix 'need explicit cast to convert' compiler error in mprotect_dirty_init
Ivan Maidanski [Sat, 9 Jun 2018 17:25:20 +0000 (20:25 +0300)]
Fix 'need explicit cast to convert' compiler error in mprotect_dirty_init
(fix of commit 0fa40a7)

* os_dep.c [MPROTECT_VDB && !DARWIN && MSWIN32] (GC_mprotect_dirty_init):
Remove cast to signed_word when assigning SIG_DFL to GC_old_segv_handler.

6 years agoFix 'collecting from unknown thread' abort in leak-finding mode
Ivan Maidanski [Fri, 8 Jun 2018 20:41:22 +0000 (23:41 +0300)]
Fix 'collecting from unknown thread' abort in leak-finding mode

* include/private/gc_priv.h [GC_PTHREADS && !GC_WIN32_THREADS]
(GC_in_thread_creation): Move variable declaration from
pthread_support.h.
* misc.c [!DONT_USE_ATEXIT && GC_PTHREADS && !GC_WIN32_THREADS]
(GC_exit_check): Set GC_in_thread_creation to TRUE before GC_gcollect
call.

6 years agoFix 'scope of var can be reduced' cppcheck warnings in check_heap_stats
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.

6 years agoMatch GC_NOEXCEPT definition between gc_cpp.h and gc_allocator.h
Ivan Maidanski [Fri, 8 Jun 2018 08:54:32 +0000 (11:54 +0300)]
Match GC_NOEXCEPT definition between gc_cpp.h and gc_allocator.h
(fix of commit 48e8a7f)

* include/gc_allocator.h [!GC_NOEXCEPT]: Define to nothing also if
__DMC__.

6 years agoUse noexcept specifier in gc_cpp if C++11
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.

6 years agoFix gctest in leak-finding mode
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().

6 years agoReformat code and comments in gc_allocator.h
Ivan Maidanski [Thu, 7 Jun 2018 08:57:32 +0000 (11:57 +0300)]
Reformat code and comments in gc_allocator.h
(code refactoring)

* include/gc_allocator.h [!GC_NO_MEMBER_TEMPLATES && _MSC_VER
&& _MSC_VER<= 1200] (GC_NO_MEMBER_TEMPLATES): Define internal macro.
* include/gc_allocator.h: Reformat some comments (use same comment
style across the file).
* include/gc_allocator.h (allocate): Reformat code.

6 years agoTravis CI: Workaround gcc-8 ASan internal error (use gcc-5 for now)
Ivan Maidanski [Thu, 7 Jun 2018 08:48:12 +0000 (11:48 +0300)]
Travis CI: Workaround gcc-8 ASan internal error (use gcc-5 for now)

6 years agoUse noexcept in gc_allocator
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.

6 years agoNever return null by C++ GC allocators
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.

6 years agoTravis CI: Upgrade gcc-7 to gcc-8
Ivan Maidanski [Wed, 6 Jun 2018 06:23:46 +0000 (09:23 +0300)]
Travis CI: Upgrade gcc-7 to gcc-8

6 years agoWorkaround 'dynamic exception specifications deprecated in C++11' warning
Ivan Maidanski [Wed, 6 Jun 2018 06:14:03 +0000 (09:14 +0300)]
Workaround 'dynamic exception specifications deprecated in C++11' warning
(fix of commit cb1194d17)

* include/gc_cpp.h [GC_NEW_DELETE_NEED_THROW && __cplusplus>=201103L
&& !__clang__] (GC_DECL_NEW_THROW, GC_DECL_DELETE_THROW): Define to
empty.

6 years agoEliminate 'cast between incompatible function types' compiler warning
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.

6 years agoTravis CI: Upgrade clang-4.0 to clang-5.0, and gcc-5 to gcc-7
Ivan Maidanski [Mon, 4 Jun 2018 07:53:09 +0000 (10:53 +0300)]
Travis CI: Upgrade clang-4.0 to clang-5.0, and gcc-5 to gcc-7

6 years agoFix new and delete operators definition for DigitalMars compiler
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).

6 years agoRequire DllMain-based thread registration when compiling by DMC
Ivan Maidanski [Mon, 4 Jun 2018 06:40:40 +0000 (09:40 +0300)]
Require DllMain-based thread registration when compiling by DMC
(fix of commit 4d68389)

* digimars.mak (DEFINES): Add -D GC_DISCOVER_TASK_THREADS.
* digimars.mak (gc_cpp.obj): Add dependency on gc_cpp.cc

6 years agoFix compilation by digimars.mak (DMC)
Ivan Maidanski [Fri, 1 Jun 2018 08:58:30 +0000 (11:58 +0300)]
Fix compilation by digimars.mak (DMC)

Also, the script now builds test_cpp executable.

* digimars.mak (DEFINES): Remove -D NDEBUG; replace -D WIN32_THREADS to
-D GC_THREADS.
* digimars.mak (CFLAGS): Add -I libatomic_ops\src.
* digimars.mak (targets): Add test_cpp.exe.
* digimars.mak (gc.dll, gctest.exe): Replace sc with $(CC).
* digimars.mak (gc.def): Refine DESCRIPTION.
* digimars.mak (clean): Also delete gc.dll, gc.lib, gc.map, gctest.map,
test_cpp.map, tests\test.obj, gctest.exe, tests\test_cpp.obj,
test_cpp.exe.
* digimars.mak (test_cpp.exe, tests\test_cpp.obj): New rule.
* digimars.mak (tests\test.obj): Replace compiler options with $(CFLAGS).

6 years agoNever return null pointer by C++ operator new (gc_cpp)
Ivan Maidanski [Fri, 1 Jun 2018 08:29:41 +0000 (11:29 +0300)]
Never return null pointer by C++ operator new (gc_cpp)

Now, in case of the allocation failure, new and new[] operators throw
bad_alloc (or abort the application if an ancient compiler is used).

* gc_cpp.cc (GC_NEW_DELETE_NEED_THROW): Remove.
* gc_cpp.cc (GC_DECL_NEW_THROW, GC_DECL_DELETE_THROW): Move macro
definition to gc_cpp.h.
* gc_cpp.cc [GC_NEW_DELETE_NEED_THROW]: Do not include "new" header.
* gc_cpp.cc [!_MSC_VER] (operator new): Call GC_OP_NEW_OOM_CHECK() for
the allocation result.
* gc_cpp.cc [!_MSC_VER && GC_OPERATOR_NEW_ARRAY && !CPPCHECK]
(operator new[]): Likewise.
* include/gc.h (GC_abort_on_oom): Declare new API function.
* include/gc_cpp.h [!GC_NEW_DELETE_THROW_NOT_NEEDED
&& (GC_GNUC_PREREQ(4,2) || __BORLANDC__>=0x0550 || _MSC_VER>1020
|| __WATCOMC__>=1050)] (GC_NEW_DELETE_NEED_THROW):
Define macro.
* include/gc_cpp.h [GC_NEW_DELETE_NEED_THROW]: Include "new" header.
* include/gc_cpp.h (GC_OP_NEW_OOM_CHECK): New internal macro (throws
bad_alloc or cals GC_abort_on_oom).
* include/gc_cpp.h (gc::new(size_t), gc::new(size_t,GCPlacement), new):
Add GC_DECL_NEW_THROW; call GC_OP_NEW_OOM_CHECK() for the allocation
result.
* include/gc_cpp.h [GC_OPERATOR_NEW_ARRAY] (gc::new[](size_t),
gc::new[](size_t,GCPlacement, new[]): Likewise.
* misc.c (GC_abort_on_oom): Implement function.
* tests/test.c [CPPCHECK] (main): Call UNTESTED(GC_abort_on_oom).

6 years agoWorkaround 'template-id not supported in this context' compiler error (WCC)
Ivan Maidanski [Fri, 1 Jun 2018 06:36:07 +0000 (09:36 +0300)]
Workaround 'template-id not supported in this context' compiler error (WCC)

* include/gc_allocator.h (GC_selective_alloc<GC_true_type>): Do not
define if __WATCOMC__; add comment.

6 years ago.gitignore: Ignore gc.def (produced by digimars.mak)
Ivan Maidanski [Thu, 31 May 2018 23:11:41 +0000 (02:11 +0300)]
.gitignore: Ignore gc.def (produced by digimars.mak)

6 years agoFix compilation by WCC makefile
Ivan Maidanski [Thu, 31 May 2018 08:26:18 +0000 (11:26 +0300)]
Fix compilation by WCC makefile

* WCC_MAKEFILE (CFLAGS, CXXFLAGS): Add -iinclude.
* WCC_MAKEFILE (CXXFLAGS, TEST_CXXFLAGS): Add -xs.
* WCC_MAKEFILE (gc_cpp.obj, test_cpp.obj): Remove -iinclude.
* WCC_MAKEFILE (test.obj): Pass tests\test.c instead of $*.c.
* WCC_MAKEFILE (test_cpp.obj): Pass tests\test_cpp.cc instead of $*.cc.

6 years agoDo not redefine MSWIN32 macro (WCC)
Ivan Maidanski [Thu, 31 May 2018 08:20:34 +0000 (11:20 +0300)]
Do not redefine MSWIN32 macro (WCC)

* include/private/gcconfig.h [!_WIN32_WCE && !__CEGCC__
&& !__MINGW32CE__ && !_XBOX_ONE] (MSWIN32): Do not define if already
defined.