platform/upstream/libgc.git
11 years agoFix GC_call_with_stack_base to prevent its tail-call optimization
Ivan Maidanski [Wed, 1 Aug 2012 19:12:22 +0000 (23:12 +0400)]
Fix GC_call_with_stack_base to prevent its tail-call optimization

* misc.c (GC_call_with_stack_base): Call GC_noop1 after fn()
invocation to prevent a tail-call optimization.

11 years agoResolve GCC warning in setjmp_t.c
Ivan Maidanski [Wed, 1 Aug 2012 05:50:01 +0000 (09:50 +0400)]
Resolve GCC warning in setjmp_t.c

* tools/setjmp_t.c (nested_sp): Change 'sp' local variable type from
int to word (to avoid 'cast from pointer to int' compiler warning).
* tools/setjmp_t.c (main): Cast pointers to unsigned long via word
type; cast WORDSZ value passed to printf() to match format type
specifier (to avoid compiler warnings).

11 years agoFix all address-of-dummy operations by adding volatile
Ivan Maidanski [Wed, 1 Aug 2012 05:42:36 +0000 (09:42 +0400)]
Fix all address-of-dummy operations by adding volatile

* alloc.c (min_bytes_allocd, GC_stopped_mark): Use volatile for
'dummy' local variable (used to get 'sp' value) to prevent any
harmful optimizations (e.g., some Mac OS X clang releases might turn
a conditional expression that uses 'dummy' address into a constant).
* dyn_load.c (GC_cond_add_roots): Likewise.
* mach_dep.c (GC_with_callee_saves_pushed): Likewise.
* misc.c (GC_clear_stack_inner, GC_init, GC_call_with_stack_base):
Likewise.
* os_dep.c (GC_get_stack_base, GC_get_main_stack_base,
async_set_pht_entry_from_index): Likewise.
* pthread_stop_world.c (nacl_pre_syscall_hook,
__nacl_suspend_thread_if_needed): Likewise.
* pthread_support.c (GC_thr_init): Likewise.
* ptr_chck.c (GC_on_stack): Likewise.
* tools/setjmp_t.c (main): Likewise.
* win32_threads.c (GC_push_stack_for): Likewise.
* dyn_load.c (dummy): Change variable type from char to int.
* include/private/gcconfig.h: Update comment about GC_stackbottom
initialization.
* os_dep.c (GC_get_stack_base): Remove 'sp' local variable.
* os_dep.c (GC_get_main_stack_base): Define and use volatile 'dummy'
variable (instead of 'result') to get 'sp' value (revert part of
commit bddc75f).
* os_dep.c (GC_get_stack_base): Add missing cast of 'dummy' address
(only if NEED_FIND_LIMIT).
* pthread_stop_world.c (GC_suspend_handler_inner): Define and use
volatile 'dummy' variable (instead of 'me') to get 'sp' value (revert
part of commit 31fc0f6).
* pthread_stop_world.c (nacl_pre_syscall_hook,
__nacl_suspend_thread_if_needed): Rename 'local_dummy' to 'dummy'
local variable.

11 years agoTODO file: Add FIXME item about deadlock on Darwin
Ivan Maidanski [Tue, 24 Jul 2012 10:07:26 +0000 (14:07 +0400)]
TODO file: Add FIXME item about deadlock on Darwin

11 years agoUpdate ChangeLog file
Ivan Maidanski [Tue, 24 Jul 2012 09:33:08 +0000 (13:33 +0400)]
Update ChangeLog file

11 years agoUpdate TODO file (regarding segfault in GC_typed_mark_proc)
Ivan Maidanski [Tue, 24 Jul 2012 09:32:37 +0000 (13:32 +0400)]
Update TODO file (regarding segfault in GC_typed_mark_proc)

11 years agoPostpone the suspend signal in GC_dirty_init only if used to stop world
Ivan Maidanski [Tue, 24 Jul 2012 09:23:12 +0000 (13:23 +0400)]
Postpone the suspend signal in GC_dirty_init only if used to stop world

* os_dep.c (GC_dirty_init): Do not call sigaddset(SIG_SUSPEND) if
no THREADS or if SIG_SUSPEND is unused for suspending threads.

11 years agoFix GC_dirty_init by avoiding GC_get_suspend_signal if no threads support
Ivan Maidanski [Tue, 24 Jul 2012 06:34:15 +0000 (10:34 +0400)]
Fix GC_dirty_init by avoiding GC_get_suspend_signal if no threads support
(fix commit '05daaee')

* os_dep.c (GC_dirty_init): Pass SIG_SUSPEND instead of
GC_get_suspend_signal() to sigaddset() if no THREADS (or if
GC_OPENBSD_THREADS, or GC_WIN32_THREADS or NACL).
* pthread_support.c (pthread_sigmask): Assert GC_get_suspend_signal()
does not return -1 (only if not GC_NO_PTHREAD_SIGMASK).

11 years agoTODO file: Refine FIXME item about OpenBSD
Ivan Maidanski [Sun, 22 Jul 2012 06:20:57 +0000 (10:20 +0400)]
TODO file: Refine FIXME item about OpenBSD

11 years agoUpdate ChangeLog file
Ivan Maidanski [Sat, 21 Jul 2012 09:32:50 +0000 (13:32 +0400)]
Update ChangeLog file

11 years agoTODO file: Update FIXME item about OpenBSD
Ivan Maidanski [Sat, 21 Jul 2012 08:02:37 +0000 (12:02 +0400)]
TODO file: Update FIXME item about OpenBSD

11 years agoDummy merge branch 'fix-logging-atexit-not-working'
Ivan Maidanski [Sat, 21 Jul 2012 07:55:56 +0000 (11:55 +0400)]
Dummy merge branch 'fix-logging-atexit-not-working'
(the solution seems to not fix the problem)

