platform/upstream/libgc.git
8 years agoUpdate AUTHORS file
Ivan Maidanski [Tue, 5 Jul 2016 11:39:11 +0000 (14:39 +0300)]
Update AUTHORS file

8 years agoMissing volatile in declaration of GC_with_callee_saves_pushed
Thomas Linder Puls [Sun, 3 Jul 2016 22:09:18 +0000 (00:09 +0200)]
Missing volatile in declaration of GC_with_callee_saves_pushed
(fix for commit 8ffc3db)

Otherwise MS VC reports a warning at level 4.

* include/private/gc_priv.h (GC_with_callee_saves_pushed): Add
volatile for arg (to match the function definition).

8 years agoFix 'arg parameter might be clobbered by setjmp' compiler warning
Ivan Maidanski [Fri, 1 Jul 2016 07:41:16 +0000 (10:41 +0300)]
Fix 'arg parameter might be clobbered by setjmp' compiler warning

* mach_dep.c (GC_with_callee_saves_pushed): Make "arg" parameter
volatile (to prevent it from potential clobbering).

8 years agoReplace (fix) 'objs' acronym in comments with 'objects word
Ivan Maidanski [Fri, 1 Jul 2016 07:30:57 +0000 (10:30 +0300)]
Replace (fix) 'objs' acronym in comments with 'objects word

* include/gc.h (GC_PROTECTS_POINTER_HEAP): Replace "objs" word to
"objects" in comment.
* include/private/gc_priv.h (GC_arrays._aobjfreelist,
GC_arrays._uobjfreelist, GC_arrays._auobjfreelist, GC_aobjfreelist):
Likewise.
* mark.c (INITIAL_MARK_STACK_SIZE): Likewise.
* include/private/gc_priv.h (GC_arrays._uobjfreelist): Add missing dot
to delimit the end of a sentence in comment.

8 years agoMerge branch 'generalize-alloc-via-ok_freelist'
Ivan Maidanski [Thu, 30 Jun 2016 07:50:59 +0000 (10:50 +0300)]
Merge branch 'generalize-alloc-via-ok_freelist'

* mark.c (GC_n_kinds): Resolve merge conflict.

8 years agoRevert "Refactoring of GC_Xobjfreelist" partially
Ivan Maidanski [Thu, 30 Jun 2016 07:20:53 +0000 (10:20 +0300)]
Revert "Refactoring of GC_Xobjfreelist" partially

This reverts commit 41871b970c8fd9704835c1a221a8f9f1deea707a partially
(GC_malloc_kind_global, GC_generic_malloc_uncollectable,
GC_destroy_thread_local are not reverted).

8 years agoReplace GC_freelists usage with GC_obj_kinds[].ok_freelist
Ivan Maidanski [Wed, 29 Jun 2016 22:03:54 +0000 (01:03 +0300)]
Replace GC_freelists usage with GC_obj_kinds[].ok_freelist

* malloc.c (GC_malloc_kind_global, GC_generic_malloc_uncollectable):
Use GC_obj_kinds[k].ok_freelist instead of GC_freelists[k].
* thread_local_alloc.c (GC_destroy_thread_local): Likewise.
* thread_local_alloc.c (GC_destroy_thread_local): Stop iteration when
an uninitialized kind reached.

8 years agoRevert "Fix GC_new_kind in case of client-defined PREDEFINED_KINDS"
Ivan Maidanski [Wed, 29 Jun 2016 22:29:02 +0000 (01:29 +0300)]
Revert "Fix GC_new_kind in case of client-defined PREDEFINED_KINDS"

This reverts commit 0d4d41f1e2b12c1321cb37e2bcbe07c8bb089a2d.

8 years agoRevert "Remove redundant comments in GC_obj_kinds"
Ivan Maidanski [Wed, 29 Jun 2016 22:26:58 +0000 (01:26 +0300)]
Revert "Remove redundant comments in GC_obj_kinds"

This reverts commit be76fecc24a410f26ac33fb363cfb90a1ace6fca.

8 years agoFix unchecked fork() result in gctest (Unix, Cygwin)
Ivan Maidanski [Fri, 24 Jun 2016 20:01:53 +0000 (23:01 +0300)]
Fix unchecked fork() result in gctest (Unix, Cygwin)

Fail gctest if forked process failed.

* tests/test.c [!NO_TEST_HANDLE_FORK]: Include sys/types.h, sys/wait.h.
* tests/test.c (run_one_test) [!NO_TEST_HANDLE_FORK]: Declare pid,
wstatus local variables; FAIL if fork() returns -1; call waitpid() for
the child process; FAIL if the child process failed.

8 years agoFix GC_new_kind in case of client-defined PREDEFINED_KINDS
Ivan Maidanski [Sat, 30 Apr 2016 22:07:53 +0000 (01:07 +0300)]
Fix GC_new_kind in case of client-defined PREDEFINED_KINDS

There are 2 types of kinds - "pre-allocated" ones (with the number less
than PREDEFINED_KINDS) which have pre-allocated free lists and object
allocation for these kinds is dealt by GC_malloc_kind typically,
and "custom" kinds which require the client to supply the free list
(e.g., allocated by GC_new_free_list[_inner]) and arrange own object
allocation procedure.
By design, GC_new_kind[_inner] creates new "custom" kind.

* mark.c (GC_N_KINDS_INITIAL_VALUE): Simplify and comment out (for now).
* mark.c (GC_n_kinds): Initialize to PREDEFINED_KINDS (instead of
GC_N_KINDS_INITIAL_VALUE); add TODO item.

8 years agoAdd assertion for GC_new_kind boolean arguments
Ivan Maidanski [Tue, 15 Mar 2016 20:42:43 +0000 (23:42 +0300)]
Add assertion for GC_new_kind boolean arguments

* misc.c (GC_new_kind_inner): Add assertions for "adjust" and "clear"
arguments (should be zero or one).

8 years agoFix assertion violation in GC_wait_builder called from start_mark_threads
Ivan Maidanski [Tue, 21 Jun 2016 20:38:23 +0000 (23:38 +0300)]
Fix assertion violation in GC_wait_builder called from start_mark_threads
(fix commit 0ca6d3f)

* include/private/gc_priv.h [PARALLEL_MARK]
(GC_start_mark_threads_inner): Declare even if no CAN_HANDLE_FORK.
* misc.c [THREADS] (GC_start_mark_threads): Define also for the case
of PARALLEL_MARK and CAN_HANDLE_FORK - call GC_start_mark_threads_inner
surrounded with DISABLE/RESTORE_CANCEL.
* pthread_support.c [PARALLEL_MARK] (GC_start_mark_threads_inner):
Always define as GC_INNER.
* win32_threads.c [GC_PTHREADS_PARAMARK] (GC_start_mark_threads_inner):
Likewise.

