]> granicus.if.org Git - gc/log
gc
7 years agoNew target (check-cpp) to avoid Makefile.direct parallel build issue
Ivan Maidanski [Wed, 22 Mar 2017 08:23:37 +0000 (11:23 +0300)]
New target (check-cpp) to avoid Makefile.direct parallel build issue
(Cherry-pick commit 4dfe88e from 'master' branch.)

* Makefile.direct: Add comment about check-cpp.
* Makefile.direct (test_cpp): Replace dependency on "c++" with
"gc_cpp.o base_lib"; link with gc_cpp.o directly.
* Makefile.direct (check-cpp): New target (same as c++-t but do not
depend on c++ target and pass no arguments to test_cpp).

7 years agoSupport CFLAGS_EXTRA when checking for inline and dladdr (configure)
Ivan Maidanski [Thu, 23 Mar 2017 08:38:38 +0000 (11:38 +0300)]
Support CFLAGS_EXTRA when checking for inline and dladdr (configure)
(fix commits 0e175f35dedb24)

* configure.ac (AC_C_INLINE, AC_TRY_COMPILE(dladdr)): Add $CFLAGS_EXTRA
to CFLAGS temporarily (restore CFLAGS after the check).

7 years agoRename 'test' to 'check' target in Makefile.direct
Ivan Maidanski [Mon, 13 Mar 2017 21:08:26 +0000 (00:08 +0300)]
Rename 'test' to 'check' target in Makefile.direct
(Cherry-pick commit 4fad4e5 from 'master' branch.)

This is to match the target name in Makefile generated by configure.

* Makefile.direct: Update comment about testing (rename "test" target
to "check").
* Makefile.direct (check): Renamed from "test".
* Makefile.direct (test): Depend on check; add comment.
* README.QUICK (INSTALLATION): Leave information only about the recent
GC version.
* README.QUICK (INSTALLATION): Replace "make test" with "make check".
* README.md (Installation and Portability): Likewise.

7 years agoUpdate shared libraries version info to differentiate against v7.4
Ivan Maidanski [Thu, 6 Apr 2017 09:13:03 +0000 (12:13 +0300)]
Update shared libraries version info to differentiate against v7.4

There are no API changes in libcord and libgccpp against release-7_4
but some implementation changes exist, 3:*:* version info is reserved
for release-7_4, so the version info for libcord and libgccpp is
now 4:0:3.

There some API changes in libgc against release-7_4, so the "current"
number of the version info is incremented, thus the full version info
is now 4:0:2.

* Makefile.am (LIBGC_VER_INFO): Change version info to 4:0:2
(release-7_4 is supposed to use 3:x:1).
* Makefile.am (LIBGCCPP_VER_INFO): Change version info to 4:0:3
(release-7_4 is supposed to use 3:x:2).
* cord/cord.am (LIBCORD_VER_INFO): Likewise.

7 years agoFix GC shared library tests failure (musl)
Ivan Maidanski [Fri, 17 Mar 2017 08:21:13 +0000 (11:21 +0300)]
Fix GC shared library tests failure (musl)

Detect dl_iterate_phdr() presence by configure.

* configure.ac (dl_iterate_phdr): Add AC_CHECK_FUNCS for.
* configure.ac [ac_cv_func_dl_iterate_phdr] (HAVE_DL_ITERATE_PHDR):
AC_DEFINE it.

7 years agoUpdate AUTHORS file
Ivan Maidanski [Thu, 16 Mar 2017 07:11:15 +0000 (10:11 +0300)]
Update AUTHORS file

7 years agoconfigure: match uclinux pattern
Romain Naour [Sat, 6 Aug 2016 21:24:35 +0000 (23:24 +0200)]
configure: match uclinux pattern

BDWGC does not recognize "uclinux" as a valid OS part of the target
tuple which is used by some arm cortex-M toolchains.

* configure.ac [$THREADS=pthreads] (GC_LINUX_THREADS, _REENTRANT): Define
for hosts matching "*-*-*linux*" (instead of "*-*-linux*").

7 years agoUse AC_DEFINE for defining NO_GETCONTEXT in configure
Ivan Maidanski [Wed, 15 Mar 2017 21:49:22 +0000 (00:49 +0300)]
Use AC_DEFINE for defining NO_GETCONTEXT in configure
(code refactoring of commit 7c13fb8)

* configure.ac [!ac_cv_func_getcontext]: Use AC_DEFINE(NO_GETCONTEXT)
instead of directly adding -D NO_GETCONTEXT to CFLAGS.

7 years agoUpdate AUTHORS file
Ivan Maidanski [Wed, 15 Mar 2017 21:41:11 +0000 (00:41 +0300)]
Update AUTHORS file

7 years agoconfigure.ac: add check for NO_GETCONTEXT definition
Samuel Martin [Wed, 15 Mar 2017 21:39:37 +0000 (00:39 +0300)]
configure.ac: add check for NO_GETCONTEXT definition

* configure.ac: Add AC_CHECK_FUNCS(getcontext); add -DNO_GETCONTEXT to
CFLAGS if $ac_cv_func_getcontext is "no".

7 years agoAllow HAVE_DL_ITERATE_PHDR to be defined by client (musl)
Ivan Maidanski [Fri, 17 Mar 2017 08:05:56 +0000 (11:05 +0300)]
Allow HAVE_DL_ITERATE_PHDR to be defined by client (musl)

Do not redefine HAVE_DL_ITERATE_PHDR macro if already defined.

* dyn_load.c [OPENBSD>=200519] (HAVE_DL_ITERATE_PHDR): Do not define
if already defined.
* dyn_load.c [!USE_PROC_FOR_LIBRARIES && (__GLIBC__>=2
|| PLATFORM_ANDROID)] (HAVE_DL_ITERATE_PHDR): Likewise.
* dyn_load.c [!USE_PROC_FOR_LIBRARIES && HAVE_DL_ITERATE_PHDR
&& !DL_ITERATE_PHDR_STRONG] (dl_iterate_phdr): Define as weak symbol
(even if HAVE_DL_ITERATE_PHDR is defined outside this file).

7 years agoRefine configure messages when checking for compiler option support
Ivan Maidanski [Tue, 14 Mar 2017 22:45:16 +0000 (01:45 +0300)]
Refine configure messages when checking for compiler option support

* configure.ac (AC_MSG_CHECKING): Refine message when checking for
a compiler option support (replace "gcc" with "compiler").

7 years agoWorkaround 'WinMain() is never used' cppcheck false warning (de_win)
Ivan Maidanski [Thu, 16 Mar 2017 22:20:11 +0000 (01:20 +0300)]
Workaround 'WinMain() is never used' cppcheck false warning (de_win)

* cord/tests/de_win.c (WinMain): Call GC_noop1(&WinMain) if CPPCHECK.

7 years agoWorkaround '32-bit value shift by >31 bits is undefined' cppcheck warnings
Ivan Maidanski [Thu, 9 Mar 2017 20:48:45 +0000 (23:48 +0300)]
Workaround '32-bit value shift by >31 bits is undefined' cppcheck warnings

* include/private/gcconfig.h [CPPCHECK] (CPP_WORDSZ): Undefine
(platform-specific explicit value) and redefine to __SIZEOF_POINTER__*8.

