Slava Barinov [Thu, 9 Apr 2020 15:39:40 +0000 (18:39 +0300)]
packaging: Add devel-static package
Change-Id: I6d096b33dc9746345d73277af734730de441e1f9
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
Slava Barinov [Wed, 18 Mar 2020 14:52:15 +0000 (17:52 +0300)]
Remove libatomic_ops dependency
Slava Barinov [Fri, 13 Mar 2020 13:18:15 +0000 (16:18 +0300)]
Version bump
Slava Barinov [Mon, 3 Dec 2018 15:34:20 +0000 (18:34 +0300)]
Packaging created
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
Ivan Maidanski [Fri, 6 Mar 2020 22:23:35 +0000 (01:23 +0300)]
Pass -no-undefined linker flag if building shared libraries (CMake)
Declare that the libraries do not refer to external symbols.
Same as in configure script.
* CMakeLists.txt [BUILD_SHARED_LIBS] (HAVE_FLAG_WL_NO_UNDEFINED): Check
C compiler supports "-Wl,--no-undefined" option, set the variable
accordingly.
* CMakeLists.txt [BUILD_SHARED_LIBS && HAVE_FLAG_WL_NO_UNDEFINED] (gc):
Specify "-Wl,--no-undefined" link option (by target_link_libraries);
add TODO item.
* CMakeLists.txt [BUILD_SHARED_LIBS && HAVE_FLAG_WL_NO_UNDEFINED
&& enable_cplusplus] (gccpp): Likewise.
* CMakeLists.txt [BUILD_SHARED_LIBS && HAVE_FLAG_WL_NO_UNDEFINED
&& enable_cplusplus && enable_throw_bad_alloc_library] (gctba):
Likewise.
* CMakeLists.txt [BUILD_SHARED_LIBS && HAVE_FLAG_WL_NO_UNDEFINED
&& build_cord] (cord): Likewise.
Ivan Maidanski [Tue, 3 Mar 2020 07:24:10 +0000 (10:24 +0300)]
Replace obsolete AC_HELP_STRING with AS_HELP_STRING
(code refactoring)
* configure.ac (AC_ARG_ENABLE): Specify AS_HELP_STRING instead of
AC_HELP_STRING; adjust indentation.
* configure.ac [$THREADS=dgux386] (THREADS): Remove assignment to the
same value (dgux386).
* configure.ac (handle-fork): Remove extra leading space in help
string.
Ivan Maidanski [Mon, 2 Mar 2020 21:20:41 +0000 (00:20 +0300)]
Remove commented out assignment of gc_use_mmap in configure
(code refactoring)
The check and assignment is no longer needed as configured in gcconfig.h.
* configure.ac (gc_use_mmap): Refine comment.
* configure.ac [$host=*-linux*] (gc_use_mmap): Remove commented out
code; remove FIXME item.
Ivan Maidanski [Mon, 2 Mar 2020 21:14:43 +0000 (00:14 +0300)]
Detect presence and flavor of pthread_setname_np by CMake script
Issue #300 (bdwgc).
The detection works similar to that in configure.
* CMakeLists.txt [!BORLAND && !MSVC && !WATCOM] (HAVE_FLAG_WERROR): Set
the variable depending on -Werror option support by C compiler.
* CMakeLists.txt [!BORLAND && !MSVC && !WATCOM && HAVE_FLAG_WERROR]
(CMAKE_REQUIRED_FLAGS): Set variable to "-Werror".
* CMakeLists.txt [CMAKE_USE_PTHREADS_INIT]
(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID,
HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG,
HAVE_PTHREAD_SETNAME_NP_WITH_TID): Define C macro if pthread_setname_np
available.
Ivan Maidanski [Fri, 28 Feb 2020 19:57:08 +0000 (22:57 +0300)]
Support -fvisibility=hidden option in CMake script
The option is passed only if it is supported and the shared library
build is requested. The functionality is similar to that of configure.
* CMakeLists.txt [BUILD_SHARED_LIBS] (HAVE_FLAG_F_VISIBILITY_HIDDEN):
Check "-fvisibility=hidden" C compiler flag and set the variable
accordingly.
* CMakeLists.txt [BUILD_SHARED_LIBS && HAVE_FLAG_F_VISIBILITY_HIDDEN]
(GC_VISIBILITY_HIDDEN_SET): Define macro.
* CMakeLists.txt [BUILD_SHARED_LIBS && !HAVE_FLAG_F_VISIBILITY_HIDDEN]
(GC_NO_VISIBILITY): Likewise.
* CMakeLists.txt [BUILD_SHARED_LIBS && HAVE_FLAG_F_VISIBILITY_HIDDEN]:
Add "-fvisibility=hidden" compile option.
Ivan Maidanski [Fri, 28 Feb 2020 08:26:01 +0000 (11:26 +0300)]
New CMake option (disable_handle_fork) to disable fork handling completely
* CMakeLists.txt (disable_handle_fork): New option (off by default).
* CMakeLists.txt [CMAKE_USE_PTHREADS_INIT && !ANDROID && !MSYS
&& enable_handle_fork] (HANDLE_FORK): Do not define if
disable_handle_fork.
* CMakeLists.txt [disable_handle_fork] (NO_HANDLE_FORK): Define macro.
Ivan Maidanski [Thu, 27 Feb 2020 22:08:18 +0000 (01:08 +0300)]
Read environment variables from a file on WinCE (CMake script)
* CMakeLists.txt [!disable_gc_debug && WINCE] (GC_READ_ENV_FILE): Define
macro.
Ivan Maidanski [Thu, 27 Feb 2020 21:56:33 +0000 (00:56 +0300)]
AppVeyor CI: Test with CMake disable_gc_debug
Ivan Maidanski [Thu, 27 Feb 2020 21:51:58 +0000 (00:51 +0300)]
New CMake option (disable_gc_debug) to remove debugging code
This is similar to configure --disable-gc-debug.
* CMakeLists.txt (disable_gc_debug): New option.
* CMakeLists.txt [disable_gc_debug] (NO_DEBUGGING): Define macro.
Ivan Maidanski [Thu, 27 Feb 2020 08:16:03 +0000 (11:16 +0300)]
Eliminate 'gc_pthread_redirects.h should contain header guard' code defect
(revert part of commit
d07f685fb)
* gc_pthread_redirects.h (GC_PTHREAD_REDIRECTS_H): Add header inclusion
guard (to prevent multiple inclusion).
Ivan Maidanski [Wed, 26 Feb 2020 22:22:07 +0000 (01:22 +0300)]
Detect dladdr() presence in CMake script
* CMakeLists.txt (CheckCSourceCompiles): Include module.
* CMakeLists.txt: Check if C test code which calls dladdr() can be
compiled and linked successfully; set HAVE_DLADDR variable accordingly.
* CMakeLists.txt [HAVE_DLADDR] (HAVE_DLADDR): Define macro.
Ivan Maidanski [Tue, 25 Feb 2020 07:52:27 +0000 (10:52 +0300)]
Workaround 'x might be clobbered by longjmp' g++ warning in setjmp_t
(fix of commits
e59ed5784,
90331999b)
* tools/setjmp_t.c [!CPPCHECK && __cplusplus] (a_str): Define as
a macro.
Ivan Maidanski [Tue, 25 Feb 2020 07:21:09 +0000 (10:21 +0300)]
Detect sigsetjmp() availability in CMake script
* CMakeLists.txt (CheckSymbolExists): Include module.
* CMakeLists.txt (sigsetjmp): Check symbol exists in setjmp.h; set
HAVE_SIGSETJMP accordingly.
* CMakeLists.txt [!HAVE_SIGSETJMP] (GC_NO_SIGSETJMP): Define macro.
Ivan Maidanski [Tue, 25 Feb 2020 05:33:40 +0000 (08:33 +0300)]
Fix spelling of CheckIncludeFile module name in CMake script
(fix of commits
08405546d,
d42f5377a)
* CMakeLists.txt (CheckIncludeFile): Include module (instead of
CheckIncludeFiles).
Ivan Maidanski [Fri, 21 Feb 2020 19:49:48 +0000 (22:49 +0300)]
Disable Clang/GCC aliasing optimization in CMake script by default
* CMakeLists.txt (CheckCCompilerFlag): Include.
* CMakeLists.txt (HAVE_FLAG_F_NO_STRICT_ALIASING): Set variable
depending whether -fno-strict-aliasing option is supported by compiler.
* CMakeLists.txt [HAVE_FLAG_F_NO_STRICT_ALIASING]: Add
-fno-strict-aliasing compile option.
Ivan Maidanski [Fri, 21 Feb 2020 07:27:00 +0000 (10:27 +0300)]
Fix 'unknown CMake command check_include_file' build error
(fix of commit
08405546d)
* CMakeLists.txt (CheckIncludeFiles): Include module.
Ivan Maidanski [Fri, 21 Feb 2020 07:24:39 +0000 (10:24 +0300)]
Fix 'conversion from string constant to char*' warning in setjmp_t.c
(fix of commit
e59ed5784)
* tools/setjmp_t.c (a_str): Change type from char* to const char*.
Ivan Maidanski [Thu, 20 Feb 2020 08:31:23 +0000 (11:31 +0300)]
Detect presence of execinfo.h system header in CMake script
Previously, the check existed only in configure.
* CMakeLists.txt (execinfo.h): Check include file presence (set
HAVE_EXECINFO_H variable).
* CMakeLists.txt [!HAVE_EXECINFO_H] (GC_MISSING_EXECINFO_H): Define
macro.
Ivan Maidanski [Thu, 20 Feb 2020 07:50:08 +0000 (10:50 +0300)]
Detect presence of getcontext and dl_iterate_phdr in CMake script
Previously, presence of these system functions were done by configure
only.
* CMakeLists.txt (CheckFunctionExists): Include.
* CMakeLists.txt (getcontext, dl_iterate_phdr): Check function exists
(to set HAVE_GETCONTEXT and HAVE_DL_ITERATE_PHDR variables,
respectively).
* CMakeLists.txt [!HAVE_GETCONTEXT] (NO_GETCONTEXT): Define macro.
* CMakeLists.txt [HAVE_DL_ITERATE_PHDR] (HAVE_DL_ITERATE_PHDR):
Likewise.
Ivan Maidanski [Mon, 17 Feb 2020 21:54:32 +0000 (00:54 +0300)]
Workaround 'checking if unsigned GC_time_lim_nsec is < 0' cppcheck FP
* alloc.c [!GC_DISABLE_INCREMENTAL && !NO_CLOCK && CPPCHECK]
(GC_timeout_stop_func): Pass address of nsec_diff to GC_noop1().
Ivan Maidanski [Mon, 17 Feb 2020 08:01:11 +0000 (11:01 +0300)]
Workaround 'NULL==*flh is always true' cppcheck style warning in allocobj
* alloc.c [CPPCHECK] (GC_allocobj): Pass address of flh to GC_noop1
instead of its value.
Ivan Maidanski [Mon, 17 Feb 2020 07:33:05 +0000 (10:33 +0300)]
Workaround 'me->thread_blocked is always 1' cppcheck warning in do_blocking
* pthread_support.c [CPPCHECK] (GC_do_blocking_inner): Pass address of
me->thread_blocked to GC_noop1 (instead of its value).
Ivan Maidanski [Sat, 15 Feb 2020 14:09:16 +0000 (17:09 +0300)]
Workaround 'firstpass is always true' cppcheck FP in skip_hole_openbsd
* os_dep.c (firstpass): Move static volatile variable out of
GC_skip_hole_openbsd().
Ivan Maidanski [Sat, 15 Feb 2020 12:24:42 +0000 (15:24 +0300)]
Workaround 'condition x==2 is always false' cppcheck FP in setjmp_t
Computation of x local variable (stored in a register) in setjmp_t.c
is more disguised now.
* tools/setjmp_t.c (a_str): New global variable (initialized to "a").
* tools/setjmp_t.c (main): Pass a_str (instead of "a") to strlen().
John David Anglin [Thu, 13 Feb 2020 20:46:55 +0000 (23:46 +0300)]
Fix STACKBOTTOM on 32-bit HP/UX 11.11
Issue #305 (bdwgc).
* include/private/gcconfig.h [HP_PA && HPUX] (STACKBOTTOM): Add
comment.
* include/private/gcconfig.h [HP_PA && HPUX
&& !USE_HPUX_FIXED_STACKBOTTOM && !USE_ENVIRON_POINTER] (HEURISTIC2):
Define (instead of STACKBOTTOM).
Ivan Maidanski [Thu, 13 Feb 2020 20:24:01 +0000 (23:24 +0300)]
Update AUTHORS file (add John David Anglin)
John David Anglin [Thu, 13 Feb 2020 20:22:10 +0000 (23:22 +0300)]
Fix mmap() failures on HP/UX
Issue #305 (bdwgc).
Map memory with MAP_ANONYMOUS flag if HPUX.
Unmap memory using mprotect(PROT_NONE) instead of mmap(PROT_NONE)
if HPUX.
* include/private/gcconfig.h [(HP_PA || IA64) && HPUX && USE_MMAP]
(USE_MMAP_ANON): Define.
* os_dep.c [USE_MUNMAP && !USE_WINALLOC && !SN_TARGET_PS3 && HPUX]
(GC_unmap, GC_unmap_gap): Call mprotect() instead of mmap().
Ivan Maidanski [Wed, 12 Feb 2020 21:53:54 +0000 (00:53 +0300)]
Eliminate 'cast between incompatible function types' gcc-8 warning (Win64)
(fix of commit
9d869bcd9)
Issue #300 (bdwgc).
* win32_threads.c [!(GC_PTHREADS && HAVE_PTHREAD_SETNAME_NP_WITH_TID)
&& !MSWINCE] (set_marker_thread_name): Cast setThreadDescription_fn to
word type first; add comment.
Ivan Maidanski [Tue, 11 Feb 2020 08:56:18 +0000 (11:56 +0300)]
Revert 'Call GC_thr_init only once'
This reverts commit
03a3fbbdd5cff52360facdfcc9f86adbdc111245.
GC_thr_initialized is a static variable on Windows.
Ivan Maidanski [Tue, 11 Feb 2020 08:54:50 +0000 (11:54 +0300)]
Implement set_marker_thread_name on Windows 10
Issue #300 (bdwgc).
Call SetThreadDescription() if available.
* win32_threads.c [HAVE_PTHREAD_SETNAME_NP_WITH_TID]
(set_marker_thread_name): No-op unless GC_PTHREADS is defined.
* win32_threads.c [!(GC_PTHREADS && HAVE_PTHREAD_SETNAME_NP_WITH_TID)
&& !MSWINCE] (setThreadDescription_fn): New static variable.
* win32_threads.c [!(GC_PTHREADS && HAVE_PTHREAD_SETNAME_NP_WITH_TID)
&& !MSWINCE] (set_marker_thread_name): Compose thread name into
WCHAR buffer; call setThreadDescription_fn if non-null.
* win32_threads.c [(!HAVE_PTHREAD_SETNAME_NP_WITH_TID && !MSWINCE
&& PARALLEL_MARK) || WOW64_THREAD_CONTEXT_WORKAROUND] (GC_thr_init):
Declare and set hK32 local variable at the beginning of the function.
* win32_threads.c [PARALLEL_MARK && !HAVE_PTHREAD_SETNAME_NP_WITH_TID
&& !MSWINCE] (GC_thr_init): Set setThreadDescription_fn.
Ivan Maidanski [Tue, 11 Feb 2020 07:56:48 +0000 (10:56 +0300)]
Call GC_thr_init only once
(code refactoring)
GC_thr_init() is now called only if GC_thr_initialized;
"if(GC_thr_initialized)return" statement is removed from GC_thr_init.
* misc.c [GC_PTHREADS || GC_WIN32_THREADS] (GC_init): Do not call
GC_thr_init() if GC_thr_initialized.
* pthread_support.c (GC_thr_init): Remove return if GC_thr_initialized;
add GC_ASSERT that GC_thr_initialized is false.
* win32_threads.c (GC_thr_init): Likewise.
Ivan Maidanski [Fri, 7 Feb 2020 08:18:46 +0000 (11:18 +0300)]
Fix pthread_setname_np detection on Linux and snprintf usage warning
(fix of commit
ab91e4e84)
Issue #300 (bdwgc).
* configure.ac [$THREADS==posix]: Replace AC_TRY_LINK with
AC_TRY_COMPILE to detect pthread_setname_np presence and kind.
* pthread_support.c [PARALLEL_MARK && (HAVE_PTHREAD_SETNAME_NP_WITH_TID
|| HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)] (set_marker_thread_name):
Replace snprintf() with BCOPY() call and manual conversion of an
integer (with 1-2 digits) to a string; remove undef name_buf.
* win32_threads.c [PARALLEL_MARK && HAVE_PTHREAD_SETNAME_NP_WITH_TID]
(set_marker_thread_name): Likewise.
Ivan Maidanski [Thu, 6 Feb 2020 09:24:15 +0000 (12:24 +0300)]
Set name of GC marker threads
Issue #300 (bdwgc).
The threads are named as "GC-marker-<n>".
For now, the detection of pthread_setname_np availability and kind is
implemented in configure only.
On Darwin, the GC mprotect thread name is set too.
* configure.ac [$THREADS==posix] (HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID,
HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG,
HAVE_PTHREAD_SETNAME_NP_WITH_TID): Check for pthread_setname_np; set
the relevant HAVE_x macro.
* include/private/gc_priv.h [__CYGWIN__ && GC_THREADS && !_GNU_SOURCE]
(_GNU_SOURCE): Define.
* os_dep.c [MPROTECT_VDB && DARWIN
&& HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID] (GC_mprotect_thread): Call
pthread_setname_np().
* pthread_support.c [PARALLEL_MARK] (set_marker_thread_name): Define.
* win32_threads.c [PARALLEL_MARK] (set_marker_thread_name): Likewise.
* pthread_support.c [PARALLEL_MARK] (GC_mark_thread): Call
set_marker_thread_name(id).
* win32_threads.c [PARALLEL_MARK] (GC_mark_thread): Likewise.
Ivan Maidanski [Thu, 30 Jan 2020 08:56:45 +0000 (11:56 +0300)]
Update AUTHORS file
ssrlive [Sat, 25 Jan 2020 13:02:01 +0000 (21:02 +0800)]
Check leak of objects allocated by CRT malloc in gctest (MS VC)
Issue #302 (bdwgc).
* tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && _DEBUG
&& _MSC_VER>=1900]: Include crtdbg.h.
* tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS]
(CRTMEM_CHECK_INIT, CRTMEM_DUMP_LEAKS): New macro (defined to
_CrtSetDbgFlag and _CrtDumpMemoryLeaks, respectively, if MS compiler).
* tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS] (main): Call
CRTMEM_CHECK_INIT and CRTMEM_DUMP_LEAKS at the beginning and end of the
function, respectively.
Ivan Maidanski [Thu, 30 Jan 2020 07:47:43 +0000 (10:47 +0300)]
AppVeyor CI: Test MS VC single-threaded GC-debug build
Ivan Maidanski [Fri, 24 Jan 2020 21:41:58 +0000 (00:41 +0300)]
AppVeyor CI: Test cygwin64 single-threaded build with -D USE_WINALLOC
Ivan Maidanski [Fri, 24 Jan 2020 21:34:18 +0000 (00:34 +0300)]
Workaround 'blocks>1 is always true' cppcheck FP in reclaim_block
* reclaim.c [CPPCHECK] (GC_reclaim_block): Call GC_noop1(&blocks).
Ivan Maidanski [Fri, 24 Jan 2020 21:06:42 +0000 (00:06 +0300)]
Fix missing OS_TYPE definition for some targets
(fix of commits ce1f874, 9718229, cd63cf1, d5dad58, d16debf)
* include/private/gcconfig.h [POWERPC && SN_TARGET_PS3 || AARCH64
&& NINTENDO_SWITCH || ARM32 && (SN_TARGET_PSP2 || NN_PLATFORM_CTR)
|| X86_64 && (SN_TARGET_ORBIS || MSWIN_XBOX1)] (OS_TYPE): Define macro.
Ivan Maidanski [Fri, 24 Jan 2020 09:01:38 +0000 (12:01 +0300)]
Eliminate memory leak reported in add_current_malloc_heap at exit (Win32)
Issue #302 (bdwgc).
Explicitly free GC_malloc_heap_l linked list nodes right before program
exit to avoid complains of a memory leak.
* os_dep.c [(MSWIN32 || MSWINCE || CYGWIN32) && USE_WINALLOC
&& !REDIRECT_MALLOC] (GC_free_malloc_heap_list): New function.
* os_dep.c [(MSWIN32 || MSWINCE || CYGWIN32) && USE_WINALLOC
&& !REDIRECT_MALLOC && !MSWIN_XBOX1] (GC_win32_free_heap): Call
GC_free_malloc_heap_list.
Ivan Maidanski [Thu, 23 Jan 2020 21:24:03 +0000 (00:24 +0300)]
Define GC_win32_free_heap API function for all Windows targets
Issue #302 (bdwgc).
The function now may be no-op on some targets.
* include/gc.h (GC_win32_free_heap): Refine comment (specify that it
is not always defined).
* os_dep.c [(MSWIN32 || MSWINCE || CYGWIN32) && !REDIRECT_MALLOC]
(GC_max_root_size): Do not define unless USE_WINALLOC.
* os_dep.c [(MSWIN32 || MSWINCE || CYGWIN32) && !REDIRECT_MALLOC]
(GC_is_heap_base): Do update GC_max_root_size value unless
USE_WINALLOC.
* os_dep.c [MSWIN32 || MSWINCE || MSWIN_XBOX1] (GC_win32_free_heap):
Define API function (regardless of USE_WINALLOC).
* tests/test.c [!PCR && !GC_WIN32_THREADS && !GC_PTHREADS && (MSWINCE
|| CYGWIN32)] (main): Call GC_win32_free_heap() before exit.
Ivan Maidanski [Tue, 12 Nov 2019 08:50:39 +0000 (11:50 +0300)]
Remove obsolete information in README.darwin
* doc/README.darwin (gc_cpp.h usage, Older Information): Remove
information.
Ivan Maidanski [Sat, 9 Nov 2019 06:14:32 +0000 (09:14 +0300)]
Fix abort in GC_printf when gctest is built as WinMain executable (Cygwin)
* misc.c [!NACL && (CYGWIN32 || CONSOLE_LOG && MSWIN32)] (GC_printf):
If WRITE(GC_stdout) failed but GC_stdout is GC_DEFAULT_STDOUT_FD then
ignore the failure.
* misc.c [!NACL && (CYGWIN32 || CONSOLE_LOG && MSWIN32)]
(GC_log_printf): If WRITE(GC_log) failed but GC_log is
GC_DEFAULT_STDERR_FD then ignore the failure.
Ivan Maidanski [Thu, 7 Nov 2019 08:50:55 +0000 (11:50 +0300)]
Travis CI: Test configure --disable-throw-bad-alloc-library (Linux, OS X)
Ivan Maidanski [Thu, 7 Nov 2019 08:30:58 +0000 (11:30 +0300)]
Build gctba library
Issue #268 (bdgwc).
The library exports only GC_throw_bad_alloc C++ function. It is intended
to solve "undefined reference to GC_throw_bad_alloc" linkage error when
the client needs to avoid linking with gccpp library (to avoid "::new"
redirection, in turn).
* CMakeLists.txt (enable_throw_bad_alloc_library): New option (ON by
default).
* CMakeLists.txt [enable_cplusplus && enable_throw_bad_alloc_library]
(gctba): New library.
* Makefile.am [CPLUSPLUS && GC_TBA_LIBRARY] (lib_LTLIBRARIES): Add
libgctba.la item.
* Makefile.am [CPLUSPLUS && GC_TBA_LIBRARY] (libgctba_la_SOURCES,
libgctba_la_LIBADD, libgctba_la_LDFLAGS): New variable.
* Makefile.direct: Update head comment (mention gctba.a).
* Makefile.direct (bsd-libgctba.a, gctba.a): New target.
* NT_MAKEFILE (gctba.lib): Likewise.
* WCC_MAKEFILE (gctba.lib): Likewise.
* WCC_MAKEFILE [!ENABLE_STATIC] (gctba.dll): Likewise.
* Makefile.direct (bsd-libgc.a): Move gctba.a to bsd-libgctba.a.
* Makefile.direct (BSD-pkg-install): Copy bsd-libgctba.a; install
libgctba.a.
* Makefile.direct (c++): Add dependency on gc_badalc.o; call rus, $(AR)
and $(RANLIB) for gctba.a.
* NT_MAKEFILE (all): Add dependency on gctba.lib.
* WCC_MAKEFILE (all): Likewise.
* README.QUICK: Update information about "make c++" (reference
libgctba.a, libgctba.so and doc/gcinterface.md).
* configure.ac (throw-bad-alloc-library): Specify new AC_ARG_ENABLE.
* configure.ac (GC_TBA_LIBRARY): New AM_CONDITIONAL.
* doc/gcinterface.md (Class inheritance based interface): Add
information about libgctba library; document GC_NEW_ABORTS_ON_OOM and
GC_INCLUDE_NEW macros.
Ivan Maidanski [Mon, 4 Nov 2019 22:18:35 +0000 (01:18 +0300)]
Compile C++ code with exception handling enabled in NT_MAKEFILE
This prevents "noexcept used with no exception handling mode specified"
MS VC warning.
* NT_MAKEFILE (CXXFLAGS_SPECIFIC): New variable (set to "/EHsc").
* NT_MAKEFILE (.cpp.obj): Pass $CXXFLAGS_SPECIFIC to compiler.
Ivan Maidanski [Mon, 4 Nov 2019 07:47:45 +0000 (10:47 +0300)]
Move GC_throw_bad_alloc definition to new C++ file
Issue #268 (bdgwc).
* CMakeLists.txt [enable_cplusplus] (gccpp): Add gc_badalc.cc library
source file.
* Makefile.am [CPLUSPLUS] (libgccpp_la_SOURCES): Likewise.
* Makefile.am (EXTRA_DIST): Add gc_badalc.cpp.
* Makefile.direct (SRCS): Add gc_badalc.cc.
* Makefile.direct (gc_badalc.o): New target.
* NT_MAKEFILE (gc_badalc.obj): Likewise.
* WCC_MAKEFILE (gc_badalc.obj): Likewise.
* digimars.mak (gc_badalc.obj): Likewise.
* build/s60v3/libgc.mmp (SOURCE): Mention gc_badalc.cpp (commented out).
* Makefile.direct (c++): Add dependency on gc_badalc.o; pass gc_badalc.o
to ru tool.
* NT_MAKEFILE (gccpp.lib): Add dependency on gc_badalc.obj; pass
gc_badalc.obj to lib or link tool.
* WCC_MAKEFILE (gccpp.lib, gccpp.dll): Likewise.
* digimars.mak (OBJS): Add gc_badalc.obj.
* doc/README.Mac (Files to build the GC libraries): Add gc_badalc.cc.
* doc/gcinterface.md (C++ Interface): Mention gc_badalc.cc file.
* gc_badalc.cc: New file.
* gc_badalc.cpp: Likewise.
* gc_cpp.cc (GC_throw_bad_alloc): Move to gc_badalc.cc.
* gc_cpp.cc (GC_ALLOCATOR_THROW_OR_ABORT): Add comment; do not define
unless GC_NO_INLINE_STD_NEW, or not _MSC_VER and not __DMC__.
* tests/tests.am [CPLUSPLUS && AVOID_CPP_LIB] (test_cpp_LDADD): Add
gc_badalc.o.
Ivan Maidanski [Tue, 29 Oct 2019 18:53:30 +0000 (21:53 +0300)]
Fix 'write to GC log failed' error (Cygwin)
Issue #293 (bdwgc).
* misc.c [!(MSWIN32 && !CONSOLE_LOG || MSWINCE) && !OS2 && !MACOS
&& !GC_ANDROID_LOG && !NN_PLATFORM_CTR && !NINTENDO_SWITCH
&& !SN_TARGET_ORBIS && !SN_TARGET_PSP2]: Include errno.h.
* misc.c [!(MSWIN32 && !CONSOLE_LOG || MSWINCE) && !OS2 && !MACOS
&& !GC_ANDROID_LOG && !NN_PLATFORM_CTR && !NINTENDO_SWITCH &&
!ECOS && !SN_TARGET_ORBIS && !SN_TARGET_PSP2] (GC_write): Retry write()
result is -1 and errno is EAGAIN.
Ivan Maidanski [Tue, 29 Oct 2019 05:47:03 +0000 (08:47 +0300)]
Update AUTHORS file (add Thomas Thiriez)
Thomas Thiriez [Mon, 28 Oct 2019 14:27:46 +0000 (15:27 +0100)]
Allocate start_info struct on the stack in GC_pthread_create
Issue #296 (bdwgc).
This also works around "sem_wait failed" error when creating many
threads on OS X.
* pthread_support.c: Change type of si local variable to a non-pointer
one (so that, struct start_info is allocated on the stack); do not call
GC_INTERNAL_MALLOC/FREE; update comment.
Ivan Maidanski [Mon, 21 Oct 2019 21:01:21 +0000 (00:01 +0300)]
Workaround 'possible null dereference in frame->savedSP' cppcheck FP
* darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK && !POWERPC && !ARM32
&& !AARCH64 && CPPCHECK] (GC_FindTopOfStack): Call GC_noop1(&frame)
before ABORT().
Ivan Maidanski [Mon, 21 Oct 2019 06:39:12 +0000 (09:39 +0300)]
Do not use iOS private symbols
Issue #295 (bdwgc).
* include/private/gcconfig.h [(AARCH64 || ARM32) && DARWIN]
(MPROTECT_VDB): Do not define; add comment.
Ivan Maidanski [Tue, 15 Oct 2019 08:18:02 +0000 (11:18 +0300)]
.gitignore: Collapse multiple lib*.so items in a single one
(code refactoring)
Ivan Maidanski [Tue, 15 Oct 2019 07:24:52 +0000 (10:24 +0300)]
AppVeyor CI: Test MS VC build with -D GC_NO_INLINE_STD_NEW
Ivan Maidanski [Tue, 15 Oct 2019 06:59:19 +0000 (09:59 +0300)]
New macro to avoid system-wide new/delete inlining in gc_cpp.h (Win32)
(fix of commit 3d784ed)
* doc/README.macros (GC_NO_INLINE_STD_NEW): Document.
* gc_cpp.cc [(_MSC_VER || __DMC__) && GC_NO_INLINE_STD_NEW
&& GC_NEW_DELETE_NEED_THROW] (GC_DECL_NEW_THROW): Define.
* gc_cpp.cc [(_MSC_VER || __DMC__) && GC_NO_INLINE_STD_NEW]
(operator new, operator delete): Likewise.
* include/gc_cpp.h [_MSC_VER || __DMC__ || (__BORLANDC__ || __CYGWIN__
|| __MINGW32__ || __WATCOMC__) && !GC_BUILD && !GC_NOT_DLL]
(operator new, operator delete): Do not define inline function if
GC_NO_INLINE_STD_NEW.
* gc_cpp.cc [GC_NO_INLINE_STD_NEW && _MSC_VER] (operator new,
operator delete): Declare; move comment.
Ivan Maidanski [Sat, 12 Oct 2019 07:59:10 +0000 (10:59 +0300)]
Remove a note in README.macros that work in progress
(fix of commit
6f8f39af5)
* README.macros: Remove a note that work is in progress.
Ivan Maidanski [Fri, 11 Oct 2019 18:36:56 +0000 (21:36 +0300)]
Update AUTHORS file
Dima Pasechnik [Fri, 11 Oct 2019 18:33:31 +0000 (21:33 +0300)]
Fix 'traceable but uncollectible memory' wording in gcinterface document
Issue #268 (bdgwc).
* doc/gcinterface.md (Class inheritance-based interface): Fix a typo
("traceable but uncollectible memory").
Ivan Maidanski [Fri, 11 Oct 2019 18:14:24 +0000 (21:14 +0300)]
Fix gc_cpp.h file name in comments after renaming
* gc_cpp.cc: Rename gc_c++.h to gc_cpp.h in the head comment.
* tests/test_cpp.cc: Likewise.
Ivan Maidanski [Fri, 11 Oct 2019 08:51:55 +0000 (11:51 +0300)]
Update ChangeLog file
Ivan Maidanski [Thu, 10 Oct 2019 23:04:02 +0000 (02:04 +0300)]
Update ChangeLog file (v8.0 changes)
Ivan Maidanski [Thu, 10 Oct 2019 22:54:09 +0000 (01:54 +0300)]
Update ChangeLog file (v7.6 changes)
Ivan Maidanski [Thu, 10 Oct 2019 22:21:41 +0000 (01:21 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Mon, 7 Oct 2019 05:45:53 +0000 (08:45 +0300)]
Update AUTHORS file
Sorawee Porncharoenwase [Tue, 2 Jul 2019 04:52:31 +0000 (21:52 -0700)]
Fix a typo in 'primitives' word in ChangeLog
(a cherry-pick of
34c88d306 from 'racket_gc')
* ChangeLog (6.2alpha4): Fix typo ("primitives").
Jonathan Chambers [Mon, 16 Sep 2019 22:40:44 +0000 (18:40 -0400)]
Add dummy target for mono client
(a cherry-pick of commit
b762dda6 from Unity-Technologies/bdwgc)
* Makefile.am (test-bundle): New target (empty).
Ivan Maidanski [Fri, 4 Oct 2019 20:43:09 +0000 (23:43 +0300)]
Workaround 'condition is redundant or null deref is possible' cppcheck FP
* cord/cordprnt.c (MACRO_BLKSTMT_BEGIN, MACRO_BLKSTMT_END): New macro.
* cord/tests/de.c (MACRO_BLKSTMT_BEGIN, MACRO_BLKSTMT_END): Likewise.
* include/private/gc_priv.h (MACRO_BLKSTMT_BEGIN, MACRO_BLKSTMT_END):
Likewise.
* cord/cordprnt.c (OUT_OF_MEMORY): Use MACRO_BLKSTMT_BEGIN/END instead
of "do {" and "} while (0)".
* cord/tests/de.c (OUT_OF_MEMORY): Likewise.
* include/private/gc_priv.h (ABORT_ARG1, ABORT_ARG2, ABORT_ARG3):
Likewise.
Ivan Maidanski [Fri, 4 Oct 2019 20:25:19 +0000 (23:25 +0300)]
Workaround 'condition *flh==0 is always true' cppcheck false positive
* alloc.c [CPPCHECK] (GC_allocobj): Call GC_noop1(flh) between *flh==0
checks.
Ivan Maidanski [Fri, 4 Oct 2019 19:08:07 +0000 (22:08 +0300)]
Fix GC_new_hblk prototype in a comment
* new_hblk.c: Specify the 2nd argument (kind) of GC_new_hblk in the
head comment.
Ivan Maidanski [Fri, 4 Oct 2019 17:42:54 +0000 (20:42 +0300)]
Check thread is alive on each SuspendThread loop iteration (Win32)
(fix of commit
449eda034)
* win32_threads.c [!GC_NO_THREADS_DISCOVERY]
(GC_delete_gc_thread_no_free): Reset suspended if GC_win32_dll_threads.
* win32_threads.c [!MSWINCE] (GC_suspend): Move comment near exitCode
declaration to be near GetExitCodeThread() call; adjust comment.
* win32_threads.c [!MSWINCE && RETRY_GET_THREAD_CONTEXT] (GC_suspend):
Call GetExitCodeThread() on each iteration of the suspend loop; refine
ABORT message on ResumeThread failure.
Ivan Maidanski [Thu, 3 Oct 2019 21:38:28 +0000 (00:38 +0300)]
Do not hold GC_fault_handler_lock when in Sleep (Win32)
(fix of commits
0c0e4cd0b,
449eda034)
Also, reduce a period between GetExitCodeThread and SuspendThread.
* win32_threads.c [DEBUG_THREADS] (GC_suspend): Call GC_log_printf()
before UNPROTECT_THREAD().
* win32_threads.c [DEBUG_THREADS && !MSWINCE] (GC_suspend): Call
GC_acquire_dirty_lock() before GetExitCodeThread(); call
GC_release_dirty_lock() immediately if GetExitCodeThread() failed.
* win32_threads.c [MSWINCE || RETRY_GET_THREAD_CONTEXT] (GC_suspend):
Wrap Sleep() call with GC_release/acquire_dirty_lock().
Ivan Maidanski [Thu, 3 Oct 2019 07:17:37 +0000 (10:17 +0300)]
Workaround 'label handle_thr_start is not used' cppcheck style warning
(fix of commit
03109f287)
* mark.c [WRAP_MARK_SOME && GC_WIN32_THREADS && !GC_PTHREADS]
(GC_mark_some): Define handle_thr_start label only if MSWIN32 or
MSWINCE is defined.
Ivan Maidanski [Wed, 2 Oct 2019 22:03:51 +0000 (01:03 +0300)]
Use CreateThread without GC_ prefix in gctest
(code refactoring)
* tests/test.c (GC_NO_THREAD_REDIRECTS): Do not undefine unless
GC_NO_THREADS_DISCOVERY is defined.
* tests/test.c [GC_WIN32_THREADS] (fork_a_thread, WinMain): Call
CreateThread() instead of GC_CreateThread().
Ivan Maidanski [Wed, 2 Oct 2019 21:23:31 +0000 (00:23 +0300)]
Fix 'ACCESS_VIOLATION in marker' GC warning on Win32 async thread start
(fix of commit
38d07c167)
* mark.c [WRAP_MARK_SOME && (MSWIN32 || MSWINCE) && GC_WIN32_THREADS
&& !GC_PTHREADS] (GC_mark_some): If GC_started_thread_while_stopped()
then goto handle_thr_start instead of handle_ex.
* mark.c [WRAP_MARK_SOME && GC_WIN32_THREADS && !GC_PTHREADS]
(GC_mark_some): Define handle_thr_start label right after WARN() call.
Ivan Maidanski [Thu, 26 Sep 2019 08:31:27 +0000 (11:31 +0300)]
Workaround 'condition appendToFile is always false' cppcheck false positive
* misc.c [(MSWIN32 && !CONSOLE_LOG || MSWINCE) && !MSWINRT_FLAVOR
&& NO_GETENV_WIN32 && CPPCHECK] (GC_CreateLogFile): Define appendToFile
as macro (to FALSE) instead of a local variable; undefine appendToFile
at the function.
Ivan Maidanski [Wed, 25 Sep 2019 08:28:41 +0000 (11:28 +0300)]
Set GC_collecting hint for GC_collect_a_little_inner calls (pthreads)
* alloc.c (GC_try_to_collect_inner, GC_collect_a_little): Wrap
GC_collect_a_little_inner() call into ENTER/EXIT_GC().
* gc_dlopen.c [!USE_PROC_FOR_LIBRARIES] (disable_gc_for_dlopen):
Likewise.
* malloc.c (GC_alloc_large): Likewise.
Ivan Maidanski [Wed, 25 Sep 2019 07:31:31 +0000 (10:31 +0300)]
Prevent use of unsaved thread context registers in incremental GC (Windows)
(fix of commits
449eda034,
190e18c75)
During incremental collection GC_push_all_stacks() may be called when
the world is not stopped. If the context registers and sp value are
saved during thread suspension then GC_push_all_stacks() gets these
values of the previous GC cycle or, even, gets all zeros instead the
context registers and sp on the first GC after the thread creation.
This commit fixes this by calling GetThreadContext in GC_push_stack_for
if thread is not suspended.
* win32_threads.c (first_thread): Refine the comment.
* win32_threads.c [!GC_NO_THREADS_DISCOVERY && RETRY_GET_THREAD_CONTEXT]
(GC_delete_gc_thread_no_free): Reset context_sp if GC_win32_dll_threads.
* win32_threads.c (GC_push_stack_for): Change the assertion expression
from thread->suspended to thread->suspended||!GC_world_stopped (the
assertion is off unless THREAD_LOCAL_ALLOC).
* win32_threads.c [RETRY_GET_THREAD_CONTEXT] (GC_push_stack_for): If
thread is not suspended then call GetThreadContext(), if it fails then
use sp value and the context registers saved during the latest
stop-the-world; add comments.
* win32_threads.c (GC_push_all_stacks): Add the title comment (copied
from pthread_stop_world.c).
Ivan Maidanski [Tue, 24 Sep 2019 07:52:51 +0000 (10:52 +0300)]
Remove redundant GC_with_callee_saves_pushed call in multi-threaded builds
In GC_push_regs_and_stack, if cold_gc_frame is null and threads
support is on then there is no need to call
GC_with_callee_saves_pushed(GC_push_current_stack) as
GC_push_current_stack is no-op in this case.
* mark_rts.c (GC_push_current_stack): Reformat title comment.
* mark_rts.c [THREADS] (GC_push_current_stack): Do not check that
cold_gc_frame is non-zero; add comment about it.
* mark_rts.c [THREADS] (GC_push_regs_and_stack): If cold_gc_frame is
null then do not call GC_with_callee_saves_pushed().
Ivan Maidanski [Mon, 23 Sep 2019 06:51:53 +0000 (09:51 +0300)]
Reformat code of GC_push_roots
* mark_rts.c (GC_push_roots): Refine title comment; reformat comments;
adjust code and comments indentation.
Ivan Maidanski [Mon, 16 Sep 2019 08:39:42 +0000 (11:39 +0300)]
Add assertion that thread is suspended when using context registers
* win32_threads.c (GC_push_stack_for): Add assertion that thread is
suspended (before using context registers) if thread is not self and
not blocked.
Ivan Maidanski [Mon, 16 Sep 2019 07:41:11 +0000 (10:41 +0300)]
Add debug messages on thread suspend/resume (Win32)
The messages are similar to the ones for Darwin.
* win32_threads.c [DEBUG_THREADS] (GC_suspend): Log a message that the
thread is going to be suspended.
* win32_threads.c [DEBUG_THREADS] (GC_start_world): Log a message
whether the thread is going to be resumed or it cannot be resumed
because it is not suspended.
Ivan Maidanski [Sat, 14 Sep 2019 12:34:59 +0000 (15:34 +0300)]
Collapse multiple includes of windows.h
(code refactoring)
* dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32]: Do not define
WIN32_LEAN_AND_MEAN and NOSERVICE macros; do not include windows.h.
* include/private/gc_locks.h [GC_WIN32_THREADS && !USE_PTHREAD_LOCKS]:
Likewise.
* include/private/gc_priv.h [!NO_CLOCK && !BSD_TIME && (MSWIN32
|| MSWINCE || WINXP_USE_PERF_COUNTER)]: Likewise.
* include/private/thread_local_alloc.h [!USE_PTHREAD_SPECIFIC
&& !USE_COMPILER_TLS && !USE_WIN32_COMPILER_TLS && USE_WIN32_SPECIFIC]:
Likewise.
* mallocx.c [MSWINCE]: Likewise.
* misc.c [MSWIN32 || MSWINCE || CYGWIN32 && GC_READ_ENV_FILE]: Likewise.
* os_dep.c [MSWIN32 || MSWINCE || CYGWIN32]: Likewise.
* tests/test.c [MSWIN32 || MSWINCE]: Likewise.
* tools/setjmp_t.c [!OS2 && (MSWIN32 || MSWINCE || CYGWIN32)]: Likewise.
* win32_threads.c [GC_WIN32_THREADS]: Likewise.
* include/private/gc_priv.h [MSWIN32 || MSWINCE || CYGWIN32]
(WIN32_LEAN_AND_MEAN, NOSERVICE): Define macro (before include
windows.h).
* include/private/gc_priv.h [MSWIN32 || MSWINCE || CYGWIN32]: Inclde
windows.h and winbase.h before include gc_locks.h (instead of just
before GC_sysinfo declaration).
Ivan Maidanski [Sat, 14 Sep 2019 09:00:38 +0000 (12:00 +0300)]
Eliminate 'static GC_sysinfo definition has incomplete type' Clang warning
Tentative definition of variable with internal linkage has incomplete
non-array type 'struct _SYSTEM_INFO'.
The warning observed only in single-threaded shared builds by Clang.
* include/private/gc_priv.h [MSWIN32 || MSWINCE || CYGWIN32]
(WIN32_LEAN_AND_MEAN, NOSERVICE): Define macro.
* include/private/gc_priv.h [MSWIN32 || MSWINCE || CYGWIN32]: Include
windows.h (wrapped into EXTERN_C_END/BEGIN) before GC_sysinfo
declaration.
* include/private/gc_priv.h [MSWIN32 || MSWINCE || CYGWIN32]
(_SYSTEM_INFO): Do not declare.
* include/private/gc_priv.h [MSWIN32 || MSWINCE || CYGWIN32]
(GC_sysinfo): Change type from struct _SYSTEM_INFO to SYSTEM_INFO.
Ivan Maidanski [Thu, 12 Sep 2019 07:11:09 +0000 (10:11 +0300)]
AppVeyor CI: Test mingw build with -D CONSOLE_LOG
Ivan Maidanski [Thu, 12 Sep 2019 07:08:06 +0000 (10:08 +0300)]
New macro (CONSOLE_LOG) to enable logging to console on Win32
The macro is effective only on the Win32 (MSWIN32) target. It changes
the logging facility to be the same as on Cygwin and other Unix-like
targets.
* doc/README.macros (CONSOLE_LOG): Document new macro.
* include/private/gc_priv.h [THREADS && MSWIN32 && CONSOLE_LOG]
(GC_write_cs): Do not declare.
* include/private/gc_priv.h [THREADS && MSWIN32 && CONSOLE_LOG
&& GC_ASSERTIONS] (GC_write_disabled): Likewise.
* misc.c [CONSOLE_LOG && MSWIN32]: Include fcntl.h, sys/types.h,
sys/stat.h.
* misc.c [GC_WIN32_THREADS && MSWIN32 && CONSOLE_LOG] (GC_write_cs):
Do not define.
* win32_threads.c [GC_ASSERTIONS && MSWIN32 && CONSOLE_LOG]
(GC_write_disabled): Likewise.
* misc.c [MSWIN32 && CONSOLE_LOG] (GC_stdout, GC_stderr, GC_log): Define
STATIC variable (of int type).
* misc.c [GC_WIN32_THREADS && MSWIN32 && CONSOLE_LOG] (GC_init): Do not
call InitializeCriticalSection(&GC_write_cs); handle GC_LOG_FILE and
GC_ONLY_LOG_TO_FILE environment variables.
* misc.c [GC_WIN32_THREADS && MSWIN32 && CONSOLE_LOG] (GC_deinit): Do
not call DeleteCriticalSection(&GC_write_cs).
* misc.c [MSWIN32 && CONSOLE_LOG] (IF_NEED_TO_LOCK, getWinRTLogPath,
GC_CreateLogFile): Do not define.
* misc.c [!PCR && !SMALL_CONFIG && !GC_ANDROID_LOG && GC_WIN32_THREADS
&& GC_ASSERTIONS MSWIN32 && CONSOLE_LOG] (GC_default_on_abort): Do not
use GC_write_disabled.
* win32_threads.c [MSWIN32 && CONSOLE_LOG] (GC_stop_world): Do not use
GC_write_disabled and GC_write_cs.
Ivan Maidanski [Wed, 11 Sep 2019 20:03:49 +0000 (23:03 +0300)]
Do not define GC_write_cs for Xbox One target
(fix of commit
d16debf3e)
Issue #173 (bdwgc).
GC_write_cs is not used in GC_write thus there is no need to define
and use it in GC_stop_world.
* include/private/gc_priv.h [THREADS && MSWIN_XBOX1] (GC_write_cs):
Do not declare.
* misc.c [THREADS && MSWIN_XBOX1] (GC_write_cs): Do not define.
* win32_threads.c (GC_stop_world): Call EnterCriticalSection() and
LeaveCriticalSection() only if MSWIN32 or MSWINCE.
Ivan Maidanski [Tue, 10 Sep 2019 22:11:04 +0000 (01:11 +0300)]
Workaround 'argument to function is always 1' cppcheck false positives
* allchblk.c (GC_print_hblkfreelist): Replace "while(p!=0)" with
"while(p)"; add a marker that the change is for cppcheck.
* allchblk.c (GC_free_block_ending_at, GC_add_to_fl, GC_split_block,
GC_allochblk_nth, GC_freehblk): Replace "if(p!=0)" with "if(p)".
* alloc.c (GC_set_fl_marks): Likewise.
* extra/MacOS.c (GC_MacFreeTemporaryMemory): Likewise.
* mallocx.c (GC_generic_malloc_many): Likewise.
* allchblk.c (GC_allochblk_nth): Replace "if(0==p)" with "if(p){}else".
* malloc.c (GC_free): Likewise.
* malloc.c (GC_generic_malloc_uncollectable): Replace
"if(0==p)return 0;<code>;return p;" with "if(p){<code>}return p;".
* mallocx.c (GC_generic_malloc_many): Replace "p+=v;while((p2=*p)!=0)"
with "for(p+=v;(p2=*p)!=0;)".
* reclaim.c (GC_continue_reclaim, GC_reclaim_all): Likewise.
Ivan Maidanski [Tue, 10 Sep 2019 20:35:14 +0000 (23:35 +0300)]
Workaround 'redundant initialization for r' cppcheck false positive
* mark.c (GC_mark_and_push_stack): Replace "if(a&&b)" with
"if(a) if(b)" where b is an expression which contains r variable
assignment.
Ivan Maidanski [Tue, 10 Sep 2019 20:28:15 +0000 (23:28 +0300)]
Workaround 'cnt var assigned but not used' cppcheck FP in copy_ptr_regs
(fix of commit
912ec408d)
* win32_threads.c [!I386 && !X86_64 && !ARM32 && !AARCH64 && !SHx
&& !MIPS && !PPC && !ALPHA && CPPCHECK] (copy_ptr_regs): Set sp to cnt
value (with a cast); add comment.
Ivan Maidanski [Tue, 10 Sep 2019 20:09:29 +0000 (23:09 +0300)]
Remove redundant check of GC_free argument in register_finalizer
(code refactoring)
This also works around "Argument new_fo to function GC_free is always 1"
cppcheck false positive.
* finalize.c [!DBG_HDRS_ALL] (GC_register_finalizer_inner): Do not
check new_fo is non-NULL before GC_free(new_fo) call.
Ivan Maidanski [Tue, 10 Sep 2019 08:09:42 +0000 (11:09 +0300)]
Replace push_one calls with push_many_regs one for Win32 thread context
(code refactoring)
Also, do not define GC_push_one except for Darwin (and some ancient
targets that use the function).
* include/private/gc_priv.h [MSWIN32 || MSWINCE] (GC_push_one): Do not
declare.
* include/private/gc_priv.h [!MSWIN32 && !MSWINCE] (GC_push_one):
Declare only if AMIGA or MACOS or GC_DARWIN_THREADS.
* include/private/gc_priv.h [GC_WIN32_THREADS] (GC_push_many_regs):
Declare function; add comment.
* mark.c (GC_push_one): Define only if AMIGA or MACOS or
GC_DARWIN_THREADS.
* mark.c [GC_WIN32_THREADS] (GC_push_many_regs): New GC_INNER function.
* win32_threads.c (GC_push_stack_for): Remove i local variable; call
GC_push_many_regs() instead of a loop with GC_push_one() calls (ignore
2 first registers if WOW64_THREAD_CONTEXT_WORKAROUND).
Ivan Maidanski [Tue, 10 Sep 2019 08:01:09 +0000 (11:01 +0300)]
Fix incorrect code generation by MS VC caused by excessive Thread_Rep size
(fix of commit
449eda034)
The gctest crashes were observed in debug builds produced by MS VC.
In addition, this change greatly reduces memory usage by GC_threads[]
and dll_thread_table[] (compared to the solution that stores the full
CONTEXT in GC_Thread_Rep).
* win32_threads.c (copy_ptr_regs): Declare static function.
* win32_threads.c (PUSHED_REGS_COUNT): Define macro.
* win32_threads.c [RETRY_GET_THREAD_CONTEXT]
(GC_Thread_Rep.saved_context): Move down to be the last field; change
type from CONTEXT to word[PUSHED_REGS_COUNT]; rename to context_regs.
* win32_threads.c [RETRY_GET_THREAD_CONTEXT]
(GC_Thread_Rep.context_sp): New field.
* win32_threads.c [RETRY_GET_THREAD_CONTEXT] (GC_suspend): Declare
context local variable and use it for GetThreadContext() call; if the
latter succeeds then call copy_ptr_regs(); update comment.
* win32_threads.c (copy_ptr_regs): Define static function (move
PUSH-related part of GC_push_stack_for code here); change PUSH1(reg) to
store reg to regs[]; define context as *pcontext; add assertion that
number of stored registers is equal to PUSHED_REGS_COUNT.
* win32_threads.c [WOW64_THREAD_CONTEXT_WORKAROUND] (copy_ptr_regs):
Store ContextFlags and SegFs as the first elements of regs[].
* win32_threads.c (GC_push_stack_for): Declare i local variable (set
to 0).
* win32_threads.c [RETRY_GET_THREAD_CONTEXT] (GC_push_stack_for):
Replace pcontext and context with word *regs; set sp from
thread->context_sp; remove undef context.
* win32_threads.c [!RETRY_GET_THREAD_CONTEXT] (GC_push_stack_for):
Declare regs[PUSHED_REGS_COUNT]; call copy_ptr_regs() to initialize
regs[] and sp; limit context scope to GetThreadContext() and
copy_ptr_regs() calls only.
* win32_threads.c (GC_push_stack_for): Call GC_push_one() for each
regs[] element (except for the first 2 ones if
WOW64_THREAD_CONTEXT_WORKAROUND).
* win32_threads.c [WOW64_THREAD_CONTEXT_WORKAROUND]
(GC_push_stack_for): Define ContextFlags, SegFs local variables
(the values are obtained from regs[]); use these variables instead of
context one; do not overwrite sp local variable value so that not to
use context.Esp directly (i.e. not to use context out of its scope).
Ivan Maidanski [Thu, 5 Sep 2019 09:17:04 +0000 (12:17 +0300)]
AppVeyor CI: Test mingw64 build with -D NO_RETRY_GET_THREAD_CONTEXT
Jonathan Chambers [Thu, 5 Sep 2019 09:15:35 +0000 (12:15 +0300)]
Prevent GetThreadContext failure (Windows)
(a cherry-pick of commits 3f39ea8,
ab3699da from 'unity-master')
Calls to GetThreadContext may fail. Work around this by putting
access in suspend/resume loop to advance thread past problematic areas
where suspend fails. Capture context in per thread structure at
suspend time rather than retreiving it during the push logic.
* include/private/gcconfig.h [(I386 || X86_64) && (CYGWIN32 || MSWIN32)]
(RETRY_GET_THREAD_CONTEXT): Define macro.
* win32_threads.c [RETRY_GET_THREAD_CONTEXT]
(MAX_SUSPEND_THREAD_RETRIES): Likewise.
* include/private/gcconfig.h [NO_RETRY_GET_THREAD_CONTEXT]
(RETRY_GET_THREAD_CONTEXT): Undefine macro (for test purposes).
* win32_threads.c [RETRY_GET_THREAD_CONTEXT] (GC_Thread_Rep): Add
saved_context field; add comment.
* win32_threads.c [RETRY_GET_THREAD_CONTEXT] (GC_suspend): Define
retry_cnt local variable; set ContextFlags and call GetThreadContext()
after invocation of SuspendThread(); call ResumeThread() and proceed to
SuspendThread() if GetThreadContext() failed (the limit of iterations
is MAX_SUSPEND_THREAD_RETRIES); call Sleep(0) after ResumeThread() or
failed SuspendThread() except for the first 2 iterations.
* win32_threads.c [RETRY_GET_THREAD_CONTEXT] (GC_push_stack_for):
Declare pcontext local variable (which refers to thread->saved_context);
define context as a macro (to *pcontext) instead of a local variable;
add comment; do not set ContextFlags and do not call GetThreadContext();
undefine context after last use of PUSHn().
Ivan Maidanski [Thu, 5 Sep 2019 08:44:27 +0000 (11:44 +0300)]
Refactoring of WoW64 workaround (Win32)
(code refactoring of commit
9483d5bba)
Issue #262 (bdwgc).
* include/private/gcconfig.h [I386 && (CYGWIN32 || MSWIN32)]
(WOW64_THREAD_CONTEXT_WORKAROUND): Define macro.
* win32_threads.c [!CONTEXT_EXCEPTION_ACTIVE] (CONTEXT_EXCEPTION_ACTIVE,
CONTEXT_EXCEPTION_REQUEST, CONTEXT_EXCEPTION_REPORTING): Move macro
definition upper to be before GC_suspend(); define only if
WOW64_THREAD_CONTEXT_WORKAROUND is defined (instead of I386).
* win32_threads.c (isWow64): Move static variable upper to be before
GC_suspend(); define only if WOW64_THREAD_CONTEXT_WORKAROUND.
* win32_threads.c (GET_THREAD_CONTEXT_FLAGS): New macro.
* win32_threads.c (GC_push_stack_for): Always set context.ContextFlags
to GET_THREAD_CONTEXT_FLAGS.
* win32_threads.c [I386] (GC_push_stack_for): Always store context.Esp
to sp (as the initial value).
* win32_threads.c (GC_push_stack_for): Use WoW64 workaround only
if WOW64_THREAD_CONTEXT_WORKAROUND (instead of I386).
* win32_threads.c (GC_thr_init): Set isWow64 only if
WOW64_THREAD_CONTEXT_WORKAROUND (instead of I386).
Ivan Maidanski [Wed, 4 Sep 2019 06:03:14 +0000 (09:03 +0300)]
Define OS_TYPE and DATAEND for UWP targets
(fix of commit
1471f940e9)
* include/private/gcconfig.h [AARCH64 && MSWIN32] (OS_TYPE, DATAEND):
Define macro; add TODO about GWW_VDB and MPROTECT_VDB.
* include/private/gcconfig.h [ARM32 && MSWIN32] (OS_TYPE, DATAEND):
Likewise.