8 years agoFix GC_suspend_thread regarding potential cancellation of sem_wait
Ivan Maidanski [Tue, 21 Jun 2016 09:12:56 +0000 (12:12 +0300)]
Fix GC_suspend_thread regarding potential cancellation of sem_wait

* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread):
Call DISABLE_CANCEL before sem_wait, call RESTORE_CANCEL after it.

8 years agoMerge branch 'thread-suspend'
Ivan Maidanski [Tue, 21 Jun 2016 06:53:04 +0000 (09:53 +0300)]
Merge branch 'thread-suspend'

8 years agoFix GC_suspend_thread for terminated threads
Ivan Maidanski [Tue, 21 Jun 2016 06:48:21 +0000 (09:48 +0300)]
Fix GC_suspend_thread for terminated threads

* pthread_stop_world.c (GC_suspend_thread): Do not clear
SUSPENDED_EXT flag in case of RAISE_SIGNAL() failure, add assertion
about FINISHED (in case of ESRCH), update comment.
* pthread_stop_world.c (GC_register_my_thread): Add assertion
that SUSPENDED_EXT flag is not set if the thread is registered from
a thread key destructor.

8 years agoFix deadlock (and double lock) in explicit thread suspend/resume
Ivan Maidanski [Mon, 20 Jun 2016 08:38:50 +0000 (11:38 +0300)]
Fix deadlock (and double lock) in explicit thread suspend/resume

* pthread_stop_world.c (GC_suspend_handler_inner)
[GC_ENABLE_SUSPEND_THREAD]: If SUSPENDED_EXT flag then set
stop_info.stack_ptr, call sem_post(suspend_ack_sem), and call
suspend_self_inner instead of GC_do_blocking(suspend_self_inner).
* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread):
No-op if already suspended; UNLOCK before GC_do_blocking (if
self-suspend); add TODO about GC_retry_signals; clear SUSPENDED_EXT
flag if RAISE_SIGNAL failed with ESRCH code; sem_wait(suspend_ack_sem)
to let the suspend handler to lookup the thread and store stack_ptr
(and save registers if needed).
* pthread_stop_world.c (GC_suspend_all, GC_start_world): Skip threads
with SUSPENDED_EXT flag.

8 years agoFix STACKBOTTOM for Solaris 11/x86
Peter Wang [Thu, 16 Jun 2016 09:16:05 +0000 (12:16 +0300)]
Fix STACKBOTTOM for Solaris 11/x86

* include/private/gcconfig.h [I386 && SOLARIS] (STACKBOTTOM,
HEURISTIC2): Define conditionally depening on USERLIMIT - use
HEURISTIC2 if USERLIMIT is undefined (workaround similar to that for
Solaris/sparc and Solaris/x64); include sys/vmparam.h instead of
sys/vm.h; update comment.

8 years agoUpdate AUTHORS file
Ivan Maidanski [Fri, 10 Jun 2016 18:09:54 +0000 (21:09 +0300)]
Update AUTHORS file

8 years agoWorkaround a bug in winpthreads causing parallel marks deadlock (MinGW)
Adrian Pop [Fri, 10 Jun 2016 17:39:18 +0000 (20:39 +0300)]
Workaround a bug in winpthreads causing parallel marks deadlock (MinGW)

The solution is to use Win32 threads for parallel markers while using
winpthreads to provide GC-aware pthread_create/join/detach and fork.

See details in GitHub issue #81 and issue #119.

* win32_threads.c (GC_PTHREADS_PARAMARK): Do not define if
GC_PTHREADS, PARALLEL_MARK and __MINGW32__ (to workaround a deadlock
in do_sema_b_wait() of winpthreads).

8 years agoDump the block information in CSV format
Paul Bone [Fri, 10 Jun 2016 08:11:47 +0000 (11:11 +0300)]
Dump the block information in CSV format

This makes it easy to copy this information into a new file and
process it with tools that understand CSV, e.g. to create histograms
of block utilization.

* reclaim.c (GC_print_block_descr): add n_objs local variable;
separate printed values with a comma; print also size of block in
object units; refactor code for computing total_bytes field.
* reclaim.c (GC_print_block_list): Separate columns in printed table
header with a comma; append "#objs" column to the table.

8 years agoRefactoring of android_thread_kill/pthread_kill calls
Ivan Maidanski [Mon, 30 May 2016 19:46:59 +0000 (22:46 +0300)]
Refactoring of android_thread_kill/pthread_kill calls

* pthread_stop_world.c (android_thread_kill) [USE_TKILL_ON_ANDROID]:
Move definition upper (to be before its first use); remove forward
declaration.
* pthread_stop_world.c (THREAD_SYSTEM_ID, RAISE_SIGNAL): New macro.
* pthread_stop_world.c (GC_suspend_thread): Remove "result" local
variable
* pthread_stop_world.c (GC_suspend_thread, GC_suspend_all,
GC_start_world): Use RAISE_SIGNAL() instead of pthread_kill and
android_thread_kill.
* pthread_stop_world.c (GC_suspend_all, GC_start_world): Remove
"thread_id" local variable; use THREAD_SYSTEM_ID instead of thread_id.

8 years agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Mon, 23 May 2016 22:34:56 +0000 (01:34 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)

8 years agoRemove reference to deleted TODO file from Makefile
Ivan Maidanski [Tue, 24 May 2016 21:28:08 +0000 (00:28 +0300)]
Remove reference to deleted TODO file from Makefile
(fix commit f511a85)

* Makefile.am (EXTRA_DIST): Remove "TODO" file.
* Makefile.direct (DOC_FILES): Likewise.

8 years agoRemove (deprecate) TODO file
Ivan Maidanski [Tue, 17 May 2016 21:13:18 +0000 (00:13 +0300)]
Remove (deprecate) TODO file

ToDo/bug items are moved to "Issues" section on GitHub.

8 years agoUpdate AUTHORS file
Ivan Maidanski [Tue, 10 May 2016 20:49:29 +0000 (23:49 +0300)]
Update AUTHORS file

8 years agoSupport (add machine description for) TILE-Gx and TILEPro targets
Chris Metcalf [Tue, 10 May 2016 08:04:53 +0000 (11:04 +0300)]
Support (add machine description for) TILE-Gx and TILEPro targets

This patch is an updated version of the CentOS 6 patch that we have
been carrying as part of our own CentOS-like distribution since 2012.

