platform/upstream/libgc.git
5 years agoFix deadlocks in write and suspend handlers if AO test-and-set is emulated
Ivan Maidanski [Tue, 20 Nov 2018 08:42:52 +0000 (11:42 +0300)]
Fix deadlocks in write and suspend handlers if AO test-and-set is emulated

This could be tested with -D AO_USE_PTHREAD_DEFS passed to CFLAGS.

* configure.ac (AO_TRYLINK_CFLAGS): New variable.
* configure.ac [$with_libatomic_ops!=none && $need_atomic_ops_asm!=true]
(BASE_ATOMIC_OPS_EMULATED): New AC_DEFINE (defined in case of failure
of AC_TRY_LINK of a code snippet calling AO_test_and_set_acquire,
AO_CLEAR, AO_compiler_barrier, AO_store, AO_load, AO_char_store,
AO_char_load, AO_store_release, AO_load_acquire); use AO_TRYLINK_CFLAGS;
add comment.
* include/private/gcconfig.h [BASE_ATOMIC_OPS_EMULATED] (MPROTECT_VDB):
Undefine.
* mark.c [AO_CLEAR] (GC_noop6): Do not call AO_compiler_barrier() if
BASE_ATOMIC_OPS_EMULATED.
* misc.c [!GC_DISABLE_INCREMENTAL] (GC_init, GC_enable_incremental):
Do not set GC_manual_vdb if BASE_ATOMIC_OPS_EMULATED.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(ao_load_acquire_async, ao_load_async, ao_store_release_async,
ao_store_async): New macro; undefine it after the usage.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_store_stack_ptr): Use ao_store_async() instead of AO_store().
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_suspend_handler_inner): Use ao_load[_acquire]_async() and
ao_store_release_async() instead of AO_load[_acquire]() and
AO_store_release(), respectively.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& GC_ENABLE_SUSPEND_THREAD] (suspend_self_inner): Use
ao_load_acquire_async() instead of AO_load_acquire().

5 years agoPrevent config macros redefinition undefined in gcconfig.h
Ivan Maidanski [Fri, 16 Nov 2018 21:51:49 +0000 (00:51 +0300)]
Prevent config macros redefinition undefined in gcconfig.h
(fix of commit 4f837f7a7)

* include/private/gc_pmark.h [HAVE_CONFIG_H]: Do not include config.h
if GC_PRIVATE_H is defined; add comment.

5 years agoAvoid potential 'macro redefinition' errors for config.h macros
Ivan Maidanski [Fri, 16 Nov 2018 17:27:42 +0000 (20:27 +0300)]
Avoid potential 'macro redefinition' errors for config.h macros

If a macro that could be defined in config.h could also be defined in
gc_config_macros.h or gcconfig.h then define it to the same value (1).

* include/gc_config_macros.h [!_REENTRANT && GC_PTHREADS
&& !GC_WIN32_THREADS] (_REENTRANT): Define to 1 instead of a blank.
* include/private/gcconfig.h [SPARC && SOLARIS && !USE_MMAP
&& REDIRECT_MALLOC] (USE_MMAP): Likewise.
* include/private/gcconfig.h [I386 && SOLARIS && !USE_MMAP
&& REDIRECT_MALLOC] (USE_MMAP): Likewise.
* include/private/gcconfig.h [I386 && DGUX && !USE_MMAP] (USE_MMAP):
Likewise.
* include/private/gcconfig.h [I386 && LINUX && __ELF__
&& !GC_NO_SIGSETJMP && (HOST_TIZEN || HOST_ANDROID)] (GC_NO_SIGSETJMP):
Likewise.
* include/private/gcconfig.h [I386 && DARWIN] (DARWIN_DONT_PARSE_STACK):
Likewise.
* include/private/gcconfig.h [AARCH64 && DARWIN]
(DARWIN_DONT_PARSE_STACK): Likewise.
* include/private/gcconfig.h [AARCH64 && NINTENDO_SWITCH]
(NO_HANDLE_FORK): Likewise.
* include/private/gcconfig.h [ARM32 && DARWIN]
(DARWIN_DONT_PARSE_STACK): Likewise.
* include/private/gcconfig.h [ARM32 && SN_TARGET_PSP2] (NO_HANDLE_FORK):
Likewise.
* include/private/gcconfig.h [X86_64 && DARWIN]
(DARWIN_DONT_PARSE_STACK): Likewise.
* include/private/gcconfig.h [X86_64 && SOLARIS && !USE_MMAP
&& REDIRECT_MALLOC] (USE_MMAP): Likewise.
* include/private/gcconfig.h [X86_64 && MSWIN_XBOX1 && !USE_MMAP]
(USE_MMAP): Likewise.
* include/private/gcconfig.h [(MSWIN32 || MSWINCE) && !USE_WINALLOC]
(USE_WINALLOC): Likewise.
* include/private/gcconfig.h [UNIX_LIKE && !NO_GETCONTEXT]
(NO_GETCONTEXT): Likewise.
* include/private/gcconfig.h [(FREEBSD || DARWIN && !_POSIX_C_SOURCE
|| SOLARIS && (!_XOPEN_SOURCE || __EXTENSIONS__) || LINUX)
&& !HAVE_DLADDR] (HAVE_DLADDR): Likewise.
* include/private/gcconfig.h [MAKE_BACK_GRAPH && !DBG_HDRS_ALL]
(DBG_HDRS_ALL): Likewise.

5 years agoAppveyor CI: Use 'make check-without-test-driver' for Cygwin
Ivan Maidanski [Thu, 15 Nov 2018 21:30:37 +0000 (00:30 +0300)]
Appveyor CI: Use 'make check-without-test-driver' for Cygwin

5 years agoFix tests linkage with internal atomic_ops.o
Ivan Maidanski [Thu, 15 Nov 2018 09:08:14 +0000 (12:08 +0300)]
Fix tests linkage with internal atomic_ops.o

* tests/tests.am (test_ldadd): Add $(nodist_libgc_la_OBJECTS).

5 years agoUpdate AUTHORS file (add Fabrice Fontaine)
Ivan Maidanski [Thu, 15 Nov 2018 08:54:13 +0000 (11:54 +0300)]
Update AUTHORS file (add Fabrice Fontaine)

5 years agoFix linkage with a system libatomic_ops shared library
Fabrice Fontaine [Mon, 5 Nov 2018 21:50:40 +0000 (22:50 +0100)]
Fix linkage with a system libatomic_ops shared library

Issue #247 (bdwgc).

When bdwgc is linked with the external libatomic_ops, bdw-gc.pc must
contain the needed dynamic libraries (such as -latomic_ops) otherwise
build of applications could fail on the link stage on some hosts:
* libgc.so: undefined reference to 'AO_fetch_compare_and_swap_emulation'
* libgc.so: undefined reference to 'AO_store_full_emulation'

So, this commit sets ATOMIC_OPS_LIBS to "-latomic_ops" when a system
atomic_ops library is used and uses ATOMIC_OPS_LIBS in bdw-gc.pc.in.

* bdw-gc.pc.in (Libs): Add @ATOMIC_OPS_LIBS@.
* configure.ac [$with_libatomic_ops!=no && $with_libatomic_ops!=none
&& $THREADS!=none] (ATOMIC_OPS_LIBS): Set to -latomic_ops; do AC_SUBST.

5 years agoFix typo in '#endif' in gcconfig.h
Ivan Maidanski [Wed, 14 Nov 2018 08:32:34 +0000 (11:32 +0300)]
Fix typo in '#endif' in gcconfig.h
(fix of commit 85422f3)

* include/private/gcconfig.h [CPPCHECK]: Fix typo in pragma ("#endif").

5 years agoWorkaround cppcheck warnings regarding CLOCKS_PER_SEC, REDIRECT_REALLOC
Ivan Maidanski [Wed, 14 Nov 2018 08:02:01 +0000 (11:02 +0300)]
Workaround cppcheck warnings regarding CLOCKS_PER_SEC, REDIRECT_REALLOC

Also, this commit adjusts the workaround for FIXUP_POINTER.

* include/private/gcconfig.h [CPPCHECK] (CLOCKS_PER_SEC, FIXUP_POINTER,
POINTER_MASK, POINTER_SHIFT, REDIRECT_REALLOC): Undefine.
* include/private/gcconfig.h [!FIXUP_POINTER && POINTER_MASK]
(FIXUP_POINTER): Same definition regardless of CPPCHECK.