12 years agoFix stop_info.stack_ptr assignment in GC_suspend_all for OpenBSD
Ivan Maidanski [Fri, 20 Jul 2012 20:36:34 +0000 (00:36 +0400)]
Fix stop_info.stack_ptr assignment in GC_suspend_all for OpenBSD

* os_dep.c (GC_get_stack_base): Abort if pthread_stackseg_np fails
(if GC_OPENBSD_THREADS).
* pthread_stop_world.c (GC_suspend_all): Get correct stack_ptr by
calling pthread_stackseg_np (subtracting ss_size from ss_sp) instead
of retrieving it from OpenBSD pthread implementation-dependent context
(if GC_OPENBSD_THREADS); remove test of stack_ptr and comment.

12 years agoTest SP obtained from OpenBSD-specific pthread context in GC_suspend_all
Ivan Maidanski [Fri, 20 Jul 2012 11:27:54 +0000 (15:27 +0400)]
Test SP obtained from OpenBSD-specific pthread context in GC_suspend_all

* pthread_stop_world.c (GC_suspend_all): Abort if stop_info.stack_ptr
obtained from OpenBSD-specific pthread context is NULL; add FIXME for
GC_OPENBSD_THREADS case (the implementation should probably use
pthread_sp_np).

12 years agoReplace sprintf with defensive snprintf
Ivan Maidanski [Fri, 20 Jul 2012 10:23:10 +0000 (14:23 +0400)]
Replace sprintf with defensive snprintf

* dyn_load.c (GC_register_dynamic_libraries): Replace sprintf with
snprintf add put traling '\0' to buffer to prevent buffer overrun;
cast snprintf result to void (to suppress compiler warning).
* cord/tests/cordtest.c (test_printf): Likewise.
* os_dep.c (GC_print_callers): Likewise.
* os_dep.c (GC_dirty_init): Likewise (if PROC_VDB).
* dyn_load.c (GC_dyld_image_add, GC_dyld_image_remove): Put trailing
'\0' to buffer and cast snprintf result to void (Darwin).

12 years agoSuppress GCC warning in GC_get_main_stack_base (OpenBSD)
Ivan Maidanski [Fri, 20 Jul 2012 09:09:18 +0000 (13:09 +0400)]
Suppress GCC warning in GC_get_main_stack_base (OpenBSD)

* include/private/gcconfig.h (STACKBOTTOM): Cast USRSTACK to ptr_t if
OPENBSD (to suppress GCC warning in GC_get_main_stack_base).

12 years agoUse memcpy (BCOPY) instead of strcpy (to suppress GCC warning)
Ivan Maidanski [Fri, 20 Jul 2012 08:59:46 +0000 (12:59 +0400)]
Use memcpy (BCOPY) instead of strcpy (to suppress GCC warning)

* cord/cordbscs.c (CORD_from_fn, CORD_substr_checked): Use memcpy
instead of strcpy (to suppress GCC/ld warning
"strcpy() is almost always misused").
* dbg_mlc.c (GC_debug_strdup): Replace strcpy and memcpy with
cross-platform BCOPY (with reversed order of "src" and "dest"
arguments).
* mallocx.c (GC_strdup): Likewise.
* misc.c (GC_envfile_init, GC_CreateLogFile): Likewise.
* os_dep.c (GC_print_callers): Likewise.

12 years agoInclude pthread_np.h from pthread_stop_world.c on OpenBSD
Ivan Maidanski [Fri, 20 Jul 2012 07:22:24 +0000 (11:22 +0400)]
Include pthread_np.h from pthread_stop_world.c on OpenBSD

* pthread_stop_world.c: Include pthread_np.h if GC_OPENBSD_THREADS to
get pthread_suspend_np() and pthread_resume_np() declarations.

12 years agoDisable find-leak GC_gcollect on GC abnormal EXIT
Ivan Maidanski [Fri, 20 Jul 2012 07:10:10 +0000 (11:10 +0400)]
Disable find-leak GC_gcollect on GC abnormal EXIT

* misc.c (GC_exit_check): Test GC_find_leak, if it is switched off
then do not invoke GC_gcollect.
* misc.c (GC_default_on_abort): Explicitly turn off GC_find_leak to
prevent redundant garbage collection on EXIT (caused by some GC
failure).

12 years agoCode refactoring of GC_x_printf (move shared code to macro)
Ivan Maidanski [Thu, 19 Jul 2012 09:48:07 +0000 (13:48 +0400)]
Code refactoring of GC_x_printf (move shared code to macro)

* misc.c (GC_PRINTF_IMPL): New macro (used by GC_[err/log_]printf
only); copy code from GC_err_printf parametrizing output stream.
* misc.c (GC_printf, GC_err_printf, GC_log_printf): Replace shared
code with GC_PRINTF_IMPL macro usage.

12 years agoCode refactoring of GC_x_printf (move shared code to macro)
Ivan Maidanski [Thu, 19 Jul 2012 09:48:07 +0000 (13:48 +0400)]
Code refactoring of GC_x_printf (move shared code to macro)

* misc.c (GC_PRINTF_IMPL): New macro (used by GC_[err/log_]printf
only); copy code from GC_err_printf parametrizing output stream.
* misc.c (GC_printf, GC_err_printf, GC_log_printf): Replace shared
code with GC_PRINTF_IMPL macro usage.

12 years agoFix GC_err_printf called from atexit hook by duping GC_stderr (Unix)
Ivan Maidanski [Wed, 18 Jul 2012 15:41:43 +0000 (19:41 +0400)]
Fix GC_err_printf called from atexit hook by duping GC_stderr (Unix)

