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

6 years agoDo not use PKG_CHECK_MODULES in configure
Ivan Maidanski [Fri, 18 May 2018 19:00:36 +0000 (22:00 +0300)]
Do not use PKG_CHECK_MODULES in configure

Issue #200 (bdwgc).

Presence of libatomic_ops is now detected only by checking the
installed headers, but libatomic_ops is no longer needed for most of
the clients which have atomic intrinsics support by the compiler.

* README.md (Installation and Portability): Remove information about
"syntax error near unexpected token ATOMIC_OPS".
* autogen.sh: Update comment removing pkg-config from the requirements.
* configure.ac (PKG_CHECK_MODULES(ATOMIC_OPS)): Comment out; update the
comment.

6 years agoFix comments style in configure.ac and Makefile.am
Ivan Maidanski [Fri, 18 May 2018 18:36:37 +0000 (21:36 +0300)]
Fix comments style in configure.ac and Makefile.am
(code refactoring)

Do not allow the comments that are meaningless in the auto-generated
configure and Makefile.in to be put to these files.

* Makefile.am (EXTRA_DIST, SINGLE_GC_OBJ, EXTRA_DIST,
include doc/doc.am): Change comment style from "#" to "##".
* Makefile.am (CPLUSPLUS): Move "#" inside the conditional block.
* configure.ac: Update the copyright.
* configure.ac: Change comment style from "#" to "dnl" for the comments
that are meaningless in auto-generated configure file.

6 years agoTravis CI: Test MANUAL_VDB (w/o parallel mark)
Ivan Maidanski [Fri, 18 May 2018 08:16:54 +0000 (11:16 +0300)]
Travis CI: Test MANUAL_VDB (w/o parallel mark)

6 years agoFix missing GC_dirty calls for GC-allocated objects used internally
Ivan Maidanski [Fri, 18 May 2018 07:58:54 +0000 (10:58 +0300)]
Fix missing GC_dirty calls for GC-allocated objects used internally

This change matters only in case of MANUAL_VDB mode.

* finalize.c (GC_grow_table, GC_register_disappearing_link,
GC_unregister_disappearing_link_inner, GC_process_togglerefs,
GC_toggleref_add, GC_move_disappearing_link_inner,
GC_register_finalizer_inner, ITERATE_DL_HASHTBL_END,
DELETE_DL_HASHTBL_ENTRY, GC_finalize, GC_enqueue_all_finalizers): Call
GC_dirty where needed.
* gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcj_malloc, GC_debug_gcj_malloc,
GC_gcj_malloc_ignore_off_page): Likewise.
* pthread_start.c [GC_PTHREADS && !GC_WIN32_THREADS]
(GC_inner_start_routine): Likewise.
* pthread_support.c [GC_PTHREADS && !GC_WIN32_THREADS] (GC_new_thread,
GC_delete_thread, GC_delete_gc_thread): Likewise.
* specific.c [USE_CUSTOM_SPECIFIC] (GC_setspecific,
GC_remove_specific_after_fork): Likewise.
* typd_mlc.c (GC_make_sequence_descriptor, GC_malloc_explicitly_typed,
GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed):
Likewise.
* win32_threads.c (GC_new_thread, GC_delete_gc_thread_no_free,
GC_delete_thread, GC_CreateThread): Likewise.
* win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1]
(GC_beginthreadex): Likewise.
* win32_threads.c [GC_PTHREADS] (GC_pthread_create,
GC_pthread_start_inner): Likewise.
* include/gc_inline.h (GC_FAST_MALLOC_GRANS): Call
GC_end_stubborn_change(my_fl) after GC_FAST_M_AO_STORE() call unless
kind is GC_I_PTRFREE.
* include/gc_inline.h (GC_CONS): Call GC_end_stubborn_change(result).

6 years agoRename GC_dirty_async back to GC_dirty
Ivan Maidanski [Thu, 17 May 2018 21:24:30 +0000 (00:24 +0300)]
Rename GC_dirty_async back to GC_dirty
(fix of commit bb8e97c)

* include/private/gc_priv.h [MANUAL_VDB] (GC_dirty_async_inner): Rename
to GC_dirty_inner; add comment.
* os_dep.c [MANUAL_VDB] (GC_dirty_async_inner): Likewise.
* include/private/gc_priv.h (GC_dirty_async): Rename to GC_dirty.
* mallocx.c (GC_end_stubborn_change): Rename GC_dirty_async to GC_dirty.
* mark.c [THREADS] (GC_mark_and_push_stack): Likewise.