5 years agoUse standalone private macro to guard against ptr_t redefinition
Ivan Maidanski [Wed, 14 Nov 2018 07:49:27 +0000 (10:49 +0300)]
Use standalone private macro to guard against ptr_t redefinition
(code refactoring)

* include/private/gc_priv.h (ptr_t): Define only if PTR_T_DEFINED is
not defined (previously).
* include/private/gcconfig.h (ptr_t): Likewise.
* include/private/gc_priv.h (PTR_T_DEFINED): Define macro.
* include/private/gcconfig.h (PTR_T_DEFINED): Likewise.
* include/private/gcconfig.h (ptr_t): Change type to char*; remove
void comments.
* include/private/gcconfig.h: Include stddef.h only if sony_news is
not defined (like in gc_priv.h).

5 years agoRemove redundant header double-inclusion checks in the private headers
Ivan Maidanski [Tue, 13 Nov 2018 22:24:13 +0000 (01:24 +0300)]
Remove redundant header double-inclusion checks in the private headers
(code refactoring)

* include/private/gc_pmark.h [HAVE_CONFIG_H]: Include config.h
regardless of GC_PRIVATE_H.
* include/private/gc_pmark.h: Include gc_mark.h regardless of GC_MARK_H;
include gc_priv.h regardless of GC_PRIVATE_H.
* include/private/gc_priv.h: Include gc_tiny_fl.h regardless of
GC_TINY_FL_H; include gc_mark.h regardless of GC_MARK_H; include
gcconfig.h regardless of GCCONFIG_H; include gc_locks.h regardless
of GC_LOCKS_H.

5 years agoWorkaround 'local address assignment to a global variable' CSA warning
Ivan Maidanski [Tue, 13 Nov 2018 08:02:49 +0000 (11:02 +0300)]
Workaround 'local address assignment to a global variable' CSA warning

* include/gc.h [(!__GNUC__ || __INTEL_COMPILER) && LINT2]
(GC_reachable_here): Transform ptr in the same way as COVERT_DATAFLOW()
does.
* mach_dep.c (GC_with_callee_saves_pushed): Transform the argument of
GC_noop1() by COVERT_DATAFLOW().
* misc.c [!ASM_CLEAR_CODE] (GC_clear_stack_inner): Likewise.
* misc.c (GC_call_with_stack_base, GC_call_with_gc_active): Likewise.
* pthread_support.c (GC_call_with_gc_active): Likewise.
* win32_threads.c (GC_call_with_gc_active): Likewise.
* misc.c (GC_call_with_gc_active): Transform &stacksect by
COVERT_DATAFLOW() when storing to GC_stackbottom.
* pthread_support.c (GC_call_with_gc_active): Likewise.

5 years agoEliminate 'non-virtual destructor for class with inheritors' CSA warning
Ivan Maidanski [Mon, 12 Nov 2018 18:16:42 +0000 (21:16 +0300)]
Eliminate 'non-virtual destructor for class with inheritors' CSA warning

* tests/test_cpp.cc (A): Add virtual empty destructor.

5 years agoGuard against potential buffer overflow in CORD_next and CORD_pos_fetch
Ivan Maidanski [Mon, 12 Nov 2018 17:57:32 +0000 (20:57 +0300)]
Guard against potential buffer overflow in CORD_next and CORD_pos_fetch

* cord/cordbscs.c (CORD__pos_fetch, CORD__next): Call ABORT() if
CORD_pos_valid() returns false for the argument (do not compute pe
in this case).

5 years agoWorkaround 'potential non-terminated string' false positive in cordbscs
Ivan Maidanski [Mon, 12 Nov 2018 08:12:09 +0000 (11:12 +0300)]
Workaround 'potential non-terminated string' false positive in cordbscs

* cordbscs.c [LINT2] (CORD_cat_char_star): Pass lenx+1 to memcpy()
instead of lenx; add comment.

5 years agoFix 'too wide non-owner permissions are set for resource' code defect
Ivan Maidanski [Mon, 12 Nov 2018 07:52:01 +0000 (10:52 +0300)]
Fix 'too wide non-owner permissions are set for resource' code defect

* misc.c [(UNIX_LIKE && !GC_ANDROID_LOG || CYGWIN32 || SYMBIAN)
&& !SMALL_CONFIG] (GC_init): Pass 0644 permissions mode instead of 0666
to open (create) a log file.
* os_dep.c [MMAP_SUPPORTED && !USE_MMAP_ANON && SYMBIAN]
(GC_unix_mmap_get_mem): Pass 0644 mode instead of 0666 to open "zero"
file.

5 years agoEliminate 'casting signed to bigger unsigned int' CSA warning
Ivan Maidanski [Mon, 12 Nov 2018 07:30:18 +0000 (10:30 +0300)]
Eliminate 'casting signed to bigger unsigned int' CSA warning

* cord/cordprnt.c (CORD_vsprintf): Cast prec, width, max_size, res
local variables to unsigned.
* cord/tests/cordtest.c (test_basics): Change type of i local variable
from int to size_t; cast c local variable to unsigned char.
* dbg_mlc.c (GC_store_debug_info_inner): Do not cast linenum parameter.
* include/private/dbg_mlc.h (oh.oh_string, oh.oh_int): Refine comment.
* include/private/dbg_mlc.h (oh.oh_int): Change type from word to
signed_word.
* misc.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (fill_prof_stats): Cast
GC_markers_m1 to signed_word first.
* misc.c (GC_init): Cast space_divisor local variable to unsigned
(instead of word).
* misc.c [!MSWIN32 && !MSWINCE && !OS2 && !MACOS && !GC_ANDROID_LOG]
(GC_write): Cast bytes_written local variable to unsigned (instead of
size_t).

5 years agoAdjust #error messages format
Ivan Maidanski [Fri, 9 Nov 2018 18:25:29 +0000 (21:25 +0300)]
Adjust #error messages format
(code refactoring)

Remove double quotes, "-->" prefix and the trailing dot from the error
messages.

* include/private/gcconfig.h [hp9000s300 && !CPPCHECK]: Adjust #error
message format.
* include/private/gcconfig.h [ibm032 && !CPPCHECK]: Likewise.
* include/private/gcconfig.h [!mach_type_known && !CPPCHECK]: Likewise.
* include/private/gcconfig.h [HEXAGON && (!__GLIBC__ || __GLIBC__ < 2
|| !__ELF__ && !CPPCHECK || !LINUX)]: Likewise.
* include/private/gcconfig.h [!ALIGNMENT && !CPPCHECK]: Likewise.
* include/private/gcconfig.h [!STACKBOTTOM && (ECOS || NOSYS)
&& !CPPCHECK]: Likewise.
* include/private/gcconfig.h [!CPPCHECK && (GC_IRIX_THREADS
|| GC_LINUX_THREADS || GC_NETBSD_THREADS || GC_FREEBSD_THREADS
|| GC_SOLARIS_THREADS || GC_HPUX_THREADS || GC_AIX_THREADS
|| GC_WIN32_THREADS || GC_WIN32_PTHREADS)]: Likewise.
* include/private/gcconfig.h [PARALLEL_MARK && !THREADS && !CPPCHECK]:
Likewise.
* include/private/gcconfig.h [!CPPCHECK && (MARK_BIT_PER_GRANULE
&& MARK_BIT_PER_OBJ || STACK_GROWS_UP && STACK_GROWS_DOWN
|| !STACK_GROWS_UP && !STACK_GROWS_DOWN || REDIRECT_MALLOC && THREADS
&& !LINUX && !REDIRECT_MALLOC_IN_HEADER)]: Likewise.
* os_dep.c [(MMAP_SUPPORTED || ADD_HEAP_GUARD_PAGES) && USE_MUNMAP
&& !USE_MMAP && !CPPCHECK]: Likewise.
* win32_threads.c [!I386 && !X86_64 && !ARM32 && !AARCH64 && !SHx
!MIPS && !PPC && !ALPHA && !CPPCHECK] (GC_push_stack_for): Likewise.