* misc.c: Include unistd.h if UNIX_LIKE (or CYGWIN32 or SYMBIAN) for
dup() prototype.
* misc.c (GC_init): Test "GC_FIND_LEAK" environment variable before
that for "GC_LOG_FILE" (since the block for the latter uses
GC_find_leak value).
* misc.c (GC_init): Invoke dup (only if UNIX_LIKE or CYGWIN32 or
SYMBIAN) for GC_stderr and GC_stdout in case of GC_find_leak but
when GC_stdout/err are not redirected to a file (to workaround
outputting to closed stderr/out file descriptor when GC_gcollect
(GC_print_callers) is called from atexit hook); add comment.

12 years agoTODO: Add FIXME items for FreeBSD and OpenBSD
Ivan Maidanski [Wed, 18 Jul 2012 14:06:46 +0000 (18:06 +0400)]
TODO: Add FIXME items for FreeBSD and OpenBSD

12 years agoUpdate ChangeLog file
Ivan Maidanski [Sat, 14 Jul 2012 08:57:57 +0000 (12:57 +0400)]
Update ChangeLog file

12 years agoRecognize GC_SIG_SUSPEND and GC_SIG_THR_RESTART tuning macros in gc.h
Ivan Maidanski [Sat, 14 Jul 2012 08:51:01 +0000 (12:51 +0400)]
Recognize GC_SIG_SUSPEND and GC_SIG_THR_RESTART tuning macros in gc.h

* include/gc.h (GC_SIG_SUSPEND, GC_SIG_THR_RESTART): New micro
recognized to tune GC_INIT with the non-default signal to be used by
GC to suspend (and resume, respectively) threads (only if GC_THREADS).
* include/gc.h (GC_INIT_CONF_SUSPEND_SIGNAL,
GC_INIT_CONF_THR_RESTART_SIGNAL): New macro (used internally by
GC_INIT).
* include/gc.h (GC_INIT): Invoke GC_INIT_CONF_SUSPEND_SIGNAL and
GC_INIT_CONF_THR_RESTART_SIGNAL before GC_init().

12 years agoMerge branch 'add-signals-setters'
Ivan Maidanski [Sat, 14 Jul 2012 08:11:00 +0000 (12:11 +0400)]
Merge branch 'add-signals-setters'

12 years agoDummy merge remote-tracking branch 'jcbeaudoin/signals_init'
Ivan Maidanski [Wed, 4 Jul 2012 16:55:02 +0000 (20:55 +0400)]
Dummy merge remote-tracking branch 'jcbeaudoin/signals_init'

12 years agoAdd thread suspend/resume signals public setters (POSIX threads)
Jean-Claude Beaudoin [Wed, 4 Jul 2012 16:53:57 +0000 (20:53 +0400)]
Add thread suspend/resume signals public setters (POSIX threads)

* include/gc.h (GC_set_suspend_signal, GC_set_thr_restart_signal):
Add public function declaration (to specify non-default signals to
suspend/resume threads).
* include/gc.h (GC_get_suspend_signal, GC_get_thr_restart_signal):
Update comment.
* misc.c (GC_set_suspend_signal, GC_set_thr_restart_signal): Add
public no-op function (only for Darwin, OpenBSD, Win32 and NaCl).
* pthread_stop_world.c (GC_set_suspend_signal,
GC_set_thr_restart_signal): Add public setter to alter the default
signals used to suspend and resume threads (only if not OpenBSD or
NaCl); has no effect if GC is initialized.

12 years agoMove GC_get_suspend/thr_restart_signal to misc.c for NaCl and OpenBSD
Ivan Maidanski [Wed, 4 Jul 2012 15:59:34 +0000 (19:59 +0400)]
Move GC_get_suspend/thr_restart_signal to misc.c for NaCl and OpenBSD

* misc.c (GC_get_suspend_signal, GC_get_thr_restart_signal): Define
also for OpenBSD and NaCl targets in this file (always returns -1).
* pthread_stop_world.c (GC_get_suspend_signal,
GC_get_thr_restart_signal): Move function definition up to the
definition of GC_sig_suspend and GC_sig_thr_restart variables (i.e.,
define function only if not OpenBSD and not NaCl target in this file).

12 years agoReplace SIG_SUSPEND macro to a variable in pthread_stop_world
Ivan Maidanski [Wed, 4 Jul 2012 15:00:41 +0000 (19:00 +0400)]
Replace SIG_SUSPEND macro to a variable in pthread_stop_world

* misc.c (GC_get_suspend_signal): Define (as always returning -1) in
this file only if Darwin or Win32 threads.
* os_dep.c (GC_dirty_init): Replace SIG_SUSPEND with the value of
GC_get_suspend_signal() invocation.
* pthread_support.c (pthread_sigmask): Likewise.
* pthread_stop_world.c (GC_sig_suspend): New STATIC variable (only
unless NaCl or OpenBSD) initialized to SIG_SUSPEND.
* pthread_stop_world.c (GC_unblock_gc_signals,
GC_suspend_handler_inner, GC_suspend_all, GC_stop_init): Use
GC_sig_suspend instead of SIG_SUSPEND (only unless NaCl or OpenBSD);
update comment.
* pthread_stop_world.c (GC_get_suspend_signal): Define function (which
returns GC_sig_suspend if available).

12 years agoReplace SIG_THR_RESTART macro to a variable in pthread_stop_world
Ivan Maidanski [Wed, 4 Jul 2012 04:33:33 +0000 (08:33 +0400)]
Replace SIG_THR_RESTART macro to a variable in pthread_stop_world

* pthread_stop_world.c (GC_sig_thr_restart): New STATIC variable
(only unless NaCl or OpenBSD) initialized to SIG_THR_RESTART.
* pthread_stop_world.c (GC_unblock_gc_signals,
GC_suspend_handler_inner, GC_restart_handler, GC_start_world,
GC_stop_init, GC_get_thr_restart_signal): Use GC_sig_thr_restart
instead of SIG_THR_RESTART (only unless NaCl or OpenBSD); update
comment.