7 years agoWorkaround 'memory leak: result' cppcheck false error (POSIX)
Ivan Maidanski [Tue, 7 Mar 2017 16:23:49 +0000 (19:23 +0300)]
Workaround 'memory leak: result' cppcheck false error (POSIX)

The report is a false positive because result (returned by mmap) should
be equal to start_addr (passed to mmap).

* os_dep.c [USE_MUNMAP && !USE_WINALLOC] (GC_unmap, GC_unmap_gap): Call
GC_noop1(result) if CPPCHECK (same as for LINT2).
* os_dep.c [USE_MUNMAP && !USE_WINALLOC && NACL] (GC_remap): Likewise.

7 years agoEliminate 'non-reentrant function strtok called' cppcheck warning (POSIX)
Ivan Maidanski [Thu, 9 Mar 2017 06:57:56 +0000 (09:57 +0300)]
Eliminate 'non-reentrant function strtok called' cppcheck warning (POSIX)

* tests/test_cpp.cc [(MSWIN32 && !__MINGW32__ || MSWINCE)
&& !NO_WINMAIN_ENTRY] (WinMain): Manually inline strtok(); add comment.

7 years agoWorkaround 'obsolescent usleep called' cppcheck warning (POSIX)
Ivan Maidanski [Tue, 7 Mar 2017 16:03:00 +0000 (19:03 +0300)]
Workaround 'obsolescent usleep called' cppcheck warning (POSIX)

* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]: Include time.h.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_world):
Use nanosleep() instead of usleep() if CPPCHECK.

7 years agoWorkaround 'obsolescent bcopy, bzero called' cppcheck warnings (POSIX)
Ivan Maidanski [Tue, 7 Mar 2017 15:52:08 +0000 (18:52 +0300)]
Workaround 'obsolescent bcopy, bzero called' cppcheck warnings (POSIX)

* include/private/gc_priv.h (BCOPY, BZERO): Define to memcpy/set if
CPPCHECK (regardless of BCOPY_EXISTS).

7 years agoEliminate 'scope of variable can be reduced' cppcheck warnings (Win32)
Ivan Maidanski [Tue, 7 Mar 2017 15:41:13 +0000 (18:41 +0300)]
Eliminate 'scope of variable can be reduced' cppcheck warnings (Win32)

* os_dep.c [MSWIN32] (GC_register_root_section): Move "protect" local
variable declaration to the inner scope where the variable is actually
used.
* win32_threads.c [!MSWINCE && !CYGWIN32] (GC_CreateThread): Move
"thread_h" local variable declaration to the inner scope.

7 years agoEliminate 'condition ret==NULL always true' cppcheck style warning (Amiga)
Ivan Maidanski [Sun, 5 Mar 2017 05:22:39 +0000 (08:22 +0300)]
Eliminate 'condition ret==NULL always true' cppcheck style warning (Amiga)

* extra/AmigaOS.c [GC_AMIGA_FASTALLOC && !GC_AMIGA_ONLYFAST
&& GC_AMIGA_GC] (GC_amiga_allocwrapper_any): Do not check ret==NULL
twice.
* extra/AmigaOS.c [GC_AMIGA_FASTALLOC && GC_AMIGA_GC]
(GC_amiga_allocwrapper_fast): Likewise.
* extra/AmigaOS.c [GC_AMIGA_GC] (GC_amiga_realloc): Likewise.

7 years agoEliminate 'checking unsigned variable < 0' cppcheck warning in gc_inline
Ivan Maidanski [Tue, 28 Feb 2017 22:25:34 +0000 (01:25 +0300)]
Eliminate 'checking unsigned variable < 0' cppcheck warning in gc_inline

* include/gc_inline.h (GC_FAST_MALLOC_GRANS): Replace
(word)my_entry<=num_direct with (signed_word)my_entry-num_direct<=0
to avoid "checking unsigned var < 0" warning if num_direct==0
(no overflow is expected in (signed_word)my_entry-num_direct as it is
guaranteed that (word)my_entry<=num_direct+GC_TINY_FREELISTS+1).

7 years agoEliminate 'label not used' cppcheck false warnings in GC_mark_X
Ivan Maidanski [Tue, 28 Feb 2017 20:02:55 +0000 (23:02 +0300)]
Eliminate 'label not used' cppcheck false warnings in GC_mark_X
(code refactoring of PUSH_CONTENTS[_HDR] to eliminate 'goto' statement)

* include/private/gc_hdrs.h (HC_GET_HDR): Remove exit_label argument;
replace goto with break; remove do-while(0) (as break is now used to
pass control to some place of the caller).
* include/private/gc_pmark.h (SET_MARK_BIT_EXIT_IF_SET): Likewise.
* include/private/gc_pmark.h [!USE_MARK_BYTES] (OR_WORD_EXIT_IF_SET):
Likewise.
* include/private/gc_pmark.h (PUSH_CONTENTS, PUSH_CONTENTS_HDR):
Remove exit_label argument (and the comment about it).
* include/private/gc_pmark.h (SET_MARK_BIT_EXIT_IF_SET): Refine comment
about the exit.
* mark.c (GC_mark_from): Remove PUSH_CONTENTS exit<N> argument.
* typd_mlc.c (GC_typed_mark_proc): Likewise.
* mark.c (GC_mark_and_push, GC_mark_and_push_stack): Remove
PUSH_CONTENTS_HDR label argument and the label itself.

7 years agoEliminate 'ISO C forbids object to function pointer conversion' warning
Ivan Maidanski [Thu, 16 Mar 2017 07:22:29 +0000 (10:22 +0300)]
Eliminate 'ISO C forbids object to function pointer conversion' warning

* dyn_load.c [SOLARISDL && !USE_PROC_FOR_LIBRARIES
&& SUNOS53_SHARED_LIB] (GC_FirstDLOpenedLinkMap): Cast result of dlsym()
to word type before casting it to a function pointer.
* pthread_support.c [GC_USE_DLOPEN_WRAP] (GC_init_real_syms): Likewise.

7 years agoEliminate 'type defaults to int in declaration' warning (REDIRECT_MALLOC)
Ivan Maidanski [Wed, 15 Mar 2017 22:02:12 +0000 (01:02 +0300)]
Eliminate 'type defaults to int in declaration' warning (REDIRECT_MALLOC)

* os_dep.c [REDIRECT_MALLOC] (GC_in_save_callers): Add missing type
(GC_bool) of the declared variable.

7 years agoFix cord/de build in Makefile.direct (Linux)
Ivan Maidanski [Tue, 21 Mar 2017 08:58:30 +0000 (11:58 +0300)]
Fix cord/de build in Makefile.direct (Linux)
(Cherry-pick commit ded6139 from 'master' branch.)

As of Ubuntu 14, termlib package is missing and not needed to
build 'de' test application (the required symbols are provided in
libcurses).

* Makefile.direct (CURSES): Remove -ltermlib; add comment about it.
* Makefile.direct [DRSNX, HPUX] (cord/de): Replace $(CURSES) with
"-lcurses -ltermlib".