5 years agoWorkaround '#error' cppcheck messages in backgraph and private headers
Ivan Maidanski [Fri, 9 Nov 2018 17:54:23 +0000 (20:54 +0300)]
Workaround '#error' cppcheck messages in backgraph and private headers

* backgraph.c [!DBG_HDRS_ALL || ALIGNMENT!=CPP_WORDSZ/8]: Skip #error
directive if CPPCHECK.
* include/private/dbg_mlc.h [(KEEP_BACK_PTRS || MAKE_BACK_GRAPH)
&& SHORT_DBG_HDRS]: Likewise.
* include/private/gc_atomic_ops.h [!GC_BUILTIN_ATOMIC && (!AO_HAVE_load
|| !AO_HAVE_store)]: Likewise.
* include/private/gc_hdrs.h [CPP_WORDSZ!=32 && CPP_WORDSZ<36]: Likewise.
* include/private/gc_priv.h [HBLKSIZE]: Likewise.
* include/private/gcconfig.h [SPARC && LINUX && !__ELF__]: Likewise.
* include/private/gcconfig.h [I386 && (__LP64__ || _WIN64)]: Likewise.
* include/private/gcconfig.h [IA64 && HPUX && !_ILP32 && !_LP64]:
Likewise.
* include/private/gcconfig.h [CPP_WORDSZ!=32 && CPP_WORDSZ!=64]:
Likewise.

5 years agoEliminate 'uninitialized var' cppcheck false positive in mach_dep, os_dep
Ivan Maidanski [Fri, 9 Nov 2018 17:08:20 +0000 (20:08 +0300)]
Eliminate 'uninitialized var' cppcheck false positive in mach_dep, os_dep

* mach_dep.c (GC_with_callee_saves_pushed): Change type of "context"
local variable from void* volatile to volatile ptr_t.
* os_dep.c [(SVR4 || AIX || DGUX || (LINUX && SPARC)) && !PCR]
(GC_SysVGetDataStart): Change type of "result" local variable from
char* volatile to volatile ptr_t.

5 years agoWorkaround 'AST broken' syntax error reported by cppcheck in GC_mark_some
Ivan Maidanski [Fri, 9 Nov 2018 08:35:37 +0000 (11:35 +0300)]
Workaround 'AST broken' syntax error reported by cppcheck in GC_mark_some

Cppcheck does not support GNU-specific "&&label" syntax currently.

* mark.c [WRAP_MARK_SOME && (MSWIN32 || MSWINCE) && __GNUC__
&& !GC_GNUC_PREREQ(4,7) && !GC_CLANG_PREREQ(3,3)] (GC_mark_some): Skip
"er.alt_path=&&handle_ex" statement if CPPCHECK.

5 years agoWorkaround 'local variable obj_displ shadows outer symbol' cppcheck warning
Ivan Maidanski [Fri, 9 Nov 2018 08:14:02 +0000 (11:14 +0300)]
Workaround 'local variable obj_displ shadows outer symbol' cppcheck warning
(fix of commit 8d64dbd10)

* include/private/gc_pmark.h [MARK_BIT_PER_OBJ] (GC_push_contents_hdr):
Do not declare obj_displ if MARK_BIT_PER_GRANULE.

5 years agoWorkaround 'local variable end shadows outer symbol' cppcheck warnings
Ivan Maidanski [Fri, 9 Nov 2018 07:35:36 +0000 (10:35 +0300)]
Workaround 'local variable end shadows outer symbol' cppcheck warnings

* include/private/gcconfig.h [SPARC && FREEBSD] (end): Do not declare
external variable if CPPCHECK.
* include/private/gcconfig.h [MIPS && EWS4800 && (!_MIPS_SZPTR
|| _MIPS_SZPTR!=64)] (end): Likewise.
* include/private/gcconfig.h [ALPHA && FREEBSD] (end): Likewise.
* include/private/gcconfig.h [!DATAEND] (end): Likewise.
* include/private/gcconfig.h [I386 && RTEMS] (end): Do not declare
(because it automatically declared in DATAEND is undefined).
* include/private/gcconfig.h [I386 && RTEMS] (DATAEND): Do not define.
* include/private/gcconfig.h [MIPS && EWS4800]: Adjust indentation.

5 years agoFix 'set_pht_entry_from_index_concurrent value is unknown' cppcheck warning
Ivan Maidanski [Fri, 9 Nov 2018 07:14:09 +0000 (10:14 +0300)]
Fix 'set_pht_entry_from_index_concurrent value is unknown' cppcheck warning
(fix of commit cdc201f40)

* blacklst.c [PARALLEL_MARK && THREAD_SANITIZER]
(backlist_set_pht_entry_from_index): Assume
set_pht_entry_from_index_concurrent is always defined.
* include/private/gc_priv.h [!THREADS || !AO_HAVE_or]
(set_pht_entry_from_index_concurrent): Define (to
set_pht_entry_from_index).
* include/private/gc_priv.h [THREADS && AO_HAVE_or]
(GC_acquire_dirty_lock, GC_release_dirty_lock): Define to empty.
* os_dep.c [!GC_DISABLE_INCREMENTAL && (!THREADS || AO_HAVE_or)]
(async_set_pht_entry_from_index): Define to
set_pht_entry_from_index_concurrent.

5 years agoEliminate redundant check in backwards_height
Ivan Maidanski [Thu, 8 Nov 2018 22:05:51 +0000 (01:05 +0300)]
Eliminate redundant check in backwards_height

This eliminates 'the condition pred!=NULL is redundant' cppcheck warning.

* backgraph.c [MAKE_BACK_GRAPH] (backwards_height): Remove duplicate
pred!=NULL check (the case of NULL is already handled by
"if(NULL==pred)return 1" statement).

5 years agoReduce scope of local variables in GC_remove_all_threads_but_me
Ivan Maidanski [Thu, 8 Nov 2018 21:45:14 +0000 (00:45 +0300)]
Reduce scope of local variables in GC_remove_all_threads_but_me

This eliminates 'the scope of the variable can be reduced' cppcheck
warning in GC_remove_all_threads_but_me.

* pthread_support.c [CAN_HANDLE_FORK] (GC_remove_all_threads_but_me):
Move p, next, me local variables to an inner scope there they are used.
* win32_threads.c [CAN_HANDLE_FORK] (GC_remove_all_threads_but_me):
Move p, next local variables to an inner scope.

5 years agoPrevent double inclusion of javaxfc.h and private/specific.h
Ivan Maidanski [Thu, 8 Nov 2018 21:30:33 +0000 (00:30 +0300)]
Prevent double inclusion of javaxfc.h and private/specific.h

* include/javaxfc.h [GC_JAVAXFC_H]: Skip the whole header file.
* include/private/specific.h [GC_SPECIFIC_H]: Likewise.
* include/new_gc_alloc.h (GC_ALLOC_H): Rename to GC_NEW_ALLOC_H.
* include/private/dbg_mlc.h (_DBG_MLC_H): Rename to GC_DBG_MLC_H.

5 years agoTravis CI: Execute cppcheck without sudo and -U long
Ivan Maidanski [Thu, 8 Nov 2018 09:22:04 +0000 (12:22 +0300)]
Travis CI: Execute cppcheck without sudo and -U long

5 years agoUse GC_WORD_MAX macro across all C source files
Ivan Maidanski [Wed, 7 Nov 2018 20:34:04 +0000 (23:34 +0300)]
Use GC_WORD_MAX macro across all C source files
(code refactoring)

* alloc.c (GC_collect_at_heapsize, GC_compute_heap_usage_percent,
GC_add_to_heap, GC_expand_hp_inner): Use GC_WORD_MAX instead of
(word)-1.
* dyn_load.c [DATASTART_IS_FUNC]
(GC_register_dynamic_libraries_dl_iterate_phdr): Likewise.
* finalize.c [KEEP_BACK_PTRS] (GC_notify_or_invoke_finalizers):
Likewise.
* headers.c (GC_install_counts): Likewise.
* include/private/thread_local_alloc.h [GC_GCJ_SUPPORT] (ERROR_FL):
Likewise.
* os_dep.c [NEED_FIND_LIMIT || USE_PROC_FOR_LIBRARIES] (GC_find_limit):
Likewise.
* os_dep.c [MPROTECT_VDB && DARWIN] (GC_mprotect_thread): Likewise.
* pthread_support.c [PARALLEL_MARK] (GC_mark_thread): Likewise.
* win32_threads.c (ADDR_LIMIT): Likewise.
* win32_threads.c [PARALLEL_MARK] (GC_mark_thread): Likewise.
* alloc.c (GC_least_plausible_heap_addr): Use GC_WORD_MAX instead of
ONES macro.
* include/private/gc_priv.h [STACK_GROWS_DOWN] (MAKE_COOLER): Likewise.
* mark.c (GC_set_hdr_marks): Likewise.
* alloc.c (GC_WORD_MAX): Remove definition (in this file).
* headers.c (GC_install_counts): Reformat code.
* include/private/gc_priv.h (ONES): Rename to GC_WORD_MAX.

