platform/upstream/libgc.git
4 months agopackaging: do not pass --enable-parallel-mark to configure 58/313358/2 accepted/tizen_9.0_base accepted/tizen_base accepted/tizen_base_toolchain accepted/tizen_base_x tizen_9.0_base tizen_base accepted/tizen/9.0/base/20241030.075738 accepted/tizen/base/20240701.054925 accepted/tizen/base/toolchain/20240722.045600 accepted/tizen/base/x/20240705.022206 tizen_9.0_m2_release
Dongkyun Son [Mon, 24 Jun 2024 12:54:57 +0000 (21:54 +0900)]
packaging: do not pass --enable-parallel-mark to configure

NOTE: --enable-parallel-mark option has no effect since v8.0.

Change-Id: I89be59a31954daaf4504e0b24f731ab1dbaa1915
Signed-off-by: Dongkyun Son <dongkyun.s@samsung.com>
5 months agoVersion bump to 8.2.6 sandbox/dkson95/8.2.6 accepted/tizen/base/20240624.210555 accepted/tizen/base/toolchain/20240624.230849
Dongkyun Son [Thu, 13 Jun 2024 23:50:25 +0000 (08:50 +0900)]
Version bump to 8.2.6

Signed-off-by: Dongkyun Son <dongkyun.s@samsung.com>
5 months agopackaging: Add devel-static package
Slava Barinov [Thu, 9 Apr 2020 15:39:40 +0000 (18:39 +0300)]
packaging: Add devel-static package

Change-Id: I6d096b33dc9746345d73277af734730de441e1f9
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
5 months agoRemove libatomic_ops dependency
Slava Barinov [Wed, 18 Mar 2020 14:52:15 +0000 (17:52 +0300)]
Remove libatomic_ops dependency

5 months agoVersion bump
Slava Barinov [Fri, 13 Mar 2020 13:18:15 +0000 (16:18 +0300)]
Version bump

5 months agoPackaging created
Slava Barinov [Mon, 3 Dec 2018 15:34:20 +0000 (18:34 +0300)]
Packaging created

Signed-off-by: Slava Barinov <v.barinov@samsung.com>
9 months ago[8.2.6] upstream/8.2.6
Ivan Maidanski [Sun, 4 Feb 2024 07:20:30 +0000 (10:20 +0300)]
[8.2.6]

Bump gc version to 8.2.6

* CMakeLists.txt (PACKAGE_VERSION): Bump micro version (to 8.2.6).
* README.md: Likewise.
* configure.ac (AC_INIT): Likewise.
* doc/README.cmake (HOW TO IMPORT BDWGC): Likewise.
* include/gc_version.h (GC_TMP_VERSION_MICRO): Likewise.
* CMakeLists.txt (LIBCORD_VER_INFO): Increment revision (change version
info of libcord.so to 6:1:5).
* cord/cord.am (LIBCORD_VER_INFO): Likewise.
* CMakeLists.txt (LIBGC_VER_INFO): Increment revision (change version
info of libgc.so to 6:3:5).
* Makefile.am (LIBGC_VER_INFO): Likewise.
* ChangeLog (8.2.6): Set release date.

9 months agoUpdate ChangeLog file (v8.2 changes)
Ivan Maidanski [Sun, 4 Feb 2024 07:11:04 +0000 (10:11 +0300)]
Update ChangeLog file (v8.2 changes)

9 months agoFix lf_cache update in cordxtra.c for case of no GCC built-in atomics
Ivan Maidanski [Sun, 4 Feb 2024 07:01:20 +0000 (10:01 +0300)]
Fix lf_cache update in cordxtra.c for case of no GCC built-in atomics
(fix of commit 226c1eb23)

* cord/cordxtra.c [!CORD_USE_GCC_ATOMIC] (refill_cache): Write
new_cache to state->lf_cache[line_no].

9 months agoUpdate ChangeLog file (set v8.0.12 release date)
Ivan Maidanski [Sat, 3 Feb 2024 21:34:17 +0000 (00:34 +0300)]
Update ChangeLog file (set v8.0.12 release date)

9 months agoUpdate ChangeLog file (set v7.6.20 release date)
Ivan Maidanski [Sat, 3 Feb 2024 21:12:43 +0000 (00:12 +0300)]
Update ChangeLog file (set v7.6.20 release date)

9 months agoUpdate ChangeLog file (set v7.4.26 release date)
Ivan Maidanski [Sat, 3 Feb 2024 16:15:16 +0000 (19:15 +0300)]
Update ChangeLog file (set v7.4.26 release date)

9 months agoUpdate ChangeLog file (set v7.2r release date)
Ivan Maidanski [Sat, 3 Feb 2024 15:41:45 +0000 (18:41 +0300)]
Update ChangeLog file (set v7.2r release date)

9 months agoUpdate ChangeLog file (v8.0 changes)
Ivan Maidanski [Sat, 3 Feb 2024 11:56:45 +0000 (14:56 +0300)]
Update ChangeLog file (v8.0 changes)

9 months agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Sat, 3 Feb 2024 11:45:00 +0000 (14:45 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)

9 months agoUpdate AUTHORS file (add Jeaye Wilkerson)
Ivan Maidanski [Fri, 29 Dec 2023 21:54:19 +0000 (00:54 +0300)]
Update AUTHORS file (add Jeaye Wilkerson)

9 months agoSpecify constexpr in GC allocators if C++20 or later
Jeaye Wilkerson [Thu, 28 Dec 2023 19:14:43 +0000 (11:14 -0800)]
Specify constexpr in GC allocators if C++20 or later
(a cherry-pick of commit 9702965b6 from 'master')

PR #603 (bdwgc).

This adds the `constexpr` attribute on each allocator member function,
including ctors and dtors, to enable easier use of these allocators in
compile-time execution.  A practical example of this would be a modern
C++ string class which supports constexpr construction, usage, and
destruction.  Without this change, the C++ compiler will not allow
such a class.

* include/gc_allocator.h (gc_allocator, traceable_allocator,
gc_allocator_ignore_off_page): Declare all member functions as
GC_CONSTEXPR; reformat code.
* include/gc_config_macros.h [__cplusplus && !GC_CONSTEXPR]
(GC_CONSTEXPR): Define macro.

9 months agoFix race in init_lib_bounds on Linux with glibc v2.34+ if redirect malloc
Ivan Maidanski [Mon, 25 Dec 2023 05:57:39 +0000 (08:57 +0300)]
Fix race in init_lib_bounds on Linux with glibc v2.34+ if redirect malloc
(a cherry-pick of commit ef7bebf78 from 'master')

In new glibc, pthread_create does not call the redirected calloc(),
thus GC_init_lib_bounds should be called manually before going
multi-threaded to avoid a race inside GC_init_lib_bounds.