7 years agoFix test_cpp and c++ parallel build in Makefile.direct
Ivan Maidanski [Mon, 20 Mar 2017 08:33:37 +0000 (11:33 +0300)]
Fix test_cpp and c++ parallel build in Makefile.direct
(Cherry-pick commit 41db6f8 from 'master' branch.)

* Makefile.direct (test_cpp): Add dependency on c++ (and remove
dependency on base_lib and gc_cpp.o); do not link with gc_cpp.o
directly (it should be in gc.a).

7 years agoRun test_cpp only if requested (Makefile.direct)
Ivan Maidanski [Thu, 16 Mar 2017 07:53:28 +0000 (10:53 +0300)]
Run test_cpp only if requested (Makefile.direct)

* Makefile.direct (c++-t): Add dependency on test_cpp target.
* Makefile.direct (c++): Remove dependency on test_cpp target; do not
execute test_cpp.

7 years agoFix parallel build in Makefile.direct
Ivan Maidanski [Thu, 16 Mar 2017 07:45:09 +0000 (10:45 +0300)]
Fix parallel build in Makefile.direct

* Makefile.direct (all, cord/cordtest, cord/de, gctest): Depend on
base_lib instead of gc.a target.
* Makefile.direct (base_lib): Generate "base_lib" file after
"runlib gc.a".
* Makefile.direct (cords, c++): Add dependency on base_lib target.

7 years agoFix missing .exe for disclaim test filenames in Makefile (MinGW)
Ivan Maidanski [Wed, 1 Mar 2017 23:03:11 +0000 (02:03 +0300)]
Fix missing .exe for disclaim test filenames in Makefile (MinGW)
(fix commit 6c1a924)

Also add 4 blank lines to improve tests.am readability.

* tests/tests.am [ENABLE_DISCLAIM] (TESTS): Add $(EXEEXT) suffix to
disclaim_test, disclaim_bench.

7 years agoFix gc.h compliance to strict ANSI (pthreads)
Ivan Maidanski [Thu, 30 Mar 2017 21:11:04 +0000 (00:11 +0300)]
Fix gc.h compliance to strict ANSI (pthreads)
(Cherry-pick commits 15542970970110 from 'master' branch.)

If -std=cXX option is passed to gcc/clang then sigset_t is undefined,
thus GC_pthread_sigmask declaration should be omitted.  However, this
symbol should be available during GC source code audit by cppcheck.

* include/gc_pthread_redirects.h [!GC_NO_PTHREAD_SIGMASK]
(GC_pthread_sigmask): Declare only if GC_PTHREAD_SIGMASK_NEEDED or
_POSIX_C_SOURCE >= 199506 or _XOPEN_SOURCE >= 500, or _BSD_SOURCE
or _GNU_SOURCE.
* tests/test.c [CPPCHECK && !_GNU_SOURCE && GC_PTHREADS] (_GNU_SOURCE):
Likewise.

7 years agoFix mixed include of GC public header and gc_priv.h in disclaim bench/test
Ivan Maidanski [Thu, 30 Mar 2017 19:06:09 +0000 (22:06 +0300)]
Fix mixed include of GC public header and gc_priv.h in disclaim bench/test

Include gc_priv.h should be avoided in tests (if possible) or, at
least, this include should not precede include of the public GC
headers (because, e.g., gc_priv.h define GC_BUILD which influences
declspec of the GC public symbols in case of a shared library).

* tests/disclaim_bench.c: Move include gc_priv.h to be after
gc_disclaim.h; add comment .
* tests/disclaim_bench.c [HAVE_CONFIG_H]: Include "config.h" (before
include gc_disclaim.h).
* tests/disclaim_test.c [LINT2]: Do not include gc_priv.h; include
config.h instead.
* tests/disclaim_test.c [LINT2] (GC_API_PRIV): Define.
* tests/disclaim_test.c [LINT2] (GC_random): Declare the function
(instead of including gc_priv.h to get the prototype).

7 years agoFix finalize.c compilation in 'strict ANSI' mode
Ivan Maidanski [Thu, 23 Mar 2017 20:12:07 +0000 (23:12 +0300)]
Fix finalize.c compilation in 'strict ANSI' mode

This and some other GC .c files include gc_pmark.h directly (not
gc_priv.h), so the compiler complains that sigset_t (used in
gc_pthread_redirects.h) is undefined if 'strict ANSI' mode is on and
_GNU_SOURCE is not defined before including system headers.

* include/private/gc_pmark.h [(__linux__ || __GLIBC__ || __GNU__)
&& GC_PTHREADS && !GC_NO_PTHREAD_SIGMASK] (_GNU_SOURCE): Define (before
including other headers).

7 years agoFix static assertion violation in LONG_MULT for 64-bit targets
Ivan Maidanski [Thu, 23 Mar 2017 19:44:11 +0000 (22:44 +0300)]
Fix static assertion violation in LONG_MULT for 64-bit targets

* include/private/gc_pmark.h [MARK_BIT_PER_OBJ] (PUSH_CONTENTS_HDR):
Cast displ to unsigned32 when passed to LONG_MULT (it is safe because
displ is less than HBLKSIZE).

7 years agoFix tools/setjmp_t hang (OS X)
Ivan Maidanski [Thu, 23 Mar 2017 00:16:12 +0000 (03:16 +0300)]
Fix tools/setjmp_t hang (OS X)

* tools/setjmp_t.c (main): Declare "y" static variable as volatile (to
prevent reordering/optimization of y++).

7 years agoFix gctest thread stack overflow (musl-gcc)
Ivan Maidanski [Fri, 17 Mar 2017 07:39:57 +0000 (10:39 +0300)]
Fix gctest thread stack overflow (musl-gcc)
(Cherry-pick commits 3bfeb8a21b68ca from 'master' branch.)

* tests/test.c (BIG): Remove commented out defined(MSWIN32); define
to 1000 if NO_GETCONTEXT (and UNIX_LIKE); update comment.

7 years agoFix gctest failure for Darwin if CPPCHECK is defined
Ivan Maidanski [Thu, 16 Mar 2017 22:10:41 +0000 (01:10 +0300)]
Fix gctest failure for Darwin if CPPCHECK is defined
(fix commits c5d4ef9857bb8a)

* tests/test.c [TEST_FORK_WITHOUT_ATFORK] (NO_TEST_HANDLE_FORK):
Define even if CPPCHECK (i.e., CPPCHECK should not imply testing of
HANDLE_FORK).
* tests/test.c [GC_PTHREADS && CPPCHECK] (main): Remove duplicate check
for GC_PTHREADS.
* tests/test.c [GC_PTHREADS && CPPCHECK && NO_TEST_HANDLE_FORK] (main):
Call UNTESTED() for GC_atfork_child, GC_atfork_parent,
GC_atfork_prepare, GC_set_handle_fork, GC_start_mark_threads.

7 years agoFix GC_SIZE_MAX definition (Linux/musl-gcc)
Ivan Maidanski [Tue, 14 Mar 2017 22:58:41 +0000 (01:58 +0300)]
Fix GC_SIZE_MAX definition (Linux/musl-gcc)

* include/private/gc_priv.h [SIZE_MAX && !CPPCHECK] (GC_SIZE_MAX): Cast
SIZE_MAX to size_t explicitly (to workaround incorrect definition
of SIZE_MAX - e.g. it is defined as ~0ULL in musl-tools which is not
correct for a 32-bit target).

