platform/upstream/libgc.git
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.

6 years agoCleanup BCC makefile (remove absolute GC paths, fix del cmd, update clean)
Ivan Maidanski [Thu, 31 May 2018 06:10:02 +0000 (09:10 +0300)]
Cleanup BCC makefile (remove absolute GC paths, fix del cmd, update clean)

* BCC_MAKEFILE (gcinclude1): Use relative path.
* BCC_MAKEFILE (gcinclude2): Remove.
* BCC_MAKEFILE (gc.lib, clean): Ignore errors of "del" command.
* BCC_MAKEFILE (gc_cpp.cpp, scratch): Remove rule.
* BCC_MAKEFILE (.rc.res, gctest.exe, cord\de.exe, test_cpp.exe): Use
tabs consistently.
* BCC_MAKEFILE (clean): Remove also *.log, *.tds, "gc.#0*" files, and
the ones which were specified for scratch rule.

6 years ago.gitignore: Ignore *.tds files (generated by bcc)
Ivan Maidanski [Thu, 31 May 2018 05:44:23 +0000 (08:44 +0300)]
.gitignore: Ignore *.tds files (generated by bcc)

6 years agoSuppress 'functions containing switch are not expanded inline' bcc warning
Ivan Maidanski [Tue, 29 May 2018 18:08:09 +0000 (21:08 +0300)]
Suppress 'functions containing switch are not expanded inline' bcc warning

* BCC_MAKEFILE (cflags): Add -w-inl.

6 years agoMake subthreadcreate test compilable even without libatomic_ops
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.

6 years agoEliminate 'comparing signed and unsigned values' compiler warnings (bcc)
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.

6 years agoEliminate 'possibly incorrect assignment in CORD_vsprintf' compiler warning
Ivan Maidanski [Tue, 29 May 2018 17:45:23 +0000 (20:45 +0300)]
Eliminate 'possibly incorrect assignment in CORD_vsprintf' compiler warning

* cord/cordprnt.c (CORD_vsprintf): Replace while((c=expr)) with
while((c=expr)!=0).

6 years agoTravis CI: Test USE_CUSTOM_SPECIFIC in 32-bit mode (Linux)
Ivan Maidanski [Mon, 28 May 2018 20:45:15 +0000 (23:45 +0300)]
Travis CI: Test USE_CUSTOM_SPECIFIC in 32-bit mode (Linux)

6 years agoTravis CI: Test MARK_BIT_PER_OBJ with USE_CUSTOM_SPECIFIC in 64-bit mode
Ivan Maidanski [Fri, 25 May 2018 07:18:44 +0000 (10:18 +0300)]
Travis CI: Test MARK_BIT_PER_OBJ with USE_CUSTOM_SPECIFIC in 64-bit mode

6 years agoTravis CI: Enable assertion checking for MARK_BIT_PER_OBJ
Ivan Maidanski [Fri, 25 May 2018 07:16:56 +0000 (10:16 +0300)]
Travis CI: Enable assertion checking for MARK_BIT_PER_OBJ

6 years agoHide value stored to thread-specific entries for a test purpose
Ivan Maidanski [Fri, 25 May 2018 07:12:56 +0000 (10:12 +0300)]
Hide value stored to thread-specific entries for a test purpose

* include/private/specific.h (ts_entry_value_t): New type.
* include/private/specific.h (TS_HIDE_VALUE, TS_REVEAL_PTR): New macro.
* include/private/specific.h (thread_specific_entry): Replace void* to
ts_entry_value_t (for value).
* include/private/specific.h (GC_getspecific): Apply TS_REVEAL_PTR to
entry->value.
* specific.c [USE_CUSTOM_SPECIFIC] (GC_slow_getspecific): Likewise.
* specific.c [USE_CUSTOM_SPECIFIC] (GC_setspecific): Apply TS_HIDE_VALUE
to value stored to entry.

6 years agoFix GC_out_of_line_malloc in new_gc_alloc.h for out-of-memory case
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.

6 years agoFix test_cpp for MANUAL_VDB
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.

6 years agoTurn on incremental mode in test_cpp
Ivan Maidanski [Thu, 24 May 2018 08:05:35 +0000 (11:05 +0300)]
Turn on incremental mode in test_cpp