* include/private/gc_priv.h [REDIRECT_MALLOC && GC_LINUX_THREADS
&& !REDIRECT_MALLOC_IN_HEADER] (GC_init_lib_bounds): Declare function
as GC_INNER.
* include/private/gc_priv.h [!REDIRECT_MALLOC || !GC_LINUX_THREADS
|| REDIRECT_MALLOC_IN_HEADER] (GC_init_lib_bounds): Define as macro (to
no-op).
* malloc.c [REDIRECT_MALLOC && !REDIRECT_MALLOC_IN_HEADER
&& GC_LINUX_THREADS] (lib_bounds_set): Move outside of calloc().
* malloc.c [REDIRECT_MALLOC && !REDIRECT_MALLOC_IN_HEADER
&& GC_LINUX_THREADS] (GC_init_lib_bounds): Define as GC_INNER instead
of STATIC; if lib_bounds_set is true (check it instead of
GC_libpthread_start) then just return; set lib_bounds_set to true at
the end of the function; do not call LOCK/UNLOCK() if not GC_ASSERTIONS
or not GC_ALWAYS_MULTITHREADED; do not set GC_libpthread_start to 1.
* malloc.c [REDIRECT_MALLOC && !REDIRECT_MALLOC_IN_HEADER
&& GC_LINUX_THREADS] (calloc): Do not use and set lib_bounds_set (call
GC_init_lib_bounds() unconditionally).
* pthread_support.c (GC_allow_register_threads): Call
GC_init_lib_bounds().
* pthread_support.c [GC_PTHREADS && !SN_TARGET_ORBIS
&& !SN_TARGET_PSP2] (GC_pthread_create): Likewise.

9 months agoFix assertion violation in GC_get_maps on Linux if malloc redirection
Ivan Maidanski [Mon, 25 Dec 2023 05:31:38 +0000 (08:31 +0300)]
Fix assertion violation in GC_get_maps on Linux if malloc redirection
(a cherry-pick of commit 417cbe6c1 from 'master')

* malloc.c [REDIRECT_MALLOC && !REDIRECT_MALLOC_IN_HEADER
&& GC_LINUX_THREADS] (GC_init_lib_bounds): Wrap GC_text_mapping() calls
into LOCK/UNLOCK(); add comment.

9 months agoFix skipped removal of page protection in case of address hash collision
Ivan Maidanski [Wed, 27 Dec 2023 05:19:42 +0000 (08:19 +0300)]
Fix skipped removal of page protection in case of address hash collision
(a cherry-pick of commit 573103215 from 'master')

* os_dep.c [MPROTECT_VDB] (get_pht_entry_from_index_async): Remove.
* os_dep.c [MPROTECT_VDB] (GC_remove_protection): Do not call
get_pht_entry_from_index_async(); do not check page already marked
dirty; add comment instead.

9 months agoEliminate 'unused parameter' gcc warning in free() if IGNORE_FREE
Kristian Larsson [Wed, 20 Dec 2023 22:15:33 +0000 (23:15 +0100)]
Eliminate 'unused parameter' gcc warning in free() if IGNORE_FREE
(a cherry-pick of commit c3e77d206 from 'master')

PR #598 (bdwgc).

* malloc.c [REDIRECT_FREE && !REDIRECT_MALLOC_IN_HEADER]
(free): Specify p is an unused argument.

9 months agoFix back graph and checksums support in WCC_MAKEFILE
Ivan Maidanski [Wed, 20 Dec 2023 16:42:34 +0000 (19:42 +0300)]
Fix back graph and checksums support in WCC_MAKEFILE

* WCC_MAKEFILE [ENABLE_STATIC] (OBJS): Add backgraph.obj and
checksums.obj items.

9 months agoInclude Darwin CoreFoundation.h only if 32-bit ARM
Ivan Maidanski [Tue, 12 Dec 2023 20:10:06 +0000 (23:10 +0300)]
Include Darwin CoreFoundation.h only if 32-bit ARM

Issue #594 (bdwgc).

* darwin_stop_world.c [GC_DARWIN_THREADS]: Include CoreFoundation.h
only if ARM32 and ARM_THREAD_STATE32.

11 months agoFix checksums GC_record_fault invocation on Darwin
Ivan Maidanski [Mon, 11 Dec 2023 05:11:28 +0000 (08:11 +0300)]
Fix checksums GC_record_fault invocation on Darwin

* checksums.c [MPROTECT_VDB] (GC_record_fault): Define regardless of
DARWIN.
* include/private/gc_priv.h [CHECKSUMS && MPROTECT_VDB]
(GC_record_fault): Declare regardless of DARWIN.
* os_dep.c [MPROTECT_VDB && DARWIN && CHECKSUMS]
(catch_exception_raise): Call GC_record_fault() (if GC_mprotect_state
is GC_MP_NORMAL only).

11 months agoFix null dereference in check_finalizer_nested if redirect malloc on Linux
Ivan Maidanski [Sat, 9 Dec 2023 21:09:12 +0000 (00:09 +0300)]
Fix null dereference in check_finalizer_nested if redirect malloc on Linux
(a cherry-pick of commit 0408c6e50 from 'master')

Issue #582 (bdwgc).

As noted in GC_start_routine, an allocation may happen in
GC_get_stack_base, causing GC_notify_or_invoke_finalizers to be called
before the thread gets registered.

* pthread_support.c [!GC_NO_FINALIZATION && INCLUDE_LINUX_THREAD_DESCR
&& REDIRECT_MALLOC] (GC_check_finalizer_nested): If me variable is NULL
then return NULL; add comment.

11 months agoFix thread_id variable definition placement in main of subthreadcreatetest
Ivan Maidanski [Fri, 8 Dec 2023 20:14:49 +0000 (23:14 +0300)]
Fix thread_id variable definition placement in main of subthreadcreatetest
(fix of commit a3df481b8)

* tests/subthreadcreate.c [AO_HAVE_fetch_and_add1 && NTHREADS>0
&& !GC_PTHREADS] (main): Make thread_id local variable to be defined
at the beginning of a block statement.

11 months agoFix a typo in mach_header_64 name in comment of GC_init_dyld on Darwin
Ivan Maidanski [Fri, 8 Dec 2023 16:11:23 +0000 (19:11 +0300)]
Fix a typo in mach_header_64 name in comment of GC_init_dyld on Darwin
(fix of commit 6909c54e5)

* dyn_load.c [DARWIN] (GC_init_dyld): Fix typo in comment
("mach_header_64").

11 months agoFix posix_memalign() to overwrite pointer storage only on success
Ivan Maidanski [Thu, 30 Nov 2023 16:25:52 +0000 (19:25 +0300)]
Fix posix_memalign() to overwrite pointer storage only on success
(a cherry-pick of commit 602c93ab7 from 'master')

On Linux, posix_memalign() does not modify *memptr on failure; same
should apply to GC_posix_memalign().

* mallocx.c (GC_posix_memalign): Define p local variable; specify that
the result of GC_memalign() is unlikely to be NULL; set *memptr only
when the function returns zero.

11 months agoTurn on handle fork by default on Darwin (multi-threaded only)
Ivan Maidanski [Thu, 30 Nov 2023 05:28:20 +0000 (08:28 +0300)]
Turn on handle fork by default on Darwin (multi-threaded only)
(a cherry-pick of commit ba2861e70 from 'master')

Issue #103 (bdwgc).

Remove mutual exclusion between fork handling and GC incremental mode
on Darwin in a multi-threaded configuration.

Note: the incremental mode is turned off in the child process after
fork, for now.