6 years agoHide and rename GC_dirty to GC_dirty_async[_inner]
Ivan Maidanski [Thu, 17 May 2018 08:14:51 +0000 (11:14 +0300)]
Hide and rename GC_dirty to GC_dirty_async[_inner]
(code refactoring)

Also, do not call GC_dirty_async_inner unless GC_incremental.

* include/private/gc_priv.h [MANUAL_VDB] (GC_dirty_async_inner):
Declare GC_INNER function.
* include/private/gc_priv.h (GC_dirty_async): New macro (calls
GC_dirty_async_inner if MANUAL_VDB and GC_incremental.
* mallocx.c [MANUAL_VDB] (GC_dirty): Remove declaration.
* mark.c [MANUAL_VDB && THREADS] (GC_dirty): Likewise.
* mallocx.c (GC_end_stubborn_change): Remove GC_ATTR_UNUSED; call
GC_dirty_async (unconditionally) instead of GC_dirty.
* mark.c [THREADS] (GC_mark_and_push_stack): Call GC_dirty_async
instead of GC_dirty.
* os_dep.c [MANUAL_VDB] (GC_dirty): Rename to GC_dirty_async_inner;
add GC_INNER; change argument type from ptr_t to const void*.

6 years agoRemove code duplication in gcj_malloc and malloc_explicitly_typed
Ivan Maidanski [Wed, 16 May 2018 08:49:33 +0000 (11:49 +0300)]
Remove code duplication in gcj_malloc and malloc_explicitly_typed
(code refactoring)

* gcj_mlc.c [GC_GCJ_SUPPORT] (GC_gcj_malloc): Store
ptr_to_struct_containing_descr in a single place of code.
* typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Store d (to
the object) in a single place of code.

6 years agoAdd assertions to finalize and threads support for MANUAL_VDB needs
Ivan Maidanski [Wed, 16 May 2018 08:33:02 +0000 (11:33 +0300)]
Add assertions to finalize and threads support for MANUAL_VDB needs
(code refactoring)

* finalize.c (GC_unregister_disappearing_link_inner,
GC_enqueue_all_finalizers): Remove redundant comment about held lock.
* finalize.c (GC_unregister_disappearing_link_inner,
GC_move_disappearing_link_inner, ITERATE_DL_HASHTBL_BEGIN,
GC_finalize, GC_enqueue_all_finalizers): Add assertion that the
allocation lock is held.
* pthread_support.c (first_thread): Refine comment.
* pthread_support.c (GC_new_thread): Add assertion that when the first
thread is added then GC_threads[hv] is null (thus "next" field is set
to null).
* win32_threads.c (GC_new_thread): Likewise.
* pthread_support.c (GC_delete_thread, GC_delete_gc_thread): Add
assertion that "next" field of the first thread is not modified.
* win32_threads.c (GC_delete_gc_thread_no_free, GC_delete_thread):
Likewise.
* win32_threads.c (GC_delete_thread): Use EXPECT() when checking that
p is not the first thread.
* win32_threads.c [GC_PTHREADS] (GC_pthread_start_inner): Add assertion
that the current thread is not the first one (thus "status" field of
the first thread is not modified).

6 years agoWorkaround 'function nested_sp is never used' cppcheck style warning
Ivan Maidanski [Tue, 15 May 2018 09:39:03 +0000 (12:39 +0300)]
Workaround 'function nested_sp is never used' cppcheck style warning

The warning should not be produced by cppcheck as nested_sp is assigned
to nested_sp_fn variable.

* tools/setjmp_t.c [CPPCHECK] (main): Call nested_sp() directly; add
comment.

6 years agowindows-untested: Update after stubborn.c file removal
Ivan Maidanski [Tue, 15 May 2018 09:26:32 +0000 (12:26 +0300)]
windows-untested: Update after stubborn.c file removal

6 years agoRemove stubborn.c file
Ivan Maidanski [Tue, 15 May 2018 09:23:19 +0000 (12:23 +0300)]
Remove stubborn.c file
(code refactoring)

* BCC_MAKEFILE (XXXOBJS): Remove XXXstubborn.obj entry.
* CMakeLists.txt (SRC): Remove stubborn.c entry.
* Makefile.am (libgc_la_SOURCES): Likewise.
* Makefile.direct (CSRCS): Likewise.
* PCR-Makefile (CSRC): Likewise.
* build/s60v3/libgc.mmp (SOURCE): Likewise.
* doc/README.Mac (Files to build the GC libraries): Likewise.
* Makefile.direct (OBJS): Remove stubborn.o entry.
* PCR-Makefile (COBJ): Likewise.
* SMakefile.amiga (OBJS): Likewise.
* digimars.mak (OBJS): Likewise.
* NT_MAKEFILE (OBJS): Remove stubborn.obj entry.
* OS2_MAKEFILE (OBJS): Likewise.
* WCC_MAKEFILE (OBJS): Likewise.
* SMakefile.amiga (stubborn.o): Remove rule.
* digimars.mak (stubborn.obj): Likewise.
* extra/gc.c: Do not include stubborn.c.
* gc.mak: Remove rules for stubborn.obj and stubborn.sbr.
* mallocx.c [MANUAL_VDB] (GC_dirty): Move the function declaration from
stubborn.c.
* mallocx.c (GC_malloc_stubborn, GC_change_stubborn,
GC_end_stubborn_change): Move the function implementation from
stubborn.c.
* stubborn.c: Delete file.

6 years agoFix return type in GC_set_warn_proc API documentation
Ivan Maidanski [Tue, 15 May 2018 07:47:18 +0000 (10:47 +0300)]
Fix return type in GC_set_warn_proc API documentation
(fix of commit 2dd4ee71d)

* doc/gcinterface.md: Change GC_set_warn_proc return type from
GC_warn_proc to void.

6 years agoRemove stubborn objects allocation code completely
Ivan Maidanski [Tue, 15 May 2018 07:35:59 +0000 (10:35 +0300)]
Remove stubborn objects allocation code completely
(code refactoring)

* README.md (Incremental/Generational Collection): Remove information
about stubborn objects; add information about GC_end_stubborn_change
usage.
* alloc.c [STUBBORN_ALLOC] (GC_finish_collection): Do not call
GC_clean_changing_list.
* checksums.c (NSUMS, GC_check_dirty): Remove comment related to
stubborn objects.
* checksums.c [STUBBORN_ALLOC] (GC_on_free_list): Remove.
* doc/README.macros (STUBBORN_ALLOC): Likewise.
* include/private/gc_priv.h [STUBBORN_ALLOC] (GC_sobjfreelist,
GC_arrays._sobjfreelist, GC_changed_pages, GC_arrays._changed_pages,
GC_prev_changed_pages, GC_arrays._prev_changed_pages): Likewise.
* include/private/gc_priv.h (GC_read_changed, GC_page_was_changed,
GC_clean_changing_list, GC_stubborn_init): Likewise.
* tests/test.c (stubborn_count): Likewise.
* checksums.c (GC_n_changed_errors): Likewise.
* checksums.c [STUBBORN_ALLOC] (GC_update_check_page, GC_check_dirty):
Do not update GC_n_changed_errors value.
* checksums.c (GC_check_dirty): Do not check/print GC_n_changed_errors
value.
* configure.ac (checksums): Update help message (remove information
about stubborn objects).
* dbg_mlc.c (GC_print_obj, GC_debug_end_stubborn_change,
GC_debug_realloc, GC_debug_generic_or_special_malloc): Do not handle
STUBBORN object kind specially.
* mallocx.c (GC_generic_or_special_malloc, GC_realloc): Likewise.
* mark.c [!GC_DISABLE_INCREMENTAL] (GC_push_next_marked_dirty):
Likewise.
* dbg_mlc.c [STUBBORN_ALLOC] (GC_debug_malloc_stubborn): Redirect to
GC_debug_malloc; remove GC_ATTR_MALLOC.
* dbg_mlc.c [STUBBORN_ALLOC] (GC_debug_change_stubborn): Change to
no-op.
* doc/README.amiga (WHATS NEW): Do not reference GC_malloc_stubborn.
* doc/README.macros (CHECKSUMS): Update (remove information about
stubborn objects).
* doc/gcdescr.md (Allocation, Generational Collection and Dirty Bits):
Likewise.
* doc/gcinterface.md (C/C++ Interface): Likewise.
* doc/leak.md (Using the Garbage Collector as Leak Detector): Likewise.
* doc/gcdescr.md (Generational Collection and Dirty Bits): Add
information about MANUAL_VDB.
* include/gc.h (GC_malloc, GC_free, GC_realloc): Update comment (remove
information about stubborn objects).
* malloc.c (GC_generic_malloc_inner): Likewise.
* tests/test.c (reverse_test_inner): Likewise.
* include/gc.h (GC_malloc_stubborn, GC_debug_malloc_stubborn): Add
GC_ATTR_DEPRECATED; remove GC_ATTR_MALLOC and GC_ATTR_ALLOC_SIZE.
* include/gc.h (GC_MALLOC_STUBBORN, GC_NEW_STUBBORN): Redirect to normal
GC_MALLOC/NEW; add comment that stubborn objects allocation is
deprecated.
* include/gc.h [GC_DEBUG] (GC_CHANGE_STUBBORN): Redirect to
GC_change_stubborn (not GC_debug_change_stubborn).
* include/gc.h (GC_change_stubborn): Add GC_ATTR_DEPRECATED.
* include/gc.h [!CPPCHECK] (GC_debug_change_stubborn): Likewise.
* include/gc.h (GC_change_stubborn, GC_debug_change_stubborn): Remove
GC_ATTR_NONNULL.
* include/gc.h (GC_end_stubborn_change): Add comment related to usage
when the library is built with MANUAL_VDB defined.
* include/gc.h [_AMIGA && !GC_AMIGA_MAKINGLIB] (GC_malloc_stubborn):
Remove macro.
* include/private/gc_priv.h (STUBBORN_ALLOC): Remove comment.
* include/private/gc_priv.h (STUBBORN): Replace with
GC_N_KINDS_INITIAL_VALUE definition.
* mark.c (GC_obj_kinds): Remove initialization for STUBBORN_ALLOC
element.
* mark.c (GC_N_KINDS_INITIAL_VALUE): Move to gc_priv.h.
* mark.c (GC_n_rescuing_pages): Define only if GC_DISABLE_INCREMENTAL.
* mark.c [STUBBORN_ALLOC] (GC_initiate_gc): Do not call GC_read_changed.
* misc.c [STUBBORN_ALLOC] (GC_init): Do not call GC_stubborn_init.
* stubborn.c (GC_malloc_stubborn): Remove GC_ATTR_MALLOC.
* tests/test.c [!VERY_SMALL_CONFIG] (cons): Replace GC_MALLOC_STUBBORN
with GC_MALLOC call; update collectable_count instead of stubborn_count.
* tests/test.c (check_heap_stats): Do not print stubborn_count value.

6 years agoFix tests for GC compiled with MANUAL_VDB
Ivan Maidanski [Tue, 8 May 2018 19:21:59 +0000 (22:21 +0300)]
Fix tests for GC compiled with MANUAL_VDB

* tests/disclaim_test.c (pair_dct, pair_new): Call
GC_end_stubborn_change(p) after writing the last pointer field of p.
* tests/test.c [!DBG_HDRS_ALL] (run_one_test): Likewise.
* tests/test.c (small_cons, small_cons_uncollectable, mktree,
typed_test): Call GC_END_STUBBORN_CHANGE(r) after writing the last
pointer field of r.
* tests/test.c [GC_GCJ_SUPPORT] (gcj_cons): Likewise.
* tests/test.c [!SMALL_CONFIG && !GC_DEBUG] (alloc8bytes): Likewise.

6 years agoKeep pointer to the start of previous entry in remove_specific_after_fork
Ivan Maidanski [Tue, 8 May 2018 18:36:41 +0000 (21:36 +0300)]
Keep pointer to the start of previous entry in remove_specific_after_fork
(code refactoring)

* specific.c [USE_CUSTOM_SPECIFIC] (GC_remove_specific_after_fork):
Replace tse** link local variable with tse* prev one; replace *link
with either key->hash[hash_val].p or prev->next.

6 years agoFix missing GC_dirty invocation from debug_end_stubborn_change
Ivan Maidanski [Tue, 8 May 2018 18:04:55 +0000 (21:04 +0300)]
Fix missing GC_dirty invocation from debug_end_stubborn_change

GC_debug_end_stubborn_change was no-op unless STUBBORN_ALLOC defined.

* dbg_mlc.c (GC_debug_end_stubborn_change): De-duplicate definition;
remove hhdr local variable.
* dbg_mlc.c [!STUBBORN_ALLOC] (GC_debug_end_stubborn_change): Check
p belongs to GC heap; call GC_end_stubborn_change(GC_base(p)).

6 years agoEliminate source code duplication in stubborn.c
Ivan Maidanski [Tue, 8 May 2018 17:42:31 +0000 (20:42 +0300)]
Eliminate source code duplication in stubborn.c
(code refactoring)

* stubborn.c (GC_malloc_stubborn, GC_end_stubborn_change,
GC_change_stubborn): De-duplicate definition (for MANUAL_VDB and
non-MANUAL_VDB cases).

6 years agoFix assertion violation and partial overlapping in remove_roots_subregion
Ivan Maidanski [Tue, 8 May 2018 17:17:48 +0000 (20:17 +0300)]
Fix assertion violation and partial overlapping in remove_roots_subregion
(fix of commit 38d194a)

Issue #218 (bdwgc).

* mark_rts.c [USE_PROC_FOR_LIBRARIES] (GC_remove_roots_subregion):
Update comment; add assertion that b and e pointers are word-aligned;
handle also cases of partial overlapping with the existing roots;
call GC_rebuild_root_index() only when needed; update existing root
instead of removing old and adding new one (where possible); move
newly static added root to precede dynamic ones (if any); process all
static roots even if an intersection is already found.

6 years agoDo not merge dynamic root with the existing static one in add_roots_inner
Ivan Maidanski [Tue, 8 May 2018 07:33:48 +0000 (10:33 +0300)]
Do not merge dynamic root with the existing static one in add_roots_inner

* mark_rts.c [!MSWIN32 && !MSWINCE && !CYGWIN32] (GC_add_roots_inner):
If the root already exists and it is static then set the found root
to static (if not yet); if dynamic root with the same r_start but
different r_tmp is found then add a new root starting from r_end of
the found root (instead of extending the found root).

6 years agoFix potential null dereference in GC_CONS
Ivan Maidanski [Mon, 7 May 2018 21:47:48 +0000 (00:47 +0300)]
Fix potential null dereference in GC_CONS

* include/gc_inline.h (GC_CONS): Remove granules local variable; replace
GC_FAST_MALLOC_GRANS(GC_malloc_kind) to GC_MALLOC_WORDS_KIND(n=2);
store second element only if result is non-null; store first element
along with second one.

6 years agoTravis CI: Workaround 'pcr_interface.c is not analyzed' cppcheck warning
Ivan Maidanski [Mon, 7 May 2018 21:34:50 +0000 (00:34 +0300)]
Travis CI: Workaround 'pcr_interface.c is not analyzed' cppcheck warning

6 years agoTravis CI: Test -D DEBUG_DIRTY_BITS properly
Ivan Maidanski [Mon, 7 May 2018 21:27:12 +0000 (00:27 +0300)]
Travis CI: Test -D DEBUG_DIRTY_BITS properly
(fix of commit 19db2c6a0)

6 years agoFix infinite restarting of mark_some when a static root disappeared (Linux)
Ivan Maidanski [Mon, 7 May 2018 08:05:15 +0000 (11:05 +0300)]
Fix infinite restarting of mark_some when a static root disappeared (Linux)

Issue #218 (bdwgc).

* dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Call
GC_remove_roots_subregion for each region which has prot starting
with "---"; add comment.
* include/private/gc_priv.h [USE_PROC_FOR_LIBRARIES]
(GC_remove_roots_subregion): Declare function.
* mark_rts.c[USE_PROC_FOR_LIBRARIES] (GC_remove_roots_subregion):
Implement.

6 years agoTurn on incremental collection in gctest also if DEFAULT_VDB or MANUAL_VDB
Ivan Maidanski [Mon, 7 May 2018 05:20:57 +0000 (08:20 +0300)]
Turn on incremental collection in gctest also if DEFAULT_VDB or MANUAL_VDB

* tests/test.c [DEFAULT_VDB] (TEST_DEFAULT_VDB): Define (before include
gc.h).
* tests/test.c [!GC_DISABLE_INCREMENTAL] (main): Call
GC_enable_incremental also if MANUAL_VDB or TEST_DEFAULT_VDB; print
message about emulating dirty bits with mprotect only if MPROTECT_VDB.