5 years agoAdd comment about hbp overflow in GC_install_counts
Ivan Maidanski [Wed, 7 Nov 2018 20:01:31 +0000 (23:01 +0300)]
Add comment about hbp overflow in GC_install_counts
(fix of commit 6a32bb4)

Issue #245 (bdwgc).

* headers.c (GC_install_counts): Better comment for the case of
overflow.

5 years agoEliminate 'unreferenced formal parameter' compiler warning in msvc_dbg
Ivan Maidanski [Wed, 7 Nov 2018 19:47:02 +0000 (22:47 +0300)]
Eliminate 'unreferenced formal parameter' compiler warning in msvc_dbg

* extra/msvc_dbg.c (GetDescriptionFromAddress): Cast format argument
to void.
* extra/msvc_dbg.c (GetDescriptionFromStack): Pass format argument to
GetDescriptionFromAddress (instead of NULL).

5 years agoWorkaround 'pointer addition with NULL pointer' cppcheck error in msvc_dbg
Ivan Maidanski [Wed, 7 Nov 2018 07:15:31 +0000 (10:15 +0300)]
Workaround 'pointer addition with NULL pointer' cppcheck error in msvc_dbg

* extra/msvc_dbg.c (GetDescriptionFromStack): Change type of begin,
end, buffer local variables from char* to GC_ULONG_PTR; do not update
size local variable value; do not store elements to description[]
if description is NULL (instead of checking of size is non-zero).

5 years agoRemove strlen calls with a constant string argument in msvc_dbg
Ivan Maidanski [Wed, 7 Nov 2018 07:00:21 +0000 (10:00 +0300)]
Remove strlen calls with a constant string argument in msvc_dbg
(code refactoring)

* extra/msvc_dbg.c (GetDescriptionFromAddress): Replace
strlen(<literal_str>) to sizeof(<literal_str>)-1.

5 years agoUse macro to operate on a flag residing in GC_stop_count
Ivan Maidanski [Tue, 6 Nov 2018 22:11:23 +0000 (01:11 +0300)]
Use macro to operate on a flag residing in GC_stop_count
(code refactoring of commit 295a2f24e)

* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(THREAD_RESTARTED): New macro.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_count):
Refine comment.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_suspend_handler_inner, GC_stop_world, GC_restart_all): Use
THREAD_RESTARTED.

5 years agoDocument assertion in the setters that used to return old value
Ivan Maidanski [Tue, 6 Nov 2018 21:48:21 +0000 (00:48 +0300)]
Document assertion in the setters that used to return old value
(code refactoring)

* misc.c (GC_set_finalize_on_demand, GC_set_java_finalization,
GC_set_dont_expand, GC_set_no_dls, GC_set_max_retries,
GC_set_dont_precollect, GC_set_time_limit): Add comment about GC_ASSERT.

5 years agoRemove redundant type casts in backgraph HEIGHT_UNKNOWN/IN_PROGRESS
Ivan Maidanski [Tue, 6 Nov 2018 21:30:18 +0000 (00:30 +0300)]
Remove redundant type casts in backgraph HEIGHT_UNKNOWN/IN_PROGRESS
(code refactoring)

* backgraph.c [MAKE_BACK_GRAPH] (HEIGHT_UNKNOWN, HEIGHT_IN_PROGRESS):
Remove unneeded type cast (to signed_word).

5 years agoAppveyor CI: Test with cygwin (32-bit) configuration
Ivan Maidanski [Sun, 4 Nov 2018 09:10:40 +0000 (12:10 +0300)]
Appveyor CI: Test with cygwin (32-bit) configuration

5 years agoFix hbp overflow in GC_install_counts
Ivan Maidanski [Sun, 4 Nov 2018 08:59:11 +0000 (11:59 +0300)]
Fix hbp overflow in GC_install_counts

Issue #245 (bdwgc).

The overflow resulted in an infinite loop in GC_install_counts on Win32.

* headers.c (GC_install_counts): If hbp+=BOTTOM_SZ overflow is expected
then break the first loop.

5 years agoAppveyor CI: Remove echo of environment variables
Ivan Maidanski [Sun, 4 Nov 2018 08:41:52 +0000 (11:41 +0300)]
Appveyor CI: Remove echo of environment variables
(code refactoring of commits e9b50024e5533d1c7c696dd85af)

5 years agoFix marks and hb_n_marks consistency when disclaim returns true
Petter A. Urkedal [Tue, 30 Oct 2018 20:00:32 +0000 (21:00 +0100)]
Fix marks and hb_n_marks consistency when disclaim returns true

* reclaim.c [ENABLE_DISCLAIM] (GC_disclaim_and_reclaim): When a
disclaim callback returns 1 to protect an object from being reclaimed,
mark it to skip it on repeated scans within the cycle. In particular,
this fixes sz*hhdr->hb_n_marks<=HBLKSIZE assertion failure due to
excessive increments of hb_n_marks.

5 years agoFix data race in disclaim_weakmap_test statistic counters update
Ivan Maidanski [Tue, 30 Oct 2018 07:38:56 +0000 (10:38 +0300)]
Fix data race in disclaim_weakmap_test statistic counters update
(fix of commit 6eba4218a)

Issue #239 (bdwgc).

The stat_* variables need to be atomically updated, since the locking
of the map is granular (cf WEAKMAP_MUTEX_COUNT) to allow parallelism
between different key hashes.

* tests/disclaim_weakmap_test.c [!AO_CLEAR] (AO_t): Define.
* tests/disclaim_weakmap_test.c [!AO_HAVE_fetch_and_add1]
(AO_fetch_and_add1): Define.
* tests/disclaim_weakmap_test.c (stat_added, stat_found, stat_removed,
stat_skip_marked, stat_skip_locked): Change type back from unsigned to
volatile AO_t.
* tests/disclaim_weakmap_test.c (weakmap_add, weakmap_disclaim):
Update stat_* counters using AO_fetch_and_add1(); move counters update
outside weakmap_lock/unlock block.
* tests/disclaim_weakmap_test.c (main): Cast stat_* counters to
unsigned type in printf() call.

5 years agoEnable compilation without C runtime (Win32)
Michael DeRoy [Mon, 29 Oct 2018 04:45:59 +0000 (07:45 +0300)]
Enable compilation without C runtime (Win32)
(part of commit 193af77 from Unity-Technologies/bdwgc)

* include/private/gcconfig.h [MSWIN32 && !__GNUC__
&& !NO_WRAP_MARK_SOME] (WRAP_MARK_SOME): Do not define if NO_CRT.
* mach_dep.c [!HAVE_BUILTIN_UNWIND_INIT && NO_CRT && MSWIN32]
(GC_with_callee_saves_pushed): Call RtlCaptureContext() instead of
setjmp().
* misc.c [MSWIN32 && _MSC_VER && _DEBUG] (GC_write): Do not call
MultiByteToWideChar() and OutputDebugStringW() if NO_CRT.
* win32_threads.c [NO_CRT] (GC_NO_THREADS_DISCOVERY): Define.
* win32_threads.c [!__GNUC__] (GC_win32_start_inner): Do not use __try
and __finally if NO_CRT.
* win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1]
(GC_beginthreadex): Do not define if NO_CRT.

5 years agoSupport UWP/arm64 target
Tautvydas Zilys [Mon, 10 Sep 2018 18:43:39 +0000 (11:43 -0700)]
Support UWP/arm64 target