* include/private/gcconfig.h (TILEGX, TILEPRO) [__tile__]: New macro.
* include/private/gcconfig.h (mach_type_known, CPP_WORDSZ, MACH_TYPE,
ALIGNMENT, ALIGN_DOUBLE, PREFETCH, CACHE_LINE_SIZE,
USE_GENERIC_PUSH_REGS, OS_TYPE, __data_start, DATASTART,
LINUX_STACKBOTTOM, DYNAMIC_LOADING, ALIGNMENT): Define for TILEGX and
TILEPRO.

8 years agoFix GC_new_kind in case of client-defined PREDEFINED_KINDS
Ivan Maidanski [Sat, 30 Apr 2016 22:07:53 +0000 (01:07 +0300)]
Fix GC_new_kind in case of client-defined PREDEFINED_KINDS

There are 2 types of kinds - "pre-allocated" ones (with the number less
than PREDEFINED_KINDS) which have pre-allocated free lists and object
allocation for these kinds is dealt by GC_malloc_kind typically,
and "custom" kinds which require the client to supply the free list
(e.g., allocated by GC_new_free_list[_inner]) and arrange own object
allocation procedure.
By design, GC_new_kind[_inner] creates new "custom" kind.

* mark.c (GC_N_KINDS_INITIAL_VALUE): Simplify and comment out (for now).
* mark.c (GC_n_kinds): Initialize to PREDEFINED_KINDS (instead of
GC_N_KINDS_INITIAL_VALUE); add TODO item.

8 years agoUpdate ChangeLog file
Ivan Maidanski [Thu, 28 Apr 2016 08:18:11 +0000 (11:18 +0300)]
Update ChangeLog file

8 years agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Wed, 27 Apr 2016 08:22:01 +0000 (11:22 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)

8 years agoFix GC_REALLOC to call GC_FREE if new size is zero and pointer is non-NULL
Ivan Maidanski [Tue, 5 Apr 2016 19:08:55 +0000 (22:08 +0300)]
Fix GC_REALLOC to call GC_FREE if new size is zero and pointer is non-NULL

* dbg_mlc.c (GC_debug_realloc): Call GC_debug_free (and return NULL)
if lb is zero and p is non-NULL.
* extra/AmigaOS.c (GC_amiga_realloc): Do not retry and do not call
WARN if new_size_in_bytes is zero.
* include/gc.h (GC_realloc): Refine comment (better document the cases
of NULL and/or zero arguments).
* mallocx.c (GC_realloc): Call GC_free (skip it if IGNORE_FREE) and
return NULL if lb is zero and p is non-NULL.

8 years agoUpdate AUTHORS file
Ivan Maidanski [Thu, 31 Mar 2016 21:10:05 +0000 (00:10 +0300)]
Update AUTHORS file

8 years agoMerge pull request #95 from tschwinge/hurd-mmap
Ivan Maidanski [Thu, 31 Mar 2016 21:04:47 +0000 (00:04 +0300)]
Merge pull request #95 from tschwinge/hurd-mmap

Use mmap instead of sbrk (Hurd)

8 years ago[Hurd] Use mmap instead of sbrk
Thomas Schwinge [Wed, 30 Mar 2016 08:52:43 +0000 (10:52 +0200)]
[Hurd] Use mmap instead of sbrk

* include/private/gcconfig.h [I386 && HURD]: Define USE_MMAP, USE_MMAP_ANON.

8 years agoFix 'GC_generic_malloc_inner_ignore_off_page not used' compiler warning
Ivan Maidanski [Fri, 18 Mar 2016 18:06:53 +0000 (21:06 +0300)]
Fix 'GC_generic_malloc_inner_ignore_off_page not used' compiler warning
(for GC_NO_FINALIZATION case)

* include/private/gc_priv.h (GC_generic_malloc_inner_ignore_off_page):
Do not declare unless DBG_HDRS_ALL or GC_GCJ_SUPPORT, or
!GC_NO_FINALIZATION.
* malloc.c (GC_generic_malloc_inner_ignore_off_page): Do not define
unless DBG_HDRS_ALL or GC_GCJ_SUPPORT, or !GC_NO_FINALIZATION.

8 years agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Fri, 18 Mar 2016 07:32:05 +0000 (10:32 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)

8 years agoAdd assertion for GC_new_kind boolean arguments
Ivan Maidanski [Tue, 15 Mar 2016 20:42:43 +0000 (23:42 +0300)]
Add assertion for GC_new_kind boolean arguments

* misc.c (GC_new_kind_inner): Add assertions for "adjust" and "clear"
arguments (should be zero or one).

8 years agoRefactoring of mark_and_push_stack (check GC_base result for null)
Ivan Maidanski [Wed, 9 Mar 2016 20:12:25 +0000 (23:12 +0300)]
Refactoring of mark_and_push_stack (check GC_base result for null)

* mark.c (GC_mark_and_push_stack): Check GC_base() result (do not pass
NULL to HDR()).

8 years agostart_mark_threads refactoring regarding GC_markers_m1 update (Win32)
Ivan Maidanski [Fri, 4 Mar 2016 22:11:05 +0000 (01:11 +0300)]
start_mark_threads refactoring regarding GC_markers_m1 update (Win32)
(Sync semantics around GC_markers_m1 with that of pthread_support.c.)
(fix commit 95947bd)

* win32_threads.c (GC_start_mark_threads_inner): Update GC_markers_m1
value to i just after loop creating the threads.

8 years agoRevert "Prevent code analysis tool warning about GC_base unchecked result"
Ivan Maidanski [Fri, 4 Mar 2016 21:47:07 +0000 (00:47 +0300)]
Revert "Prevent code analysis tool warning about GC_base unchecked result"
(It breaks gctest if assertion is on.)

This reverts commit 70fbfadd3842c828ae9dd10ef3212a2d0957ca86.

8 years agoUpdate AUTHORS file
Ivan Maidanski [Thu, 3 Mar 2016 21:34:51 +0000 (00:34 +0300)]
Update AUTHORS file

8 years agoFix user-defined signals drop by marker threads
Hiroshi Yokota [Sat, 6 Feb 2016 01:25:48 +0000 (10:25 +0900)]
Fix user-defined signals drop by marker threads

When one user thread sets its own signal handler in multi-threaded
code, GC marker thread sometimes steal and drop user signal calls.
Because GC marker thread doesn't knows the user thread's signal
handler, and uses the default signal handler that ignores any signal
call.  This becomes to drop the signal call.

This patch inhibits to accept signals by GC marker threads except
GC system signals, and don't drop user signal calls.

This patch comes from Gauche.

* include/private/gcconfig.h (NO_MARKER_SPECIAL_SIGMASK): New macro.
* pthread_support.c (GC_start_mark_threads_inner): Unless
NO_MARKER_SPECIAL_SIGMASK, call pthread_sigmask to block all signals
(except for the ones used for GC suspend/resume if any) before
starting marker threads and restore signals mask afterwards.
* win32_threads.c (GC_start_mark_threads_inner): Likewise.