12 years agoFixed typo in restart signal setter function name.
Jean-Claude Beaudoin [Tue, 3 Jul 2012 01:38:55 +0000 (21:38 -0400)]
Fixed typo in restart signal setter function name.

12 years agoExtend new suspend/restart signal macro redirection to other OSes beyond Linux.
Jean-Claude Beaudoin [Tue, 3 Jul 2012 01:36:10 +0000 (21:36 -0400)]
Extend new suspend/restart signal macro redirection to other OSes beyond Linux.

12 years agoUpdate ChangeLog file
Ivan Maidanski [Sat, 30 Jun 2012 14:35:24 +0000 (18:35 +0400)]
Update ChangeLog file

12 years agoMerge branch 'add-abort-exit-setters'
Ivan Maidanski [Sat, 30 Jun 2012 14:32:13 +0000 (18:32 +0400)]
Merge branch 'add-abort-exit-setters'

12 years agoUpdate ChangeLog file
Ivan Maidanski [Wed, 27 Jun 2012 19:44:45 +0000 (23:44 +0400)]
Update ChangeLog file

12 years agoUpdate ChangeLog file
Ivan Maidanski [Tue, 26 Jun 2012 13:29:12 +0000 (17:29 +0400)]
Update ChangeLog file

12 years agoDummy merge branch 'jcbeaudoin/exit_abort_hooks'
Ivan Maidanski [Sun, 24 Jun 2012 09:45:33 +0000 (13:45 +0400)]
Dummy merge branch 'jcbeaudoin/exit_abort_hooks'
(superseded by functionality added in commit d020903)

12 years agoAdd public GC_set/get_abort_func to replace default GC_on_abort
Ivan Maidanski [Sat, 23 Jun 2012 18:42:36 +0000 (22:42 +0400)]
Add public GC_set/get_abort_func to replace default GC_on_abort

* include/gc.h (GC_abort_func): New public typedef.
* include/gc.h (GC_set_abort_func, GC_get_abort_func): New API
function declaration.
* include/private/gc_priv.h (GC_on_abort): Change function
declaration to function pointer of GC_abort_func type (only if
SMALL_CONFIG and not PCR).
* misc.c (GC_on_abort): Rename to GC_default_on_abort; make it STATIC
and decorate with GC_CALLBACK; define GC_on_abort variable initialized
to GC_default_on_abort (only if SMALL_CONFIG and not PCR).
* misc.c (GC_set_abort_func, GC_get_abort_func): New public function
(only if if SMALL_CONFIG and not PCR) to alter and read GC_on_abort
value.

12 years agoTurn off GC_LOOP_ON_ABORT functionality if GC compiled with NO_DEBUGGING
Ivan Maidanski [Sun, 24 Jun 2012 09:04:32 +0000 (13:04 +0400)]
Turn off GC_LOOP_ON_ABORT functionality if GC compiled with NO_DEBUGGING

* misc.c (looping_handler, installed_looping_handler): Do not define
if NO_DEBUGGING.
* misc.c (maybe_install_looping_handler): Define as an empty macro if
NO_DEBUGGING.
* misc.c (GC_on_abort): Do not test "GC_LOOP_ON_ABORT" environment
variable if GC_LOOP_ON_ABORT.

12 years agoCall GC_on_abort (with NULL argument) on exit(1)
Ivan Maidanski [Sun, 24 Jun 2012 08:49:10 +0000 (12:49 +0400)]
Call GC_on_abort (with NULL argument) on exit(1)

* include/private/gc_priv.h (EXIT): Call GC_on_abort(NULL) before
exit(1) (unless PCR) enabling the collector to enter a tight loop
(for debugging purpose) on abnormal EXIT if "GC_LOOP_ON_ABORT"
environment variable is set.
* misc.c (GC_on_abort): Allow "msg" argument to be NULL (skip
printing the message in such a case); update comment.

12 years agoBetter handling in signal setter/getter of non-signal-using OSes.
Jean-Claude Beaudoin [Sun, 24 Jun 2012 07:28:11 +0000 (03:28 -0400)]
Better handling in signal setter/getter of non-signal-using OSes.

12 years agoSegregated suspend/restart signal init changes into their own branch.
Jean-Claude Beaudoin [Sun, 24 Jun 2012 07:15:46 +0000 (03:15 -0400)]
Segregated suspend/restart signal init changes into their own branch.

12 years agoAdded documentation to abort and exit callback hook declarations.
Jean-Claude Beaudoin [Sun, 24 Jun 2012 06:32:51 +0000 (02:32 -0400)]
Added documentation to abort and exit callback hook declarations.

12 years agoAdded getters for exit and abort callback hooks.
Jean-Claude Beaudoin [Sun, 24 Jun 2012 04:08:50 +0000 (00:08 -0400)]
Added getters for exit and abort callback hooks.

12 years agoSegregated exit and abort hooks changes into their own branch
Jean-Claude Beaudoin [Sun, 24 Jun 2012 03:34:50 +0000 (23:34 -0400)]
Segregated exit and abort hooks changes into their own branch

12 years agoReplace exit(1) with EXIT call in catch_exception_raise (code refactoring)
Ivan Maidanski [Sat, 23 Jun 2012 19:37:30 +0000 (23:37 +0400)]
Replace exit(1) with EXIT call in catch_exception_raise (code refactoring)

* os_dep.c (catch_exception_raise): Replace exit(EXIT_FAILURE) call
with EXIT() macro call.

12 years agoAdded GC_CALLBACK to abort() and exit() callback hooks typedefs.
Jean-Claude Beaudoin [Fri, 22 Jun 2012 04:53:57 +0000 (00:53 -0400)]
Added GC_CALLBACK to abort() and exit() callback hooks typedefs.