* include/private/gcconfig.h [!_WIN32_WCE && _WIN32 && !__CYGWIN32__
&& !__INTERIX && !SYMBIAN && _M_X64] (X86_64): Define (do not check
_WIN64).
* include/private/gcconfig.h [!_WIN32_WCE && _WIN32 && !__CYGWIN32__
&& !__INTERIX && !SYMBIAN && _M_ARM64] (AARCH64): Define macro.
* win32_threads.c [AARCH64] (GC_push_stack_for): Push Xn (n=0..28) and
Lr registers.

5 years agoAppveyor CI: Test with cygwin64 configuration
Ivan Maidanski [Tue, 23 Oct 2018 23:09:47 +0000 (02:09 +0300)]
Appveyor CI: Test with cygwin64 configuration

5 years agoFix lock assertion violation in get_index if GC_ALWAYS_MULTITHREADED
Ivan Maidanski [Tue, 23 Oct 2018 23:08:14 +0000 (02:08 +0300)]
Fix lock assertion violation in get_index if GC_ALWAYS_MULTITHREADED
(fix of commit d5c65315b)

* misc.c [GC_ASSERTIONS && GC_ALWAYS_MULTITHREADED] (GC_init): Move up
LOCK() call to precede GC_expand_hp_inner() call.

5 years agoAdd I_HOLD_LOCK assertion to expand_hp_inner and related functions
Ivan Maidanski [Tue, 23 Oct 2018 22:50:14 +0000 (01:50 +0300)]
Add I_HOLD_LOCK assertion to expand_hp_inner and related functions
(code refactoring)

* alloc.c (GC_expand_hp_inner, GC_collect_or_expand): Add
GC_ASSERT(I_HOLD_LOCK()) at the beginning of the function.
* obj_map.c (GC_register_displacement_inner): Likewise.

5 years agoAppveyor CI: Test with MinGW and mingw-w64 configurations
Ivan Maidanski [Tue, 23 Oct 2018 08:19:11 +0000 (11:19 +0300)]
Appveyor CI: Test with MinGW and mingw-w64 configurations

5 years agoAppveyor CI: Refactoring of script to use environment matrix
Ivan Maidanski [Tue, 23 Oct 2018 07:34:13 +0000 (10:34 +0300)]
Appveyor CI: Refactoring of script to use environment matrix

5 years agoEnable disclaim_weakmap_test for the single-threaded environment
Ivan Maidanski [Mon, 22 Oct 2018 08:04:36 +0000 (11:04 +0300)]
Enable disclaim_weakmap_test for the single-threaded environment
(fix of commit 0cc2c0e7e)

Issue #239 (bdwgc).

Also, do some code refactoring and reformatting of disclaim_weakmap_test.c.

* tests/disclaim_weakmap_test.c: Reformat code.
* tests/disclaim_weakmap_test.c: Do not include stdarg.h, dbg_mlc.h,
gc.h.
* tests/disclaim_weakmap_test.c (THREAD_CNT): Rename to NTHREADS.
* tests/disclaim_weakmap_test.c: Include errno.h, pthread.h,
gc_atomic_ops.h only if GC_PTHREADS.
* tests/disclaim_weakmap_test.c (NTHREADS): Set to 1 unless GC_PTHREADS.
* tests/disclaim_weakmap_test.c [LINT2] (rand): Redefine to
(int)GC_random() (to workaround a code defect reported by Coverity
Scan).
* tests/disclaim_weakmap_test.c (dief): Remove.
* tests/disclaim_weakmap_test.c (FINALIZER_CLOSURE_FLAG,
INVALIDATE_FLAG): New macro (used by weakmap_add, weakmap_disclaim).
* tests/disclaim_weakmap_test.c (out_of_memory): Replace with
CHECK_OOM(p).
* tests/disclaim_weakmap_test.c (stat_added, stat_found, stat_removed,
stat_skip_marked): Change type from volatile AO_t to unsigned (because
it is accessed while holding the lock).
* tests/disclaim_weakmap_test.c (struct weakmap): Add weakobj_kind
field.
* tests/disclaim_weakmap_test.c (weakmap_lock, weakmap_trylock,
weakmap_unlock): No-op unless GC_PTHREADS.
* tests/disclaim_weakmap_test.c (weakmap_add): Call
GC_end_stubborn_change().
* tests/disclaim_weakmap_test.c (weakmap_add, weakmap_disclaim,
weakmap_new): Call GC_PTR_STORE_AND_DIRTY().
* tests/disclaim_weakmap_test.c (weakmap_new): Call pthread_mutex_init()
only if GC_PTHREADS.
* tests/disclaim_weakmap_test.c (weakmap_destroy): New function (which
calls pthread_mutex_destroy() if GC_PTHREADS).
* tests/disclaim_weakmap_test.c (_weakobj_free_list, _weakobj_kind):
Change global variable to local one declared in main().
* tests/disclaim_weakmap_test.c [TEST_MANUAL_VDB] (main): Call
GC_set_manual_vdb_allowed(1).
* tests/disclaim_weakmap_test.c [!NO_INCREMENTAL] (main): Call
GC_enable_incremental().
* tests/disclaim_weakmap_test.c (main): Call GC_init_finalized_malloc()
instead of multiple GC_register_displacement() calls; call
weakmap_destroy().
* tests/disclaim_weakmap_test.c [!GC_PTHREADS] (main): Call test() once.
* tests/tests.am (TESTS, check_PROGRAMS): Add disclaim_weakmap_test even
if no THREADS.
* tests/tests.am (disclaim_weakmap_test_SOURCES,
disclaim_weakmap_test_LDADD): Define even if no THREADS.

5 years agoUpdate AUTHORS file
Ivan Maidanski [Mon, 22 Oct 2018 05:58:29 +0000 (08:58 +0300)]
Update AUTHORS file

5 years agoUpdate documentation about arm64 ABI in gcconfig.h
Wookey [Mon, 22 Oct 2018 05:52:51 +0000 (08:52 +0300)]
Update documentation about arm64 ABI in gcconfig.h
(fix of commit b399b13b9)

Issue #242 (bdwgc).

This minor patch makes the info on available arm64/aarch64 ABIs more
consistent.

* include/private/gcconfig.h (mach_type_known): Refine comment about
AARCH64.

5 years agoWorkaround 'identical inner return condition always true' cppcheck warning
Ivan Maidanski [Fri, 19 Oct 2018 08:27:09 +0000 (11:27 +0300)]
Workaround 'identical inner return condition always true' cppcheck warning

* extra/msvc_dbg.c (GetModuleBase): Change if(dwAddrBase) to
if(dwAddrBase!=0).

5 years agoAdd copyright information about disclaim_weakmap_test source to README
Ivan Maidanski [Fri, 19 Oct 2018 08:08:48 +0000 (11:08 +0300)]
Add copyright information about disclaim_weakmap_test source to README

* README.md (Copyright & Warranty): Add copyright information about
disclaim_weakmap_test.c file.

5 years agoAdd paths to filenames mentioned in the copyright section in README
Ivan Maidanski [Fri, 19 Oct 2018 07:55:40 +0000 (10:55 +0300)]
Add paths to filenames mentioned in the copyright section in README

* README.md (Copyright & Warranty): Add the path to each mentioned file.

5 years agoTravis CI: Output content of disclaim_weak_test.log
Petter Urkedal [Fri, 19 Oct 2018 07:11:49 +0000 (10:11 +0300)]
Travis CI: Output content of disclaim_weak_test.log

Issue #239 (bdwgc).

5 years ago.gitignore: Ignore disclaim_weakmap_test executable file
Ivan Maidanski [Fri, 19 Oct 2018 07:09:25 +0000 (10:09 +0300)]
.gitignore: Ignore disclaim_weakmap_test executable file

5 years agoAdd test using disclaim notifiers to implement a weak map
Petter Urkedal [Mon, 8 Oct 2018 18:40:58 +0000 (20:40 +0200)]
Add test using disclaim notifiers to implement a weak map

Issue #239 (bdwgc).

disclaim_weakmap_test is added.

* tests/disclaim_weakmap_test.c: New file.
* tests/tests.am [THREADS] (TESTS, check_PROGRAMS): Add
disclaim_weakmap_test.
* tests/tests.am [THREADS] (disclaim_weakmap_test_SOURCES,
disclaim_weakmap_test_LDADD): Define.