8 years agoFix filename printing in cordtest
Ivan Maidanski [Wed, 2 Mar 2016 07:47:24 +0000 (10:47 +0300)]
Fix filename printing in cordtest

* cord/tests/cordtest.c (test_extras): Do not quote FNAME1 and FNAME2.

8 years agoFix 'CORD_iter5 unused result' code defect in cordxtra
Ivan Maidanski [Wed, 2 Mar 2016 07:20:28 +0000 (10:20 +0300)]
Fix 'CORD_iter5 unused result' code defect in cordxtra

* cord/cordxtra.c (CORD_fill_buf): Return CORD_iter5() result (instead
of void); update description comment.
* cord/cordxtra.c (CORD_to_char_star): Do not execute CORD_fill_buf()
if cord is empty (CORD_fill_buf returns 0 in case of empty cord);
check CORD_fill_buf result (abort in case of unexpected result).

8 years agoRemove code duplication in GC_realloc
Ivan Maidanski [Tue, 1 Mar 2016 21:44:13 +0000 (00:44 +0300)]
Remove code duplication in GC_realloc

* mallocx.c (GC_realloc): Avoid code duplication for shrink and grow
cases.

8 years agoFix 'statement unreachable' compiler warning in memalign
Ivan Maidanski [Tue, 1 Mar 2016 21:11:22 +0000 (00:11 +0300)]
Fix 'statement unreachable' compiler warning in memalign

* mallocx.c (GC_memalign): Do not handle case of
offset >= VALID_OFFSET_SZ; add assertion for offset; add static
assertion for VALID_OFFSET_SZ value.

8 years agoWorkaround false warning about unreachable code path
Ivan Maidanski [Tue, 1 Mar 2016 09:11:19 +0000 (12:11 +0300)]
Workaround false warning about unreachable code path

* tests/test.c (FAIL): Remove useless void cast applied to abort()
and Amiga_Fail().

8 years agoFix unchecked pointer dereference in check_ints (gctest)
Ivan Maidanski [Mon, 29 Feb 2016 21:41:39 +0000 (00:41 +0300)]
Fix unchecked pointer dereference in check_ints (gctest)

* tests/test.c (check_ints): Fail (with the appropriate message) if
"list" argument is nil.

8 years agoFix unchecked sigdelset() result in pthread_support
Ivan Maidanski [Mon, 29 Feb 2016 21:13:57 +0000 (00:13 +0300)]
Fix unchecked sigdelset() result in pthread_support

* pthread_support.c (GC_pthread_sigmask): Abort in case of sigdelset
failure.

8 years agoFix unchecked pthread_join() result in threadkey_test
Ivan Maidanski [Mon, 29 Feb 2016 21:07:07 +0000 (00:07 +0300)]
Fix unchecked pthread_join() result in threadkey_test

* tests/threadkey_test.c: Include stdio.h (unconditionally), stdlib.h
for fprintf() and exit().
* tests/threadkey_test.c (main): Abort in case of GC_pthread_join
failure.

8 years agoSkip GC_DS_PER_OBJECT objects with negative descriptor in GC_mark_from
Niklas Therning [Wed, 17 Feb 2016 13:16:01 +0000 (14:16 +0100)]
Skip GC_DS_PER_OBJECT objects with negative descriptor in GC_mark_from

Added a check in GC_mark_from() for GC_DS_PER_OBJECT objects with
negative descriptors to prevent mistaking the free list pointers in
free objects for being type descriptor pointers.  If the specified
descriptor offset was larger than the object size this could lead to
arbitrary data from allocated objects being misinterpreted as
descriptors and the process crashing.

* mark.c (GC_mark_from): In case of GC_DS_PER_OBJECT, skip objects
those descriptor is outside object.

8 years agoUpdate AUTHORS file
Ivan Maidanski [Fri, 19 Feb 2016 07:37:21 +0000 (10:37 +0300)]
Update AUTHORS file

8 years agoAltera NIOS2 support
Marek Vasut [Thu, 28 Jan 2016 03:13:13 +0000 (04:13 +0100)]
Altera NIOS2 support

Add simple nios2 configuration support.

* include/private/gcconfig.h (NIOS2): New macro.
* include/private/gcconfig.h (mach_type_known, CPP_WORDSZ, MACH_TYPE,
OS_TYPE, DYNAMIC_LOADING, _end, __data_start, DATASTART, DATAEND,
ALIGNMENT, HBLKSIZE, HBLKSIZE, LINUX_STACKBOTTOM, NO_GETCONTEXT):
Define for NIOS2.

8 years agoFix unchecked fcntl() result
Ivan Maidanski [Thu, 18 Feb 2016 21:55:22 +0000 (00:55 +0300)]
Fix unchecked fcntl() result

* os_dep.c (GC_unix_mmap_get_mem, GC_dirty_init): Call WARN() if
fcntl() failed.

8 years agoFix 'unreachable code' compiler warning in GC_dirty_init (Solaris)
Ivan Maidanski [Wed, 17 Feb 2016 20:51:11 +0000 (23:51 +0300)]
Fix 'unreachable code' compiler warning in GC_dirty_init (Solaris)
(fix commit ba593b45)

* os_dep.c (GC_dirty_init): Remove duplicate check for GC_proc_fd (if
PROC_VDB).

8 years agoPrevent code analysis tool warning about GC_base unchecked result
Ivan Maidanski [Wed, 17 Feb 2016 09:09:12 +0000 (12:09 +0300)]
Prevent code analysis tool warning about GC_base unchecked result

* mark.c (GC_mark_and_push_stack): Add assertion on GC_base result is
non-null (before use in HDR).

8 years agoFix 'statement unreachable' compiler warning in GC_mark_from
Ivan Maidanski [Wed, 17 Feb 2016 07:54:31 +0000 (10:54 +0300)]
Fix 'statement unreachable' compiler warning in GC_mark_from

* mark.c (GC_mark_from): Initialize 'limit' local variable
unconditionally; add static assertion on GC_DS_TAGS (to check that it
corresponds to number of switch cases); remove switch default (as it
cannot happen).

8 years agoFix 'signed-to-bigger-unsigned value assignment' in GC_init_size_map
Ivan Maidanski [Wed, 17 Feb 2016 07:42:57 +0000 (10:42 +0300)]
Fix 'signed-to-bigger-unsigned value assignment' in GC_init_size_map

* misc.c (GC_init_size_map): Cast ROUNDED_UP_GRANULES() result to
unsigned int explicitly (which is, in turn, cast to size_t implicitly).