* CMakeLists.txt [CMAKE_USE_PTHREADS_INIT && !WIN32
&& enable_handle_fork && !disable_handle_fork] (HANDLE_FORK): Define
C macro even if APPLE; remove comment.
* configure.ac [$enable_handle_fork!=yes && $enable_handle_fork!=no
&& $enable_handle_fork!=manual && $THREADS==posix
&& $host==*-*-darwin*] (HANDLE_FORK): Define AC macro; remove comment.
* tests/test.c [DARWIN && MPROTECT_VDB && !MAKE_BACK_GRAPH
&& !TEST_HANDLE_FORK && !NO_TEST_HANDLE_FORK] (NO_TEST_HANDLE_FORK): Do
not define if THREADS.
* include/private/gc_priv.h [CAN_HANDLE_FORK && MPROTECT_VDB
&& GC_DARWIN_THREADS] (GC_dirty_update_child): Declare as function
(instead of a no-op macro).
* pthread_support.c [CAN_HANDLE_FORK && !GC_DISABLE_INCREMENTAL]
(fork_child_proc): Move GC_dirty_update_child() call upper to be right
after GC_release_dirty_lock() one.
* pthread_support.c [CAN_HANDLE_FORK && GC_DARWIN_THREADS
&& MPROTECT_VDB] (GC_atfork_prepare): Remove assertion (about
GC_handle_fork) and abort.
* os_dep.c [DARWIN && MPROTECT_VDB && CAN_HANDLE_FORK && THREADS]
(GC_dirty_update_child): Implement (unprotect the entire heap, restore
the old task exception ports and turn off the incremental mode).
* os_dep.c [DARWIN && MPROTECT_VDB && THREADS] (GC_mprotect_thread):
Reformat code.
* os_dep.c [DARWIN && MPROTECT_VDB && CAN_HANDLE_FORK] (GC_dirty_init):
Do not WARN and return FALSE if THREADS and GC_handle_fork; add
assertion that me variable is non-zero.
* os_dep.c [DARWIN && MPROTECT_VDB] (GC_forward_exception): Cast 1 to
exception_mask_t before left-shift by exception; reformat code.

11 months agoRe-enable incremental mode on OS X (arm64)
Ivan Maidanski [Wed, 29 Nov 2023 05:19:08 +0000 (08:19 +0300)]
Re-enable incremental mode on OS X (arm64)
(a cherry-pick of commit 93bf66ec4 from 'master')

Issue #295 (bdwgc).

* include/private/gcconfig.h [AARCH64 && DARWIN]: Update comment about
OS; move comment about MPROTECT_VDB to the proper place.
* include/private/gcconfig.h [AARCH64 && DARWIN && TARGET_OS_OSX]
(MPROTECT_VDB): Define.

11 months agoFix GC_set_handle_fork(1) on Darwin when MPROTECT_VDB but no threads
Ivan Maidanski [Tue, 28 Nov 2023 04:25:39 +0000 (07:25 +0300)]
Fix GC_set_handle_fork(1) on Darwin when MPROTECT_VDB but no threads
(fix of commit 38d81b9f9)

* include/private/gcconfig.h [!CAN_HANDLE_FORK && !NO_HANDLE_FORK
&& !HAVE_NO_FORK && DARWIN && MPROTECT_VDB && !GC_PTHREADS]
(CAN_HANDLE_FORK): Define macro; reformat code.

11 months agoFix indent of a closing curly brace in GC_forward_exception
Ivan Maidanski [Tue, 28 Nov 2023 03:53:43 +0000 (06:53 +0300)]
Fix indent of a closing curly brace in GC_forward_exception
(fix of commit bb22ea92d)

* os_dep.c [MPROTECT_VDB && DARWIN] (GC_forward_exception): Adjust
indentation of '}' for a block statement.

11 months agoUpdate AUTHORS file (add Robert Hensing)
Ivan Maidanski [Fri, 24 Nov 2023 05:46:16 +0000 (08:46 +0300)]
Update AUTHORS file (add Robert Hensing)

11 months agoMake gc_allocator<void> members public
Robert Hensing [Tue, 21 Nov 2023 18:56:13 +0000 (19:56 +0100)]
Make gc_allocator<void> members public
(a cherry-pick of commit 86b3bf0c9 from 'master')

PR #586 (bdwgc).

A private value_type is a problem for boost small_vector<X>, which
instantiates rebind<void> at some point.  E.g., instantiating
small_vector<int, 8, traceable_allocator<int>> results in
"'value_type' is a private member of 'traceable_allocator<void>'"
compiler error.

I don't see a reason why any of the members should be private, and
arguably it violates the Liskov substitution principle.  It seems that
these were left private by an accidental omission.

* include/gc_allocator.h (gc_allocator<void>,
gc_allocator_ignore_off_page<void>, traceable_allocator<void>): Declare
all members of the class as public.

11 months agoUpdate ChangeLog file (v8.2 changes)
Ivan Maidanski [Fri, 17 Nov 2023 16:51:18 +0000 (19:51 +0300)]
Update ChangeLog file (v8.2 changes)

11 months agoUpdate ChangeLog file (v8.0 changes)
Ivan Maidanski [Fri, 17 Nov 2023 16:01:46 +0000 (19:01 +0300)]
Update ChangeLog file (v8.0 changes)

11 months agoUpdate ChangeLog file (v7.6 changes)
Ivan Maidanski [Fri, 17 Nov 2023 15:36:58 +0000 (18:36 +0300)]
Update ChangeLog file (v7.6 changes)

11 months agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Fri, 17 Nov 2023 05:16:28 +0000 (08:16 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)
(a cherry-pick of commits 1a436be9881ef2b8e8 from 'release-8_0')

11 months agoTravis CI: Speedup cppcheck job by dividing *.c files set into 2 sets
Ivan Maidanski [Fri, 29 Sep 2023 19:25:02 +0000 (22:25 +0300)]
Travis CI: Speedup cppcheck job by dividing *.c files set into 2 sets
(a cherry-pick of commit e3338f439 from 'master')

11 months agoGH Actions: Build and test using cmake
Ivan Maidanski [Thu, 16 Nov 2023 04:57:37 +0000 (07:57 +0300)]
GH Actions: Build and test using cmake

11 months agoEliminate 'unused parameter' compiler warnings reported by MS clang
Ivan Maidanski [Thu, 16 Nov 2023 04:13:03 +0000 (07:13 +0300)]
Eliminate 'unused parameter' compiler warnings reported by MS clang

* cord/cordxtra.c [__clang__] (CORD_ATTR_UNUSED): Define to
attribute(unused).
* include/private/gc_priv.h [!GC_ATTR_UNUSED && __clang__]
(GC_ATTR_UNUSED): Likewise.

11 months agoSupport non-msys MinGW build by CMake
Ivan Maidanski [Sun, 12 Nov 2023 09:07:40 +0000 (12:07 +0300)]
Support non-msys MinGW build by CMake
(a cherry-pick of commit 0513f6115 from 'master')

* CMakeLists.txt [!BORLAND && MSVC] (_CRT_SECURE_NO_DEPRECATE): Do not
add C macro definition.
* CMakeLists.txt [WIN32] (_CRT_SECURE_NO_DEPRECATE): Add C macro
definition; update comment.
* CMakeLists.txt [CMAKE_USE_PTHREADS_INIT]: Check WIN32 variable
instead of MSYS.