12 years agoFixed STATIC style for exit() and abort() callback hooks.
Jean-Claude Beaudoin [Fri, 22 Jun 2012 04:40:04 +0000 (00:40 -0400)]
Fixed STATIC style for exit() and abort() callback hooks.

12 years agoAdded abort() and exit() callback hooks.
Jean-Claude Beaudoin [Fri, 22 Jun 2012 03:16:32 +0000 (23:16 -0400)]
Added abort() and exit() callback hooks.
Added SIG_SUSPEND and SIG_THR_RESTART configuration at GC_init() time.

12 years agoFix thread-related tests for pthreads-w32
Ivan Maidanski [Sun, 17 Jun 2012 16:25:09 +0000 (20:25 +0400)]
Fix thread-related tests for pthreads-w32

* tests/initsecondarythread.c: Include "private/config.h" if
HAVE_CONFIG_H (mostly to have GC_WIN32_PTHREADS defined for
pthreads-w32 target).
* tests/thread_leak_test.c: Likewise.
* tests/threadkey_test.c: Likewise.

12 years agotools: Include proper header file for configuration macros
Ivan Maidanski [Sat, 16 Jun 2012 09:35:53 +0000 (13:35 +0400)]
tools: Include proper header file for configuration macros

* tools/if_mach.c: Include private/gc_priv.h instead of
private/gcconfig.h (to get proper configuration macros defined).
* tools/if_not_there.c: Likewise.
* tools/threadlibs.c: Likewise.
* tools/threadlibs.c: Do not include gc_config_macros.h directly.

12 years agotest_cpp: Fix WinMain to prevent SEGV if zero arguments passed (MinGW)
Ivan Maidanski [Sat, 16 Jun 2012 08:54:36 +0000 (12:54 +0400)]
test_cpp: Fix WinMain to prevent SEGV if zero arguments passed (MinGW)

* tests/test_cpp.cc (WinMain): Prevent SEGV in strtok() by checking
"cmd" WinMain argument for NULL (in that case "argc" local variable is
set to 0).

12 years agoFix test_cpp (ensure the collector recognizes pointers to interiors)
Ivan Maidanski [Sat, 16 Jun 2012 08:34:06 +0000 (12:34 +0400)]
Fix test_cpp (ensure the collector recognizes pointers to interiors)

* tests/test_cpp.cc (main): Call GC_set_all_interior_pointers(1)
before GC_INIT to ensure that the collector considers pointers to
object interiors as valid ones (such a pointer could emerge as
a result of a type cast to subclass in case of multiple inheritance);
add comment.

12 years agocord tests: Suppress GCC warnings in 'de' app
Ivan Maidanski [Sat, 16 Jun 2012 07:57:18 +0000 (11:57 +0400)]
cord tests: Suppress GCC warnings in 'de' app

* cord/tests/de.c (retrieve_line): Change type of "eol" local variable
from int to size_t (to prevent "comparison between signed and unsigned"
compiler warning).
* cord/tests/de_win.c (WinMain): Cast GetLastError() result to
unsigned int (to match printf format specifier).
* cord/tests/de_win.c (AboutBoxCallback): Suppress "unused parameter"
compiler warning for "lParam" (by casting the later to void).

12 years agotest_cpp: Suppress GCC warnings in WinMain
Ivan Maidanski [Fri, 15 Jun 2012 14:24:18 +0000 (18:24 +0400)]
test_cpp: Suppress GCC warnings in WinMain

* tests/test_cpp.cc (ATTR_UNUSED): New macro.
* tests/test_cpp.cc (WinMain): Tag "instance", "prev" and "cmdShow"
arguments with ATTR_UNUSED.
* tests/test_cpp.cc (WinMain): Explicitly cast "xio", "f", "d", "a"
local variables to void (to suppress "variable set but not used"
compiler warning).

12 years agoUpdate ChangeLog file
Ivan Maidanski [Sat, 9 Jun 2012 18:17:01 +0000 (22:17 +0400)]
Update ChangeLog file

12 years agoRecognize GC_DONT_GC macro in gc.h (causes GC_INIT to turn off GC)
Ivan Maidanski [Sat, 9 Jun 2012 18:13:53 +0000 (22:13 +0400)]
Recognize GC_DONT_GC macro in gc.h (causes GC_INIT to turn off GC)

* include/gc.h (GC_INIT_CONF_MAX_RETRIES): Recognize GC_DONT_GC
(set GC_dont_gc to 1 in that case) to turn off GC at start-up (for
a debugging purpose).

12 years agoUpdate ChangeLog file
Ivan Maidanski [Fri, 8 Jun 2012 17:27:06 +0000 (21:27 +0400)]
Update ChangeLog file

12 years agoAdd comment in GC_memalign
Ivan Maidanski [Fri, 8 Jun 2012 17:13:14 +0000 (21:13 +0400)]
Add comment in GC_memalign

* mallocx.c (GC_memalign): Add comment for GC_malloc invocation result.

12 years agoFix CORD_cat_char_star to prevent SEGV in case of out-of-memory
Ivan Maidanski [Fri, 8 Jun 2012 17:10:17 +0000 (21:10 +0400)]
Fix CORD_cat_char_star to prevent SEGV in case of out-of-memory

* cordbscs.c (CORD_cat_char_star): Check GC_MALLOC_ATOMIC result for
NULL (do OUT_OF_MEMORY in such case) to prevent SEGV.

12 years agoUpdate ChangeLog file
Ivan Maidanski [Thu, 7 Jun 2012 19:02:55 +0000 (23:02 +0400)]
Update ChangeLog file