8 years agoFix 'signed-to-bigger-unsigned value assignment' warning in GC_setpagesize
Ivan Maidanski [Wed, 17 Feb 2016 07:23:55 +0000 (10:23 +0300)]
Fix 'signed-to-bigger-unsigned value assignment' warning in GC_setpagesize

* include/private/gcconfig.h (GETPAGESIZE): Cast getpagesize() and
sysconf() result to unsigned int.
* tools/setjmp_t.c (main): Change type of "ps" local variable from
long to unsigned int.

8 years agoFix 'signed-to-bigger-unsigned value assignment' warning for hb_map
Ivan Maidanski [Tue, 16 Feb 2016 20:34:43 +0000 (23:34 +0300)]
Fix 'signed-to-bigger-unsigned value assignment' warning for hb_map

* include/private/gc_priv.h (hblkhdr): Change type of hb_map from
short to unsigned short.
* include/private/gc_priv.h (_GC_arrays): Change type of _obj_map from
short to unsigned short.
* obj_map.c (GC_add_map_entry): Change type of new_map local variable
from short to unsigned short.

8 years agoFix 'implicit declaration of function' compiler warnings in cord/de
Ivan Maidanski [Tue, 16 Feb 2016 08:09:34 +0000 (11:09 +0300)]
Fix 'implicit declaration of function' compiler warnings in cord/de

* cord/tests/de.c: Include stdlib.h (for "exit" prototype); include
ctype.h unconditionally (for "iscntrl", "isdigit" prototypes); include
unistd.h (for "sleep" prototype) unless WIN32 or MACINTOSH.

8 years agoFix null-pointer dereferences on out-of-memory in cord/de
Ivan Maidanski [Mon, 15 Feb 2016 21:32:01 +0000 (00:32 +0300)]
Fix null-pointer dereferences on out-of-memory in cord/de

* cord/tests/de.c (add_map, add_hist): Check GC_NEW() result for null.

8 years agoFix potential left shift overflows in finalize.c (64-bit targets)
Ivan Maidanski [Mon, 15 Feb 2016 21:18:54 +0000 (00:18 +0300)]
Fix potential left shift overflows in finalize.c (64-bit targets)

* finalize.c (HASH2, GC_grow_table): Cast 1 to word before shift to
avoid overflow.
* finalize.c (GC_dump_finalization_links, GC_dump_finalization,
ITERATE_DL_HASHTBL_BEGIN, GC_finalize): Cast 1 to size_t before
shift to avoid overflow.

8 years agoFix potential multiplication overflow in check_heap_stats (test)
Ivan Maidanski [Fri, 12 Feb 2016 18:36:08 +0000 (21:36 +0300)]
Fix potential multiplication overflow in check_heap_stats (test)

* tests/test.c (check_heap_stats): Cast n_tests to size_t before
multiplication by 2700000 (instead of implicit cast to size_t of the
result).

8 years agoFix missing numeric casts in cord
Ivan Maidanski [Fri, 12 Feb 2016 18:12:40 +0000 (21:12 +0300)]
Fix missing numeric casts in cord

* cord/cordprnt.c (CORD_vsprintf): Explicitly cast "prec" to unsigned
(to avoid assignment of a signed value to a variable of a bigger
unsigned integer type).
* cord/cordxtra.c (CORD_nul_func, CORD_chars): Cast between pointer
and char via GC_word (instead of long); explicitly cast char to
unsigned char (to avoid a signed value cast to a bigger unsigned one).
* cord/tests/de.c (replace_line): Explicitly cast COLS to unsigned
(when compared to "len" local variable).

8 years agocord/de: Change main() declaration style from K-R to ANSI C
Ivan Maidanski [Fri, 12 Feb 2016 16:49:31 +0000 (19:49 +0300)]
cord/de: Change main() declaration style from K-R to ANSI C

* cord/tests/de.c (main): Replace the K&R-style function definition
with the ANSI C one.
* cord/tests/de.c (main): Replace goto with a block.
* cord/tests/de.c (main): Replace exit(0) with return.

8 years agoFix 'unused label' compiler warning in cord/de
Ivan Maidanski [Fri, 12 Feb 2016 16:13:14 +0000 (19:13 +0300)]
Fix 'unused label' compiler warning in cord/de

* cord/tests/de.c (main): Remove unused "done" label.

8 years agoRemove duplicate new-line in OUT_OF_MEMORY message (cord)
Ivan Maidanski [Fri, 12 Feb 2016 09:20:36 +0000 (12:20 +0300)]
Remove duplicate new-line in OUT_OF_MEMORY message (cord)

* cord/cordbscs.c (OUT_OF_MEMORY): Remove '\n' in ABORT message.
* cord/cordxtra.c (OUT_OF_MEMORY): Likewise.

8 years agoEliminate 'divide by zero' compiler warning in cordtest
Ivan Maidanski [Fri, 12 Feb 2016 09:13:58 +0000 (12:13 +0300)]
Eliminate 'divide by zero' compiler warning in cordtest

* cord/tests/cordtest.c (ABORT): Remove "int x = 0; x = 1 / x" code.

8 years agoFix GC initialization in de_win for Cygwin
Ivan Maidanski [Fri, 12 Feb 2016 09:04:16 +0000 (12:04 +0300)]
Fix GC initialization in de_win for Cygwin
(make GC initialization portable)

* cord/tests/de_win.c (WinMain): Call GC_INIT() unconditionally.

8 years agoFix de_win WndProc prototype parameters for 64-bit (Win64)
Ivan Maidanski [Fri, 12 Feb 2016 08:46:06 +0000 (11:46 +0300)]
Fix de_win WndProc prototype parameters for 64-bit (Win64)

* cord/tests/de_win.h (WndProc): Change UINT type (for wParam) to
WPARAM; change LONG type to LPARAM.
* cord/tests/de_win.h (AboutBox): Remove unused declaration.

8 years agoFix null-pointer dereferences in case of out-of-memory in cord
Ivan Maidanski [Thu, 11 Feb 2016 21:22:44 +0000 (00:22 +0300)]
Fix null-pointer dereferences in case of out-of-memory in cord

* cord/cordprnt.c: Include <stdlib.h> (for abort() declaration).
* cord/cordprnt.c (OUT_OF_MEMORY): New macro.
* cord/tests/de.c (OUT_OF_MEMORY): Likewise.
* cord/cordprnt.c (CORD_vsprintf): Execute OUT_OF_MEMORY if
GC_MALLOC_ATOMIC returns NULL.
* cord/cordxtra.c (CORD_ec_flush_buf): Likewise.
* cord/tests/de.c (replace_line, main): Likewise.
* tests/cordtest.c (test_extras): Declare "u" local variable; do ABORT
if CORD_substr returns NULL (to avoid null pointer dereference in
strcmp).
* cord/tests/de_win.c (plain_chars, control_chars): Return NULL if
GC_MALLOC_ATOMIC returns NULL.
* cord/tests/de_win.c (WndProc): Execute de_error() (with the
appropriate message) if plain_chars() or control_chars() returned
NULL (and do not call the corresponding TextOutA in such a case).