5 years agoCheck result of pthread_mutex_unlock in specific.c
Ivan Maidanski [Wed, 17 Oct 2018 07:21:10 +0000 (10:21 +0300)]
Check result of pthread_mutex_unlock in specific.c

* specific.c [USE_CUSTOM_SPECIFIC] (GC_setspecific,
GC_remove_specific_after_fork): Call ABORT if pthread_mutex_unlock()
fails.

5 years agoNew API function to get size of object debug header
Ivan Maidanski [Mon, 15 Oct 2018 20:54:57 +0000 (23:54 +0300)]
New API function to get size of object debug header

GC_get_debug_header_size() is exported in addition to
GC_debug_header_size variable.  The usage of the latter is deprecated.

* dbg_mlc.c [CPPCHECK] (GC_start_debugging_inner): Call
GC_noop1(GC_debug_header_size) to suppress a cppcheck warning about
unused symbol.
* dbg_mlc.c (GC_debug_header_size): Add const.
* dbg_mlc.c (GC_get_debug_header_size): New API function definition.
* include/gc_config_macros.h (GC_ATTR_CONST): New macro.
* include/gc_mark.h (GC_debug_header_size): Add GC_ATTR_DEPRECATED and
const; update comment.
* include/gc_mark.h (GC_get_debug_header_size): New API public const
function declaration; move the comment from GC_debug_header_size.
* include/gc_mark.h (GC_USR_PTR_FROM_BASE): Use
GC_get_debug_header_size() instead of GC_debug_header_size.

5 years agoPass -Wall -Wextra -Wpedantic to g++ if supported (configure)
Ivan Maidanski [Thu, 11 Oct 2018 21:33:56 +0000 (00:33 +0300)]
Pass -Wall -Wextra -Wpedantic to g++ if supported (configure)

* configure.ac [$GCC=yes] (CXXFLAGS): Prepend -Wall $WEXTRA $WPEDANTIC.

5 years agoEliminate 'pointer targets differ in signedness' compiler warning (Win32)
Ivan Maidanski [Tue, 9 Oct 2018 07:59:39 +0000 (10:59 +0300)]
Eliminate 'pointer targets differ in signedness' compiler warning (Win32)
(fix of commit b66a887d7)

* win32_threads.c [!GC_NO_THREADS_DISCOVERY] (GC_Thread_Rep.tm): Add
long_in_use field to union; add comment.
* win32_threads.c [!GC_NO_THREADS_DISCOVERY]
(GC_register_my_thread_inner): Pass pointer to long_in_use field
instead of a pointer to in_use one casted to word*; remove outdated
comment.

5 years agoUpdate ChangeLog file (v8.0 changes)
Ivan Maidanski [Thu, 4 Oct 2018 21:43:43 +0000 (00:43 +0300)]
Update ChangeLog file (v8.0 changes)

5 years agoUpdate ChangeLog file (v7.6 changes)
Ivan Maidanski [Wed, 3 Oct 2018 21:11:15 +0000 (00:11 +0300)]
Update ChangeLog file (v7.6 changes)
(a cherry-pick of commit 16cbc85d from 'release-7_6')

5 years agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Tue, 2 Oct 2018 22:41:39 +0000 (01:41 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)
(a cherry-pick of commit 4bcd0c33 from 'release-7_4')

5 years agoFix memory allocation on GCF (Linux/x64)
Ivan Maidanski [Wed, 3 Oct 2018 08:02:07 +0000 (11:02 +0300)]
Fix memory allocation on GCF (Linux/x64)

Issue #225 (bdwgc).

GCF (Google Cloud Function) seems to have mmap("/dev/zero") operation
unsupported.  The workaround is to use mmap(MAP_ANONYMOUS).

* include/private/gcconfig.h [X86_64 && LINUX && __GLIBC__
&& !__UCLIBC__] (USE_MMAP_ANON): Define macro; add comment.

5 years agoFix 'USE_MUNMAP macro redefinition' error for NaCl
Ivan Maidanski [Wed, 3 Oct 2018 07:28:26 +0000 (10:28 +0300)]
Fix 'USE_MUNMAP macro redefinition' error for NaCl
(fix of commit 1aabce0f9)

* include/private/gcconfig.h [I386 && NACL] (USE_MUNMAP): Remove macro
(as it is defined in configure/CMake by default since gc v8.0.0).

5 years agoRemove extra USE_MMAP definition for Interix
Ivan Maidanski [Wed, 3 Oct 2018 07:08:17 +0000 (10:08 +0300)]
Remove extra USE_MMAP definition for Interix
(code refactoring)

* include/private/gcconfig.h [I386 && INTERIX && !USE_MMAP] (USE_MMAP):
Remove macro definition (because in gc v8.0.0+ it is defined later in this
file).

5 years agoCall real pthread_sigmask instead of its wrapper in start_mark_threads
Ivan Maidanski [Fri, 28 Sep 2018 06:35:51 +0000 (09:35 +0300)]
Call real pthread_sigmask instead of its wrapper in start_mark_threads
(fix of commit 95947bdc5)

The wrapper itself does not do anything useful in this case.

* pthread_support.c [PARALLEL_MARK && !NO_MARKER_SPECIAL_SIGMASK]
(GC_start_mark_threads_inner): Call REAL_FUNC(pthread_sigmask) instead
of pthread_sigmask.

5 years agoPrevent a deadlock in suspend_thread and after process forking
Ivan Maidanski [Wed, 26 Sep 2018 22:38:02 +0000 (01:38 +0300)]
Prevent a deadlock in suspend_thread and after process forking
(fix of commit 0c0e4cd)

Issue #235 (bdwgc).

* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread):
Remove unneeded comment for AO_store_release() call; invoke
GC_acquire_dirty_lock() and GC_release_dirty_lock() only if
GC_manual_vdb; add comment for GC_acquire_dirty_lock() call.
* pthread_stop_world.c [NACL] (GC_suspend_all): If GC_manual_vdb then
call GC_acquire_dirty_lock() and GC_release_dirty_lock() around the
code which ensures parking of threads.
* pthread_support.c [CAN_HANDLE_FORK] (fork_prepare_proc): Call
GC_acquire_dirty_lock().
* pthread_support.c [CAN_HANDLE_FORK] (fork_parent_proc,
fork_child_proc): Call GC_release_dirty_lock().

5 years agoUse AO_or in async_set_pht_entry_from_index if available
Ivan Maidanski [Wed, 26 Sep 2018 07:12:06 +0000 (10:12 +0300)]
Use AO_or in async_set_pht_entry_from_index if available

* blacklst.c (backlist_set_pht_entry_from_index): New macro; move
comment from gc_priv.h.
* blacklst.c (GC_add_to_black_list_normal, GC_add_to_black_list_stack):
Use backlist_set_pht_entry_from_index() instead of
set_pht_entry_from_index_concurrent().
* include/private/gc_priv.h (set_pht_entry_from_index): Add outermost
parentheses; cast result to void.
* include/private/gc_priv.h [THREADS]
(set_pht_entry_from_index_concurrent): Define only if AO_HAVE_or;
update comment.
* include/private/gc_priv.h [THREADS] (GC_acquire_dirty_lock,
GC_release_dirty_lock): Define to no-op if
set_pht_entry_from_index_concurrent is defined.
* include/private/gc_priv.h [THREADS
&& set_pht_entry_from_index_concurrent] (GC_fault_handler_lock): Do not
declare.
* os_dep.c [!GC_DISABLE_INCREMENTAL && THREADS
&& set_pht_entry_from_index_concurrent]
(async_set_pht_entry_from_index): Redirect to
set_pht_entry_from_index_concurrent; do not define
GC_fault_handler_lock variable.
* os_dep.c [!GC_DISABLE_INCREMENTAL && THREADS
&& !set_pht_entry_from_index_concurrent && AO_HAVE_test_and_set_acquire]
(async_set_pht_entry_from_index): Remove GC_ATTR_NO_SANITIZE_THREAD
(because AO_HAVE_or should be defined in case of TSan).

5 years agoFix concurrent bitmap update in GC_dirty
Ivan Maidanski [Mon, 24 Sep 2018 06:54:03 +0000 (09:54 +0300)]
Fix concurrent bitmap update in GC_dirty

Issue #235 (bdwgc).

