Maya Rashish [Thu, 6 Jun 2019 02:43:51 +0000 (05:43 +0300)]
Get rid of some non-ELF ifdefs
(code refactoring)
Issue #283 (bdwgc).
Linux started switching to ELF in 1995 (Linux-2.0), due to the previous
a.out being really bad.
NetBSD has used ELF since 2002 (NetBSD 1.6), it's OK to let it go now.
FreeBSD switched to ELF in FreeBSD 3.0 (1998).
Victor Romero [Thu, 6 Jun 2019 07:24:28 +0000 (10:24 +0300)]
Do not build the tests by default (CMake)
Issue #281 (bdwgc).
build_cord and build_tests options are introduced in the CMake script.
* CMakeLists.txt (build_cord): Add option (on by default); add comment.
* CMakeLists.txt (build_tests): Add option (off by default).
* CMakeLists.txt (cord): Specify add_subdirectory only if build_cord.
* CMakeLists.txt (tests): Specify add_subdirectory only if build_tests.
* cord/CMakeLists.txt: Skip cordtest and de tests unless build_tests.
Ivan Maidanski [Wed, 5 Jun 2019 06:53:15 +0000 (09:53 +0300)]
Turn off C++ API in CMake script by default
Issue #281 (bdwgc).
This is to match the behavior of configure script.
Now, -Denable_cplusplus=ON should be passed to cmake to enable C++ API.
* CMakeLists.txt (enable_cplusplus): Add option (off by default);
remove TODO.
* CMakeLists.txt (SRC): Add gc_cpp.cc only if enable_cplusplus.
* tests/CMakeLists.txt (leak_test.c, test.c): Set CXX langunage
property only if enable_cplusplus.
* tests/CMakeLists.txt [enable_cplusplus]: Add TODO to add test_cpp as
a test.
Ivan Maidanski [Thu, 30 May 2019 20:57:46 +0000 (23:57 +0300)]
Fix 'GC_old_bus_handler defined but not used' compiler warning
* os_dep.c [!DARWIN && !MSWIN32 && !MSWINCE] (GC_old_bus_handler):
Define variable only if FREEBSD or HPUX, or HURD, or LINUX.
* os_dep.c [!DARWIN && !MSWIN32 && !MSWINCE && (HPUX || HURD
|| FREEBSD)] (GC_dirty_init): Do not set GC_old_bus_handler_used_si
to FALSE (because it is already initialized to FALSE).
Ivan Maidanski [Wed, 29 May 2019 08:16:04 +0000 (11:16 +0300)]
Fix 'unused function GC_lock' compiler warning
* include/private/gc_locks.h [GC_PTHREADS && !USE_SPIN_LOCK] (GC_lock):
Declare only if USE_PTHREAD_LOCKS and (GC_ASSERTIONS or
not NO_PTHREAD_TRYLOCK).
* pthread_support.c [!USE_SPIN_LOCK] (GC_lock): Define only if
USE_PTHREAD_LOCKS and (not NO_PTHREAD_TRYLOCK or GC_ASSERTIONS).
Ivan Maidanski [Mon, 27 May 2019 19:00:59 +0000 (22:00 +0300)]
Use lowercase naming of commands in CMake scripts
(code refactoring)
* CMakeLists.txt: Convert all commands from uppercase to lowercase.
* tests/CMakeLists.txt: Likewise.
* CMakeLists.txt: Reformat the whole file (indent is 2 spaces).
Ivan Maidanski [Mon, 29 Apr 2019 06:44:42 +0000 (09:44 +0300)]
Fix first_thread stack_base initialzation if custom GC_stackbottom (Win32)
Stack bottom value of the primordial thread should be obtained from
GC_stackbottom.
* win32_threads.c [GC_ASSERTIONS] (GC_thr_init): Remove sb_result local
variable.
* win32_threads.c (GC_thr_init): Initalize sb mem_base and reg_base
fields with GC_stackbottom and GC_register_stackbottom, respectively;
do not call GC_get_stack_base().
Ivan Maidanski [Fri, 26 Apr 2019 16:03:42 +0000 (19:03 +0300)]
Replace 'stack base' with 'stack bottom' in the documentation
* README.md (The C Interface to the Allocator): Outline that stack base
means its bottom; remove a note that client should set GC_stackbottom
on HP PA machines manually.
* doc/README.macros (USE_GET_STACKBASE_FOR_MAIN): Rename "stack base"
to "stack bottom".
* doc/porting.md (Adding Platforms to gcconfig.h): Likewise.
* doc/porting.md (Adding Platforms to gcconfig.h): Rename
"cool end of the stack" to "cold end of the stack"; refine
documentation about STACKBOTTOM.
* include/private/gcconfig.h (STACKBOTTOM): Rename "cool end" to
"cold end" in comment.
* include/gc.h (GC_stackbottom): Likewise.
* include/private/gcconfig.h (LINUX_STACKBOTTOM): Rename "stack base"
to "stack bottom" in comment.
* include/gc.h (GC_stack_base, GC_call_with_stack_base): Likewise.
* include/gc.h [GC_THREADS] (GC_register_my_thread): Likewise.
* misc.c [!THREADS] (GC_call_with_gc_active): Likewise.
* os_dep.c [LINUX_STACKBOTTOM] (GC_linux_main_stack_base): Likewise.
* os_dep.c (GC_get_stack_base): Likewise.
* pthread_support.c (GC_call_with_gc_active): Likewise.
* win32_threads.c (GC_call_with_gc_active): Likewise.
Ivan Maidanski [Thu, 25 Apr 2019 07:28:40 +0000 (10:28 +0300)]
Refine do_blocking() documentation in gc.h
* include/gc.h (GC_do_blocking): Refine comment (copy part of comment
from misc.c, add information that GC should be initialized and the
current thread should be registered).
* misc.c (GC_do_blocking): Remove title comment (as it duplicates the
one in gc.h).
Ivan Maidanski [Thu, 25 Apr 2019 06:54:13 +0000 (09:54 +0300)]
Check real-symbols are already initialized in pthread_join/detach
* pthread_support.c (ASSERT_SYMS_INITIALIZED): New macro (checks either
GC_syms_initialized or parallel_initialized depending on
GC_USE_DLOPEN_WRAP).
* pthread_support.c [!SN_TARGET_ORBIS && !SN_TARGET_PSP2] (pthread_join,
pthread_detach): Call ASSERT_SYMS_INITIALIZED() instead of
INIT_REAL_SYMS().
Ivan Maidanski [Tue, 23 Apr 2019 19:21:54 +0000 (22:21 +0300)]
Workaround 'duplicate expression for condition and assignment' cppcheck FP
The entitled cppcheck warnings are false positives.
* alloc.c (GC_should_collect): Move reassignment of the global variable
which is checked in the conditional expression to the end of the
conditional block statement.
* finalize.c (GC_notify_or_invoke_finalizers): Likewise.
* mark.c [WRAP_MARK_SOME] (GC_mark_some): Likewise.
Ivan Maidanski [Fri, 19 Apr 2019 05:07:52 +0000 (08:07 +0300)]
Remove Win32 main_thread static variable if threads discovery is disabled
(code refactoring)
* win32_threads.c (GC_main_thread): Do not define static variable if
GC_NO_THREADS_DISCOVERY.
* win32_threads.c [!GC_NO_THREADS_DISCOVERY] (GC_attached_thread):
Reformat comment; move the definition to be near GC_please_stop.
* win32_threads.c [GC_NO_THREADS_DISCOVERY] (GC_thr_init): Define
GC_main_thread as a macro (and undefine it at the end of the function).
Ivan Maidanski [Tue, 16 Apr 2019 21:52:59 +0000 (00:52 +0300)]
Enable true incremental collection even if parallel marker is on
Issue #151 (bdwgc).
Because of the current limitation of the parallel marker implementation,
it is not possible to interrupt the collection when performed by the
parallel marker. This change allows to have the true incremental mode
at the expense of disabling the parallel marker during most collection
phases. By default, the old behavior (a generational collection with
the parallel marker enabled) is preserved unless the client sets
GC_time_limit to a value other than GC_TIME_UNLIMITED.
* alloc.c [(!GC_TIME_LIMIT || CPPCHECK) && PARALLEL_MARK]
(GC_time_limit): Set to GC_TIME_UNLIMITED; add comment.
* alloc.c [PARALLEL_MARK] (GC_collect_a_little_inner): Temporarily
set GC_parallel_mark_disabled to TRUE before GC_mark_some repeated
invocation if GC_time_limit is not GC_TIME_UNLIMITED.
* alloc.c [PARALLEL_MARK] (GC_stopped_mark): Temporarily set
GC_parallel_mark_disabled to TRUE before GC_mark_some repeated
invocation if stop_func is not GC_never_stop_func; add verbose logging
if parallel marking is disabled temporarily.
* doc/README.environment (GC_PAUSE_TIME_TARGET): Update the description
(remove the limitation for the case when parallel marking is on).
* doc/scale.md (The Parallel Marking Algorithm): Update the
documentation regarding incremental mode.
* include/gc.h (GC_parallel, GC_enable_incremental): Update the comment
(remove the limitation on the incremental mode when parallel marking
is on).
* include/private/gc_priv.h [PARALLEL_MARK] (GC_parallel_mark_disabled):
Declare global variable.
* mark.c [PARALLEL_MARK] (GC_parallel_mark_disabled): Define.
* mark.c [PARALLEL_MARK] (GC_mark_some_inner): Do not call
GC_do_parallel_mark() if GC_parallel_mark_disabled; update comment.
* pthread_support.c [PARALLEL_MARK] (GC_thr_init): Do not set
GC_time_limit to GC_TIME_UNLIMITED if available_markers_m1 > 0; remove
comment.
* win32_threads.c [PARALLEL_MARK] (GC_thr_init): Likewise.
Ivan Maidanski [Tue, 16 Apr 2019 06:29:42 +0000 (09:29 +0300)]
Simplify loops of collect_a_little/stopped_mark invoking mark_some
(code refactoring)
* alloc.c (GC_collect_a_little_inner, GC_stopped_mark): If
GC_mark_some() returns true then just break to quit the loop; move the
logic that is needed to funish the collection outside the loop.
* alloc.c (GC_stopped_mark): Change i local variable type from unsigned
to int.
Ivan Maidanski [Fri, 12 Apr 2019 17:25:47 +0000 (20:25 +0300)]
Allow GC_PAUSE_TIME_TARGET environment variable values smaller than 5 ms
All time limit values starting from 1 ms are now accepted.
* misc.c [!GC_DISABLE_INCREMENTAL] (GC_init): Do not set GC_time_limit
if NO_CLOCK; allow all non-zero time_limit values (instead of >4);
do not call WARN() if time_limit value is incorrect.
Ivan Maidanski [Wed, 10 Apr 2019 20:25:50 +0000 (23:25 +0300)]
Fix 'un-mprotect failed' gctest error on Cygwin
(fix of commit fa7f7a72b)
Issue #272 (bdwgc).
* include/private/gcconfig.h [(I386 || X86_64) && CYGWIN32]
(MPROTECT_VDB): Do not define if USE_WINALLOC.
* os_dep.c [CYGWIN32 && MPROTECT_VDB] (GC_setpagesize): Set
GC_page_size to dwAllocationGranularity.
Ivan Maidanski [Tue, 9 Apr 2019 19:50:09 +0000 (22:50 +0300)]
Move QNX and Emscripten macro definitions to proper place in gcconfig.h
(code refactoring)
* include/private/gcconfig.h [__QNX__] (I386, mach_type_known): Move
macro definition down (to be in a group where mach_type_known is
defined for most platforms).
* include/private/gcconfig.h [__QNX__] (OS_TYPE, SA_RESTART,
HEURISTIC1, DATASTART, DATAEND): Move macro definition down; define
only if I386.
* include/private/gcconfig.h [__EMSCRIPTEN__] (OS_TYPE, CPP_WORDSZ,
ALIGNMENT, DATASTART, DATAEND, STACK_NOT_SCANNED): Likewise.
Ivan Maidanski [Thu, 4 Apr 2019 21:34:04 +0000 (00:34 +0300)]
Update documentation about the incremental collector support
* doc/README.darwin (Important Usage Notes): Remove outdated note about
flaky incremental mode.
* doc/README.darwin (Implementation Information): Remove information
about old incremental collector implementation.
* doc/README.win32 (Watcom compiler): Refine information about the
incremental mode support.
* doc/scale.md (Options for enhanced scalability): Refine when the
dedicated marker threads are created.