8 years agoFix null pointer dereference on out-of-memory in tests
Ivan Maidanski [Tue, 9 Feb 2016 20:35:33 +0000 (23:35 +0300)]
Fix null pointer dereference on out-of-memory in tests

* tests/disclaim_bench.c (main): Check GC_MALLOC result for NULL
(abort in case of out-of-memory) before dereference.
* tests/test.c (run_one_test): Likewise.
* tests/disclaim_test.c (pair_new): Move is_pair call (in my_assert)
down to be after GC_finalized_malloc result check for NULL.

8 years agoWorkaround 'identical expr on both sides of bitwise op' warning
Ivan Maidanski [Tue, 9 Feb 2016 06:51:22 +0000 (09:51 +0300)]
Workaround 'identical expr on both sides of bitwise op' warning

* gcj_mlc.c (GC_init_gcj_malloc): Comment out "0 |" (in the expression
of "0 | GC_DS_LENGTH").
* mark.c (GC_obj_kinds, GC_push_marked, GC_push_unconditionally):
Likewise.

8 years agoUpdate AUTHORS file
Ivan Maidanski [Wed, 3 Feb 2016 20:53:04 +0000 (23:53 +0300)]
Update AUTHORS file

8 years agoFix Cygwin64 build
Yuki Okumura [Tue, 2 Feb 2016 13:49:11 +0000 (22:49 +0900)]
Fix Cygwin64 build

On x86_64, Cygwin symbols do not have leading underscore anymore,
so an additional underscore is needed on linker-generated symbols
access from C.

* include/gc.h (GC_DATASTART, GC_DATAEND): Prefix _data_start__,
_bss_start__, _data_end__ and _bss_end__ with an extra underscore if
__x86_64__ (only if __CYGWIN__); reformat code.

8 years agoGC_malloc[_atomic] global and thread-local generalization with kind
Alessandro Bruni [Wed, 27 Jan 2016 21:03:49 +0000 (00:03 +0300)]
GC_malloc[_atomic] global and thread-local generalization with kind

* include/gc_inline.h (GC_malloc_kind, GC_malloc_kind_global): New
public function declaration.
* include/gc_inline.h (GC_MALLOC_WORDS_KIND): New public macro.
* include/gc_inline.h (GC_MALLOC_WORDS, GC_MALLOC_ATOMIC_WORDS): Use
GC_MALLOC_WORDS_KIND.
* include/gc_inline.h (GC_CONS): Use GC_malloc_kind (instead of
GC_malloc); reformat code.
* include/private/gc_priv.h (MAXOBJKINDS): Allow user-defined values.
* include/private/gc_priv.h (GC_core_malloc, GC_core_malloc_atomic):
Remove prototype.
* malloc.c: Include gc_inline.h (to get GC_malloc_kind prototype).
* mallocx.c: Likewise.
* malloc.c (GC_generic_malloc_inner,
GC_generic_malloc_inner_ignore_off_page, GC_generic_malloc): Add
assertion on "k" (kind) argument (should be less than MAXOBJKINDS).
* mallocx.c (GC_generic_malloc_ignore_off_page,
GC_generic_malloc_many): Likewise.
* malloc.c (GC_generic_malloc_uncollectable): Add assertion on "k"
argument (should be less than PREDEFINED_KINDS).
* malloc.c (GC_core_malloc_atomic, GC_core_malloc): Replace with
GC_malloc_kind_global.
* malloc.c (GC_malloc_atomic, GC_malloc): Define as a wrapper around
GC_malloc_kind_global.
* malloc.c (GC_malloc_kind): Redirect to GC_malloc_kind_global if
not defined in gc_inline.h (as a macro) or in thread_local_alloc.c.
* mallocx.c (GC_generic_or_special_malloc): Call GC_malloc_kind
instead of GC_malloc_kind and GC_malloc.
* thread_local_alloc.c (GC_malloc, GC_malloc_atomic): Replace with
GC_malloc_kind; remove tiny_fl local variable; call
GC_malloc_kind_global instead of GC_core_malloc and
GC_core_malloc_atomic.
* thread_local_alloc.c (GC_destroy_thread_local): Adjust static assert
to guard against global _freelists overrun.

8 years agoGC_malloc_[atomic_]uncollectable generalization
Ivan Maidanski [Fri, 15 Jan 2016 09:48:06 +0000 (12:48 +0300)]
GC_malloc_[atomic_]uncollectable generalization

* include/gc_mark.h (GC_generic_malloc_uncollectable): New public
function declaration.
* malloc.c (GC_generic_malloc_uncollectable): New function
(imlementation mostly copied from GC_malloc_uncollectable).
* malloc.c (GC_malloc_uncollectable, GC_malloc_atomic_uncollectable,
calloc): Use GC_malloc_atomic_uncollectable.
* mallocx.c (GC_generic_or_special_malloc): Likewise.
* mallocx.c (GC_malloc_atomic_uncollectable): Move to malloc.c.

8 years agoRemove redundant comments in GC_obj_kinds
Ivan Maidanski [Fri, 15 Jan 2016 09:26:36 +0000 (12:26 +0300)]
Remove redundant comments in GC_obj_kinds

* mark.c (GC_obj_kinds): Remove comments duplicating code.

8 years agoFix typo in GC_malloc_uncollectable comment
Ivan Maidanski [Wed, 13 Jan 2016 08:34:56 +0000 (11:34 +0300)]
Fix typo in GC_malloc_uncollectable comment

* ChangeLog: Fix typo ("was").
* malloc.c (GC_malloc_uncollectable): Fix typo ("was") in comment.

8 years agoRefactoring of thread-local *_freelists
Alessandro Bruni [Tue, 12 Jan 2016 08:09:00 +0000 (11:09 +0300)]
Refactoring of thread-local *_freelists
(use single array to keep free lists except for GCJ and "finalized" kinds)

* include/private/thread_local_alloc.h (THREAD_FREELISTS_KINDS): New
macro.
* include/private/thread_local_alloc.h (thread_local_freelists):
Replace ptrfree_freelists and normal_freelists fields with
_freelists[]; define ptrfree_freelists and normal_freelists as macros
(they are used by some external clients, e.g., Mono).
* thread_local_alloc.c (GC_init_thread_local): Rename "i" local
variable to "j"; refine comment about zero-sized GCJ object; remove
loop unrolling (for zero index).
* thread_local_alloc.c (GC_init_thread_local, GC_destroy_thread_local,
GC_mark_thread_local_fls_for, GC_check_tls_for): Define "i" local
variable; replace ptrfree_freelists and normal_freelists with
_freelists[i].