* darwin_stop_world.c [!GC_NO_THREADS_DISCOVERY]
(GC_suspend_thread_list): Call GC_acquire_dirty_lock and
GC_release_dirty_lock around thread_suspend().
* darwin_stop_world.c (GC_stop_world): Likewise.
* include/private/gc_priv.h (set_pht_entry_from_index_safe): Remove
unused macro.
* include/private/gc_priv.h [THREADS] (GC_acquire_dirty_lock,
GC_release_dirty_lock): Define new macro; move comment from
win32_threads.c.
* include/private/gc_priv.h [THREADS && !GC_DISABLE_INCREMENTAL]
(GC_fault_handler_lock): Declare global variable (even if not
MPROTECT_VDB).
* os_dep.c [!GC_DISABLE_INCREMENTAL] (async_set_pht_entry_from_index):
Define even if not MPROTECT_VDB; reformat comments.
* os_dep.c [!GC_DISABLE_INCREMENTAL && AO_HAVE_test_and_set_acquire]
(GC_fault_handler_lock): Likewise.
* os_dep.c [THREADS && AO_HAVE_test_and_set_acquire]
(async_set_pht_entry_from_index): Use GC_acquire_dirty_lock and
GC_release_dirty_lock; remove wrong comment.
* os_dep.c [THREADS && !AO_HAVE_test_and_set_acquire]
(currently_updating, async_set_pht_entry_from_index): Remove incorrect
implementation.
* os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_dirty_inner): Call
async_set_pht_entry_from_index instead of set_pht_entry_from_index;
remove FIXME.
* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread):
Refine comment for AO_store_release call; call GC_acquire_dirty_lock
and GC_release_dirty_lock around a block of RAISE_SIGNAL() and
sem_wait().
* pthread_stop_world.c [GC_OPENBSD_UTHREADS] (GC_suspend_all): Call
GC_acquire_dirty_lock and GC_release_dirty_lock around
pthread_suspend_np().
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS] (GC_suspend_all): Add
comment.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_world):
If GC_manual_vdb then call GC_acquire_dirty_lock and
GC_release_dirty_lock around a block of GC_suspend_all() and
suspend_restart_barrier(); add comment.
* win32_threads.c (GC_suspend): Use GC_acquire_dirty_lock and
GC_release_dirty_lock (regardless of MPROTECT_VDB).

5 years agoRemove unused clear_pht_entry_from_index macro
Ivan Maidanski [Sat, 22 Sep 2018 12:59:42 +0000 (15:59 +0300)]
Remove unused clear_pht_entry_from_index macro
(code refactoring)

* include/private/gc_priv.h (clear_pht_entry_from_index): Remove macro.

5 years agoRefine documentation in gc_disclaim.h about closure object protection
Ivan Maidanski [Sat, 22 Sep 2018 12:55:45 +0000 (15:55 +0300)]
Refine documentation in gc_disclaim.h about closure object protection
(fix of commit 8ce6ef6)

* include/gc_disclaim.h (GC_register_disclaim_proc,
GC_finalized_malloc): Refine comment about the protection of the
finalizer closure object from collection.

5 years agoFix disclaim_test failure in case of GC_DEBUG
Ivan Maidanski [Fri, 21 Sep 2018 06:56:23 +0000 (09:56 +0300)]
Fix disclaim_test failure in case of GC_DEBUG
(fix of commit 21312a0)

* fnlz_mlc.c [ENABLE_DISCLAIM]: Include dbg_mlc.h.
* fnlz_mlc.c [ENABLE_DISCLAIM] (GC_init_finalized_malloc): Call
GC_register_displacement_inner(sizeof(oh)+FINALIZER_CLOSURE_FLAG).

5 years agoDefault to a single-threaded build for Nintendo, Orbis, Sony PSP targets
Ivan Maidanski [Wed, 19 Sep 2018 21:17:38 +0000 (00:17 +0300)]
Default to a single-threaded build for Nintendo, Orbis, Sony PSP targets
(fix of commits ce1f8746197182297ed5dad58d3cd63cf1e8)

* include/gc_config_macros.h [!GC_THREADS] (GC_THREADS): Do not check
SN_TARGET_ORBIS and SN_TARGET_PSP2 macros.
* include/private/gcconfig.h [X86_64 && SN_TARGET_ORBIS]: Do not
include pthread.h (should be included from gc_locks.h).
* include/private/gcconfig.h [NN_PLATFORM_CTR || NINTENDO_SWITCH
|| SN_TARGET_ORBIS || SN_TARGET_PS3 || SN_TARGET_PSP2] (THREADS):
Define only if GC_THREADS is defined.

5 years agoTest marking of finalizer closure object in disclaim_test
Ivan Maidanski [Wed, 19 Sep 2018 06:57:51 +0000 (09:57 +0300)]
Test marking of finalizer closure object in disclaim_test

* tests/disclaim_test.c (PTR_HASH): New macro.
* tests/disclaim_test.c (pair_dct): Change assertion condition about cd
(it should be equal to the hash value of p).
* tests/disclaim_test.c (pair_new): Replace static fc variable to local
pfc one which is assigned a pointer to atomic object; set pfc->cd to
the hash value of p.

5 years agoFix marking of finalizer closure object
Petter Urkedal [Tue, 18 Sep 2018 21:23:47 +0000 (00:23 +0300)]
Fix marking of finalizer closure object

* fnlz_mlc.c [ENABLE_DISCLAIM] (GC_init_finalized_malloc): Call
GC_register_displacement_inner(FINALIZER_CLOSURE_FLAG); add comment.
* fnlz_mlc.c [ENABLE_DISCLAIM] (GC_finalized_malloc): Call GC_dirty and
REACHABLE_AFTER_DIRTY after storing fclos.

5 years agoFix unneeded end_stubborn_change/ptr_store_and_dirty in disclaim_test
Ivan Maidanski [Mon, 17 Sep 2018 06:49:56 +0000 (09:49 +0300)]
Fix unneeded end_stubborn_change/ptr_store_and_dirty in disclaim_test
(fix of commits b52c140, 263ffbb)

* tests/disclaim_test.c (pair_dct): Add my_assert that cd is null;
store null to p->car (instead of storing cd and calling
GC_end_stubborn_change/GC_reachable_here).

5 years agoRefine documentation in gc_disclaim.h
Ivan Maidanski [Thu, 13 Sep 2018 19:16:20 +0000 (22:16 +0300)]
Refine documentation in gc_disclaim.h

* include/gc_disclaim.h (GC_disclaim_proc, GC_register_disclaim_proc,
GC_finalized_malloc): Refine comment.

5 years agoFix comment typo in CMakeLists.txt
Ivan Maidanski [Thu, 13 Sep 2018 07:58:29 +0000 (10:58 +0300)]
Fix comment typo in CMakeLists.txt

* CMakeLists.txt (CMAKE_USE_PTHREADS_INIT): Fix typo ("lib and includes")
in comment.

5 years agoSpecify register_disclaim_proc and finalized_malloc argument as non-null
Ivan Maidanski [Thu, 13 Sep 2018 06:31:11 +0000 (09:31 +0300)]
Specify register_disclaim_proc and finalized_malloc argument as non-null

Also, a check is added that the actual finalizer closure pointer does
not have FINALIZER_CLOSURE_FLAG set.

* fnlz_mlc.c (GC_register_disclaim_proc): Add assertion that proc is
non-null.
* fnlz_mlc.c (GC_finalized_malloc): Add assertions that fclos argument
is non-null and that fclos itself does not have FINALIZER_CLOSURE_FLAG
set.
* include/gc_disclaim.h (GC_register_disclaim_proc,
GC_finalized_malloc): Add GC_ATTR_NONNULL for the pointer argument.

5 years agoFix GC_VSNPRINTF in cordprnt for DJGPP and MS VC for WinCE
Ivan Maidanski [Fri, 7 Sep 2018 18:21:01 +0000 (21:21 +0300)]
Fix GC_VSNPRINTF in cordprnt for DJGPP and MS VC for WinCE
(fix of commit c10a1d900)

GC-internal DJGPP and MSWINCE macros are not available in cord.

* cord/cordprnt.c (GC_VSNPRINTF): Test __DJGPP__ instead of DJGPP macro.
* cord/cordprnt.c [_MSC_VER] (GC_VSNPRINTF): Test _WIN32_WCE instead
of MSWINCE macro.