12 years agoFix GC_scratch_alloc and GC_get_maps invocations to prevent SEGV
Ivan Maidanski [Thu, 7 Jun 2012 18:00:37 +0000 (22:00 +0400)]
Fix GC_scratch_alloc and GC_get_maps invocations to prevent SEGV
(if out of memory)

* dyn_load.c (GC_register_dynamic_libraries): If GC_scratch_alloc
fails (returns null) then abort (with the appropriate message) instead
of causing SEGV.
* os_dep.c (GC_dirty_init): Likewise.
* headers.c (GC_init_headers): Report error and exit if
GC_scratch_alloc fails.
* include/private/gc_priv.h (GC_scratch_alloc): Improve comment.
* os_dep.c (GC_print_address_map): If GC_get_maps return null then
print the appropriate message (instead of passing null to GC_err_puts
thus causing SEGV).

12 years agoUpdate ChangeLog file
Ivan Maidanski [Sun, 3 Jun 2012 13:55:00 +0000 (17:55 +0400)]
Update ChangeLog file

12 years agoAdd public setter and getter for GC_push_other_roots
Ivan Maidanski [Sat, 2 Jun 2012 16:21:18 +0000 (20:21 +0400)]
Add public setter and getter for GC_push_other_roots

* include/gc_mark.h (GC_push_other_roots_proc): New type.
* include/gc_mark.h (GC_set_push_other_roots,
GC_get_push_other_roots): New API function (unsynchronized).
* os_dep.c (GC_set_push_other_roots, GC_get_push_other_roots):
Likewise.
* include/private/gc_priv.h (GC_push_other_roots): Declare using
GC_push_other_roots_proc type .
* os_dep.c (GC_push_other_roots): Likewise.
* os_dep.c (GC_default_push_other_roots): Use GC_CALLBACK calling
convention.

12 years agoAdd GC_push_all/conditional() to GC public API
Ivan Maidanski [Sat, 2 Jun 2012 15:27:57 +0000 (19:27 +0400)]
Add GC_push_all/conditional() to GC public API

* include/gc_mark.h (GC_push_all, GC_push_conditional): Expose
function as a part of public API (use GC_API and GC_CALL); replace
internal ptr_t and GC_bool type to char* and int, respectively; add
comment.
* mark.c (GC_push_all, GC_push_conditional): Likewise.
* include/private/gc_priv.h (GC_push_all, GC_push_conditional): Remove
function declaration.
* include/private/gc_priv.h (GC_PUSH_CONDITIONAL): New macro used
internally instead of GC_push_conditional (defined depending on
GC_DISABLE_INCREMENTAL).
* include/private/gc_priv.h (GC_PUSH_CONDITIONAL, GC_push_all_stack):
Update comment.
* mark.c (GC_push_conditional): Define for GC_DISABLE_INCREMENTAL case
(rediect to GC_push_all).
* mark_rts.c (GC_push_conditional_with_exclusions): Use
GC_PUSH_CONDITIONAL() instead of GC_push_conditional().
* mark_rts.c (GC_push_roots): Reformat the comment.

12 years agoFix visibility of GC_push_all/conditional, GC_push_other_roots symbols
Ivan Maidanski [Sat, 2 Jun 2012 08:33:03 +0000 (12:33 +0400)]
Fix visibility of GC_push_all/conditional, GC_push_other_roots symbols

* include/private/gc_priv.h (GC_push_all, GC_push_other_roots):
Declare as GC_API_PRIV (instead of GC_INNER) to make the symbol
externally visible to some well-known 3rd-party software (e.g., ECL).
* include/private/gc_priv.h (GC_push_conditional): Declare as
GC_API_PRIV (only if GC_DISABLE_INCREMENTAL is undefined).
* mark.c (GC_push_all, GC_push_conditional): Remove GC_INNER (to match
the declaration).
* os_dep.c (GC_push_other_roots): Likewise.

12 years agoUpdate AUTHORS file
Ivan Maidanski [Sat, 2 Jun 2012 09:21:08 +0000 (13:21 +0400)]
Update AUTHORS file

12 years agoFix GC_FirstDLOpenedLinkMap() for NetBSD 6 release
Tsugutomo Enami [Sat, 2 Jun 2012 09:31:43 +0000 (13:31 +0400)]
Fix GC_FirstDLOpenedLinkMap() for NetBSD 6 release
(this empty commit contains only the fixed message for the previous commit)

* dyn_load.c: Include sys/param.h and dlfcn.h on NetBSD.
* dyn_load.c (GC_FirstDLOpenedLinkMap): Obtain link map using dlinfo()
on NetBSD if RTLD_DI_LINKMAP feature present (defined).

12 years agoFix GC_FirstDLOpenedLinkMap() for FreeBSD 9 release
Tsugutomo Enami [Thu, 31 May 2012 23:12:24 +0000 (03:12 +0400)]
Fix GC_FirstDLOpenedLinkMap() for FreeBSD 9 release

* dyn_load.c: Include sys/param.h and dlfcn.h on FreeBSD.
* dyn_load.c (GC_FirstDLOpenedLinkMap): Obtain link map using dlinfo()
on FreeBSD if RTLD_DI_LINKMAP feature present (defined).

12 years agoUpdate ChangeLog file
Ivan Maidanski [Fri, 25 May 2012 04:46:56 +0000 (08:46 +0400)]
Update ChangeLog file

12 years agoFix assertion in GC_malloc_[atomic_]uncollectable (THREADS case only)
Ivan Maidanski [Wed, 16 May 2012 04:34:10 +0000 (08:34 +0400)]
Fix assertion in GC_malloc_[atomic_]uncollectable (THREADS case only)

* malloc.c (GC_malloc_uncollectable): Do not check assertion on
hb_n_marks to be zero if multi-threaded; add comment.
* mallocx.c (GC_malloc_atomic_uncollectable): Likewise.