7 years agoFix 'ISO C90 forbids mixed declarations/code' compiler warning (gc_pmark)
Ivan Maidanski [Mon, 13 Mar 2017 21:31:08 +0000 (00:31 +0300)]
Fix 'ISO C90 forbids mixed declarations/code' compiler warning (gc_pmark)

* include/private/gc_pmark.h [MARK_BIT_PER_OBJ] (PUSH_CONTENTS_HDR):
Declare "obj_displ" local variable at the beginning of the block (not
after GC_STATIC_ASSERT).

7 years agoUpdate AUTHORS file
Ivan Maidanski [Thu, 2 Mar 2017 21:42:01 +0000 (00:42 +0300)]
Update AUTHORS file

7 years agoFix 'size of tv is unknown' error in brief_async_signal_safe_sleep (musl)
Mikael Djurfeldt [Sun, 26 Feb 2017 19:09:56 +0000 (20:09 +0100)]
Fix 'size of tv is unknown' error in brief_async_signal_safe_sleep (musl)
(fix commits 62097c39f48082)

Include <sys/time.h> to get struct timeval defined and select() declared.

* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD]: Include sys/time.h
before GC_brief_async_signal_safe_sleep definition.

7 years agoMove libraries version info to the beginning of Makefile.am
Ivan Maidanski [Wed, 1 Mar 2017 08:10:00 +0000 (11:10 +0300)]
Move libraries version info to the beginning of Makefile.am
(code refactoring)

* Makefile.am (LIBGC_VER_INFO, LIBGCCPP_VER_INFO): New variable; add
comment about the version update rule.
* cord/cord.am (LIBCORD_VER_INFO): Likewise.
* Makefile.am (libgc_la_LDFLAGS, libgccpp_la_LDFLAGS): Use
LIBGC[CPP]_VER_INFO instead the direct hard-coding of version info.
* cord/cord.am (libcord_la_LDFLAGS): Likewise.

7 years agoUpdate AUTHORS file
Max Mouratov [Wed, 1 Mar 2017 03:12:14 +0000 (08:12 +0500)]
Update AUTHORS file

7 years agoFix typo in comment at GC_setup_temporary_fault_handler declaration
Ivan Maidanski [Thu, 23 Mar 2017 00:24:49 +0000 (03:24 +0300)]
Fix typo in comment at GC_setup_temporary_fault_handler declaration

* include/private/gc_priv.h (GC_setup_temporary_fault_handler): Fix typo
in comment (replace trailing ';' with a dot).

7 years agoFix name typos in GC_FAST_MALLOC_GRANS comment
Ivan Maidanski [Tue, 28 Feb 2017 21:45:45 +0000 (00:45 +0300)]
Fix name typos in GC_FAST_MALLOC_GRANS comment

* include/gc_inline.h (GC_FAST_MALLOC_GRANS): Fix typos in names in
comment ("num_direct", "generic_malloc").

7 years agoFix typo in GC_AMIGA_GC documentation in README
Ivan Maidanski [Mon, 20 Feb 2017 21:32:49 +0000 (00:32 +0300)]
Fix typo in GC_AMIGA_GC documentation in README

* doc/README.amiga (GC_AMIGA_GC): Fix a typo ("very").

7 years agoUpdate AUTHORS file
Ivan Maidanski [Mon, 20 Feb 2017 21:25:29 +0000 (00:25 +0300)]
Update AUTHORS file

7 years agoFix various typos in comments and printed messages
Klemens Zwischenbrugger [Mon, 20 Feb 2017 21:17:57 +0000 (00:17 +0300)]
Fix various typos in comments and printed messages