* tests/test_cpp.cc [!NO_INCREMENTAL] (main): Call GC_enable_incremental
after GC_INIT.

6 years agoDo not install gc_allocator.h, gc_disclaim.h unless the features enabled
Ivan Maidanski [Thu, 24 May 2018 08:01:38 +0000 (11:01 +0300)]
Do not install gc_allocator.h, gc_disclaim.h unless the features enabled

* Makefile.am [ENABLE_DISCLAIM] (pkginclude_HEADERS): Add gc_disclaim.h
item.
* Makefile.am [CPLUSPLUS] (pkginclude_HEADERS): Add gc_allocator.h item.
* include/include.am (pkginclude_HEADERS): Remove gc_allocator.h and
gc_disclaim.h items.

6 years agowindows-untested: Update after include/weakpointer.h file removal
Ivan Maidanski [Wed, 23 May 2018 21:45:47 +0000 (00:45 +0300)]
windows-untested: Update after include/weakpointer.h file removal

Issue #221 (bdwgc).

6 years agoRemove C++ WeakPointer and CleanUp API which lacks implementation
Ivan Maidanski [Wed, 23 May 2018 21:35:26 +0000 (00:35 +0300)]
Remove C++ WeakPointer and CleanUp API which lacks implementation

Issue #221 (bdwgc).

_WeakPointer_* and _CleanUp_* C functions declared in weakpointer.h
are not implemented (since commit e35a417).

* Makefile.direct (SRCS): Remove weakpointer.h item.
* include/include.am (pkginclude_HEADERS): Likewise.
* include/weakpointer.h: Remove file.

6 years agoTravis CI: Test Makefile.direct with MANUAL_VDB
Ivan Maidanski [Wed, 23 May 2018 08:45:16 +0000 (11:45 +0300)]
Travis CI: Test Makefile.direct with MANUAL_VDB

6 years agoFix cords for MANUAL_VDB
Ivan Maidanski [Wed, 23 May 2018 08:43:04 +0000 (11:43 +0300)]
Fix cords for MANUAL_VDB

* cord/cordbscs.c (CORD_cat_char_star, CORD CORD_cat,
CORD_from_fn_inner, CORD_substr_closure): Call 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.

6 years agoFix staticroots and trace tests for MANUAL_VDB
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.

6 years agoFix typo in comment for CORD_ec_flush_buf prototype
Ivan Maidanski [Wed, 23 May 2018 08:10:32 +0000 (11:10 +0300)]
Fix typo in comment for CORD_ec_flush_buf prototype

* include/ec.h (CORD_ec_flush_buf): Fix a typo ("cord") in comment.

6 years agoTurn on incremental mode in cordtest cord/de and staticroots test
Ivan Maidanski [Wed, 23 May 2018 08:05:29 +0000 (11:05 +0300)]
Turn on incremental mode in cordtest cord/de and staticroots test

* cord/tests/cordtest.c [!NO_INCREMENTAL] (main): Call
GC_enable_incremental() after GC_INIT.
* cord/tests/de.c [!NO_INCREMENTAL] (main): Likewise.
* cord/tests/de_win.c [!NO_INCREMENTAL] (WinMain): Likewise.
* tests/staticrootslib.c [!NO_INCREMENTAL] (main): Likewise.

6 years agoCollapse multiple page_was_dirty, remove_protection, read_dirty definitions
Ivan Maidanski [Tue, 22 May 2018 06:03:07 +0000 (09:03 +0300)]
Collapse multiple page_was_dirty, remove_protection, read_dirty definitions
(code refactoring)

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

6 years agoFix FAST_MALLOC_GRANS and malloc_many for MANUAL_VDB
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).

6 years agoEnable compilation for Cygwin with MPROTECT_VDB
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.

6 years agoTravis CI: Test MANUAL_VDB with --disable-munmap
Ivan Maidanski [Fri, 18 May 2018 19:09:34 +0000 (22:09 +0300)]
Travis CI: Test MANUAL_VDB with --disable-munmap

6 years agoTravis CI: Do not require pkg-config
Ivan Maidanski [Fri, 18 May 2018 19:06:53 +0000 (22:06 +0300)]
Travis CI: Do not require pkg-config

pkg-config is not required because PKG_CHECK_MODULES is dropped
(commented out) in configure.