12 years agoBump libgc version
Ivan Maidanski [Tue, 15 May 2012 07:42:52 +0000 (11:42 +0400)]
Bump libgc version

* README: Bump version to 7.3alpha3.
* configure.ac: Likewise.
* include/gc_version.h (GC_TMP_ALPHA_VERSION): Likewise.

12 years agoBump libgc version to 7.3alpha2 gc7_3alpha2
Ivan Maidanski [Fri, 11 May 2012 17:44:19 +0000 (21:44 +0400)]
Bump libgc version to 7.3alpha2

* ChangeLog: Set release dates.
* README: Bump version.
* configure.ac: Likewise.
* include/gc_version.h (GC_TMP_ALPHA_VERSION): Likewise.

12 years agoUpdate ChangeLog file
Ivan Maidanski [Tue, 1 May 2012 15:10:09 +0000 (19:10 +0400)]
Update ChangeLog file

12 years agoSet GC_GRANULE_BYTES/GC_GRANULE_WORDS for x32
H.J. Lu [Mon, 16 Apr 2012 16:27:45 +0000 (09:27 -0700)]
Set GC_GRANULE_BYTES/GC_GRANULE_WORDS for x32

* include/gc_tiny_fl.h (GC_GRANULE_BYTES): Set to 8 for x32.
(GC_GRANULE_WORDS): Set to 2 for x32.

12 years agoDefine ALIGNMENT and CPP_WORDSZ for x32
H.J. Lu [Mon, 16 Apr 2012 16:26:07 +0000 (09:26 -0700)]
Define ALIGNMENT and CPP_WORDSZ for x32

* include/private/gcconfig.h: (ALIGNMENT): Set to 4 for x32.
(CPP_WORDSZ): Set to 32 for x32.

12 years agoMerge commit 'paurkedal/fix-freelist-check-and-specific'
Ivan Maidanski [Mon, 30 Apr 2012 15:38:31 +0000 (19:38 +0400)]
Merge commit 'paurkedal/fix-freelist-check-and-specific'

12 years agoUpdate ChangeLog file
Ivan Maidanski [Sun, 29 Apr 2012 14:19:02 +0000 (18:19 +0400)]
Update ChangeLog file

12 years agoMerge branch 'freebsd-use-pthread-specific'
Ivan Maidanski [Sun, 29 Apr 2012 13:40:06 +0000 (17:40 +0400)]
Merge branch 'freebsd-use-pthread-specific'

12 years agoMerge branch 'fix-freelist-check-and-specific'
Ivan Maidanski [Sun, 29 Apr 2012 13:39:20 +0000 (17:39 +0400)]
Merge branch 'fix-freelist-check-and-specific'

12 years agoAdd two missing GC_start_debugging() calls.
Petter Urkedal [Sun, 29 Apr 2012 11:30:39 +0000 (13:30 +0200)]
Add two missing GC_start_debugging() calls.

* dbg_mlc.c (GC_debug_generic_malloc_inner): Add GC_start_debugging() if not
done.  This fixes the missing registration of the debug header displacement.
* dbg_mlc.c (GC_debug_generic_malloc_inner_ignore_off_page): Ditto.

12 years agoFix USE_CUSTOM_SPECIFIC mode (if manually enabled) for Win32
Ivan Maidanski [Sat, 21 Apr 2012 16:18:55 +0000 (20:18 +0400)]
Fix USE_CUSTOM_SPECIFIC mode (if manually enabled) for Win32

* win32_threads.c (GC_unregister_my_thread,
GC_remove_all_threads_but_me, GC_thread_exit_proc): Invoke
GC_remove_specific (if THREAD_LOCAL_ALLOC) after destroying
thread-local list (same as in pthread_support.c).

12 years agoUpdate ChangeLog file
Ivan Maidanski [Sun, 22 Apr 2012 11:52:18 +0000 (15:52 +0400)]
Update ChangeLog file

12 years agoUpdate TODO file (add FIXME item)
Ivan Maidanski [Sun, 22 Apr 2012 07:47:10 +0000 (11:47 +0400)]
Update TODO file (add FIXME item)

12 years agoUse USE_COMPILER_TLS on Cygwin
Ivan Maidanski [Sun, 22 Apr 2012 07:32:08 +0000 (11:32 +0400)]
Use USE_COMPILER_TLS on Cygwin

* include/private/thread_local_alloc.h (USE_COMPILER_TLS): Define for
Cygwin by default (only starting from GCC v4).

12 years agoUse pthread_key for thread-local storage on FreeBSD
Ivan Maidanski [Sun, 22 Apr 2012 06:14:15 +0000 (10:14 +0400)]
Use pthread_key for thread-local storage on FreeBSD

* include/private/thread_local_alloc.h (USE_PTHREAD_SPECIFIC): Define
for FreeBSD by default (instead of USE_CUSTOM_SPECIFIC).

12 years agoAdd assertion in GC_getspecific on qtid
Ivan Maidanski [Sat, 21 Apr 2012 19:51:41 +0000 (23:51 +0400)]
Add assertion in GC_getspecific on qtid

* include/private/specific.h (GC_getspecific): Add assertion on "qtid"
value.

12 years agoCode refactoring of specific.c and specific.h;
Ivan Maidanski [Sat, 21 Apr 2012 19:44:19 +0000 (23:44 +0400)]
Code refactoring of specific.c and specific.h;
cast pointers to word instead of unsigned long