8 years agoUpdate AUTHORS file
Ivan Maidanski [Mon, 11 Jan 2016 07:06:28 +0000 (10:06 +0300)]
Update AUTHORS file

8 years agoEnable build with musl libc
Michael Fox [Mon, 11 Jan 2016 07:01:34 +0000 (10:01 +0300)]
Enable build with musl libc

* include/private/gcconfig.h (NO_GETCONTEXT): Define if __gnu_linux__
undefined (in case of LINUX is defined).

8 years agoUpdate AUTHORS file
Ivan Maidanski [Tue, 5 Jan 2016 08:08:37 +0000 (11:08 +0300)]
Update AUTHORS file

8 years agoRefactoring of GC_Xobjfreelist
Alessandro Bruni [Tue, 5 Jan 2016 07:51:52 +0000 (10:51 +0300)]
Refactoring of GC_Xobjfreelist
(use single array to keep free lists of all kinds)

* alloc.c: Update comment (replace GC_objfreelist with
GC_freelists[NORMAL]).
* checksums.c (GC_on_free_list): Replace GC_sobjfreelist with
GC_freelists[STUBBORN].
* mark.c (GC_obj_kinds): Likewise.
* include/private/gc_priv.h (PTRFREE, NORMAL, UNCOLLECTABLE,
AUNCOLLECTABLE, STUBBORN, IS_UNCOLLECTABLE): Move definition upper to
be before _GC_arrays declaration.
* include/private/gc_priv.h (PREDEFINED_KINDS): New macro.
* include/private/gc_priv.h (GC_freelists): New macro (of global
variable if SEPARATE_GLOBALS).
* include/private/gc_priv.h (_GC_arrays): Replace _objfreelist,
_aobjfreelist, _uobjfreelist, _auobjfreelist, _sobjfreelist fields
with single _freelists[] field.
* include/private/gc_priv.h (GC_objfreelist, GC_aobjfreelist,
GC_auobjfreelist, GC_sobjfreelist, GC_uobjfreelist,
beginGC_objfreelist, endGC_objfreelist, beginGC_aobjfreelist,
endGC_aobjfreelist): Remove macro.
* include/private/gc_priv.h (GC_objfreelist, GC_aobjfreelist): Replace
variable declarations with single GC_freelists[] one (if
SEPARATE_GLOBALS).
* malloc.c (GC_malloc_atomic): Replace GC_aobjfreelist with
GC_freelists[PTRFREE].
* mallocx.c (GC_aobjfreelist_ptr): Likewise.
* mark.c (GC_obj_kinds): Likewise.
* thread_local_alloc.c (GC_destroy_thread_local): Likewise.
* malloc.c (GC_malloc): Replace GC_objfreelist with
GC_freelists[NORMAL].
* mallocx.c (GC_objfreelist_ptr): Likewise.
* mark.c (GC_obj_kinds): Likewise.
* thread_local_alloc.c (GC_destroy_thread_local): Likewise.
* malloc.c (GC_malloc_uncollectable): Replace GC_uobjfreelist with
GC_freelists[UNCOLLECTABLE].
* mallocx.c (GC_uobjfreelist_ptr): Likewise.
* mark.c (GC_obj_kinds): Likewise.
* mallocx.c (GC_auobjfreelist_ptr, GC_malloc_atomic_uncollectable):
Replace GC_auobjfreelist with GC_freelists[AUNCOLLECTABLE].
* mark.c (GC_obj_kinds): Likewise.
* misc.c (GC_init): Exclude whole GC_freelists from scanning instead
of beginGC_objfreelist and beginGC_aobjfreelist (if SEPARATE_GLOBALS).

8 years agoFix typo in comment of ERROR_FL
Ivan Maidanski [Wed, 30 Dec 2015 09:13:55 +0000 (12:13 +0300)]
Fix typo in comment of ERROR_FL

* include/private/thread_local_alloc.h (ERROR_FL): Fix typo in comment
("gcj_freelists").

8 years agoFix typos in gc_priv.h
Ivan Maidanski [Wed, 30 Dec 2015 05:44:18 +0000 (08:44 +0300)]
Fix typos in gc_priv.h

* include/private/gc_priv.h (CPP_MAXOBJBYTES): Add missing ')' in
comment.
* include/private/gc_priv.h (obj_kind.ok_freelist): Fix typo in
comment ("list headers").
* include/private/gc_priv.h (obj_kind.ok_freelist,
obj_kind.ok_reclaim_list): Reformat comment.

8 years agoFix undefined PTRFREE/NORMAL in gc_inline.h
Ivan Maidanski [Mon, 28 Dec 2015 17:24:33 +0000 (20:24 +0300)]
Fix undefined PTRFREE/NORMAL in gc_inline.h

Allow to use gc_inline.h public header without include gc_priv.h.

* include/gc_inline.h (GC_I_PTRFREE, GC_I_NORMAL): New macro.
* include/gc_inline.h (GC_FAST_MALLOC_GRANS, GC_MALLOC_WORDS,
GC_MALLOC_ATOMIC_WORDS, GC_CONS): Use GC_I_PTRFREE and GC_I_NORMAL
instead of PTRFREE and NORMAL (private macros), respectively.

8 years agoPrefix PREFETCH_FOR_WRITE with GC_ as used in gc_inline.h public header
Ivan Maidanski [Mon, 28 Dec 2015 16:11:43 +0000 (19:11 +0300)]
Prefix PREFETCH_FOR_WRITE with GC_ as used in gc_inline.h public header

* doc/porting.html: Rename PREFETCH_FOR_WRITE to GC_PREFETCH_FOR_WRITE.
* fnlz_mlc.c (GC_finalized_malloc): Likewise.
* include/gc_inline.h (GC_FAST_MALLOC_GRANS): Likewise.
* include/private/gcconfig.h: Likewise.
* new_hblk.c (GC_build_fl_clear4, GC_build_fl4, GC_build_fl): Likewise.
* include/gc_inline.h (GC_PREFETCH_FOR_WRITE): Define to no-op if
undefined.

8 years agoAllow GC_FAST_MALLOC_GRANS() multiple use in a function
Ivan Maidanski [Mon, 28 Dec 2015 15:34:57 +0000 (18:34 +0300)]
Allow GC_FAST_MALLOC_GRANS() multiple use in a function

Avoid goto statement in gc_inline.h public header (to fix
'duplicate label' compiler error in GC_FAST_MALLOC_GRANS if the macro
is used multiple times in a function).

* include/gc_inline.h (GC_FAST_MALLOC_GRANS): Replace goto with break