11 months agoFix deprecation warning about support of CMake older than v3.5
Ivan Maidanski [Mon, 11 Sep 2023 21:37:22 +0000 (00:37 +0300)]
Fix deprecation warning about support of CMake older than v3.5

Update cmake minimum required version to 3.5.

* CMakeLists.txt (VERSION): Change cmake_minimum_required from 3.1
to 3.5.

11 months agoDo not compile pthread_start.c on Cygwin even if build shared libs (CMake)
Ivan Maidanski [Mon, 29 Nov 2021 19:49:43 +0000 (22:49 +0300)]
Do not compile pthread_start.c on Cygwin even if build shared libs (CMake)

* CMakeLists.txt [(enable_single_obj_compilation || BUILD_SHARED_LIBS)
&& CMAKE_USE_PTHREADS_INIT] (GC_PTHREAD_START_STANDALONE): Do not
define C macro if CYGWIN or MSYS.
* CMakeLists.txt [(enable_single_obj_compilation || BUILD_SHARED_LIBS)
&& CMAKE_USE_PTHREADS_INIT] (SRC): Do not add pthread_start.c if
CYGWIN or MSYS.

11 months agoTravis CI: Use Ubuntu Jammy instead of Bionic
Ivan Maidanski [Thu, 16 Nov 2023 04:17:46 +0000 (07:17 +0300)]
Travis CI: Use Ubuntu Jammy instead of Bionic

11 months agoFix lock assertion violation in GC_try_to_collect_inner on OS X
Ivan Maidanski [Tue, 14 Nov 2023 17:08:29 +0000 (20:08 +0300)]
Fix lock assertion violation in GC_try_to_collect_inner on OS X
(fix of commit b7b1004a2)

Issue #583 (bdwgc).

This happens only in the multi-threaded collector with assertions on
and malloc redirection if GC_enable_incremental() is called.

* include/private/gc_priv.h [MPROTECT_VDB && DARWIN]: Include pthread.h
(wrapped into EXTERN_C_END/BEGIN).
* include/private/gc_priv.h [MPROTECT_VDB && DARWIN && THREADS]
(GC_inner_pthread_create): Declare (as GC_INNER function).
* include/private/gc_priv.h [MPROTECT_VDB && DARWIN && !THREADS]
(GC_inner_pthread_create): Define as macro (redirecting to
pthread_create).
* os_dep.c [MPROTECT_VDB && DARWIN]: Do not include pthread.h.
* os_dep.c [MPROTECT_VDB && DARWIN] (pthread_create): Do not undefine.
* os_dep.c [MPROTECT_VDB && DARWIN] (GC_dirty_init): Call
GC_inner_pthread_create() instead of pthread_create().
* pthread_support.c [MPROTECT_VDB && DARWIN] (GC_inner_pthread_create):
Define function (call INIT_REAL_SYMS() and REAL_FUNC(pthread_create)).

11 months agoFix handling of GC_gc_no counter wrap in GC_notify_or_invoke_finalizers
Ivan Maidanski [Wed, 4 Oct 2023 20:40:42 +0000 (23:40 +0300)]
Fix handling of GC_gc_no counter wrap in GC_notify_or_invoke_finalizers
(a cherry-pick of commits 6594e9a7bfa19ed0f2 from 'master')

* finalize.c [KEEP_BACK_PTRS] (GC_notify_or_invoke_finalizers):
Compare GC_gc_no and last_back_trace_gc_no values using inequality
operator (instead of greater-than); define bt_in_progress static
variable; if bt_in_progress then do not do print any backtraces, else
set bt_in_progress (instead of setting last_back_trace_gc_no to
GC_WORD_MAX) while printing the backtraces; remove comment about
wrap of GC_gc_no counter.

11 months agoHandle GC_gc_no counter overflow properly in GC_print_trace
Ivan Maidanski [Wed, 4 Oct 2023 06:43:59 +0000 (09:43 +0300)]
Handle GC_gc_no counter overflow properly in GC_print_trace
(a cherry-pick of commit 42d769885 from 'master')

* mark.c (GC_print_trace_inner, GC_print_trace): Change type of
argument from word to GC_word.
* mark.c (GC_print_trace_inner): Change p->gc_no<gc_no to
(p->gc_no-gc_no)&SIGNB to take into account potential overflow of the
compared entities.

11 months agoFix handling of GC_gc_no counter wrap in GC_clear_stack
Ivan Maidanski [Wed, 4 Oct 2023 06:33:16 +0000 (09:33 +0300)]
Fix handling of GC_gc_no counter wrap in GC_clear_stack

* misc.c [!THREADS] (GC_clear_stack): Compare GC_gc_no and
GC_stack_last_cleared using inequality operator (instead of
greater-than); compare GC_high_water to 0 (instead of comparing
GC_stack_last_cleared to 0); use EXPECT to compare GC_high_water.

11 months agoFix 'sigset_t undeclared' MS VC error if pthreads-w32 is used
Ivan Maidanski [Mon, 13 Nov 2023 05:48:00 +0000 (08:48 +0300)]
Fix 'sigset_t undeclared' MS VC error if pthreads-w32 is used
(a cherry-pick of commit 5569289a4 from 'master')

* win32_threads.c [PARALLEL_MARK && GC_PTHREADS
&& !GC_PTHREADS_PARAMARK && !__MINGW32__] (GC_PTHREADS_PARAMARK): Move
definition to gcconfig.h (to be before NO_MARKER_SPECIAL_SIGMASK one);
refine comments.
* include/private/gcconfig.h [!NO_MARKER_SPECIAL_SIGMASK
&& GC_PTHREADS_PARAMARK && GC_WIN32_THREADS]
(NO_MARKER_SPECIAL_SIGMASK): Define.

11 months agoWorkaround 'malloc inconsistent dll linkage' MSVC error in CMake script
Ivan Maidanski [Sun, 12 Nov 2023 09:52:08 +0000 (12:52 +0300)]
Workaround 'malloc inconsistent dll linkage' MSVC error in CMake script

Use source-level redirection of malloc/realloc/free() for Windows
builds.

* CMakeLists.txt [enable_redirect_malloc && WIN32]
(REDIRECT_MALLOC_IN_HEADER): Add C macro definition.
* CMakeLists.txt [enable_redirect_malloc && WIN32]
(GC_USE_DLOPEN_WRAP): Do not define C macro.

11 months agoWorkaround MS Clang failure to compile de_win.rc
Ivan Maidanski [Sun, 12 Nov 2023 09:42:12 +0000 (12:42 +0300)]
Workaround MS Clang failure to compile de_win.rc
(a cherry-pick of commit 98705c8fa from 'master')

* CMakeLists.txt [build_cord && WIN32 && CMAKE_C_COMPILER_ID!=Clang]
(DE_WIN_RC): New variable (set to "cord/tests/de_win.rc"); add comment.
* CMakeLists.txt [build_cord && WIN32] (de): Use DE_WIN_RC variable.

11 months agoFix 'implicit declaration of function pthread_atfork' gcc error on MinGW
Ivan Maidanski [Sun, 12 Nov 2023 07:54:51 +0000 (10:54 +0300)]
Fix 'implicit declaration of function pthread_atfork' gcc error on MinGW