This patch contains some spelling fixes (just in comments and C strings
passed to printf) as found by bot (https://github.com/ka7/misspell_fixer).

* SMakefile.amiga: Fix typo in comment ("don't").
* WCC_MAKEFILE (SYSTEM): Fix typo in comment ("uncomment").
* configure.ac [!GCC] (gc_cflags): Fix typo in comment ("actually").
* configure.ac (NO_CLOCK): Fix typo in comment ("targeting").
* doc/README.amiga: Fix typos in documentation ("there's", "compliant",
"documentation").
* extra/AmigaOS.c [GC_AMIGA_PRINTSTATS] (GC_amiga_free_all_mem): Fix
typos in printed messages ("succeeded", "succeeding").
* include/gc.h (GC_get_heap_size): Fix typo in comment ("below").
* tools/setjmp_t.c (main): Fix typo in printed message ("won't").

7 years agoFix typo in Makefile.am comment
Ivan Maidanski [Wed, 15 Feb 2017 08:56:06 +0000 (11:56 +0300)]
Fix typo in Makefile.am comment

* Makefile.am (SUBDIRS): Fix typo in comment ("to be").

7 years ago.gitignore: Ignore gctest_* and lib*gc.so produced by Makefile.direct
Ivan Maidanski [Wed, 22 Mar 2017 08:31:16 +0000 (11:31 +0300)]
.gitignore: Ignore gctest_* and lib*gc.so produced by Makefile.direct

7 years ago.gitignore: Ignore bsd-libgc.a, bsd-libleak.a
Ivan Maidanski [Mon, 20 Mar 2017 20:10:48 +0000 (23:10 +0300)]
.gitignore: Ignore bsd-libgc.a, bsd-libleak.a

7 years ago.gitignore: Ignore *.sancov (generated by ASan)
Ivan Maidanski [Wed, 15 Feb 2017 21:42:22 +0000 (00:42 +0300)]
.gitignore: Ignore *.sancov (generated by ASan)

7 years agoWorkaround '!GC_page_size is always false' cppcheck style warning
Ivan Maidanski [Tue, 14 Feb 2017 08:24:18 +0000 (11:24 +0300)]
Workaround '!GC_page_size is always false' cppcheck style warning

* os_dep.c [!MSWIN32] (GC_setpagesize): Do not check that GC_page_size
is non-zero if CPPCHECK.

7 years agoUpdate ChangeLog file (v7.6 changes only)
Ivan Maidanski [Fri, 10 Feb 2017 12:52:36 +0000 (15:52 +0300)]
Update ChangeLog file (v7.6 changes only)

7 years agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Fri, 10 Feb 2017 11:18:00 +0000 (14:18 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)

7 years agoFix enable_parallel_mark condition in CMake script
Ivan Maidanski [Tue, 31 Jan 2017 23:30:18 +0000 (02:30 +0300)]
Fix enable_parallel_mark condition in CMake script

* CMakeLists.txt [enable_parallel_mark] (ADD_DEFINITIONS): Add
-DPARALLEL_MARK; remove ADD_DEFINITIONS("-DPARALLEL_MARK") in other
places; remove ${} for enable_parallel_mark in IF.

7 years agoAppveyor CI: build/test with GCJ support
Ivan Maidanski [Thu, 26 Jan 2017 07:53:32 +0000 (10:53 +0300)]
Appveyor CI: build/test with GCJ support
(Cherry-pick commit ad57086 from 'master' branch.)

7 years agoExecute more single-threaded GC tests by CMake
Ivan Maidanski [Mon, 19 Dec 2016 21:47:17 +0000 (00:47 +0300)]
Execute more single-threaded GC tests by CMake
(Cherry-pick commits 495b4fe686c871 from 'master' branch.)

Note: support of the multi-threaded tests, disclaim_bench/test,
trace_test, staticrootstest is not added to cmake test script yet.

* tests/CMakeLists.txt (ADD_EXECUTABLE, TARGET_LINK_LIBRARIES,
ADD_TEST): Add hugetest, leaktest, middletest, realloc_test, smashtest
(similar to gctest).

7 years agoAdd minimal testing of GC_MALLOC_[ATOMIC_]WORDS and GC_CONS (gctest)
Ivan Maidanski [Thu, 22 Dec 2016 22:07:41 +0000 (01:07 +0300)]
Add minimal testing of GC_MALLOC_[ATOMIC_]WORDS and GC_CONS (gctest)

* tests/test.c: Include "gc_inline.h" unconditionally.
* tests/test.c (test_tinyfl): New function (which invokes
GC_MALLOC_WORDS, GC_MALLOC_ATOMIC_WORDS and GC_CONS).
* tests/test.c (run_one_test): Call test_tinyfl.

7 years agoTest GCJ object creation with length-based descriptor (gctest)
Ivan Maidanski [Mon, 5 Dec 2016 22:38:49 +0000 (01:38 +0300)]
Test GCJ object creation with length-based descriptor (gctest)

* tests/test.c [GC_GCJ_SUPPORT] (gcj_cons): Define new static variable
obj_cnt; increment obj_cnt on each call; if obj_cnt is odd then pass
gcj_class_struct1 to GC_GCJ_MALLOC instead of gcj_class_struct2.

7 years agoRemove page_was_dirty and remove_protection duplicate definitions
Ivan Maidanski [Thu, 8 Dec 2016 23:41:54 +0000 (02:41 +0300)]
Remove page_was_dirty and remove_protection duplicate definitions

* include/private/gc_priv.h [!GC_DISABLE_INCREMENTAL]
(GC_page_was_dirty): Refine comment (move the comment
content from GC_page_was_dirty in os_dep.c).
* os_dep.c [GWW_VDB && MPROTECT_VDB] (GC_gww_page_was_dirty): Remove.
* os_dep.c [GWW_VDB || MPROTECT_VDB || PROC_VDB || MANUAL_VDB]
(GC_page_was_dirty): Avoid code duplication (remove the functions of
the identical implementation).
* os_dep.c [(GWW_VDB || PROC_VDB) && !MPROTECT_VDB || MANUAL_VDB
|| DEFAULT_VDB] (GC_remove_protection): Likewise.
* os_dep.c [CHECKSUMS && GWW_VDB || PROC_VDB] (GC_or_pages): Remove
nesting of #if.

7 years agoAdd configure --enable-gcov option (enable code coverage analysis)
Ivan Maidanski [Wed, 18 Jan 2017 08:47:44 +0000 (11:47 +0300)]
Add configure --enable-gcov option (enable code coverage analysis)

* configure.ac (gcov): New --enable-* option.
* configure.ac [enable_gcov] (CFLAGS): Add "--coverage" option.
* configure.ac [enable_gcov && !enable_shared] (CXXFLAGS): Add
"--coverage" option (the shared library build is skipped to workaround
a bug in GCC or linker, atlist for gcc-4.8.4/x86_64).
* configure.ac [enable_gcov] (CFLAGS, CXXFLAGS): Filter out compiler
"-O" options (except for -O0).

7 years agoSupport CFLAGS_EXTRA to pass extra user-defined compiler flags (configure)
Ivan Maidanski [Fri, 9 Dec 2016 00:21:05 +0000 (03:21 +0300)]
Support CFLAGS_EXTRA to pass extra user-defined compiler flags (configure)

* Makefile.am (CFLAGS, CXXFLAGS): Append $(CFLAGS_EXTRA).
* configure.ac: Add AC_SUBST(CFLAGS_EXTRA).

7 years agoEliminate 'GC_collecting is set but never used' code defect (Win32)
Ivan Maidanski [Wed, 18 Jan 2017 08:58:42 +0000 (11:58 +0300)]
Eliminate 'GC_collecting is set but never used' code defect (Win32)

* include/private/gc_locks.h [USE_PTHREAD_LOCKS && GC_PTHREADS]
(GC_collecting): Do not declare if GC_WIN32_THREADS.
* include/private/gc_locks.h [USE_PTHREAD_LOCKS && GC_PTHREADS]
(ENTER_GC, EXIT_GC): Do not define if GC_WIN32_THREADS; remove
trailing ';', add cast to void.
* win32_threads.c [USE_PTHREAD_LOCKS] (GC_collecting): Remove definition.

7 years agoWorkaround 'condition is always true' cppcheck style warnings in GC_init
Ivan Maidanski [Thu, 22 Dec 2016 22:44:06 +0000 (01:44 +0300)]
Workaround 'condition is always true' cppcheck style warnings in GC_init

* misc.c (GC_init): Skip GC_STATIC_ASSERT for sizeof(ptr_t),
sizeof(word), (word)-1>(word)0 and ((signed_word)-1)<0 if CPPCHECK.

7 years agoEliminate 'array vs singleton' code defect in typed_test (gctest)
Ivan Maidanski [Thu, 22 Dec 2016 22:00:28 +0000 (01:00 +0300)]
Eliminate 'array vs singleton' code defect in typed_test (gctest)

Taking address of bmX yields a singleton pointer but GC_make_descriptor
expects an array (of words).

* tests/test.c (typed_test): Define bm3, bm2, bm_large as 1-element
arrays (instead of values of a primitive type), and remove
"&" operator when passing them to GC_make_descriptor.

7 years agoEliminate 'memory leak' code defect for scratch-allocated memory
Ivan Maidanski [Thu, 22 Dec 2016 08:05:41 +0000 (11:05 +0300)]
Eliminate 'memory leak' code defect for scratch-allocated memory

Reuse memory allocated by GC_scratch_alloc and GET_MEM in GC heap
if possible.

* backgraph.c (push_in_progress): Replace in_progress_size==0 with
in_progress_space==NULL (to ensure BCOPY argument is non-NULL);
eliminate code duplication regarding GC_add_to_our_memory call;
call GC_scratch_recycle_no_gww (for old in_progress_space value) unless
GWW_VDB (and remove corresponding FIXME).
* dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX]
(GC_register_dynamic_libraries): Call GC_scratch_recycle_no_gww (for
old addr_map and current_sz values).
* include/private/gc_priv.h [!GWW_VDB] (GC_scratch_recycle_no_gww): New
internal macro.
* include/private/gc_priv.h (GC_scratch_recycle_inner): New prototype.
* mark.c (GC_scratch_recycle_inner): New function (move code portion
from alloc_mark_stack).
* mark.c (alloc_mark_stack): Call GC_scratch_recycle_inner (if
recycle_old).
* os_dep.c [NEED_PROC_MAPS] (GC_get_maps): Call GC_scratch_recycle_no_gww
(for old maps_buf and maps_buf_sz values).
* os_dep.c [PROC_VDB] (GC_read_dirty): Call GC_scratch_recycle_no_gww
(for old GC_proc_buf and GC_proc_buf_size values).

