Ivan Maidanski [Thu, 29 Mar 2018 06:54:39 +0000 (09:54 +0300)]
Minimize delay between sem_post and sigsuspend in suspend_handler if TSan
(fix of commit af409e4)
Issue #181 (bdwgc).
This change is to do as less as possible (even in case of TSan usage)
between the sem_post and sigsuspend calls in GC_suspend_handler_inner
(to match the relevant comment after sigsuspend call).
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& THREAD_SANITIZER] (GC_suspend_handler_inner): Move sigemptyset()
and pthread_sigmask() calls to be just before sem_post() call.
Ivan Maidanski [Wed, 28 Mar 2018 22:08:11 +0000 (01:08 +0300)]
Enable handle-fork by default
Issue #174 (bdwgc).
* CMakeLists.txt (enable_handle_fork): New option (on by default).
* CMakeLists.txt [CMAKE_USE_PTHREADS_INIT && enable_handle_fork]:
Define HANDLE_FORK macro for aix, cygwin, freebsd, haiku, hpux11,
irix, kfreebsd, linux, netbsd, openbsd, osf, solaris hosts.
* CMakeLists.txt [CMAKE_USE_PTHREADS_INIT && HOST=*-*-darwin*
&& enable_handle_fork && enable_parallel_mark]: Define HANDLE_FORK
macro; add comment.
* configure.ac (AC_ARG_ENABLE(handle-fork)): Allow "auto" and "manual"
values; update help message.
* configure.ac [$enable_handle_fork!=yes && $enable_handle_fork!=no
&& $enable_handle_fork!=manual && $THREADS=posix]: Define HANDLE_FORK
macro for aix, cygwin, freebsd, haiku, hpux11, irix, kfreebsd, linux,
netbsd, openbsd, osf, solaris hosts (and also for darwin if
enable_parallel_mark); add comment.
Ivan Maidanski [Tue, 27 Mar 2018 22:06:01 +0000 (01:06 +0300)]
Support Haiku multi-threaded build by CMake
Issue #97 (bdwgc).
* CMakeLists.txt [CMAKE_USE_PTHREADS_INIT && HOST=*-*-haiku*]: Define
GC_THREADS and _REENTRANT macros.
* CMakeLists.txt [CMAKE_USE_PTHREADS_INIT && HOST=*-*-haiku*
&& enable_parallel_mark]: Define PARALLEL_MARK macro.
* CMakeLists.txt [CMAKE_USE_PTHREADS_INIT && HOST=*-*-haiku*
&& enable_thread_local_alloc]: Define THREAD_LOCAL_ALLOC macro.
Ivan Maidanski [Tue, 27 Mar 2018 18:27:48 +0000 (21:27 +0300)]
Accept Android platform by both CMake and configure
(fix of commit 1680d91)
* CMakeLists.txt (_HOST): Adjust FIXME comment.
* CMakeLists.txt (HOST): Remove replacement of "android" to "linux".
* CMakeLists.txt [CMAKE_USE_PTHREADS_INIT && HOST=*-*-android*]:
Define GC_THREADS and _REENTRANT macros.
* CMakeLists.txt [CMAKE_USE_PTHREADS_INIT && HOST=*-*-android*
&& enable_parallel_mark]: Define PARALLEL_MARK macro.
* CMakeLists.txt [CMAKE_USE_PTHREADS_INIT && HOST=*-*-android*
&& enable_thread_local_alloc]: Define THREAD_LOCAL_ALLOC macro.
* configure.ac [$THREADS=posix && $host=*-*-android*] (GC_THREADS,
_REENTRANT): Define macro.
* configure.ac [$THREADS=posix && $host=*-*-android*
&& $enable_parallel_mark] (PARALLEL_MARK): Likewise.
* configure.ac [$THREADS=posix && $host=*-*-android*
&& $enable_thread_local_alloc] (THREAD_LOCAL_ALLOC): Likewise.
Ivan Maidanski [Mon, 26 Mar 2018 18:30:32 +0000 (21:30 +0300)]
Reduce probability of collision in threads hashtable for 64-bit targets
* include/private/pthread_support.h [GC_PTHREADS && !GC_WIN32_THREADS
&& CPP_WORDSZ==64] (THREAD_TABLE_INDEX): Xor also 4th byte of id value.
Ivan Maidanski [Mon, 26 Mar 2018 07:15:50 +0000 (10:15 +0300)]
Do not use AO_store in FAST_MALLOC_GRANS() in the single-threaded mode
(fix of commit effa229)
Issue #214 (bdwgc).
* include/gc_inline.h (GC_FAST_M_AO_STORE): Do not use AO_store unless
GC_THREADS.
Ivan Maidanski [Fri, 23 Mar 2018 18:47:39 +0000 (21:47 +0300)]
Include malloc.c in extra/gc.c after include gc_inline.h
(code refactoring)
* extra/gc.c: Move include malloc.c to be near include mallocx.c.
Ivan Maidanski [Fri, 23 Mar 2018 18:29:28 +0000 (21:29 +0300)]
Avoid potential race between malloc_kind and mark_thread_local_fls_for
Issue #214 (bdwgc).
* include/gc_inline.h (GC_FAST_M_AO_STORE): New internal macro.
* include/gc_inline.h (GC_FAST_MALLOC_GRANS): Use GC_FAST_M_AO_STORE.
* thread_local_alloc.c [THREAD_LOCAL_ALLOC]
(GC_mark_thread_local_fls_for): Use AO_load to get _freelists[i][j]
value; add comment.
* thread_local_alloc.c [THREAD_LOCAL_ALLOC && GC_GCJ_SUPPORT]
(GC_mark_thread_local_fls_for): Use AO_load to get gcj_freelists[j].
Ivan Maidanski [Fri, 23 Mar 2018 08:13:23 +0000 (11:13 +0300)]
Fix thread_suspend fail for threads registered from key destructor (OS X)
Issue #213 (bdwgc).
* pthread_support.c [GC_DARWIN_THREADS] (GC_register_my_thread):
Reinitialize stop_info.mach_thread if the thread is registered from
the client thread key destructor; add comment.
Ivan Maidanski [Thu, 22 Mar 2018 22:09:40 +0000 (01:09 +0300)]
Explicitly unblock GC signals on GC initialization
Issue #175 (bdgwc).
Note: NO_SIGNALS_UNBLOCK_IN_MAIN macro is to be defined manually to
turn off this feature (for a reason).
* include/private/gcconfig.h [GC_NO_PTHREAD_SIGMASK]
(NO_SIGNALS_UNBLOCK_IN_MAIN): New macro.
* pthread_stop_world.c [GC_PTHREADS && !GC_WIN32_THREADS
&& !GC_DARWIN_THREADS && !SN_TARGET_ORBIS && !SN_TARGET_PSP2 && !NACL
&& !GC_OPENBSD_UTHREADS && !NO_SIGNALS_UNBLOCK_IN_MAIN]
(GC_unblock_gc_signals): Define.
* pthread_stop_world.c [GC_PTHREADS && !GC_WIN32_THREADS
&& !GC_DARWIN_THREADS && !SN_TARGET_ORBIS && !SN_TARGET_PSP2 && !NACL
&& !GC_OPENBSD_UTHREADS && !NO_SIGNALS_UNBLOCK_IN_MAIN] (GC_stop_init):
Call GC_unblock_gc_signals; add comment.
Ivan Maidanski [Thu, 22 Mar 2018 21:41:13 +0000 (00:41 +0300)]
Match GC_FAST_MALLOC_GRANS formal and actual arguments where possible
(code refactoring)
* include/gc_inline.h (GC_MALLOC_WORDS_KIND): Rename k argument to kind.
* include/gc_inline.h (GC_MALLOC_WORDS_KIND, GC_CONS): Rename grans
local variable to granules.
* thread_local_alloc.c [THREAD_LOCAL_ALLOC] (GC_malloc_kind): Rename
knd to kind.
Ivan Maidanski [Thu, 22 Mar 2018 08:24:04 +0000 (11:24 +0300)]
Fix assertion violation in DllMain of win32_threads
DllMain(DLL_THREAD_ATTACH) might be called for C runtime threads
before main() is launched, so this commit just removes wrong
assertion in DllMain.
* win32_threads.c [!GC_NO_THREADS_DISCOVERY] (GC_DllMain): Remove
entry_count static variable; remove assertion for entry_count and
parallel_initialized values in DLL_THREAD_ATTACH case.
Ivan Maidanski [Thu, 22 Mar 2018 07:37:00 +0000 (10:37 +0300)]
Check consistency of descr, adjust, clear arguments of GC_new_kind
Issue #83 (bdgwc).
* misc.c (GC_new_kind_inner): Improve assertion about clear argument
to check for the consistency of descr and adjust arguments (in case of
clear is false).
Ivan Maidanski [Wed, 21 Mar 2018 07:26:10 +0000 (10:26 +0300)]
Fix ASSERT_CANCEL_DISABLED violation in try_to_collect_inner
(fix of commit b04b346)
Issue #182 (bdwgc).
* finalize.c (GC_ON_GROW_LOG_SIZE_MIN): Define to CPP_LOG_HBLKSIZE
value by default.
* finalize.c (GC_grow_table): Surround GC_try_to_collect_inner call
with DISABLE/RESTORE_CANCEL.
Ivan Maidanski [Tue, 20 Mar 2018 21:58:24 +0000 (00:58 +0300)]
Fix unbounded heap growth in case of intensive disappearing links usage
Issue #182 (bdwgc).
* finalize.c (GC_ON_GROW_LOG_SIZE_MIN): New macro.
* finalize.c (GC_grow_table): Rename size_ptr to log_size_ptr in
comment; add entries_ptr argument; add comment; call if log_old_size is
GC_ON_GROW_LOG_SIZE_MIN or bigger then call GC_try_to_collect_inner
and, then, return from the function if the number of entries is less
than 75% of the table capacity.
* finalize.c (GC_register_disappearing_link_inner): Pass
dl_hashtbl->entries pointer to GC_grow_table.
* finalize.c (GC_register_finalizer_inner): Pass GC_fo_entries pointer
to GC_grow_table.
Ivan Maidanski [Mon, 19 Mar 2018 21:51:18 +0000 (00:51 +0300)]
Use OPT_RA instead of STORE_DEBUG_INFO in dbg_mlc
(fix of commit d6ccabe)
* dbg_mlc.c (STORE_DEBUG_INFO): Remove macro.
* dbg_mlc.c (GC_debug_malloc, GC_debug_malloc_ignore_off_page,
GC_debug_malloc_atomic_ignore_off_page, GC_debug_generic_malloc,
GC_debug_malloc_stubborn, GC_debug_malloc_atomic,
GC_debug_malloc_uncollectable, GC_debug_malloc_atomic_uncollectable):
Replace STORE_DEBUG_INFO() to store_debug_info() call; use OPT_RA.
Ivan Maidanski [Thu, 15 Mar 2018 20:38:31 +0000 (23:38 +0300)]
Fix 'scope of var can be reduced' cppcheck err in enqueue_all_finalizers
* finalize.c [!JAVA_FINALIZATION_NOT_NEEDED]
(GC_enqueue_all_finalizers): Declare curr_fo and real_ptr in the scopes
of their use.
Ivan Maidanski [Thu, 15 Mar 2018 20:16:36 +0000 (23:16 +0300)]
Add assertions to ensure ADD_CALL_CHAIN is called holding the lock
(code refactoring)
* alloc.c (GC_collect_a_little_inner, GC_allocobj): Add assertion that
the allocation lock is held.
* dbg_mlc.c (GC_store_debug_info_inner): Likewise.
* dbg_mlc.c [DBG_HDRS_ALL] (GC_debug_generic_malloc_inner,
GC_debug_generic_malloc_inner_ignore_off_page): Likewise.
* finalize.c [!GC_TOGGLE_REFS_NOT_NEEDED] (ensure_toggleref_capacity):
Likewise.
* specific.c [USE_CUSTOM_SPECIFIC] (GC_key_create_inner): Likewise.
* alloc.c (GC_allocobj): Remove comment (about the lock).
* dbg_mlc.c [DBG_HDRS_ALL] (GC_debug_generic_malloc_inner): Likewise.
Ivan Maidanski [Thu, 15 Mar 2018 07:41:22 +0000 (10:41 +0300)]
Fix comment for debug_generic_malloc_inner[_ignore_off_page]
(fix of commit
38965f279)
* dbg_mlc.c [DBG_HDRS_ALL] (GC_debug_generic_malloc_inner): Update
comment after adding GC_start_debugging[_inner] call.
Ivan Maidanski [Thu, 15 Mar 2018 07:10:39 +0000 (10:10 +0300)]
Fix the collector hang when it is configured with --enable-gc-debug
Issue #205 (bdwgc).
* dbg_mlc.c (GC_store_debug_info_inner): Remove comment (as it exists
in the header); change from STATIC to GC_INNER.
* dbg_mlc.c (STORE_DEBUG_INFO): New macro.
* dbg_mlc.c (GC_store_debug_info): Change from GC_INNER to static;
remove GC_ prefix; replace ptr_t to void*; add fn argument;
replace "const char *string, int linenum" with GC_EXTRA_PARAMS;
change "word sz" argument to "size_t lb"; allow p to be null (print
error message in this case); call GC_start_debugging_inner unless
GC_debugging_started; call ADD_CALL_CHAIN.
* dbg_mlc.c (GC_start_debugging): Remove.
* dbg_mlc.c (GC_debug_malloc, GC_debug_malloc_ignore_off_page,
GC_debug_malloc_atomic_ignore_off_page, GC_debug_generic_malloc,
GC_debug_malloc_atomic, GC_debug_malloc_uncollectable): Call
STORE_DEBUG_INFO() instead of checking result for null and calling
GC_start_debugging, ADD_CALL_CHAIN, GC_store_debug_info.
* dbg_mlc.c [STUBBORN_ALLOC] (GC_debug_malloc_stubborn): Likewise.
* dbg_mlc.c [GC_ATOMIC_UNCOLLECTABLE]
(GC_debug_malloc_atomic_uncollectable): Likewise.
* gcj_mlc.c [GC_GCJ_SUPPORT] (GC_debug_gcj_malloc): Call ADD_CALL_CHAIN
while holding the lock; call GC_store_debug_info_inner (holding the
lock) instead of GC_store_debug_info.
* include/private/dbg_mlc.h (ADD_CALL_CHAIN): Update comment.
* include/private/gc_priv.h (GC_store_debug_info): Replace with
GC_store_debug_info_inner; update comment; change ptr_t to void*.
* os_dep.c [SAVE_CALL_CHAIN] (GC_save_callers): Add assertion that the
allocation lock is held; add comment.
Ivan Maidanski [Tue, 13 Mar 2018 22:18:30 +0000 (01:18 +0300)]
Access finalize_now atomically to avoid TSan warning without no-sanitize
* finalize.c (SET_FINALIZE_NOW): New macro (which uses AO_store if
available).
* finalize.c (GC_finalize): Use SET_FINALIZE_NOW(fo) instead of
GC_fnlz_roots.finalize_now=fo.
* finalize.c [!JAVA_FINALIZATION_NOT_NEEDED]
(GC_enqueue_all_finalizers): Likewise.
* finalize.c [THREADS] (GC_invoke_finalizers): Likewise.
* finalize.c (GC_should_invoke_finalizers): Remove
GC_ATTR_NO_SANITIZE_THREAD.
* finalize.c [AO_HAVE_load] (GC_should_invoke_finalizers): Use AO_load
to get GC_fnlz_roots.finalize_now value.
Ivan Maidanski [Tue, 13 Mar 2018 21:44:42 +0000 (00:44 +0300)]
Travis CI: Test pointer backtracing full support with TSan
Ivan Maidanski [Tue, 13 Mar 2018 08:02:27 +0000 (11:02 +0300)]
Use atomic load/store for the concurrently accessed variables in GC_lock
* include/private/gc_locks.h [!GC_WIN32_THREADS && GC_PTHREADS
&& AO_HAVE_char_store] (ENTER_GC, EXIT_GC): Use AO_char_store to update
GC_collecting.
* pthread_support.c [AO_HAVE_char_load] (is_collecting): Replace
function to macro (and remove GC_ATTR_NO_SANITIZE_THREAD); use
AO_char_load to get GC_collecting value; remove .
* pthread_support.c [USE_SPIN_LOCK] (spin_max, last_spins): Change type
from unsigned to AO_t; reformat comment.
* pthread_support.c [USE_SPIN_LOCK] (set_last_spins_and_high_spin_max,
reset_spin_max): Remove static functions (together with
GC_ATTR_NO_SANITIZE_THREAD).
* pthread_support.c [USE_SPIN_LOCK] (GC_lock): Use AO_load to get
spin_max and last_spins values; replace set_last_spins_and_high_spin_max
and reset_spin_max calls with the relevant AO_store calls.
Ivan Maidanski [Mon, 12 Mar 2018 22:23:49 +0000 (01:23 +0300)]
Eliminate TSan warning about non-atomic read in store_back_pointer
(fix of commit 701858e)
* include/private/dbg_mlc.h [PARALLEL_MARK && KEEP_BACK_PTRS]
(GC_HAS_DEBUG_INFO): Use AO_load to access the word pointed by p; add
comment.
Ivan Maidanski [Fri, 9 Mar 2018 20:23:56 +0000 (23:23 +0300)]
Avoid potential race in SET_MARK_BIT_EXIT_IF_SET if parallel marking
* include/private/gc_atomic_ops.h [GC_BUILTIN_ATOMIC] (AO_char_load,
AO_HAVE_char_load, AO_char_store, AO_HAVE_char_store): Define macro.
* include/private/gc_pmark.h [USE_MARK_BYTES && PARALLEL_MARK
&& AO_HAVE_char_store && !AO_USE_PTHREAD_DEFS]
(SET_MARK_BIT_EXIT_IF_SET): Use AO_char_load/store to access hb_marks.
* include/private/gc_pmark.h [!USE_MARK_BYTES && PARALLEL_MARK
&& THREAD_SANITIZER] (OR_WORD_EXIT_IF_SET): Use AO_load to fetch the
word at addr.
* tests/test_atomic_ops.c [AO_HAVE_char_load || AO_HAVE_char_store]
(main): Define c local variable.
* tests/test_atomic_ops.c [AO_HAVE_char_load] (main): Test AO_char_load.
* tests/test_atomic_ops.c [AO_HAVE_char_store] (main): Test
AO_char_store.
Ivan Maidanski [Wed, 7 Mar 2018 18:34:28 +0000 (21:34 +0300)]
Really use AO_load/store in realloc, clear_hdr_marks and reclaim_generic
(fix of commit bc7d075)
* include/private/gc_atomic_ops.h [GC_BUILTIN_ATOMIC] (AO_HAVE_load,
AO_HAVE_store, AO_HAVE_store_release_write): Define macro.
Ivan Maidanski [Wed, 7 Mar 2018 17:40:05 +0000 (20:40 +0300)]
Avoid potential race when storing oh_back_ptr during parallel marking
* dbg_mlc.c [KEEP_BACK_PTRS && PARALLEL_MARK] (GC_store_back_pointer):
Store source to dest->oh_back_ptr atomically (unordered atomic store
is sufficient here).
Ivan Maidanski [Tue, 6 Mar 2018 22:24:05 +0000 (01:24 +0300)]
Workaround sem_wait failure in pthread_create on Haiku
Issue #97 (bdwgc).
sem_wait() fails because of some bug in Haiku OS (as of hrev51798).
* pthread_support.c [GC_HAIKU_THREADS] (WRAP_FUNC(pthread_create)):
If errno is EACCES then just retry sem_wait instead of ABORT.
Ivan Maidanski [Tue, 6 Mar 2018 22:13:15 +0000 (01:13 +0300)]
Workaround Haiku pthread_join failure in subthreadcreate_test
Issue #97 (bdwgc).
The underlying pthread_join fails because of some bug in Haiku OS
(as of hrev51798) when many threads are created in parallel.
* tests/subthread_create.c [__HAIKU__]: Include errno.h.
* tests/subthread_create.c [__HAIKU__] (main): If pthread_join returned
value is ESRCH then just end the test normally (i.e. ignore the failure
of pthread_join); add comment and TODO item.
Ivan Maidanski [Tue, 6 Mar 2018 21:48:29 +0000 (00:48 +0300)]
Revert 'Report errno in case of sem_wait failure in GC_pthread_create'
This reverts commit
003470047cd1873080657dcb821d02cb806409b4.
The reverted commit was needed only to print the error code on Haiku;
the commit is not needed permanently.
Ivan Maidanski [Tue, 6 Mar 2018 08:34:17 +0000 (11:34 +0300)]
Avoid duplication of code handling pthreads case in configure
(code refactoring)
* configure.ac [$THREADS=pthreads] (default_threadlibs): New variable.
* configure.ac [$THREADS=pthreads && ($host in *-*-aix* | *-*-cygwin*
| *-*-darwin* | *-*-dragonfly* | *-*-freebsd* | *-*-haiku*
| *-*-hpux11* | *-*-irix* | *-*-kfreebsd*-gnu | *-*-gnu* | *-*-*linux*
| *-*-nacl* | *-*-netbsd* | *-*-openbsd* | *-*-osf* | *-*-solaris*)]
(default_threadlibs): Set to true.
* configure.ac [$THREADS=pthreads && !($host in
*-*-hpux11* | *-*-openbsd* | *-*-freebsd* | *-*-gnu* | *-*-netbsd*
| *-*-solaris* | *-*-cygwin* | *-*-mingw* | *-*-darwin* | *-*-osf*)]:
Do AC_MSG_ERROR() only if default_threadlibs is false.
Ivan Maidanski [Tue, 6 Mar 2018 08:02:02 +0000 (11:02 +0300)]
Fix 'pthreads not supported by GC' configure error for DragonFly and Haiku
(fix of commits 19c81d8, 847927f)
Issue #97 (bdwgc).
* configure.ac [$THREADS=pthreads && ($host=*-*-dragonfly*
|| $host=*-*-haiku*)]: Do not AC_MSG_ERROR (i.e. use the default
THREADDLLIBS).
Ivan Maidanski [Mon, 5 Mar 2018 14:04:52 +0000 (17:04 +0300)]
Update ChangeLog file
Ivan Maidanski [Mon, 5 Mar 2018 10:55:41 +0000 (13:55 +0300)]
Update ChangeLog file (v7.6 changes only)
(a cherry-pick of commit
12d1a4d3 from 'release-7_6')
Ivan Maidanski [Sun, 4 Mar 2018 15:52:32 +0000 (18:52 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)
(a cherry-pick of commit
08a2e0ba from 'release-7_4')
Ivan Maidanski [Fri, 2 Mar 2018 09:05:24 +0000 (12:05 +0300)]
Travis CI: Test compilation of C files by clang++
Ivan Maidanski [Fri, 2 Mar 2018 09:03:01 +0000 (12:03 +0300)]
Change backtrace-specific code to comply with C++11 standard
Issue #206 (bdwgc).
* dbg_mlc.c (GC_get_back_ptr_info): Cast GC_REVEAL_POINTER() result
to ptr_t (when assigned to bp local variable).
* dbg_mlc.c (GC_generate_random_valid_address): Cast result of
GC_generate_random_heap_address() to ptr_t.
* dbg_mlc.c (GC_print_backtrace): Cast GC_print_heap_obj() argument
to ptr_t.
Ivan Maidanski [Fri, 2 Mar 2018 08:28:50 +0000 (11:28 +0300)]
Workaround missing extern 'C' for _DYNAMIC in link.h on some Linux hosts
Issue #206 (bdwgc).
* dyn_load.c [DYNAMIC_LOADING && (SCO_ELF || DGUX || HURD
|| __ELF__ && (LINUX || FREEBSD || NACL || NETBSD || OPENBSD))
&& !HOST_ANDROID]: Put EXTERN_C_BEGIN/END around include link.h; add
comment.
Ivan Maidanski [Thu, 1 Mar 2018 22:38:10 +0000 (01:38 +0300)]
Wrap remaining extern symbols in .c files into EXTERN_C_BEGIN/END
Issue #206 (bdwgc).
* dyn_load.c [SOLARISDL && !USE_PROC_FOR_LIBRARIES] (_DYNAMIC):
Move the extern symbol declaration out of a function body.
* os_dep.c [!PCR && !MACOS && REDIRECT_MALLOC && GC_SOLARIS_THREADS]
(sbrk): Likewise.
* dyn_load.c [SOLARISDL && !USE_PROC_FOR_LIBRARIES] (_DYNAMIC):
Wrap into EXTERN_C_BEGIN/END block.
* dyn_load.c [__ELF__ && LINUX && HOST_ANDROID || HAVE_DL_ITERATE_PHDR]
(dl_iterate_phdr): Likewise.
* dyn_load.c [!USE_PROC_FOR_LIBRARIES] (_DYNAMIC): Likewise.
* dyn_load.c [ALPHA && OSF1 || HPUX] (sys_errlist, sys_nerr, errno):
Likewise.
* os_dep.c [SEARCH_FOR_DATA_START && (LINUX || HURD)] (__data_start,
data_start): Likewise.
* os_dep.c [SEARCH_FOR_DATA_START && LINUX && HOST_ANDROID] (_etext,
__dso_handle): Likewise.
* os_dep.c [NETBSD && __ELF__] (environ): Likewise.
* os_dep.c [OPENBSD && THREADS] (__syscall): Likewise.
* os_dep.c [LINUX_STACKBOTTOM && USE_LIBC_PRIVATES] (__libc_stack_end):
Likewise.
* os_dep.c [LINUX_STACKBOTTOM && USE_LIBC_PRIVATES && IA64]
(__libc_ia64_register_backing_store_base): Likewise.
* os_dep.c [SYMBIAN] (GC_get_main_symbian_stack_base): Likewise.
* os_dep.c [!PCR && !MACOS && REDIRECT_MALLOC && GC_SOLARIS_THREADS]
(sbrk): Likewise.
* os_dep.c [MMAP_SUPPORTED && SYMBIAN]
(GC_get_private_path_and_zero_file): Likewise.
* pthread_stop_world.c [USE_TKILL_ON_ANDROID] (tkill): Likewise.
* pthread_stop_world.c [NACL] (nacl_interface_query): Likewise.
* pthread_support.c [PTHREAD_REGISTER_CANCEL_WEAK_STUBS]
(__pthread_register_cancel, __pthread_unregister_cancel): Likewise.
* pthread_support.c [PTHREAD_REGISTER_CANCEL_WEAK_STUBS]
(__pthread_register_cancel, __pthread_unregister_cancel): Use "void"
to denote empty arguments list.
Ivan Maidanski [Thu, 1 Mar 2018 20:06:54 +0000 (23:06 +0300)]
windows-untested: Add gc_alloc_ptrs.h source file
Ivan Maidanski [Thu, 1 Mar 2018 20:02:41 +0000 (23:02 +0300)]
Eliminate 'unused const variable' C++ warnings for [a][u]objfreelist_ptr
Issue #206 (bdwgc).
* Makefile.direct (SRCS): Add include/gc_alloc_ptrs.h.
* include/include.am (dist_noinst_HEADERS): Likewise.
* include/gc_alloc_ptrs.h: New file.
* include/new_gc_alloc.h (GC_objfreelist_ptr, GC_aobjfreelist_ptr,
GC_uobjfreelist_ptr, GC_auobjfreelist_ptr, GC_incr_bytes_allocd,
GC_incr_bytes_freed): Move to the declarations to gc_alloc_ptrs.h.
* include/new_gc_alloc.h: Include gc_alloc_ptrs.h; update comment.
* mallocx.c: Likewise.
Ivan Maidanski [Thu, 1 Mar 2018 19:47:22 +0000 (22:47 +0300)]
Fix missing GC_generic_malloc_words_small implementation in new_gc_alloc.h
* include/new_gc_alloc.h (GC_generic_malloc_words_small): Replace
prototype with a macro (that uses GC_generic_malloc); remove FIXME item.
Ivan Maidanski [Thu, 1 Mar 2018 08:58:48 +0000 (11:58 +0300)]
Fix missing explicit cast of si_addr to char* in write_fault_handler
Issue #206 (bdwgc).
* os_dep.c [!DARWIN && !MSWIN32 && !MSWINCE] (GC_write_fault_handler):
Cast si->si_addr to char* when assigned to addr local variable.
Ivan Maidanski [Thu, 1 Mar 2018 08:47:58 +0000 (11:47 +0300)]
Travis CI: Test javaxfc.h symbols linkage in case of a C++ compiler
Ivan Maidanski [Thu, 1 Mar 2018 08:44:07 +0000 (11:44 +0300)]
Eliminate 'unused const variable' Clang warning for copyright and version
Issue #206 (bdwgc).
* alloc.c (GC_copyright): Declare (inside EXTERN_C_BEGIN/END) before
the definition.
* alloc.c [!GC_NO_VERSION_VAR] (GC_version): Likewise.
Ivan Maidanski [Thu, 1 Mar 2018 08:35:41 +0000 (11:35 +0300)]
Fix linkage of javaxfc.h symbols for the case of compilation as C++ code
Issue #206 (bdwgc).
The functions should be declared (as extern "C") before the definition.
* finalize.c [!GC_NO_FINALIZATION]: Include javaxfc.h.
* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD]: Likewise.
Ivan Maidanski [Wed, 28 Feb 2018 20:45:12 +0000 (23:45 +0300)]
Move include gcconfig.h ouf of extern 'C' block
(fix of commit f4fbef0)
Issue #201 (bdwgc).
Extern "C" should be only around declarations, not includes.
* tests/test_cpp.cc: Move the beginning of extern "C" block
below #include gcconfig.h.
Ivan Maidanski [Wed, 28 Feb 2018 20:16:36 +0000 (23:16 +0300)]
Fix include gc_gcj.h in thread_local_alloc.c
The #include for the public GC headers should not contain "include/"
prefix.
* thread_local_alloc.c [GC_GCJ_SUPPORT]: Include "gc_gcj.h" instead of
"include/gc_gcj.h".
Ivan Maidanski [Wed, 28 Feb 2018 18:39:04 +0000 (21:39 +0300)]
Replace conditional extern 'C' blocks begin/end with EXTERN_C_BEGIN/END
(code refactoring)
Issue #206 (bdwgc).
Note: EXTERN_C_BEGIN and EXTERN_C_END are not available in the GC
public headers.
* include/private/darwin_stop_world.h: Replace the conditional
extern "C" block begin/end with EXTERN_C_BEGIN and EXTERN_C_END,
respectively.
* include/private/dbg_mlc.h: Likewise.
* include/private/gc_hdrs.h: Likewise.
* include/private/gc_locks.h: Likewise.
* include/private/gc_pmark.h: Likewise.
* include/private/gc_priv.h: Likewise.
* include/private/gcconfig.h: Likewise.
* include/private/pthread_stop_world.h: Likewise.
* include/private/pthread_support.h: Likewise.
* include/private/specific.h: Likewise.
* include/private/thread_local_alloc.h: Likewise.
* os_dep.c [MPROTECT_VDB && DARWIN]: Likewise.
* tests/test.c [GC_AMIGA_FASTALLOC && AMIGA]: Likewise.
* include/private/gcconfig.h (EXTERN_C_BEGIN, EXTERN_C_END): Define
macro.
Ivan Maidanski [Wed, 28 Feb 2018 06:40:27 +0000 (09:40 +0300)]
Remove a redundant check of __cplusplus in Symbian-specific .cpp files
(code refactoring)
* extra/symbian.cpp: Remove "#ifdef __cplusplus" as the latter should
be defined (by default) in case of .cpp file.
* extra/symbian/global_end.cpp: Likewise.
* extra/symbian/global_start.cpp: Likewise.
* extra/symbian/init_global_static_roots.cpp: Likewise.
* extra/symbian/init_global_static_roots.cpp
(GC_init_global_static_roots): Adjust indentation.
Ivan Maidanski [Wed, 28 Feb 2018 06:27:26 +0000 (09:27 +0300)]
Remove API symbols renaming in WCC_MAKEFILE
GC_is_marked, GC_incr_bytes_allocd, GC_incr_bytes_freed are now
declared as GC_API, the so symbols renaming by the linker is not needed.
GC_generic_malloc_words_small does not exist anymore.
* WCC_MAKEFILE [MAKE_AS_DLL] (gc.dll): Remove "append $*.lnk export"
for GC_is_marked, GC_incr_bytes_allocd, GC_incr_bytes_freed,
GC_generic_malloc_words_small.
* WCC_MAKEFILE (gc.lib): Adjust indentation.
* WCC_MAKEFILE [MAKE_AS_DLL] (gctest.exe): Remove "append $*.lnk import"
for GC_is_marked.
* WCC_MAKEFILE [MAKE_AS_DLL] (test_cpp.exe): Remove
"append $*.lnk import" for GC_incr_bytes_allocd, GC_incr_bytes_freed,
GC_generic_malloc_words_small.
Ivan Maidanski [Wed, 28 Feb 2018 06:21:18 +0000 (09:21 +0300)]
Travis CI: Output content of threadkey_test.log
Ivan Maidanski [Wed, 28 Feb 2018 06:12:54 +0000 (09:12 +0300)]
Declare all internal functions in private headers instead of .c files
(code refactoring)
Issue #206 (bdwgc).
* include/private/darwin_stop_world.h [MPROTECT_VDB
&& !GC_NO_THREADS_DISCOVERY] (GC_darwin_register_mach_handler_thread):
Declare function.
* include/private/gc_priv.h [WRAP_MARK_SOME && PARALLEL_MARK]
(GC_push_conditional_eager): Likewise.
* include/private/gc_priv.h [!THREADS && TRACE_BUF]
(GC_add_trace_entry): Likewise.
* include/private/gc_priv.h (GC_collect_or_expand): Likewise.
* include/private/gc_priv.h [MPROTECT_VDB && USE_MUNMAP]
(GC_mprotect_dirty_init, GC_has_unmapped_memory): Likewise.
* include/private/gc_priv.h [CHECKSUMS && MPROTECT_VDB && !DARWIN]
(GC_record_fault): Likewise.
* include/private/gc_priv.h [CHECKSUMS] (GC_check_dirty): Likewise.
* include/private/gc_priv.h [GC_WIN32_THREADS && WRAP_MARK_SOME
&& !GC_PTHREADS] (GC_started_thread_while_stopped): Likewise.
* include/private/gc_priv.h [SEARCH_FOR_DATA_START
|| NETBSD && __ELF__] (GC_find_limit): Likewise.
* include/private/gc_priv.h [NEED_PROC_MAPS && (IA64
|| INCLUDE_LINUX_THREAD_DESCR)] (GC_enclosing_mapping): Likewise.
* include/private/pthread_support.h (GC_inner_start_routine): Likewise.
* include/private/thread_local_alloc.h [GC_ASSERTIONS]
(GC_is_thread_tsd_valid, GC_check_tls_for): Likewise.
* include/private/thread_local_alloc.h [GC_ASSERTIONS
&& USE_CUSTOM_SPECIFIC] (GC_check_tsd_marks): Likewise.
* include/private/gc_priv.h [HEURISTIC2 || SEARCH_FOR_DATA_START
|| !STACKBOTTOM && HEURISTIC2 || (SVR4 || AIX || DGUX
|| LINUX && SPARC) && !PCR] (NEED_FIND_LIMIT): Collapse multiple
definitions.
* malloc.c (GC_collect_or_expand): Remove prototype.
* mark.c [CHECKSUMS] (GC_check_dirty): Likewise.
* mark.c [GC_WIN32_THREADS && !GC_PTHREADS]
(GC_started_thread_while_stopped): Likewise.
* mark_rts.c [WRAP_MARK_SOME && PARALLEL_MARK]
(GC_push_conditional_eager): Likewise.
* mark_rts.c [!THREADS && TRACE_BUF] (GC_add_trace_entry): Likewise.
* os_dep.c [SEARCH_FOR_DATA_START || NETBSD && __ELF__]
(GC_find_limit): Likewise.
* os_dep.c [CHECKSUMS && MPROTECT_VDB && !DARWIN] (GC_record_fault):
Likewise.
* os_dep.c [MPROTECT_VDB && USE_MUNMAP] (GC_has_unmapped_memory,
GC_mprotect_dirty_init): Likewise.
* os_dep.c [MPROTECT_VDB && !GC_NO_THREADS_DISCOVERY]
(GC_darwin_register_mach_handler_thread): Likewise.
* pthread_support.c [GC_ASSERTIONS] (GC_check_tls_for): Likewise.
* pthread_support.c [GC_ASSERTIONS && USE_CUSTOM_SPECIFIC]
(GC_check_tsd_marks): Likewise.
* pthread_support.c [INCLUDE_LINUX_THREAD_DESCR]
(GC_enclosing_mapping): Likewise.
* pthread_support.c [!SN_TARGET_ORBIS && !SN_TARGET_PSP2]
(GC_inner_start_routine): Likewise.
* thread_local_alloc.c [GC_ASSERTIONS] (GC_is_thread_tsd_valid):
Likewise.
* win32_threads.c [GC_ASSERTIONS] (GC_check_tls_for): Likewise.
* win32_threads.c [GC_ASSERTIONS && USE_CUSTOM_SPECIFIC]
(GC_check_tsd_marks): Likewise.
Ivan Maidanski [Wed, 28 Feb 2018 05:26:27 +0000 (08:26 +0300)]
Fix typo in AIX macro name
* include/private/gc_priv.h [AIX] (NEED_FIND_LIMIT): Define macro
(rename AUX to AIX).
* os_dep.c [AIX && !PCR] (GC_SysVGetDataStart): Define function.
Ivan Maidanski [Wed, 28 Feb 2018 02:55:59 +0000 (05:55 +0300)]
Eliminate warning about unused start_routine for Orbis and PSP2
(fix of commits d5dad58, cd63cf1)
Issue #173 (bdwgc).
* pthread_support.c (GC_inner_start_routine, GC_start_routine): Do not
define if SN_TARGET_ORBIS or SN_TARGET_PSP2.
Ivan Maidanski [Tue, 27 Feb 2018 21:46:23 +0000 (00:46 +0300)]
Fix GC_free_bytes[] linkage for the case of compilation as C++ code
Issue #206 (bdwgc).
* include/private/gc_priv.h [GC_GCJ_SUPPORT] (GC_free_bytes): Declare;
update comment.
Ivan Maidanski [Tue, 27 Feb 2018 21:35:19 +0000 (00:35 +0300)]
Fix dbg_mlc.c/o file name in documentation
* README.md (Debugging Facilities): Fix file name ("dbg_mlc.c").
* misc.c (GC_debugging_started): Fix file name ("dbg_mlc.o") in
comment.
Hans Boehm [Mon, 26 Feb 2018 20:45:24 +0000 (23:45 +0300)]
Avoid potential race when accessing size_map table
There is again a data race between GC_extend_size_map and GC_size_map[]
readers, though it is again not likely to fail in practice.
It is feasible to just move all of the GC_size_map accesses under the
lock, and this does not look to incur a substantial penalty.
* gcj_mlc.c (GC_gcj_malloc, GC_gcj_malloc_ignore_off_page): Move
lg=GC_size_map[lb] to be right after LOCK() instead of preceding it.
* malloc.c (GC_malloc_kind_global, GC_generic_malloc_uncollectable):
Likewise.
* typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Likewise.
* include/gc.h (GC_get_size_map_at): Update comment to note that the
client should use synchronization when calling the function.
* include/private/gc_priv.h (_GC_arrays._size_map): Add comment about
synchronization.
Ivan Maidanski [Mon, 26 Feb 2018 20:27:21 +0000 (23:27 +0300)]
Revert 'Workaround TSan false positives in extend_size_map'
This reverts commit
e522d6d791680b55825b5f11a4c082eb4770ecf5.
Because there is again a data race here, not a false positive,
though it is again not likely to fail in practice.
Ivan Maidanski [Mon, 26 Feb 2018 19:03:30 +0000 (22:03 +0300)]
Always include gc_atomic_ops.h unless threads are disabled
(code refactoring)
* include/private/gc_atomic_ops.h [!GC_BUILTIN_ATOMIC]: Issue #error
if AO_HAVE_load or AO_HAVE_store is not defined after include
atomic_ops.h.
* include/private/gc_locks.h: Do not include gc_atomic_ops.h.
* include/private/specific.h: Likewise.
* pthread_stop_world.c: Likewise.
* tests/test.c [THREADS && (GC_BUILTIN_ATOMIC || PARALLEL_MARK
|| !GC_WIN32_THREADS)]: Likewise.
* thread_local_alloc.c: Likewise.
* typd_mlc.c [GC_FORCE_INCLUDE_ATOMIC_OPS || GC_BUILTIN_ATOMIC]:
Likewise.
* win32_threads.c [(GC_DLL || GC_INSIDE_DLL) && !THREAD_LOCAL_ALLOC
&& !GC_NO_THREADS_DISCOVERY && !MSWINCE && !GC_PTHREADS]: Likewise.
* include/private/gc_priv.h [THREADS && !SN_TARGET_ORBIS
&& !SN_TARGET_PSP2]: Include gc_atomic_ops.h (after GC_INLINE
definition).
* include/private/gc_priv.h (counter_t): Do not define.
* include/private/gc_priv.h (hblkhdr): Change type of hb_n_marks
to either volatile AO_t (if PARALLEL_MARK) or size_t
* mark.c (GC_noop6): Check AO_CLEAR macro presence instead of
GC_PTHREADS and !GC_WIN32_THREADS or PARALLEL_MARK.
* tests/test_atomic_ops.c [_WIN32 || _MSC_VER || __CYGWIN__
|| __MINGW32__] (main): Do not skip the test.
Ivan Maidanski [Mon, 26 Feb 2018 06:33:23 +0000 (09:33 +0300)]
Fix Haiku/amd64 support
(fix of commit 847927f)
Issue #97 (bdwgc).
* include/gc_config_macros.h [__HAIKU__ && !GC_CAN_SAVE_CALL_STACKS]
(GC_ADD_CALLER): Define macro.
* include/private/gcconfig.h [__HAIKU__ && __x86_64__] (X86_64, HAIKU,
mach_type_known): Likewise.
* include/private/gcconfig.h [HAIKU && X86_64] (HEURISTIC2,
SEARCH_FOR_DATA_START): Likewise.
* include/private/gcconfig.h [UNIX_LIKE && HAIKU] (NO_GETCONTEXT):
Likewise.
* include/private/thread_local_alloc.h [GC_HAIKU_THREADS]
(USE_PTHREAD_SPECIFIC): Likewise.
* include/private/gcconfig.h [HAIKU && X86_64] (etext, DATASTART): Do
not define.
Jay Krell [Sun, 18 Feb 2018 05:23:34 +0000 (21:23 -0800)]
Fiddle with linkage to make extra/gc.c valid C++ code
Issue #206 (bdwgc).
Specifically: int i; int i = 0; is not valid, but:
extern int i; int i = 0; is valid. Adding static would also be
desirable here but requires a larger change.
* extra/gc.c (GC_INNER, GC_EXTERN): Do not define if __cplusplus; add
comment and TODO item.
Jay Krell [Mon, 26 Feb 2018 04:53:37 +0000 (07:53 +0300)]
Change Darwin-specific code to comply with C++11 standard
Issue #206 (bdwgc).
* darwin_stop_world.c (GC_stack_range_for): Cast pointer which is
assinged to lo local variable to ptr_t (instead of void*).
* os_dep.c [GC_DARWIN_THREADS && MPROTECT_VDB]: Include
darwin_stop_world.h (so that GC_mprotect_stop and GC_mprotect_resume
to be declared and later defined as extern "C").
* os_dep.c [MPROTECT_VDB && DARWIN] (exc_server, exception_raise,
exception_raise_state): Wrap into extern "C" block; refine comment.
* os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise_state,
catch_exception_raise_state_identity): Declare as extern "C" (before
the definition).
* os_dep.c [MPROTECT_VDB && DARWIN && THREADS] (GC_mprotect_state):
Initialize to GC_MP_NORMAL (instead of integer 0).
Ivan Maidanski [Thu, 22 Feb 2018 21:54:02 +0000 (00:54 +0300)]
Fix missing new-line in GC_INFOLOG_PRINTF call in ABORT_ARG<n>
* include/private/gc_priv.h (ABORT_ARG1, ABORT_ARG2, ABORT_ARG3):
Output "\n" after C_fmt by GC_INFOLOG_PRINTF.
Ivan Maidanski [Thu, 22 Feb 2018 21:34:39 +0000 (00:34 +0300)]
Report errno in case of sem_wait failure in GC_pthread_create
Issue #97 (bdwgc).
* pthread_support.c (WRAP_FUNC(pthread_create)): Change ABORT() for
"sem_wait failed" case to ABORT_ARG1() to report errno as well.
Ivan Maidanski [Thu, 22 Feb 2018 21:19:37 +0000 (00:19 +0300)]
Omit register keyword in performance-critical code if C++ compiler used
Issue #206 (bdwgc).
* headers.c (GC_next_used_block): Replace register keyword to REGISTER.
* include/private/gc_hdrs.h [HASH_TL] (GET_BI, GET_HDR_ADDR, GET_HDR,
SET_HDR): Likewise.
* mark.c (GC_push_all_eager): Likewise.
* mark.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager):
Likewise.
* include/private/gc_priv.h (REGISTER): New macro (defined before
include gc_hdrs.h); add comment.
Ivan Maidanski [Thu, 22 Feb 2018 20:39:38 +0000 (23:39 +0300)]
Fix type of local variables receiving result of PHT_HASH
The variables should be of word type, not int or size_t.
* os_dep.c (GC_write_fault_handler, GC_remove_protection): Change type
of index local variable from size_t to word.
* os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise): Change
type of index local variable from int to word.
Jay Krell [Thu, 22 Feb 2018 20:23:48 +0000 (23:23 +0300)]
Eliminate C++ warnings about deprecated register keyword (GC source)
Issue #206 (bdwgc).
* blacklst.c (GC_number_stack_black_listed, total_stack_black_listed):
Remove register keyword for local variables.
* dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX]
(GC_register_dynamic_libraries): Likewise.
* extra/pcr_interface.c [PCR] (GC_enumerate_block): Likewise.
* finalize.c (GC_grow_table): Likewise.
* headers.c (alloc_hdr, GC_init_headers, GC_remove_counts,
GC_prev_block): Likewise.
* include/private/gc_pmark.h (PUSH_OBJ): Likewise.
* mach_dep.c [!HAVE_PUSH_REGS && !HAVE_BUILTIN_UNWIND_INIT]
(GC_with_callee_saves_pushed): Likewise.
* mark.c (clear_marks_for_block): Likewise.
* mark_rts.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_add_roots_inner):
Likewise.
* mark_rts.c [!NO_DEBUGGING] (GC_is_tmp_root): Likewise.
* os_dep.c [GWW_VDB || MPROTECT_VDB || PROC_VDB || MANUAL_VDB]
(GC_page_was_dirty): Likewise.
* os_dep.c [CHECKSUMS && GWW_VDB || PROC_VDB] (GC_or_pages,
GC_page_was_ever_dirty): Likewise.
* os_dep.c (GC_write_fault_handler): Likewise.
* os_dep.c [PROC_VDB] (GC_read_dirty): Likewise.
* os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise): Likewise.
* os_dep.c [SAVE_CALL_CHAIN && NARGS>0] (GC_save_callers): Likewise.
* pthread_stop_world.c [!NACL] (GC_start_world): Likewise.
* pthread_support.c (GC_delete_thread, GC_delete_gc_thread): Likewise.
* typd_mlc.c (GC_push_complex_descriptor): Likewise.
* win32_threads.c (GC_delete_gc_thread_no_free, GC_delete_thread):
Likewise.
Jay Krell [Mon, 19 Feb 2018 11:42:25 +0000 (03:42 -0800)]
Eliminate C++ warning about deprecated register keyword (cord)
Issue #206 (bdwgc).
* cord/cordbscs.c (CORD_dump_inner, CORD_cat_char_star, CORD_cat,
CORD_from_fn_inner, CORD_index_access_fn, CORD_apply_access_fn,
CORD_substr_closure, CORD_substr_checked, CORD_substr, CORD_iter5,
CORD_riter4, CORD_init_min_len, CORD_init_forest, CORD_add_forest,
CORD_concat_forest, CORD_balance_insert, CORD_balance,
CORD__extend_path, CORD__pos_fetch, CORD__next, CORD__prev,
CORD_pos_fetch: Remove register keyword for local variables (and
function parameters).
* cord/cordprnt.c (extract_conv_spec, CORD_vsprintf): Likewise.
* cord/cordxtra.c (CORD_cat_char, CORD_catn, CORD_fill_proc,
CORD_batched_fill_proc, CORD_cmp, CORD_ncmp, CORD_to_char_star,
CORD_put_proc, CORD_batched_put_proc, CORD_chr_proc, CORD_rchr_proc,
CORD_batched_chr_proc, CORD_str, CORD_ec_flush_buf,
CORD_from_file_eager, refill_cache, CORD_lf_func,
CORD_from_file_lazy_inner, CORD_from_file_lazy, CORD_from_file):
Likewise.
* cord/tests/cordtest.c (test_basics, test_extras): Likewise.
* cord/tests/de.c (retrieve_line, redisplay): Likewise.
* cord/tests/de_win.c (plain_chars, control_chars, WndProc): Likewise.
Jay Krell [Mon, 19 Feb 2018 11:43:37 +0000 (03:43 -0800)]
Fix 'invalid conversion from const char* to char*' in CORD_batched_chr_proc
Issue #206 (bdwgc).
Add const to the variable receiving strchr() result for C++ compatibility.
* cord/cordxtra.c (CORD_batched_chr_proc): Change type of occ local
variable from char* to const char*; remove register keyword for occ.
Ivan Maidanski [Tue, 20 Feb 2018 20:03:29 +0000 (23:03 +0300)]
Fix 'anonymous type with no linkage used to declare variable' in GC source
Issue #206 (bdwgc).
* dyn_load.c [DARWIN] (GC_dyld_sections): Provide some name to struct.
* finalize.c (GC_fnlz_roots): Likewise.
* os_dep.c [MPROTECT_VDB && DARWIN] (GC_ports,
GC_mprotect_thread_notify, GC_mprotect_thread): Likewise.
Ivan Maidanski [Tue, 20 Feb 2018 08:48:57 +0000 (11:48 +0300)]
Update AUTHORS file
Aurelien Larcher [Tue, 20 Jun 2017 22:14:44 +0000 (22:14 +0000)]
Do not use alternate thread library on Solaris
* configure.ac [THREADS=posix && host=*-*-solaris*]
(multi_os_directory): Remove variable; remove comment.
* configure.ac [THREADS=posix && host=*-*-solaris*] (THREADDLLIBS):
Remove -L and -R options.
Shea Levy [Mon, 19 Feb 2018 15:38:26 +0000 (10:38 -0500)]
Merge RISCV 32/64-bit configurations definition
(code refactoring of commit 4f7f0ee)
Issue #208 (bdwgc).
* include/private/gcconfig.h [__riscv && LINUX] (RISCV32, RISCV64):
Replace with RISCV.
* include/private/gcconfig.h [RISCV] (MACH_TYPE): Change to "RISC-V".
* include/private/gcconfig.h [RISCV] (CPP_WORDSZ, ALIGNMENT): Define
using __riscv_xlen.
Ivan Maidanski [Tue, 20 Feb 2018 08:13:20 +0000 (11:13 +0300)]
Travis CI: Test compilation of GC/cord C files as C++ (Makefile.direct)
Ivan Maidanski [Tue, 20 Feb 2018 07:55:45 +0000 (10:55 +0300)]
Update AUTHORS file
Kimura Wataru [Mon, 19 Feb 2018 20:21:17 +0000 (23:21 +0300)]
Workaround Clang optimizer bug crashing clear_stack_inner on OS X 10.8
* misc.c [!ALWAYS_SMALL_CLEAR_STACK && !STACK_NOT_SCANNED
&& !ASM_CLEAR_CODE && __APPLE_CC__ && !GC_CLANG_PREREQ(6,0)]
(GC_clear_stack_inner): Add volatile to limit argument.
Ivan Maidanski [Mon, 19 Feb 2018 08:02:12 +0000 (11:02 +0300)]
Fix man section number (3)
Library calls should use section 3 (unlike Programs that use section 1).
* doc/gc.man (TH GC_MALLOC): Change section number from 1L to 3.
Ivan Maidanski [Mon, 19 Feb 2018 07:52:02 +0000 (10:52 +0300)]
Update AUTHORS file (add Shea Levy)
Shea Levy [Sun, 18 Feb 2018 06:37:12 +0000 (01:37 -0500)]
Add initial RISC-V support
Issue #208 (bdwgc).
* include/private/gcconfig.h [__riscv && LINUX && __riscv_xlen==32]
(RISCV32, mach_type_known): Define macro.
* include/private/gcconfig.h [__riscv && LINUX && __riscv_xlen==64]
(RISCV64, mach_type_known): Define macro.
* include/private/gcconfig.h [RISCV32 || RISCV64] (CPP_WORDSZ,
MACH_TYPE, ALIGNMENT): Likewise.
* include/private/gcconfig.h [(RISCV32 || RISCV64) && LINUX] (OS_TYPE,
DATASTART, LINUX_STACKBOTTOM, DYNAMIC_LOADING): Likewise.
* include/private/gcconfig.h [(RISCV32 || RISCV64) && LINUX]
(__data_start): Declare external variable.
Ivan Maidanski [Fri, 16 Feb 2018 18:05:21 +0000 (21:05 +0300)]
Convert GC source files to valid C++ code
Issue #206 (bdwgc).
* alloc.c (GC_copyright): Change type from char* const to
const char* const.
* alloc.c (GC_set_fl_marks, GC_clear_fl_marks, GC_finish_collection,
GC_allocobj): Add missing explicit casts from void* to ptr_t.
* backgraph.c [MAKE_BACK_GRAPH] (add_back_edges): Likewise.
* blacklst.c (GC_default_print_heap_obj_proc,
GC_print_blacklisted_ptr): Likewise.
* dbg_mlc.c (GC_get_back_ptr_info, GC_store_debug_info_inner,
GC_store_debug_info, GC_debug_malloc, GC_debug_malloc_ignore_off_page,
GC_debug_malloc_atomic_ignore_off_page, GC_debug_generic_malloc,
GC_debug_malloc_stubborn, GC_debug_malloc_atomic,
GC_debug_malloc_uncollectable, GC_debug_malloc_atomic_uncollectable,
GC_debug_free, GC_debug_free_inner, GC_debug_register_finalizer,
GC_debug_register_finalizer_no_order,
GC_debug_register_finalizer_unreachable,
GC_debug_register_finalizer_ignore_self): Likewise.
* finalize.c (GC_grow_table, push_and_mark_object,
ensure_toggleref_capacity, GC_dump_finalization_links,
GC_dump_finalization, GC_make_disappearing_links_disappear,
GC_remove_dangling_disappearing_links, GC_finalize): Likewise.
* gcj_mlc.c (GC_gcj_malloc, GC_debug_gcj_malloc,
GC_gcj_malloc_ignore_off_page): Likewise.
* include/private/gc_pmark.h (PUSH_CONTENTS_HDR): Likewise.
* mallocx.c (GC_memalign): Likewise.
* mark.c (GC_mark_from, GC_mark_and_push, GC_push_all_eager,
GC_push_all_stack, GC_push_marked1, GC_push_marked2, GC_push_marked4):
Likewise.
* mark_rts.c (GC_exclude_static_roots_inner): Likewise.
* misc.c (GC_base): Likewise.
* new_hblk.c (GC_new_hblk): Likewise.
* pthread_support.c (GC_register_altstack, GC_thr_init,
GC_record_stack_base): Likewise.
* ptr_chck.c (GC_is_visible): Likewise.
* reclaim.c (GC_reclaim_small_nonempty_block,
GC_disclaim_and_reclaim_or_free_small_block): Likewise.
* thread_local_alloc.c (GC_mark_thread_local_fls_for): Likewise.
* typd_mlc.c (GC_typed_mark_proc,
GC_malloc_explicitly_typed_ignore_off_page): Likewise.
* win32_threads.c (GC_record_stack_base, GC_get_stack_min,
GC_push_stack_for): Likewise.
* blacklst.c (GC_copy_bl): Rename "new" argument to "dest".
* dbg_mlc.c (GC_store_debug_info_inner, GC_print_smashed_obj): Change
type of p argument from ptr_t to void*.
* include/private/gc_priv.h (GC_is_heap_base, GC_is_static_root):
Likewise.
* mark_rts.c [!THREADS] (GC_is_static_root): Likewise.
* os_dep.c (GC_is_malloc_heap_base, GC_is_heap_base): Likewise.
* ptr_chck.c (GC_on_stack): Likewise.
* dbg_mlc.c (GC_print_obj): Change type of kind_str local variable
from char* to const char*.
* dbg_mlc.c (GC_debug_strdup, GC_debug_strndup): Cast result of
GC_debug_malloc_atomic() to char*.
* mallocx.c (GC_strdup, GC_strndup): Likewise.
* dbg_mlc.c (GC_debug_wcsdup): Cast result of GC_debug_malloc_atomic()
to wchar_t*.
* mallocx.c (GC_wcsdup): Likewise.
* dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32]
(GC_register_dynamic_libraries): Cast p local variable to char*.
* os_dep.c (GC_register_data_segments): Likewise.
* fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_disclaim): Cast masked
fc_word to struct GC_finalizer_closure* (instead of void*).
* fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_malloc): Cast result of
GC_malloc_kind() to word*.
* typd_mlc.c (GC_malloc_explicitly_typed, GC_calloc_explicitly_typed):
Likewise.
* include/private/gc_priv.h (WARN): Cast away const qualifier for msg
(and the string literal).
* misc.c (GC_default_on_abort): Remove cast to void* for WRITE()
buf argument.
* misc.c (GC_new_free_list_inner): Cast result local variable to void**.
* misc.c (GC_new_free_list): Change type of result local variable from
void* to void**.
* pthread_support.c (GC_start_rtn_prepare_thread): Cast arg to
struct start_info*.
* win32_threads.c [GC_PTHREADS] (GC_pthread_start_inner): Likewise.
* reclaim.c (GC_print_free_list): Replace ptr_t flh to void *flh_next
local variable; remove redundant casts.
* tools/if_mach.c (EXECV_ARGV_T): New macro; add comment.
* tools/if_not_there.c (EXECV_ARGV_T): Likewise.
* tools/if_mach.c (main): Use EXECV_ARGV_T instead of void* for
execvp() argument.
* tools/if_not_there.c (main): Likewise.
* typd_mlc.c (LeafDescriptor, ComplexArrayDescriptor,
SequenceDescriptor): Move struct definition out of union
ComplexDescriptor.
* typd_mlc.c (GC_add_ext_descriptor): Rename "new" local variable to
newExtD.
* win32_threads.c (GC_CreateThread, GC_beginthreadex): Cast result
of GC_malloc_uncollectable() to thread_args*.
* win32_threads.c [PARALLEL_MARK && !MSWINCE && __cplusplus]
(GC_thr_init): Do not cast GetProcessAffinityMask() arguments to void*.
Ivan Maidanski [Wed, 14 Feb 2018 08:58:07 +0000 (11:58 +0300)]
Fix 'implicit conversion from size_t to int changes value' clang warning
(fix of commit 9468065)
* misc.c (GC_get_size_map_at): Replace (size_t)(signed_word)-1 to
GC_SIZE_MAX.
* tests/test.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (check_heap_stats):
Replace (size_t)(GC_signed_word)-1 to -1.
Ivan Maidanski [Wed, 14 Feb 2018 08:48:57 +0000 (11:48 +0300)]
New API function (get_size_map_at) to get content of size_map table
* include/gc.h (GC_get_size_map_at): Declare public function.
* misc.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (GC_get_size_map_at):
Implement function
* tests/test.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (check_heap_stats):
Add dummy testing of GC_get_size_map_at.
Ivan Maidanski [Wed, 14 Feb 2018 08:26:45 +0000 (11:26 +0300)]
Convert cord source files to valid C++ code
Issue #206 (bdwgc).
* cord/cordbscs.c (Concatenation, Function, Generic): Define struct
outside union (i.e. the union just uses them).
* cord/cordbscs.c (CORD_cat_char_star, CORD_from_fn_inner,
CORD_substr_checked): Cast GC_MALLOC_ATOMIC() result to char*.
* cord/cordprnt.c (CORD_vsprintf): Likewise.
* cord/cordxtra.c (CORD_cat_char, CORD_to_char_star,
CORD_from_char_star, CORD_ec_flush_buf): Likewise.
* cord/cordbscs.c (CORD_substr_checked): Remove register keyword for
"result" local variable.
Jay Krell [Mon, 12 Feb 2018 21:34:21 +0000 (00:34 +0300)]
Change pointer arguments of push_all[_eager]/conditional API to void* type
Receiving void* instead of char* is easier to use, as it requires
no casting.
A small downside of this change is that anyone using decltype(GC_push)
in C++ function signatures would get a different name mangling.
* include/gc_mark.h (GC_push_all, GC_push_all_eager,
GC_push_conditional): Change type of bottom and top arguments from
char* to void*.
* mark.c (GC_push_all, GC_push_conditional, GC_push_all_eager):
Likewise.
* include/private/gc_priv.h (GC_PUSH_ALL_SYM): Cast away volatile
qualifier for &sym.
* mark.c (GC_push_all): Remove "register" keyword for length local
variable.
* mark.c [!GC_DISABLE_INCREMENTAL] (GC_push_selected): Remove unneeded
casts for GC_push_all arguments.
* mark.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager):
Change type of bottom and top arguments from ptr_t to void*.
* mark_rts.c [WRAP_MARK_SOME && PARALLEL_MARK]
(GC_push_conditional_eager): Likewise.
* mark_rts.c (GC_PUSH_CONDITIONAL): Remove unneeded casts for
GC_push_all and GC_push_conditional arguments.
Hans Boehm [Mon, 12 Feb 2018 08:24:54 +0000 (11:24 +0300)]
Avoid potential race between realloc and clear_hdr_marks/reclaim_generic
GC_realloc might be changing the block size while GC_reclaim_block
or GC_clear_hdr_marks is examining it. The change to the size field
is benign, in that GC_reclaim (and GC_clear_hdr_marks) would work
correctly with either value, since we are not changing the number
of objects in the block. But seeing a half-updated value (though
unlikely to occur in practice) could be probably bad.
Using unordered atomic accesses on the size and hb_descr fields would
solve the issue.
* mallocx.c [AO_HAVE_store] (GC_realloc): Use AO_store() to update
hhdr->hb_sz and hhdr->hb_descr; add static assert that size of
hhdr->hb_sz matches that of AO_t; add comment.
* mallocx.c [!AO_HAVE_store] (GC_realloc): Add LOCK/UNLOCK around
hb_sz and hb_descr fields assignment.
* mark.c [AO_HAVE_load] (GC_clear_hdr_marks): Use AO_load() to get
hhdr->hb_sz value; add comment.
* reclaim.c (IS_PTRFREE_SAFE): New macro (uses AO_load() if available).
* reclaim.c (GC_reclaim_generic, GC_reclaim_block): Replace
(hhdr)->hb_descr==0 with IS_PTRFREE_SAFE(hhdr).
Ivan Maidanski [Fri, 9 Feb 2018 15:40:20 +0000 (18:40 +0300)]
Revert 'Workaround TSan false positive about clear_hdr_marks/realloc race'
This reverts commit
20468dd131d82be7422aea3c7383ec9201452fce.
Because it is not a false positive. And we are lying to the compiler
about the value not changing asynchronously, which is never good.
The proper solution could be use of atomic accesses (even unordered)
on the size field.
Ivan Maidanski [Fri, 9 Feb 2018 08:27:36 +0000 (11:27 +0300)]
Travis CI: Test compiling GC/cord tests as C++ ones by Makefile.direct
Ivan Maidanski [Fri, 9 Feb 2018 08:17:29 +0000 (11:17 +0300)]
Fix build of cord tests as C++ files (Makefile.direct)
* Makefile.direct (cords): Do not depend on cord/cordtest.
* Makefile.direct (cord): Remove.
* Makefile.direct (cord/cordbscs.o, cord/cordxtra.o, cord/cordprnt.o):
Do not depend on cord target (folder); add "mkdir cord" (ignoring
errors) before moving .o file to "cord" folder.
Ivan Maidanski [Fri, 9 Feb 2018 08:07:03 +0000 (11:07 +0300)]
Fix 'anonymous type with no linkage used to declare variable' C++ error
(fix of commit 8086c72)
Issue #201 (bdwgc).
* tests/test.c (A): Give some name to struct.
* tools/setjmp_t.c (a): Likewise.
Ivan Maidanski [Fri, 9 Feb 2018 07:55:32 +0000 (10:55 +0300)]
Replace GC_MALLOC(sizeof T) with GC_NEW(T) in tests
(code refactoring)
* tests/realloc_test.c (main): Replace (T*)GC_MALLOC(sizeof(T)) with
GC_NEW(T).
* tests/test.c (small_cons, mktree, run_one_test): Likewise.
Ivan Maidanski [Thu, 8 Feb 2018 08:56:44 +0000 (11:56 +0300)]
Convert remaining GC tests to valid C++ code
(fix of commit 8086c72)
Issue #201 (bdwgc).
* tests/disclaim_bench.c (testobj_new): Replace GC_MALLOC(sizeof T)
with GC_NEW(T).
* tests/staticrootslib.c (libsrl_mktree): Likewise.
* tests/trace_test.c (mktree): Likewise.
* tests/disclaim_bench.c (testobj_new): Cast GC_finalized_malloc()
result to testobj_t.
* tests/disclaim_bench.c (main): Cast GC_MALLOC() result to testobj_t*.
* tests/disclaim_test.c (pair_dct): Cast obj to pair_t.
* tests/disclaim_test.c (pair_dct): Cast cd to pair_t.
* tests/disclaim_test.c (GC_finalized_malloc): Cast
GC_finalized_malloc() result to pair_t.
* tests/staticrootslib.c (root_nz): Cast element to struct treenode*.
* tests/staticrootstest.c (root_nz): Likewise.
* tests/staticrootslib.c (libsrl_mktree): Cast GC_MALLOC_ATOMIC()
result to struct treenode*.
* tests/trace_test.c (mktree): Likewise.
* tests/staticrootstest.c (init_staticroot): Cast libsrl_init() result
to char*.
* tests/thread_leak_test.c (main): Cast malloc() result to int*.
Ivan Maidanski [Thu, 8 Feb 2018 08:51:00 +0000 (11:51 +0300)]
Fix arg type of continue_reclaim prototype after the definition update
(fix of commit e794f1e)
* include/private/gc_priv.h (GC_continue_reclaim): Change type of sz
argument from size_t to word (matching the function definition).
Ivan Maidanski [Thu, 8 Feb 2018 08:45:57 +0000 (11:45 +0300)]
Fix arguments delimiter in pcr_interface.c (PCR)
* extra/pcr_interface.c (GC_enumerate_block): Replace ';' with ',' in
the arguments list.
Ivan Maidanski [Thu, 8 Feb 2018 08:41:45 +0000 (11:41 +0300)]
Change type of hb_sz field (of hblkhdr) from size_t to word
This is needed to make the size of hb_sz to be the same as of AO_t.
* allchblk.c [USE_MUNMAP] (GC_unmap_old): Cast hhdr->hb_sz to size_t
when passed to GC_unmap().
* allchblk.c (GC_allochblk_nth): Cast hhdr->hb_sz to signed_word when
assigned to size_avail.
* allchblk.c [USE_MUNMAP] (GC_allochblk_nth): Cast hhdr->hb_sz to
size_t when passed to GC_remap().
* alloc.c (GC_set_fl_marks, GC_clear_fl_marks): Change type of sz and
bit_no local variables from size_t/unsigned to word.
* dbg_mlc.c (GC_check_heap_block): Likewise.
* backgraph.c [MAKE_BACK_GRAPH] (per_object_helper): Cast hhdr->hb_sz
to size_t; change type of i local variables from int to size_t.
* checksums.c [CHECKSUMS] (GC_on_free_list): Change type of sz local
variable from size_t to word.
* mark.c (GC_push_marked, GC_push_unconditionally, GC_block_was_dirty):
Likewise.
* reclaim.c (GC_reclaim_small_nonempty_block,
GC_disclaim_and_reclaim_or_free_small_block, GC_reclaim_block,
GC_n_set_marks): Likewise.
* checksums.c [CHECKSUMS] (GC_add_block): Remove bytes local variable
(to avoid casting of hhdr->hb_sz).
* dbg_mlc.c (GC_debug_free): Change type of i and obj_sz local
variables from size_t to word.
* dbg_mlc.c (GC_check_leaked): Likewise.
* extra/pcr_interface.c (GC_enumerate_block): Change type of sz local
variable from int to size_t.
* extra/pcr_interface.c (GC_enumerate_block): Cast hhdr->hb_sz to
size_t when assigned to sz.
* mallocx.c (GC_realloc): Likewise.
* mark.c (GC_set_hdr_marks): Likewise.
* reclaim.c (GC_do_enumerate_reachable_objects): Likewise.
* include/private/gc_pmark.h [MARK_BIT_PER_OBJ] (PUSH_CONTENTS_HDR):
Cast hhdr->hb_sz to size_t in assignment of obj_displ.
* include/private/gc_priv.h (struct hblkhdr): Change type of hb_sz from
size_t to word.
* include/private/gc_priv.h (MARK_BIT_NO): Cast offset argument to word
instead of unsigned.
* malloc.c (GC_free): Cast hhdr->hb_sz to size_t.
* mallocx.c (GC_get_kind_and_size): Likewise.
* mark.c (GC_clear_hdr_marks): Likewise.
* misc.c (GC_size): Likewise.
* misc.c (GC_do_blocking): Remove redundant cast of hhdr->hb_sz.
* reclaim.c (GC_reclaim_clear, GC_reclaim_uninit,
GC_disclaim_and_reclaim, GC_continue_reclaim): Change type of sz
argument from size_t to word.
* typd_mlc.c (GC_array_mark_proc): Change type of sz and nwords local
variables from size_t to word.
Ivan Maidanski [Thu, 8 Feb 2018 07:02:19 +0000 (10:02 +0300)]
Travis CI: Test compilation of C tests as C++ ones
Issue #201 (bdwgc).
Ivan Maidanski [Thu, 8 Feb 2018 06:57:23 +0000 (09:57 +0300)]
Convert cord tests to valid C++ code
Issue #201 (bdwgc).
* cord/tests/de.c (main): Cast buf to char* when passed to setvbuf().
* cord/tests/de_win.c (de_error): Change "char*" to "const char*" for
the argument (because ISO C++ forbids converting a string constant to
char*).
* cord/tests/de_win.h (de_error): Likewise.
* cord/tests/de_win.c (WinMain): Change type of hAccel local variable
from HANDLE to HACCEL; cast GetStockObject(WHITE_BRUSH) result to
HBRUSH type.
* cord/tests/de_win.c (plain_chars, control_chars): Cast
GC_MALLOC_ATOMIC() result to char*.
* cord/tests/de_win.c (WndProc): Change type of hInstance static
variable from HANDLE to HINSTANCE.
Jay Krell [Thu, 8 Feb 2018 06:26:03 +0000 (09:26 +0300)]
Compile some GC tests as C++ to test extern 'C' in header files
Issue #201 (bdwgc).
* tests/CMakeLists.txt (SET_SOURCE_FILES_PROPERTIES): Add to treat
leak_test.c and test.c as C++ files.
Ivan Maidanski [Thu, 8 Feb 2018 06:02:14 +0000 (09:02 +0300)]
Put GC internal function prototypes in tests into extern 'C' block
Issue #201 (bdwgc).
* tests/disclaim_test.c [__cplusplus] (GC_random): Wrap the function
declaration into extern "C".
* tests/test.c [__cplusplus] [GC_AMIGA_FASTALLOC && AMIGA]
(GC_amiga_free_all_mem): Likewise.
Ivan Maidanski [Wed, 7 Feb 2018 22:53:46 +0000 (01:53 +0300)]
Put variable/function declarations into extern 'C' in cord headers
Issue #201 (bdwgc).
* include/cord.h: Wrap variable and function declarations (but not
included headers).
* include/cord_pos.h: Likewise.
* include/ec.h: Likewise.