* include/private/gcconfig.h [!CAN_HANDLE_FORK && !NO_HANDLE_FORK
&& !HAVE_NO_FORK && (DARWIN && MPROTECT_VDB || HANDLE_FORK)]
(CAN_HANDLE_FORK): Define only if GC_PTHREADS.

11 months agoFix undefined GC_real_pthread_sigmask if redirect malloc on OS X
Ivan Maidanski [Thu, 9 Nov 2023 19:33:30 +0000 (22:33 +0300)]
Fix undefined GC_real_pthread_sigmask if redirect malloc on OS X
(fix of commit 612a86972)

* include/private/gcconfig.h [!NO_MARKER_SPECIAL_SIGMASK
&& GC_NO_PTHREAD_SIGMASK] (NO_MARKER_SPECIAL_SIGMASK): Define.

11 months agoFix 'unused GC_set_and_save_fault_handler' warning on OS X
Ivan Maidanski [Thu, 9 Nov 2023 04:49:05 +0000 (07:49 +0300)]
Fix 'unused GC_set_and_save_fault_handler' warning on OS X
(a cherry-pick of commit 38f135a66 from 'master')

* include/private/gc_priv.h [UNIX_LIKE]
(GC_set_and_save_fault_handler): Do not declare if NO_DEBUGGING.
* os_dep.c [!NEED_FIND_LIMIT && !(WRAP_MARK_SOME && __GNUC__)
&& UNIX_LIKE] (GC_fault_handler_t, GC_set_and_save_fault_handler): Do
not define if NO_DEBUGGING.
* os_dep.c [USE_PROC_FOR_LIBRARIES && THREADS] (GC_fault_handler_t,
GC_set_and_save_fault_handler): Define.

11 months agoEliminate GCC warning of unsafe __builtin_return_address(1) (Cmake script)
Ivan Maidanski [Sat, 14 Oct 2023 06:39:32 +0000 (09:39 +0300)]
Eliminate GCC warning of unsafe __builtin_return_address(1) (Cmake script)

Pass -Wno-frame-address option to compiler if supported.

* CMakeLists.txt [!BORLAND & !MSVC && !WATCOM]
(HAVE_FLAG_WNO_FRAME_ADDRESS): Set if -Wno-frame-address flag is
accepted by compiler.
* CMakeLists.txt [!BORLAND & !MSVC && !WATCOM
&& HAVE_FLAG_WNO_FRAME_ADDRESS]: Add -Wno-frame-address to compile
options.

11 months agoFix a typo in name GC_gc_no in comment of GC_stack_last_cleared
Ivan Maidanski [Tue, 3 Oct 2023 20:21:11 +0000 (23:21 +0300)]
Fix a typo in name GC_gc_no in comment of GC_stack_last_cleared

* misc.c (GC_stack_last_cleared): Fix mistyped name ("GC_gc_no") in
comment.

11 months agoFix update of last_back_trace_gc_no if KEEP_BACK_PTRS is not defined
Ivan Maidanski [Tue, 3 Oct 2023 20:11:40 +0000 (23:11 +0300)]
Fix update of last_back_trace_gc_no if KEEP_BACK_PTRS is not defined
(fix of commit ffa0c9ea3)

* finalize.c [MAKE_BACK_GRAPH] (GC_notify_or_invoke_finalizers): Set
last_back_trace_gc_no to GC_gc_no regardless of KEEP_BACK_PTRS.

11 months agoFix a misleading comment about lock holder in gc_locks.h
Ivan Maidanski [Tue, 3 Oct 2023 04:49:00 +0000 (07:49 +0300)]
Fix a misleading comment about lock holder in gc_locks.h
(a cherry-pick of commit 50fb23398 from 'master')

* include/private/gc_locks.h [GC_PTHREADS && GC_ASSERTIONS]
(SET_LOCK_HOLDER): Move and update comment about the allocator lock
holder.

11 months agoFix 'l-value specifies const object' MSVC error in GC_push_many_regs
Ivan Maidanski [Fri, 29 Sep 2023 19:08:23 +0000 (22:08 +0300)]
Fix 'l-value specifies const object' MSVC error in GC_push_many_regs
(a cherry-pick of commit a25827f5b from 'master')

* include/private/gc_pmark.h [NEED_FIXUP_POINTER] (GC_PUSH_ONE_STACK):
Update comment; define pp local variable; use pp (instead of p) for
FIXUP_POINTER() and follow-up statements (so that not to alter value
of p).

11 months agoFix placement of comment about allocator lock in darwin_stop_world.c
Ivan Maidanski [Fri, 29 Sep 2023 05:01:28 +0000 (08:01 +0300)]
Fix placement of comment about allocator lock in darwin_stop_world.c
(fix of commit cd96e6d94)

* darwin_stop_world.c (GC_stop_world): Move comment about
"acquire and release the GC lock" out of PARALLEL_MARK block.

11 months agoFix a typo in comment of GC_init_dyld
Ivan Maidanski [Fri, 29 Sep 2023 04:39:19 +0000 (07:39 +0300)]
Fix a typo in comment of GC_init_dyld

* dyn_load.c [DARWIN] (GC_init_dyld): Fix typo ("is created") in
comment.

11 months agoFix 'info' buffer potential overrun in GC_save_callers
Ivan Maidanski [Thu, 21 Sep 2023 05:17:09 +0000 (08:17 +0300)]
Fix 'info' buffer potential overrun in GC_save_callers

The overrun could happen if backtrace() returns zero.

* os_dep.c [NEED_CALLINFO && SAVE_CALL_CHAIN] (IGNORE_FRAMES): Do not
define.
* os_dep.c [NEED_CALLINFO && SAVE_CALL_CHAIN] (GC_save_callers): Move
comment about retrieving pc values down to be near backtrace(); replace
IGNORE_FRAMES to 1; set i to 0 if npcs is zero.

11 months agoFix closing bracket placement for case statement in configure
Ivan Maidanski [Wed, 20 Sep 2023 05:37:08 +0000 (08:37 +0300)]
Fix closing bracket placement for case statement in configure

* configure.ac [$enable_gc_debug==yes]: Place "]" after "fi" instead
of "esac".

11 months agoFix typo regarding mark lock in comment of gc_pmark.h
Ivan Maidanski [Tue, 19 Sep 2023 04:55:21 +0000 (07:55 +0300)]
Fix typo regarding mark lock in comment of gc_pmark.h

* include/private/gc_pmark.h [PARALLEL_MARK]: Change "mark_lock" to
"mark lock" in comment.

11 months agoFix extra 'extern C' for include signal.h in gcconfig.h
Ivan Maidanski [Fri, 15 Sep 2023 20:50:05 +0000 (23:50 +0300)]
Fix extra 'extern C' for include signal.h in gcconfig.h
(fix of commit 65992c147)

* include/private/gcconfig.h [MPROTECT_VDB && !MSWIN32 && !MSWINCE]:
Wrap include signal.h into EXTERN_C_END/BEGIN.

11 months agoEnsure _GNU_SOURCE is defined if HAVE_DLADDR is defined by configure
Ivan Maidanski [Thu, 14 Sep 2023 04:06:41 +0000 (07:06 +0300)]
Ensure _GNU_SOURCE is defined if HAVE_DLADDR is defined by configure
(fix of commit 5dedb24e8)