7 years agoWorkaround 'resource leak' false positives in alloc_MS, bl/envfile_init
Ivan Maidanski [Tue, 20 Dec 2016 07:41:40 +0000 (10:41 +0300)]
Workaround 'resource leak' false positives in alloc_MS, bl/envfile_init

* blacklst.c (GC_bl_init): Add assertion that GC_old_stack_bl and
GC_incomplete_stack_bl are both null prior to their assignment (to the
result of GC_scratch_alloc).
* mark.c (alloc_mark_stack): Replace GC_mark_stack_size!=0 with
GC_mark_stack!=NULL (to ensure no memory leak when GC_mark_stack is
assigned for the first time).
* misc.c [GC_READ_ENV_FILE && (MSWIN32 || MSWINCE || CYGWIN32)]
(GC_envfile_init): Add assertion that GC_envfile_content is null prior
to its assignment.

7 years agoWorkaround 'bad address arithmetic' static analysis tool false positive
Ivan Maidanski [Sat, 17 Dec 2016 14:21:40 +0000 (17:21 +0300)]
Workaround 'bad address arithmetic' static analysis tool false positive

The tool complains whether (alloc(size)+ofs) is intentional instead of
(alloc(size+ofs)).  In our case, it is a false alarm (the offset is
added to the result to align the allocation at HBLKSIZE boundary).

* os_dep.c [USE_WINALLOC && MSWIN32] (GC_win32_get_mem): Store result
of GlobalAlloc() to "result" local variable first (then, perform result
alignment in a standalone statement); add comment.

7 years agoWorkaround 'checking unsigned value is negative' code defect in mark_from
Ivan Maidanski [Sat, 17 Dec 2016 06:57:34 +0000 (09:57 +0300)]
Workaround 'checking unsigned value is negative' code defect in mark_from

* mark.c (GC_mark_from): Replace (signed_word)descr<0 with
(descr&SIGNB)!=0.

7 years agoWorkaround 'null pointer dereference' false positive in push_next_marked
Ivan Maidanski [Sat, 17 Dec 2016 06:47:10 +0000 (09:47 +0300)]
Workaround 'null pointer dereference' false positive in push_next_marked

* mark.c [LINT2] (GC_push_next_marked,
GC_push_next_marked_uncollectable): Call ABORT if h is null (to ensure
that null is not passed to GC_push_marked).
* mark.c [!GC_DISABLE_INCREMENTAL && LINT2] (GC_push_next_marked_dirty):
Likewise.
* mark.c [!GC_DISABLE_INCREMENTAL && STUBBORN_ALLOC]
(GC_push_next_marked_dirty): Remove code duplication.

7 years agoEliminate 'integer shift by a negative amount' code defect in finalize
Ivan Maidanski [Fri, 16 Dec 2016 22:01:06 +0000 (01:01 +0300)]
Eliminate 'integer shift by a negative amount' code defect in finalize

* finalize.c (GC_register_disappearing_link_inner): Add assertion that
dl_hashtbl->log_size is non-negative after GC_grow_table() call.
* finalize.c (GC_unregister_disappearing_link_inner): If
dl_hashtbl->log_size is negative then return immediately (to avoid an
integer value shift by log_size==-1 in HASH2).
* finalize.c [!GC_MOVE_DISAPPEARING_LINK_NOT_NEEDED]
(GC_move_disappearing_link_inner): Likewise.
* finalize.c (GC_register_finalizer_inner): Add assertion that
log_fo_table_size is non-negative after GC_grow_table() call.
* finalize.c (GC_finalize): Add assertion that log_fo_table_size is
non-negative unless GC_fnlz_roots.finalize_now is null.

7 years agoEliminate 'use of vulnerable sprintf' code defect in de_win test (cord)
Ivan Maidanski [Fri, 9 Dec 2016 22:54:05 +0000 (01:54 +0300)]
Eliminate 'use of vulnerable sprintf' code defect in de_win test (cord)

* cord/tests/de_win.c (WinMain): Do not call sprintf() on RegisterClass
and CreateWindow failure; invoke de_error() with the immediate error
message strings (without the error code).

7 years agoWorkaround 'potential multiplication overflow' code defect in de_win (cord)
Ivan Maidanski [Fri, 9 Dec 2016 21:57:39 +0000 (00:57 +0300)]
Workaround 'potential multiplication overflow' code defect in de_win (cord)

* cord/tests/de_win.c (get_line_rect): Cast (extend) char_height to
LONG when multiplied by line (otherwise only the result of the
multiplication is extended to LONG implicitly).

7 years agoWorkaround 'pointer used before comparison to null' code defect (pthread)
Ivan Maidanski [Wed, 7 Dec 2016 07:40:15 +0000 (10:40 +0300)]
Workaround 'pointer used before comparison to null' code defect (pthread)
(fix commit 31b3afc)

* pthread_support.c [GC_PTHREADS && !GC_WIN32_THREADS && DEBUG_THREADS]
(GC_pthread_create): Do not check new_thread is non-NULL (because
new_thread is first passed to the underlying pthread_create() where
the argument is marked with "nonnull" attribute).

7 years agoFix '32-bit value shift followed by expansion to 64-bit' code defect
Ivan Maidanski [Wed, 7 Dec 2016 07:22:09 +0000 (10:22 +0300)]
Fix '32-bit value shift followed by expansion to 64-bit' code defect

* gcj_mlc.c [GC_GCJ_SUPPORT] (GC_core_gcj_malloc,
GC_gcj_malloc_ignore_off_page): Cast lg local variable to word before
passing it to GRANULES_TO_BYTES (so that value type widening does not
occur after the value left shift).
* malloc.c (GC_generic_malloc_inner, GC_malloc_kind_global,
GC_generic_malloc_uncollectable): Likewise.
* typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Likewise.
* misc.c (block_add_size): Cast hhdr->hb_sz to word before passing it
to WORDS_TO_BYTES; cast HBLKSIZE-1 to word before "~" operation.

7 years agoFix 'GC_written_pages never read' code defect (GWW_VDB)
Ivan Maidanski [Tue, 6 Dec 2016 07:49:52 +0000 (10:49 +0300)]
Fix 'GC_written_pages never read' code defect (GWW_VDB)

* include/private/gc_priv.h [GWW_VDB] (GC_written_pages,
GC_arrays._written_pages): Do not define unless CHECKSUMS.
* os_dep.c [GWW_VDB] (GC_or_pages): Likewise.
* os_dep.c [GWW_VDB] (GC_gww_read_dirty): Call
GC_or_pages(GC_written_pages) only if CHECKSUMS.

7 years agoWorkaround 'index out of bounds' UBSan false warning in push_marked
Ivan Maidanski [Fri, 9 Dec 2016 23:07:25 +0000 (02:07 +0300)]
Workaround 'index out of bounds' UBSan false warning in push_marked

* mark.c (GC_push_marked): Cast (h+1)->hb_body to word before
subtraction of sz value (and cast the result back to ptr_t).
* mark.c [ENABLE_DISCLAIM] (GC_push_unconditionally): Likewise.