8 years agoWorkaround 'comparison is always false' GCC warning in GC_FAST_MALLOC_GRANS
Ivan Maidanski [Mon, 28 Dec 2015 14:49:54 +0000 (17:49 +0300)]
Workaround 'comparison is always false' GCC warning in GC_FAST_MALLOC_GRANS

* include/gc_inline.h (GC_FAST_MALLOC_GRANS): Refactoring of condition
expression for entry containing counter or is NULL to avoid
"comparison of unsigned expression < 0 is always false" warning
reported by GCC.

8 years agoUpdate AUTHORS file
Ivan Maidanski [Thu, 24 Dec 2015 20:46:56 +0000 (23:46 +0300)]
Update AUTHORS file

8 years agoFix CMake warning about CMP0054 by unquoting instances of HOST
Andrew Buss [Mon, 21 Dec 2015 10:20:01 +0000 (02:20 -0800)]
Fix CMake warning about CMP0054 by unquoting instances of HOST

See CMake v3.1 policy CMP0054.

* CMakeLists.txt: Use HOST variable without quotes.

8 years agoReturn GC_UNIMPLEMENTED instead of abort in GC_get_stack_base (OS/2)
Ivan Maidanski [Thu, 17 Dec 2015 18:25:16 +0000 (21:25 +0300)]
Return GC_UNIMPLEMENTED instead of abort in GC_get_stack_base (OS/2)

* os_dep.c (GC_get_stack_base): Replace ABORT (in case of
DosGetInfoBlocks failure) with WARN() and return GC_UNIMPLEMENTED.

8 years agoFix typo (items numbering) in GC_finalize_all documentation
Ivan Maidanski [Fri, 4 Dec 2015 08:20:41 +0000 (11:20 +0300)]
Fix typo (items numbering) in GC_finalize_all documentation

* include/javaxfc.h (GC_finalize_all): Fix 2nd item numbering in
comment.

8 years agoRemove references to missing linux_threads.c from documentation
Ivan Maidanski [Wed, 2 Dec 2015 21:08:02 +0000 (00:08 +0300)]
Remove references to missing linux_threads.c from documentation

* README.md (copyright): Change linux_threads.c to pthread_stop_world.c
and pthread_support.c files.
* doc/README.DGUX386: Remove reference to linux-threads.c file.
* doc/README.environment (GC_RETRY_SIGNALS, GC_NO_RETRY_SIGNALS):
Likewise.
* doc/gcdescr.html: Likewise.
* doc/README.DGUX386: Update information how to pass DEBUG_THREADS to
make.
* doc/gcdescr.html: Update threads support information for Irix and
Solaris.
* include/private/gc_locks.h: Remove reference to linux-threads.c in
a comment.
* pthread_support.c: Likewise.

8 years agoRemove documentation about obsolete GC_REDIRECT_TO_LOCAL
Ivan Maidanski [Tue, 1 Dec 2015 08:49:02 +0000 (11:49 +0300)]
Remove documentation about obsolete GC_REDIRECT_TO_LOCAL

* doc/scale.html (GC_REDIRECT_TO_LOCAL): Remove documentation.
* doc/simple_example.html (GC_REDIRECT_TO_LOCAL): Likewise.

8 years agoFix missing GC_get_stack_base for Amiga
Ivan Maidanski [Thu, 26 Nov 2015 20:24:38 +0000 (23:24 +0300)]
Fix missing GC_get_stack_base for Amiga

* os_dep.c (GET_MAIN_STACKBASE_SPECIAL): Define if AMIGA (which, in
turn, causes default GC_get_stack_base to be defined).

8 years agoAdd test for thread suspend/resume API
Ivan Maidanski [Mon, 2 Nov 2015 06:31:45 +0000 (09:31 +0300)]
Add test for thread suspend/resume API

* tests/test.c (tiny_reverse_test): Call GC_gcollect (only if
GC_ENABLE_SUSPEND_THREAD).
* tests/test.c: Include "javaxfc.h" if GC_ENABLE_SUSPEND_THREAD (and
GC_PTHREADS) to GC_suspend/resume_thread declared.
* tests/test.c (fork_a_thread): Test GC_is_thread_suspended,
GC_suspend_thread, GC_resume_thread (only if the functions defined).

8 years agoCode refactoring of thread suspend/resume API support
Ivan Maidanski [Thu, 29 Oct 2015 17:33:48 +0000 (20:33 +0300)]
Code refactoring of thread suspend/resume API support

* CMakeLists.txt (enable_gcj_support): Define GC_ENABLE_SUSPEND_THREAD.
* configure.ac (enable_gcj_support): Likewise.
* doc/README.macros (GC_ENABLE_SUSPEND_THREAD): Document.
* include/gc.h (GC_suspend_thread, GC_resume_thread,
GC_is_thread_suspended): Move to javaxfc.h.
* include/gc_pthread_redirects.h (GC_SUSPEND_THREAD_ID): New macro.
* include/javaxfc.h (GC_SUSPEND_THREAD_ID): Likewise.
* include/javaxfc.h (GC_suspend_thread, GC_resume_thread,
GC_is_thread_suspended): Define if and only if GC_THREADS; refine
comment.
* include/javaxfc.h (GC_suspend_thread, GC_resume_thread,
GC_is_thread_suspended): Decorate with GC_CALL; change argument type
from pthread_t to GC_SUSPEND_THREAD_ID.
* pthread_stop_world.c (GC_suspend_thread, GC_resume_thread,
GC_is_thread_suspended): Likewise.
* pthread_stop_world.c (GC_suspend_handler): Move check for
SUSPENDED_EXT to GC_suspend_handler_inner (to avoid duplicate
GC_lookup_thread call).
* pthread_stop_world.c (suspend_self_inner, GC_TIME_LIMIT,
GC_brief_async_signal_safe_sleep, GC_suspend_thread, GC_resume_thread,
GC_is_thread_suspended): Do not defined unless
GC_ENABLE_SUSPEND_THREAD.
* pthread_stop_world.c (suspend_self): Remove (invoke
GC_do_blocking(suspend_self_inner) directly).
* pthread_stop_world.c (GC_brief_async_signal_safe_sleep): Decorate
with STATIC.
* pthread_stop_world.c (GC_suspend_thread, GC_resume_thread,
GC_is_thread_suspended): Wrap code into LOCK/UNLOCK (because, at least,
GC_lookup_thread should be called with the allocation lock held).
* pthread_stop_world.c (GC_suspend_thread, GC_resume_thread): Do not
ABORT if thread is unregistered in GC (just no-op instead).
* pthread_stop_world.c (GC_is_thread_suspended): Return 0 if thread is
not registered in GC.