* include/private/gc_priv.h [HAVE_DLADDR && !_GNU_SOURCE]
(_GNU_SOURCE): Define.

11 months agoFix missing GC_pthread_sigmask on NetBSD
Ivan Maidanski [Mon, 11 Sep 2023 17:12:50 +0000 (20:12 +0300)]
Fix missing GC_pthread_sigmask on NetBSD
(a cherry-pick of commit 1d9826992a from 'master')

Issue #571 (bdwgc).

* include/gc_pthread_redirects.h [!GC_NO_PTHREAD_SIGMASK
&& _NETBSD_SOURCE] (GC_pthread_sigmask): Declare.
* include/gc_pthread_redirects.h [!GC_NO_PTHREAD_SIGMASK
&& !(GC_PTHREAD_SIGMASK_NEEDED || _BSD_SOURCE || _GNU_SOURCE
|| _POSIX_C_SOURCE>=199506L || _XOPEN_SOURCE>=500
|| __POSIX_VISIBLE>=199506)] (GC_NO_PTHREAD_SIGMASK): Do not define
if _NETBSD_SOURCE.

11 months ago.gitignore: Ignore *.a, *.dylib, lib*.so files in any folder
Paul Bone [Mon, 16 Jun 2014 06:09:12 +0000 (16:09 +1000)]
.gitignore: Ignore *.a, *.dylib, lib*.so files in any folder

14 months agoUpdate ChangeLog file (v8.2 changes)
Ivan Maidanski [Sat, 9 Sep 2023 13:05:50 +0000 (16:05 +0300)]
Update ChangeLog file (v8.2 changes)

14 months agoUpdate ChangeLog file (v8.0 changes)
Ivan Maidanski [Sat, 9 Sep 2023 12:48:16 +0000 (15:48 +0300)]
Update ChangeLog file (v8.0 changes)
(a cherry-pick of commit 0039956d3 from 'release-8_0')

14 months agoUpdate ChangeLog file (v7.6 changes)
Ivan Maidanski [Sat, 9 Sep 2023 12:27:03 +0000 (15:27 +0300)]
Update ChangeLog file (v7.6 changes)
(a cherry-pick of commit cbc0d5455 from 'release-7_6')

14 months agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Sat, 9 Sep 2023 12:15:05 +0000 (15:15 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)
(a cherry-pick of commit 1d2f56cfe from 'release-7_4')

14 months agoWorkaround mark stack overflow in GC_push_finalizer_structures on MinGW
Ivan Maidanski [Wed, 6 Sep 2023 18:53:53 +0000 (21:53 +0300)]
Workaround mark stack overflow in GC_push_finalizer_structures on MinGW
(a cherry-pick of commit 99dbd7ee2 from 'master')

Issue #572 (bdwgc).

When pushing static roots, for the global symbols with the size of
one or several words, process them eagerly instead of pushing onto
the mark stack.

* include/private/gc_priv.h (GC_PUSH_ALL_SYM): Call GC_push_all_eager()
instead of GC_push_all(); add comment; remove casts to void*.
* pthread_support.c (GC_push_thread_structures): Call GC_push_all()
instead of GC_PUSH_ALL_SYM().
* win32_threads.c (GC_push_thread_structures): Likewise.
* pthread_support.c (GC_push_thread_structures): Cast &GC_threads (the
first argument of GC_push_all) to void*.

14 months agoFix missing redirect and implementation of pthread_sigmask() on OpenBSD
Ivan Maidanski [Mon, 4 Sep 2023 18:17:35 +0000 (21:17 +0300)]
Fix missing redirect and implementation of pthread_sigmask() on OpenBSD
(a cherry-pick of commit 6f8349aba from 'master')

Previously user-level threads had been always used (regardless of
GC_OPENBSD_UTHREADS macro) not needing GC_pthread_sigmask().

* include/gc_config_macros.h [!(GC_DARWIN_THREADS
|| GC_WIN32_PTHREADS || __native_client__) && !GC_NO_PTHREAD_SIGMASK]
(GC_NO_PTHREAD_SIGMASK): Do not depend on GC_OPENBSD_THREADS.

14 months agoFix missing GC_pthread_sigmask on Free/NetBSD
Ivan Maidanski [Mon, 4 Sep 2023 05:41:31 +0000 (08:41 +0300)]
Fix missing GC_pthread_sigmask on Free/NetBSD
(a cherry-pick of commit 3ed9b96eb from 'master')

Issue #571 (bdwgc).

* include/gc_pthread_redirects.h [!GC_NO_PTHREAD_SIGMASK
&& __POSIX_VISIBLE>=199506] (GC_pthread_sigmask): Declare.
* include/gc_pthread_redirects.h [!GC_NO_PTHREAD_SIGMASK
&& !(GC_PTHREAD_SIGMASK_NEEDED || _BSD_SOURCE || _GNU_SOURCE
|| _POSIX_C_SOURCE>=199506L || _XOPEN_SOURCE>=500)]
(GC_NO_PTHREAD_SIGMASK): Do not define if __POSIX_VISIBLE>=199506.

14 months agoUpdate AUTHORS file (add Marius Gerbershagen)
Ivan Maidanski [Tue, 29 Aug 2023 04:50:29 +0000 (07:50 +0300)]
Update AUTHORS file (add Marius Gerbershagen)
(a cherry-pick of commit 07a6d0ee8 from 'master')

14 months agoFix GC_push_stack_for() to push also Xmm registers on Windows/x64
Marius Gerbershagen [Sat, 26 Aug 2023 16:26:17 +0000 (18:26 +0200)]
Fix GC_push_stack_for() to push also Xmm registers on Windows/x64
(a cherry-pick of commit c245cf60f from 'master')

PR #566 (bdwgc).

Some registers that can contain pointers given the right compiler
optimization settings are not scanned during the marking phase,
as observed when the client code is compiled with gcc 13.2.0 passing
-march=native option.

* win32_threads.c [X86_64
&& !XMM_CANT_STORE_PTRS] (PUSHED_REGS_COUNT): Change from 15 to 47; add
comment.
* win32_threads.c [!WOW64_THREAD_CONTEXT_WORKAROUND && !I386
&& !XMM_CANT_STORE_PTRS] (GET_THREAD_CONTEXT_FLAGS): Add
CONTEXT_FLOATING_POINT.
* win32_threads.c (PUSH8_LH): Define macro.
* win32_threads.c [X86_64 && !XMM_CANT_STORE_PTRS] (copy_ptr_regs): Use
PUSH8_LH() to store Xmm registers.

14 months agoFix 'missing binary operator before token' gc error in gcconfig.h
Ivan Maidanski [Mon, 28 Aug 2023 06:37:31 +0000 (09:37 +0300)]
Fix 'missing binary operator before token' gc error in gcconfig.h
(a cherry-pick of commit 5507e18a5 from 'master')

The error occurs only if gcconfig.h is included before include gc.h
(as, e.g., done in init_global_static_roots.cpp).

* include/private/gcconfig.h [!GC_H && HAVE_CONFIG_H]: Include
config.h.
* include/private/gcconfig.h [!GC_H]: Include gc.h.