7 years agoUpdate README regarding make cords with Makefile.direct
Ivan Maidanski [Mon, 9 Jan 2017 20:33:38 +0000 (23:33 +0300)]
Update README regarding make cords with Makefile.direct

* README.QUICK (cord): Replace "make cords after copying to Makefile"
to "make -f Makefile.direct cords".

7 years agoFix MS VC warning about compiling unused checksums and thread_local_alloc
Ivan Maidanski [Tue, 31 Jan 2017 23:21:22 +0000 (02:21 +0300)]
Fix MS VC warning about compiling unused checksums and thread_local_alloc

* CMakeLists.txt (SRC): Remove checksums.c (to avoid MS VC warning
about unused file).
* CMakeLists.txt (SRC): Do not add thread_local_alloc.c unless
ADD_DEFINITIONS("-DTHREAD_LOCAL_ALLOC") present.

7 years agoFix 'zero-size array is extension' Clang warning in os_dep (Linux/x86)
Ivan Maidanski [Mon, 30 Jan 2017 03:51:12 +0000 (06:51 +0300)]
Fix 'zero-size array is extension' Clang warning in os_dep (Linux/x86)

* os_dep.c [I386 && LINUX && SAVE_CALL_CHAIN] (struct frame): Do not
declare fr_arg[NARGS] field if NARGS is zero.

7 years agoFix 'execvp argument incompatible pointer type' compiler warning (tools)
Ivan Maidanski [Mon, 9 Jan 2017 21:03:07 +0000 (00:03 +0300)]
Fix 'execvp argument incompatible pointer type' compiler warning (tools)

* tools/if_mach.c (main): Cast the 2nd argument of execvp to void* (to
avoid compiler warning as the argument of execvp() prototype could be
of "const char* const*" or "char**" type).
* tools/if_not_there.c (main): Likewise.

7 years agoFix (adjust) GC_scratch_alloc actual argument type
Ivan Maidanski [Tue, 20 Dec 2016 07:21:07 +0000 (10:21 +0300)]
Fix (adjust) GC_scratch_alloc actual argument type

* dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX]
(GC_register_dynamic_libraries): Do not cast GC_scratch_alloc argument
to word type (it should be of size_t).
* headers.c (alloc_hdr, GC_init_headers, get_index): Likewise.
* os_dep.c [PROC_VDB] (GC_proc_buf_size): Change type from word to size_t.
* os_dep.c [PROC_VDB] (GC_read_dirty): Change type of new_size local
variable (which is passed to GC_scratch_alloc) from word to size_t.

7 years agoFix 'context local variable might be clobbered by setjmp' compiler warning
Ivan Maidanski [Mon, 5 Dec 2016 23:21:33 +0000 (02:21 +0300)]
Fix 'context local variable might be clobbered by setjmp' compiler warning

* mach_dep.c (GC_with_callee_saves_pushed): Mark "context" local
variable as volatile (to prevent it from potential clobbering).

7 years agoFix gc_allocator.h file name in new_gc_alloc.h comment
Ivan Maidanski [Wed, 11 Jan 2017 21:26:25 +0000 (00:26 +0300)]
Fix gc_allocator.h file name in new_gc_alloc.h comment

* include/new_gc_alloc.h: Rename gc_alloc.h to gc_allocator.h in comment;
refine the comment about the STL alloc header.

7 years agoFix gc_backptr.h, gc_mark.h, GC_DS_TAGS names in documentation
Ivan Maidanski [Wed, 11 Jan 2017 08:26:11 +0000 (11:26 +0300)]
Fix gc_backptr.h, gc_mark.h, GC_DS_TAGS names in documentation

* doc/debugging.html: Rename backptr.h to gc_backptr.h.
* include/gc_mark.h (GC_DS_PER_OBJECT): Rename DS_TAGS to GC_DS_TAGS in
the comment.
* include/private/gc_priv.h (hblkhdr.hb_descr): Rename mark.h to
gc_mark.h in the comment.

7 years agoPut invariant name in quotes to make mark_state comments clearer
Ivan Maidanski [Mon, 12 Dec 2016 22:02:29 +0000 (01:02 +0300)]
Put invariant name in quotes to make mark_state comments clearer

* include/private/gc_pmark.h (mark_state_t, MS_NONE, MS_PUSH_RESCUERS,
MS_PUSH_UNCOLLECTABLE, MS_ROOTS_PUSHED, MS_PARTIALLY_INVALID,
MS_INVALID): Replace I with "I" in comment.

7 years agoFix GCJ support in CMake build script
Ivan Maidanski [Wed, 25 Jan 2017 20:52:53 +0000 (23:52 +0300)]
Fix GCJ support in CMake build script

* CMakeLists.txt [enable_gcj_support] (SRC): Add gcj_mlc.c.
* CMakeLists.txt [enable_gcj_support] (ADD_DEFINITIONS):
Add -DGC_ENABLE_SUSPEND_THREAD only if enable_threads.

7 years agoFix lack of 2 trailing zeros in _MSC_VER numbers
Ivan Maidanski [Mon, 16 Jan 2017 21:14:44 +0000 (00:14 +0300)]
Fix lack of 2 trailing zeros in _MSC_VER numbers

_MSC_VER value consists of 4 digits (as of VS 2015).

* include/gc_config_macros.h [!GC_ATTR_MALLOC && !__GNUC__ && _MSC_VER]
(GC_ATTR_MALLOC): Replace _MSC_VER>=14 with _MSC_VER>=1400.
* include/private/gc_priv.h [!__GNUC__ && _MSC_VER] (GC_ATTR_NOINLINE):
Likewise.
* include/gc_config_macros.h [!GC_BUILD && !__GNUC__ && _MSC_VER]
(GC_ATTR_DEPRECATED): Replace _MSC_VER>=12 with _MSC_VER>=1200.

7 years agoFix GC_noop6 definition to avoid its calls to be optimized away
Ivan Maidanski [Mon, 12 Dec 2016 23:34:28 +0000 (02:34 +0300)]
Fix GC_noop6 definition to avoid its calls to be optimized away
(fix commits e3ec4a51586a21)

* include/private/gc_priv.h (GC_ATTR_NOINLINE): New macro (effective
for GCC/Clang and MS VC currently).
* mark.c (GC_noop6): Use GC_ATTR_NOINLINE attribute; call
AO_compiler_barrier if PARALLEL_MARK (or GC_PTHREADS and not
GC_WIN32_THREADS), otherwise call GC_noop1(0); add
comment.

7 years agowindows-untested: Fix paths to gc_version.h
Ivan Maidanski [Wed, 11 Jan 2017 21:19:24 +0000 (00:19 +0300)]
windows-untested: Fix paths to gc_version.h

* windows-untested/gc.ver: Include gc_version.h instead of ../version.h.
* windows-untested/vc60/gc.dsp (SOURCE): Replace version.h with
include\gc_version.h.
* windows-untested/vc60/libgc.dsp (SOURCE): Likewise.
* windows-untested/vc60/libgcmt.dsp (SOURCE): Likewise.
* windows-untested/vc70/gc.vcproj (Filter.File): Likewise.
* windows-untested/vc70/libgc.vcproj (Filter.File): Likewise.
* windows-untested/vc70/libgcmt.vcproj (Filter.File): Likewise.
* windows-untested/vc71/gc.vcproj (Filter.File): Likewise.
* windows-untested/vc71/libgc.vcproj (Filter.File): Likewise.
* windows-untested/vc71/libgcmt.vcproj (Filter.File): Likewise.