5 years agoFix missing curses.h in cord/de when compiling manually (MS VC, MinGW)
Ivan Maidanski [Fri, 7 Sep 2018 17:49:32 +0000 (20:49 +0300)]
Fix missing curses.h in cord/de when compiling manually (MS VC, MinGW)

* cord/tests/de.c [__MINGW32__ || __NT__ || _WIN32] (WIN32): Define.

5 years agoEliminate 'different const qualifiers' MS VC warnings in cordbscs
Ivan Maidanski [Thu, 6 Sep 2018 08:29:15 +0000 (11:29 +0300)]
Eliminate 'different const qualifiers' MS VC warnings in cordbscs
(fix of commit 2e7daad62)

* cord/cordbscs.c (CORD_cat_char_star, CORD_cat): Cast the first
argument of GC_PTR_STORE_AND_DIRTY() to void*.

5 years agoTravis CI: Output content of disclaim_test.log
Ivan Maidanski [Thu, 6 Sep 2018 07:19:49 +0000 (10:19 +0300)]
Travis CI: Output content of disclaim_test.log

5 years agoBump libgc version (for development of 8.2 release)
Ivan Maidanski [Thu, 6 Sep 2018 07:16:32 +0000 (10:16 +0300)]
Bump libgc version (for development of 8.2 release)

* README.md: Restore build status badges (Travis, AppVeyor, Codecov,
Coveralls, Coverity, LGTM).
* README.md: Bump version to 8.1.0.
* configure.ac: Likewise.
* include/gc_version.h (GC_TMP_VERSION_MINOR): Likewise.

5 years ago[8.0.0] v8.0.0
Ivan Maidanski [Tue, 4 Sep 2018 22:07:03 +0000 (01:07 +0300)]
[8.0.0]

Bump gc version to 8.0.0 (experimental release)

* ChangeLog (8.0.0): Set release date.
* Makefile.am (LIBGC_VER_INFO): Increment revision (change version info
of libgc.so to 5:1:4).
* Makefile.am (LIBGCCPP_VER_INFO): Increment current and age (change
version info of libgccpp.so to 5:0:4).
* README.md: Bump major version (set minor and micro to 0).
* configure.ac (AC_INIT): Likewise.
* include/gc_version.h (GC_TMP_VERSION_MAJOR, GC_TMP_VERSION_MINOR,
GC_TMP_VERSION_MICRO): Likewise.
* README.md: Remove build status badges (Travis, AppVeyor, Codecov,
Coveralls, Coverity, LGTM).
* cord/cord.am (LIBCORD_VER_INFO): Increment current and age (change
version info of libcord.so to 5:0:4).

5 years agoUpdate ChangeLog file
Ivan Maidanski [Tue, 4 Sep 2018 21:47:41 +0000 (00:47 +0300)]
Update ChangeLog file

5 years agoReally fix 'potential unsafe sign check of a bitwise operation' code defect
Ivan Maidanski [Tue, 4 Sep 2018 21:45:41 +0000 (00:45 +0300)]
Really fix 'potential unsafe sign check of a bitwise operation' code defect
(fix of commit af00c4d)

* mark.c [!OS2] (GC_mark_from): Replace (signed_word)v>=0 to (v&SIGNB)==0
(anyway, the compiler generates the same code).

5 years agoAdd Codecov.io badge to README
Ivan Maidanski [Tue, 4 Sep 2018 07:11:29 +0000 (10:11 +0300)]
Add Codecov.io badge to README

5 years agoTravis CI: Send code coverage reports to Codecov as well
Ivan Maidanski [Tue, 4 Sep 2018 07:10:04 +0000 (10:10 +0300)]
Travis CI: Send code coverage reports to Codecov as well

5 years agoFix comment typos in backgraph.c, de.c, gcconfig.h
Max Mouratov [Sun, 2 Sep 2018 20:08:43 +0000 (01:08 +0500)]
Fix comment typos in backgraph.c, de.c, gcconfig.h

* ChangeLog (5.0alpha6): Fix typo ("DATASTART").
* include/private/gcconfig.h: Likewise.
* backgraph.c: Fix typo in comment ("If").
* cord/tests/de.c: Fix typo in comment ("Unbounded").

5 years agoReplace some FIXME items with TODO ones
Ivan Maidanski [Fri, 31 Aug 2018 20:22:15 +0000 (23:22 +0300)]
Replace some FIXME items with TODO ones
(code refactoring)

* alloc.c (GC_maybe_gc, GC_collect_a_little_inner,
GC_finish_collection): Replace FIXME item with TODO one.
* gcj_mlc.c (maybe_finalize): Likewise.
* include/gc.h [!GC_DEBUG || !__GNUC__] (GC_PTR_ADD): Likewise.
* include/private/gcconfig.h [X86_64 && LINUX && __GLIBC__
&& !__UCLIBC__] (GETCONTEXT_FPU_EXCMASK_BUG): Likewise.
* mach_dep.c (GC_with_callee_saves_pushed): Likewise.
* mark_rts.c (GC_push_current_stack): Likewise.
* misc.c [MSWIN32 || MSWINCE] (WRITE): Likewise.
* os_dep.c [ECOS] (ecos_gc_memory): Likewise.
* os_dep.c (GC_get_stack_base, GC_page_was_ever_dirty): Likewise.
* reclaim.c (GC_reclaim_clear): Likewise.
* include/private/gcconfig.h [OPENBSD && m68k]: Remove FIXME item.

5 years agoEliminate 'unused variable old_maps_size' compiler warning in get_maps
Ivan Maidanski [Fri, 31 Aug 2018 20:06:56 +0000 (23:06 +0300)]
Eliminate 'unused variable old_maps_size' compiler warning in get_maps
(fix of commit b3eee14)

* os_dep.c [NEED_PROC_MAPS] (GC_get_maps): Do not declare old_maps_size
local variable unless THREADS.

5 years agoRemove MIN_WORDS macro from gc_priv.h
Ivan Maidanski [Fri, 31 Aug 2018 19:38:52 +0000 (22:38 +0300)]
Remove MIN_WORDS macro from gc_priv.h
(code refactoring)

* include/private/gc_priv.h (MIN_WORDS): Move macro to test.c; remove
FIXME.
* tests/test.c: Update comment for include gc_priv.h.

5 years agoWorkaround 'bad pointer arithmetic' false waring in check_annotated_obj
Ivan Maidanski [Fri, 31 Aug 2018 17:00:33 +0000 (20:00 +0300)]
Workaround 'bad pointer arithmetic' false waring in check_annotated_obj

* dbg_mlc.c [!SHORT_DBG_HDRS] (GC_check_annotated_obj): Change
(word*)ptr+ofs expressions to &((word*)ptr)[ofs].

5 years agoEliminate 'potential unsafe sign check of a bitwise operation' code defect
Ivan Maidanski [Fri, 31 Aug 2018 16:14:18 +0000 (19:14 +0300)]
Eliminate 'potential unsafe sign check of a bitwise operation' code defect

* mark.c [!OS2] (GC_mark_from): Cast mark_stack_top-mark_stack to word
first, and cast bitwise OR operation result to signed_word, so that not
to apply bitwise OR operation to the value of ptrdiff_t.

5 years agoEliminate 'comparison is always false' code defect in get_maps
Ivan Maidanski [Fri, 31 Aug 2018 16:06:27 +0000 (19:06 +0300)]
Eliminate 'comparison is always false' code defect in get_maps

In case of a single-threaded build, the comparison is always false
because maps_size>=0 and old_maps_size<=0.

* os_dep.c [NEED_PROC_MAPS] (GC_get_maps): Do not evaluate
maps_size<old_maps_size inside while expression if THREADS; remove
comment.

5 years agoEliminate 'poor global variable name' code defect in typd_mlc
Ivan Maidanski [Thu, 30 Aug 2018 19:20:25 +0000 (22:20 +0300)]
Eliminate 'poor global variable name' code defect in typd_mlc
(fix of commit a825a2d)

* typd_mlc.c (ld, ad, sd): Remove unused global variables.

5 years agoAdd LGTM.com code quality badges to README.md
Ivan Maidanski [Thu, 30 Aug 2018 13:39:12 +0000 (16:39 +0300)]
Add LGTM.com code quality badges to README.md