14 months agoEliminate 'unused value' gcc warnings in init_global_static_roots (Symbian)
Ivan Maidanski [Mon, 28 Aug 2023 05:58:43 +0000 (08:58 +0300)]
Eliminate 'unused value' gcc warnings in init_global_static_roots (Symbian)

* extra/symbian/init_global_static_roots.cpp
(GC_init_global_static_roots): Do not initialize dataStart and dataEnd
to NULL.

14 months agoFix 'implicit declaration of function sbrk' gcc error on Symbian
Ivan Maidanski [Mon, 28 Aug 2023 05:40:29 +0000 (08:40 +0300)]
Fix 'implicit declaration of function sbrk' gcc error on Symbian

Defining USE_MMAP macro is mandatory when compiling for Symbian
because sbrk() is not provided there.

* include/private/gcconfig.h [SYMBIAN && !USE_MMAP] (USE_MMAP): Define.

14 months agoFix MACH_TYPE macro redefinition on Symbian/arm
Ivan Maidanski [Tue, 8 Aug 2023 05:26:42 +0000 (08:26 +0300)]
Fix MACH_TYPE macro redefinition on Symbian/arm
(a cherry-pick of commit d2ef89f13 from 'master')

* include/private/gcconfig.h [SYMBIAN] (mach_type_known): Define only
if ARM32.
* include/private/gcconfig.h [SYMBIAN] (MACH_TYPE, CPP_WORDSZ): Do not
define.

14 months agoChange gc.man to include gc/gc.h
Ivan Maidanski [Wed, 23 Aug 2023 04:15:37 +0000 (07:15 +0300)]
Change gc.man to include gc/gc.h
(a cherry-pick of commit cda8d871e from 'master')

* doc/gc.man (.TH): Update date.
* doc/gc.man (.SH SYNOPSIS): Include gc/gc.h instead of gc.h.

14 months agoFix a typo in comment of GC_get_back_ptr_info
Ivan Maidanski [Fri, 18 Aug 2023 06:35:16 +0000 (09:35 +0300)]
Fix a typo in comment of GC_get_back_ptr_info
(a cherry-pick of commits 49234ebf1dafda5939 from 'master')

* dbg_mlc.c (GC_get_back_ptr_info): Remove wrong statement in comment
that only 1 or 0 is returned.
* include/gc_backptr.h (GC_get_back_ptr_info): Likewise.
* include/gc_backptr.h (GC_ref_kind, GC_get_back_ptr_info): Fix
typo ("last one") in comment.

14 months agoEliminate compiler warning of missing cast in LONG_MULT after shift
Ivan Maidanski [Sat, 19 Aug 2023 19:28:19 +0000 (22:28 +0300)]
Eliminate compiler warning of missing cast in LONG_MULT after shift
(a cherry-pick of commit 96ed233e3 from 'master')

* include/private/gc_pmark.h [!I386 || !__GNUC__
|| NACL] (LONG_MULT): Add cast to unsigned32 in hprod assignment.

14 months agoFix misspelled GC_HEADERS_H macro in gc_priv.h
Ivan Maidanski [Thu, 17 Aug 2023 20:56:01 +0000 (23:56 +0300)]
Fix misspelled GC_HEADERS_H macro in gc_priv.h
(a cherry-pick of commit 4864e3e2c from 'master')

* include/private/gc_priv.h: Include gc_hdrs.h unconditionally (i.e.
do not check HEADERS_H macro which does not have GC_ prefix).

14 months agoEliminate 'make_key is defined but unused' gcc warning in threadkeytest
Ivan Maidanski [Fri, 11 Aug 2023 05:12:32 +0000 (08:12 +0300)]
Eliminate 'make_key is defined but unused' gcc warning in threadkeytest
(a cherry-pick of commit 90ebee8e5 from 'master')

* tests/threadkey_test.c [GC_SOLARIS_THREADS] (main): Call make_key()
instead of pthread_key_create().

14 months agoFix asm constraint in LONG_MULT for gcc/x86
Ivan Maidanski [Wed, 9 Aug 2023 17:18:27 +0000 (20:18 +0300)]
Fix asm constraint in LONG_MULT for gcc/x86

* include/private/gc_pmark.h [I386 && __GNUC__ && !NACL] (LONG_MULT):
Change "g"(y) simple constraint to "r"(y).

14 months agoFix missing atomic barriers in CORD_from_file_lazy
Ivan Maidanski [Mon, 7 Aug 2023 20:48:48 +0000 (23:48 +0300)]
Fix missing atomic barriers in CORD_from_file_lazy
(a cherry-pick of commit 226c1eb23 from 'master')

If available, use GCC built-in atomic load-acquire and store-release
primitives to access the cache lines safely.  Otherwise, fall back
to using the GC allocation lock even during the cache lines reading.

* cord/cordxtra.c (ATOMIC_WRITE, ATOMIC_READ): Remove.
* cord/cordxtra.c [!AO_DISABLE_GCC_ATOMICS
&& (__clang__ && __clang_major__>=8
|| __GNUC__ && (__GNUC__>5 || __GNUC__==5 && __GNUC_MINOR__>=4))]
(CORD_USE_GCC_ATOMIC): Define.
* cord/cordxtra.c (refill_cache): Remove comment about missing barrier;
do not call ATOMIC_WRITE().
* cord/cordxtra.c [CORD_USE_GCC_ATOMIC] (refill_cache): Call
__atomic_store_n(__ATOMIC_RELEASE) instead of ATOMIC_WRITE().
* cord/cordxtra.c [!CORD_USE_GCC_ATOMIC] (get_cache_line): New static
function.
* cord/cordxtra.c [CORD_USE_GCC_ATOMIC] (CORD_lf_func): Call
__atomic_load_n(__ATOMIC_ACQUIRE) instead of ATOMIC_READ().
* cord/cordxtra.c [!CORD_USE_GCC_ATOMIC] (CORD_lf_func): Call
GC_call_with_alloc_lock(get_cache_line).

14 months agoAvoid unexpected heap growth in gctest for the case of VERY_SMALL_CONFIG
Ivan Maidanski [Fri, 4 Aug 2023 05:58:45 +0000 (08:58 +0300)]
Avoid unexpected heap growth in gctest for the case of VERY_SMALL_CONFIG
(a cherry-pick of commit d962b1bf4 from 'master')

* tests/test.c (check_heap_stats): Set initial value for max_heap_sz
regardless of VERY_SMALL_CONFIG.
* tests/test.c (check_heap_stats): Divide max_heap_sz (initial value)
by 4 if VERY_SMALL_CONFIG.

14 months agoFix missing outermost parentheses in macro definitions in huge test
Ivan Maidanski [Thu, 3 Aug 2023 04:56:29 +0000 (07:56 +0300)]
Fix missing outermost parentheses in macro definitions in huge test
(a cherry-pick of commit 9ef3305fd from 'master')

* tests/huge_test.c [!GC_MAXIMUM_HEAP_SIZE] (GC_MAXIMUM_HEAP_SIZE,
GC_INITIAL_HEAP_SIZE): Wrap the expression into parentheses.

14 months agoEliminate 'alloc_small declared but unused' gcc warning in gctest
Ivan Maidanski [Thu, 3 Aug 2023 04:38:41 +0000 (07:38 +0300)]
Eliminate 'alloc_small declared but unused' gcc warning in gctest
(a cherry-pick of commit 4f2cfbda9 from 'master')