7 years agoFix Makefile.direct recursive invocation
Ivan Maidanski [Mon, 9 Jan 2017 07:29:29 +0000 (10:29 +0300)]
Fix Makefile.direct recursive invocation

* Makefile.direct (bsd-libgc.a): Add "-f Makefile.direct" option.

7 years agoFix bm_huge initialization for 64-bit targets (gctest)
Ivan Maidanski [Thu, 22 Dec 2016 21:39:10 +0000 (00:39 +0300)]
Fix bm_huge initialization for 64-bit targets (gctest)

* tests/test.c (bm_huge): Make array size depend on word size
(5 elements for 64-bit targets); initialize elements (except the last
one) to -1 instead of 0xffffffff (so that all bits are ones even on
a 64-bit target); initialize last element to ((word)-1)>>8 instead of
0x00ffffff value.
* tests/test.c (typed_test): Fail if bm_huge descriptor contains wrong
bit values at certain positions (as it had before this fix).

7 years agoFix storage class of local variable in register_dynamic_libraries (Irix)
Ivan Maidanski [Mon, 19 Dec 2016 21:54:32 +0000 (00:54 +0300)]
Fix storage class of local variable in register_dynamic_libraries (Irix)

* dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX]
(GC_register_dynamic_libraries): Remove "static" for needed_sz local
variable (and initialize it to zero).

7 years agoDisable implicit multi-threaded mode for Win32 to avoid LOCK crash
Ivan Maidanski [Sat, 17 Dec 2016 15:15:02 +0000 (18:15 +0300)]
Disable implicit multi-threaded mode for Win32 to avoid LOCK crash
(fix commit d5c6531)

* include/private/gc_locks.h [GC_ALWAYS_MULTITHREADED] (GC_need_to_lock):
Do not define to TRUE unless USE_PTHREAD_LOCKS or USE_SPIN_LOCK; issue
#error otherwise (excluding CPPCHECK case) as PCR and Windows-based
lock implementation requires it to be initialized first.
* include/private/gc_locks.h [UNCOND_LOCK && !LOCK && LINT2] (LOCK,
UNLOCK): Define (to UNCOND_[UN]LOCK) only if USE_PTHREAD_LOCKS.

7 years agoFix compilation for winpthreads if HANDLE_FORK
Ivan Maidanski [Sat, 17 Dec 2016 07:11:37 +0000 (10:11 +0300)]
Fix compilation for winpthreads if HANDLE_FORK

* tests/test.c [GC_PTHREADS && !GC_WIN32_PTHREADS]
(NO_TEST_HANDLE_FORK): Define.
* win32_threads.c [CAN_HANDLE_FORK] (available_markers_m1): Define (as
static variable) even if !GC_PTHREADS_PARAMARK.

7 years agoFix GC_mark_stack_top assertion violation properly in mark_local
Ivan Maidanski [Sat, 10 Dec 2016 07:37:04 +0000 (10:37 +0300)]
Fix GC_mark_stack_top assertion violation properly in mark_local
(fix commit a563b883)

* mark.c (GC_mark_local): Remove assertion checking that
global_first_nonempty is not greater than GC_mark_stack_top+1 (because
global_first_nonempty could be bigger slightly more at some moments due
to concurrency between the markers); replace n_on_stack==0 with
my_top<my_first_nonempty (the latter is equivalent to
(signed_word)n_on_stack<=0).

7 years agoFix assertion in GC_steal_mark_stack for non-heap regions
Ivan Maidanski [Sat, 10 Dec 2016 07:14:39 +0000 (10:14 +0300)]
Fix assertion in GC_steal_mark_stack for non-heap regions
(similar to commit da2fcda)

* mark.c (GC_steal_mark_stack): Replace top->mse_descr.w with descr
in assertion; relax assertion condition for descr (length-containing
mse_descr.w could be larger than the current GC heap size if
mse_start points to a region in a stack or a program data root;
e.g. it could happen if MemorySanitizer is used).

7 years agoFix gc_cleanup destructor for non-heap objects (gc_cpp)
Ivan Maidanski [Fri, 9 Dec 2016 23:19:32 +0000 (02:19 +0300)]
Fix gc_cleanup destructor for non-heap objects (gc_cpp)

* include/gc_cpp.h (gc_cleanup::~gc_cleanup): If GC_base(this) returns
null (could be if the object is not allocated dynamically) then do not
call GC_register_finalizer_ignore_self.

7 years agoFix '~' operator application to unsigned values shorter than word
Ivan Maidanski [Wed, 7 Dec 2016 08:32:30 +0000 (11:32 +0300)]
Fix '~' operator application to unsigned values shorter than word

Without the fix, unsigned result of "~" operator is zero-extended
to a wide type (word) thus the result has leading zeros (which is
not expected to be).

* dyn_load.c [HAVE_DL_ITERATE_PHDR] (GC_register_dynlib_callback):
Cast (sizeof(word)-1) to word before "~" operation.
* mark.c (GC_mark_from): Likewise.
* mark_rts.c (GC_add_roots_inner, GC_exclude_static_roots): Likewise.
* mark_rts.c [!MSWIN32 && !MSWINCE && !CYGWIN32]
(GC_remove_roots_inner): Likewise.
* os_dep.c [SVR4 || AUX || DGUX || LINUX && SPARC]
(GC_SysVGetDataStart): Likewise.
* os_dep.c [!MSWIN32 && DATASTART_USES_BSDGETDATASTART]
(GC_FreeBSDGetDataStart): Likewise.
* dyn_load.c [(MSWIN32 || MSWINCE || CYGWIN32) && !GC_WIN32_THREADS]
(GC_cond_add_roots): Cast (dwAllocationGranularity-1) to word before
"~" operation.
* include/private/gc_priv.h (HBLKPTR): Cast (HBLKSIZE-1) to word
before "~" operation.
* os_dep.c [USE_WINALLOC || CYGWIN32] (GC_win32_get_mem): Likewise.
* mark.c (GC_mark_from): Change type of new_size local variable from
int to word.
* os_dep.c [OPENBSD] (GC_find_limit_openbsd, GC_skip_hole_openbsd):
Change type of pgsz local variable from size_t to word (to avoid
implicit unsigned value extension after "~" operation).
* os_dep.c [PROC_VDB] (GC_read_dirty): Cast (sizeof(long)-1) to word
before "~" operation.

7 years agoFix 'bogus LR' detection in FindTopOfStack (Darwin)
Ivan Maidanski [Wed, 7 Dec 2016 08:02:59 +0000 (11:02 +0300)]
Fix 'bogus LR' detection in FindTopOfStack (Darwin)
(fix commit 5742f86)

* darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK] (GC_FindTopOfStack):
Use "UL" suffix (instead of "U") for 0x3 (on the right side of the
comparison) to avoid implicit unsigned int-to-long value extension
of "~" operator result.