* include/private/specific.h (CACHE_HASH, HASH): Add parentheses
around the argument.
* include/private/specific.h (CACHE_HASH): Remove unnecessary cast to
long.
* include/private/specific.h (HASH): Rename "n" argument to "p";
cast "p" to word instead of long; cast result to unsigned.
* include/private/specific.h (quick_thread_id, INVALID_QTID): Cast to
word instead of unsigned long.
* specific.c (GC_key_create_inner): Cast invalid_tse.next (pointer) to
word instead of unsigned long.
* include/private/specific.h (GC_slow_getspecific, GC_getspecific):
Change type of "qtid" from unsigned long to word.
* specific.c (GC_slow_getspecific): Likewise.
* include/private/specific.h (GC_getspecific): Remove "hash_val"
local variable.
* specific.c: Do not include gc_priv.h as included from
thread_local_alloc.h; do not include atomic_ops.h as included from
specific.h file.

12 years agoFix USE_CUSTOM_SPECIFIC mode (if manually enabled) for Win32
Ivan Maidanski [Sat, 21 Apr 2012 16:18:55 +0000 (20:18 +0400)]
Fix USE_CUSTOM_SPECIFIC mode (if manually enabled) for Win32

* win32_threads.c (GC_unregister_my_thread,
GC_remove_all_threads_but_me, GC_thread_exit_proc): Invoke
GC_remove_specific (if THREAD_LOCAL_ALLOC) after destroying
thread-local list (same as in pthread_support.c).

12 years agoFix GC_remove_all_threads_but_me to cleanup thread-specific data storage
Ivan Maidanski [Sat, 21 Apr 2012 15:57:25 +0000 (19:57 +0400)]
Fix GC_remove_all_threads_but_me to cleanup thread-specific data storage

* pthread_support.c (GC_remove_all_threads_but_me): Call
GC_remove_specific after destroying thread-local list.

12 years agoFix GC_setspecific to prevent garbage collection inside
Ivan Maidanski [Sat, 21 Apr 2012 10:31:26 +0000 (14:31 +0400)]
Fix GC_setspecific to prevent garbage collection inside

* specific.c (GC_setspecific): Call MALLOC_CLEAR with GC temporarily
disabled; add comment about lock.

12 years agoInclude atomic_ops.h if THREAD_LOCAL_ALLOC to enable GC_check_fl_marks
Ivan Maidanski [Sat, 21 Apr 2012 09:45:49 +0000 (13:45 +0400)]
Include atomic_ops.h if THREAD_LOCAL_ALLOC to enable GC_check_fl_marks

* include/private/gc_priv.h: Include atomic_ops.h if GC_ASSERTIONS
and THREAD_LOCAL_ALLOC to make AO_load available to GC_check_fl_marks.

12 years agoDummy merge branch 'paurkedal/fix-freelist-checks'
Ivan Maidanski [Sat, 21 Apr 2012 09:31:38 +0000 (13:31 +0400)]
Dummy merge branch 'paurkedal/fix-freelist-checks'

12 years agoFix GC_check_fl_marks regarding concurrent access
Petter Urkedal [Sat, 21 Apr 2012 09:28:12 +0000 (13:28 +0400)]
Fix GC_check_fl_marks regarding concurrent access

* alloc.c (GC_check_fl_marks): Re-read each pointer atomically before
following the pointed-to link and bail out if the result is different
(this can happen if the thread has popped the object off the
free-list); the function is a no-op if AO_load is unavailable.

12 years agoCode refactoring of GC_check_tls_for/GC_check_fl_marks
Ivan Maidanski [Fri, 20 Apr 2012 05:12:47 +0000 (09:12 +0400)]
Code refactoring of GC_check_tls_for/GC_check_fl_marks

* alloc.c (GC_check_fl_marks): Change prototype (pass pointer to
"freelist" element instead of value); do not define the function if
THREAD_LOCAL_ALLOC undefined.
* include/private/gc_priv.h (GC_check_fl_marks): Likewise.
* alloc.c (GC_check_fl_marks): Skip check if the argument points to
a special (non-pointer) value; update comment; rename "q" local
variable to "list".
* thread_local_alloc.c (GC_check_tls_for): Update code according to
GC_check_fl_marks functionality change (remove checks for special
value).

12 years agoCode refactoring of GC_generic_malloc_inner (eliminate recursion)
Ivan Maidanski [Fri, 20 Apr 2012 04:53:46 +0000 (08:53 +0400)]
Code refactoring of GC_generic_malloc_inner (eliminate recursion)

* malloc.c (GC_generic_malloc_inner): Update "lg" value after GC_init
and GC_extend_size_map calls; add assertion on "lg" value after
GC_extend_size_map call; update "opp" and "op" values and retry
allocation instead of recursive call; replace "goto" with return
(remove "out" label).

12 years agoFix checks of thread-local free-lists.
Petter Urkedal [Fri, 20 Apr 2012 08:03:28 +0000 (10:03 +0200)]
Fix checks of thread-local free-lists.

* include/private/gc_priv.h, alloc.c (GC_check_fl_marks): Re-read each
pointer before following the pointed-to link, and bail out if the result is
different.  This can happen if the thread has popped the object off the
free-list.  The prototype is changed to allow re-reading the pointers.
* thread_local_alloc.c (GC_check_tls_for): Adjust the calls accordingly.

12 years agoUpdate AUTHORS file
Ivan Maidanski [Tue, 17 Apr 2012 04:04:47 +0000 (08:04 +0400)]
Update AUTHORS file

12 years agoMinor code refactoring regarding HAVE_BUILTIN_UNWIND_INIT
Ivan Maidanski [Tue, 17 Apr 2012 03:52:08 +0000 (07:52 +0400)]
Minor code refactoring regarding HAVE_BUILTIN_UNWIND_INIT

* include/private/gcconfig.h (HAVE_BUILTIN_UNWIND_INIT): Do not define
for Darwin/ppc and RTEMS.
* mach_dep.c (GC_with_callee_saves_pushed): Remove target-specific
checks for Darwin/ppc and RTEMS as HAVE_BUILTIN_UNWIND_INIT is not
defined in that case.