* tests/test.c [GC_PTHREADS] (fl_key): Do not define if
VERY_SMALL_CONFIG.
* tests/test.c (alloc8bytes, alloc_small): Likewise.
* tests/test.c (alloc_small): Move definition upper (to be close to
alloc8bytes).
* tests/test.c [GC_PTHREADS] (main): Do not call pthread_key_create()
if VERY_SMALL_CONFIG.

14 months agoCheck for out-of-memory on every memory allocation in tests
Ivan Maidanski [Wed, 2 Aug 2023 04:18:59 +0000 (07:18 +0300)]
Check for out-of-memory on every memory allocation in tests
(a cherry-pick of commit 9636efee1 from 'master')

* tests/test.c (checkOOM): New static function.
* tests/test.c (reverse, reverse_test_inner, chktree, typed_test,
run_one_test): Call checkOOM().
* tests/test.c (test_tinyfl, run_one_test): Call
CHECK_OUT_OF_MEMORY().
* tests/initsecondarythread.c (thread): Likewise.
* tests/leak_test.c (main): Likewise.
* tests/middle.c (main): Likewise.
* tests/realloc_test.c (main): Likewise.
* tests/smash_test.c (main): Likewise.
* tests/staticrootslib.c (libsrl_mktree): Likewise.
* tests/thread_leak_test.c (test): Likewise.
* tests/trace_test.c (mktree): Likewise.
* tests/test.c (mktree): Move CHECK_OUT_OF_MEMORY() call upper (to be
right after GC_NEW()).
* tests/initsecondarythread.c (CHECK_OUT_OF_MEMORY): New macro.
* tests/leak_test.c (CHECK_OUT_OF_MEMORY): Likewise.
* tests/middle.c (CHECK_OUT_OF_MEMORY): Likewise.
* tests/realloc_test.c (CHECK_OUT_OF_MEMORY): Likewise.
* tests/smash_test.c (CHECK_OUT_OF_MEMORY): Likewise.
* tests/staticrootslib.c (CHECK_OUT_OF_MEMORY): Likewise.
* tests/thread_leak_test.c (CHECK_OUT_OF_MEMORY): Likewise.
* tests/trace_test.c (CHECK_OUT_OF_MEMORY): Likewise.
* tests/leak_test.c: Include stdlib.h.
* tests/middle.c: Likewise.
* tests/smash_test.c: Likewise.
* tests/staticrootslib.c: Likewise.
* tests/thread_leak_test.c: Likewise.
* tests/middle.c: Move include gc.h down (to be after stdlib.h).
* tests/staticrootslib.c: Include stdio.h.
* tests/leak_test.c: Likewise.

14 months agoFix hard-coded bits number in GC_DS_BITMAP comment
Ivan Maidanski [Mon, 31 Jul 2023 17:35:34 +0000 (20:35 +0300)]
Fix hard-coded bits number in GC_DS_BITMAP comment
(a cherry-pick of commit e506ac10ad from 'master')

* include/gc_mark.h (GC_DS_TAG_BITS, GC_DS_BITMAP): Do not hard-code
number of bits in comment.
* include/gc_mark.h (GC_DS_BITMAP): Reveal MSB acronym in comment;
refine comment.

14 months agoFix 'implicit declaration of iscntrl()' warning in cord/de_win (MinGW)
Ivan Maidanski [Wed, 26 Jul 2023 21:44:55 +0000 (00:44 +0300)]
Fix 'implicit declaration of iscntrl()' warning in cord/de_win (MinGW)
(a cherry-pick of commit 8d945c79f from 'master')

* cord/tests/de_win.c [__BORLANDC__ || __CYGWIN__ || __MINGW32__
|| __NT__ || _WIN32 || WIN32]: Include ctype.h.

14 months agoFix a typo in the comment documenting CORD_set_pos
Ivan Maidanski [Wed, 26 Jul 2023 05:20:25 +0000 (08:20 +0300)]
Fix a typo in the comment documenting CORD_set_pos
(a cherry-pick of commit de47da1b4 from 'master')

* include/cord_pos.h (CORD_set_pos): Fix a typo ("given") in
comment.

14 months agoRemove .log and cordtest .tmp files by 'make clean' (Makefile.direct)
Ivan Maidanski [Wed, 26 Jul 2023 05:07:20 +0000 (08:07 +0300)]
Remove .log and cordtest .tmp files by 'make clean' (Makefile.direct)

* Makefile.direct (clean): Remove also "*.log", "cordtst*.tmp" files
(which might be generated by tests on Mingw).

14 months agoFix missing _setjmp() on djgpp
Ivan Maidanski [Wed, 28 Jun 2023 06:09:02 +0000 (09:09 +0300)]
Fix missing _setjmp() on djgpp
(a cherry-pick of commit a2a81d262 from 'master')

As of djgpp v3.4, _setjmp is no longer available. Use setjmp() instead.

* mach_dep.c [!HAVE_PUSH_REGS && !HAVE_BUILTIN_UNWIND_INIT && DJGPP]
(GC_with_callee_saves_pushed): Call setjmp() instead of _setjmp().

16 months agoEliminate 'old_segv_handler is defined but unused' gcc warning on OpenBSD
Ivan Maidanski [Tue, 27 Jun 2023 20:45:21 +0000 (23:45 +0300)]
Eliminate 'old_segv_handler is defined but unused' gcc warning on OpenBSD

* os_dep.c [(NEED_FIND_LIMIT || UNIX_LIKE || WRAP_MARK_SOME
&& __GNUC__) && !SUNOS5SIGS && !IRIX5 && !OSF1 && !HAIKU && !HURD
&& !FREEBSD && !NETBSD] (old_segv_handler): Do not define if OPENBSD.

16 months agoEliminate 'rand() may return deterministic values' warning
Ivan Maidanski [Wed, 21 Jun 2023 05:08:03 +0000 (08:08 +0300)]
Eliminate 'rand() may return deterministic values' warning
(a cherry-pick of commits 96b4f1da4ced7dd69e from 'master')

The warning is observed at least on OpenBSD 7.3.

* dbg_mlc.c [KEEP_BACK_PTRS] (GC_rand, RANDOM): Define regardless of
LINT2; add comment.
* tests/disclaim_bench.c (GC_RAND_STATE_T, rand): Likewise.
* dbg_mlc.c [KEEP_BACK_PTRS && !LINT2] (GC_RAND_MAX): Do not redefine.
* include/private/gc_priv.h (GC_RAND_MAX, GC_RAND_STATE_T,
GC_RAND_NEXT): Define regardless of LINT2 and THREADS.
* tests/disclaim_test.c (NOT_GCBUILD, GC_RAND_STATE_T, rand): Define
regardless of GC_PTHREADS and LINT2.
* tests/disclaim_weakmap_test.c: Likewise.
* tests/disclaim_test.c: Include gc_priv.h unconditionally.
* tests/disclaim_weakmap_test.c: Likewise.
* tests/disclaim_test.c (rand): Update comment.
* tests/disclaim_weakmap_test.c [!GC_PTHREADS] (AO_t): Do not define if
AO_HAVE_compiler_barrier.