Ivan Maidanski [Tue, 10 Jan 2012 09:58:14 +0000 (13:58 +0400)]
Enable platform-specific disabling of static data scanning
(Reworked commit a0347f0 from 'mono_libgc' branch)
* include/private/gcconfig.h (GC_DONT_REGISTER_MAIN_STATIC_DATA):
Recognize new macro.
* include/private/gcconfig.h (DYNAMIC_LOADING): Do not define for
Darwin/arm if GC_DONT_REGISTER_MAIN_STATIC_DATA.
* misc.c (GC_REGISTER_MAIN_STATIC_DATA): Define to FALSE if
GC_DONT_REGISTER_MAIN_STATIC_DATA (and not DYNAMIC_LOADING).
Ivan Maidanski [Tue, 10 Jan 2012 06:27:33 +0000 (10:27 +0400)]
Win32: allow DllMain chaining on the client side
(Reworked commits e55eb9c, 34a996f from 'mono_libgc' branch)
* configure.ac (enable_win32_dllmain): Recognize new AC "enable"
option.
* configure.ac (GC_INSIDE_DLL): New AC macro (defined only if
enable_win32_dllmain).
* README.macros (GC_INSIDE_DLL): Document.
* include/gc.h (GC_DllMain): Declare as API function (for Win32) if
GC_INSIDE_DLL.
* win32_threads.c (GC_INSIDE_DLL): Recognize (treat the same as
GC_DLL).
* win32_threads.c (DllMain): Rename to GC_DllMain; use GC_API export
declarator if GC_INSIDE_DLL, otherwise define GC_DllMain macro as
a synonym to DllMain.
Ivan Maidanski [Thu, 29 Dec 2011 14:46:53 +0000 (18:46 +0400)]
Replace printf PRIxMAX specifier with '%p' for thread id debug output
* pthread_support.c (GC_new_thread, GC_delete_thread,
GC_delete_gc_thread, GC_unregister_my_thread_inner,
GC_unregister_my_thread, GC_thread_exit_proc,
GC_start_rtn_prepare_thread, pthread_create): Output thread id value
(when DEBUG_THREADS) using %p format specifier instead of PRIxMAX, %x
and %lx (casting passed id value to pointer type instead of uintmax_t).
* pthread_start.c (GC_inner_start_routine): Likewise.
GC_stop_world, GC_thread_resume, GC_start_world): Likewise.
* pthread_stop_world.c (GC_suspend_handler_inner, GC_restart_handler,
GC_push_all_stacks, GC_suspend_all, GC_stop_world, GC_start_world):
Likewise.
* darwin_stop_world.c (GC_stack_range_for, GC_suspend_thread_list,
* pthread_start.c: Do not include inttypes.h.
* pthread_support.c: Likewise.
* pthread_support.c (GC_count_threads): Define only if DEBUG_THREADS.
* pthread_support.c (GC_unregister_my_thread): Rename gc_self local
variable to "me".
* pthread_support.c (pthread_create): Report thread started (when
DEBUG_THREADS) only if result is 0.
Ivan Maidanski [Thu, 29 Dec 2011 12:12:37 +0000 (16:12 +0400)]
Add GC_is_heap_ptr() to GC API
* include/gc.h (GC_is_heap_ptr): New API function declaration.
* misc.c (GC_is_heap_ptr): New function.
* tests/test.c (run_one_test): Add GC_is_heap_ptr tests.
Ivan Maidanski [Thu, 29 Dec 2011 08:37:01 +0000 (12:37 +0400)]
Refactoring: rename GC_EXPECT to EXPECT in .c files
* fnlz_mlc.c (GC_core_finalized_malloc, GC_finalized_malloc):
Rename GC_EXPECT to EXPECT; replace 0/1 with TRUE/FALSE for the 2nd
argument of EXPECT.
* thread_local_alloc.c (GC_gcj_malloc): Likewise.
Ivan Maidanski [Wed, 28 Dec 2011 07:13:35 +0000 (11:13 +0400)]
configure: do not compile pthread_stop_world.c for Cygwin/Darwin
(to reduce linker warnings about empty object files)
* Makefile.am (libgc_la_SOURCES): Do not add pthread_start.c,
pthread_support.c, pthread_stop_world.c entries for Cygwin and
win32-pthread; do not add pthread_stop_world.c entry for Darwin.
Ivan Maidanski [Wed, 28 Dec 2011 06:42:49 +0000 (10:42 +0400)]
Fix compiler warning in GC_dyld_image_add/remove (Darwin)
* dyn_load.c (GC_dyld_image_add, GC_dyld_image_remove): Declare i, j
local variables as unsigned (to prevent compiler warning in
a comparison involving sizeof)
Ivan Maidanski [Wed, 28 Dec 2011 06:42:49 +0000 (10:42 +0400)]
Fix compiler warning in GC_dyld_image_add/remove (Darwin)
* dyn_load.c (GC_dyld_image_add, GC_dyld_image_remove): Declare i, j
local variables as unsigned (to prevent compiler warning in
a comparison involving sizeof)
Ivan Maidanski [Tue, 27 Dec 2011 07:43:41 +0000 (11:43 +0400)]
MacOSX: Accept i386_ prefix for exception_state_t (for compatibility)
* os_dep.c (DARWIN_EXC_STATE, DARWIN_EXC_STATE_COUNT,
DARWIN_EXC_STATE_T): Define to i386_EXCEPTION_STATE,
i386_EXCEPTION_STATE_COUNT and i386_exception_state_t, respectively,
for Darwin/x86 if i386_EXCEPTION_STATE_COUNT macro is defined.
Ivan Maidanski [Mon, 26 Dec 2011 12:36:07 +0000 (16:36 +0400)]
configure: Add script code to force USE_MMAP for some targets
(Apply part of commit 21a49a9 from 'gcc_boehmgc' branch)
* configure.ac (gc_use_mmap): New variable (blank currently); add
comment and FIXME.
* configure.ac (USE_MMAP): Force define in case of gc_use_mmap is yes.
Ivan Maidanski [Mon, 26 Dec 2011 07:18:55 +0000 (11:18 +0400)]
Localize references in 'doc' html files
* doc/gcinterface.html: Set "text/plain" type for references to GC
header files; make some absolute references to local (for HTML files
existing in doc folder).
* doc/overview.html: Likewise.
Ivan Maidanski [Fri, 23 Dec 2011 11:34:19 +0000 (15:34 +0400)]
MacOSX: Accept i386_ prefix for thread_state_t (for compatibility)
* include/private/gc_priv.h (GC_THREAD_STATE_T, GC_MACH_THREAD_STATE,
GC_MACH_THREAD_STATE_COUNT): Define to i386_thread_state_t,
i386_THREAD_STATE, i386_THREAD_STATE_COUNT for Darwin/x86 if the
latter macro is available (for compatibility).
* include/private/gc_priv.h (GC_MACH_THREAD_STATE,
GC_MACH_THREAD_STATE_COUNT): Define to ARM_MACHINE_THREAD_STATE and
ARM_MACHINE_THREAD_STATE_COUNT for Darwin/arm (iPhone), respectively,
if the latter macro is available.
* include/private/gc_priv.h (GC_MACH_THREAD_STATE,
GC_MACH_THREAD_STATE_COUNT): Define to platform-independent
MACHINE_THREAD_STATE and MACHINE_THREAD_STATE_COUNT for Darwin,
respectively, in case of missing platform-specific ones.
Ivan Maidanski [Mon, 19 Dec 2011 12:27:18 +0000 (16:27 +0400)]
Fix GC_get_thr_restart_signal for Darwin and Win32
* misc.c (GC_get_thr_restart_signal): Implement for Darwin and Win32
(always returns -1) if THREADS.
* pthread_stop_world.c (GC_get_thr_restart_signal): Remove
implementation for Darwin/Win32 (since the file might not be included
for these targets).
Ivan Maidanski [Fri, 16 Dec 2011 11:07:14 +0000 (15:07 +0400)]
Recognize __ANDROID__ as synonym for PLATFORM_ANDROID
* README.macros (PLATFORM_ANDROID): Update.
* include/gc_config_macros.h (__ANDROID__): Recognize as a synonym for
PLATFORM_ANDROID.
* include/private/gcconfig.h (PLATFORM_ANDROID): Define if __ANDROID__.
Ivan Maidanski [Thu, 15 Dec 2011 15:01:47 +0000 (19:01 +0400)]
Instruct configure to hide internal libgc.so symbols if supported (GCC)
* configure.ac (ac_cv_fvisibility_hidden): New variable (set to "yes"
if only shared library is built and GCC supports "-fvisibility" option.
* configure.ac (CFLAGS): Add "-fvisibility=hidden" and
"-DGC_VISIBILITY_HIDDEN_SET" if ac_cv_fvisibility_hidden is "yes".
* include/gc_config_macros.h (GC_API): Force "default visibility"
attribute if GC_VISIBILITY_HIDDEN_SET (only if GCC and GC_BUILD).
* tests/staticrootstest.c (GC_VISIBILITY_HIDDEN_SET): Test the macro
and skip the test if defined (since "staticrootslib" symbols are of
hidden visibility).
Ivan Maidanski [Thu, 15 Dec 2011 13:42:01 +0000 (17:42 +0400)]
Fix configure to disable GCC aliasing optimization unless forced to
* configure.ac (ac_cv_fno_strict_aliasing): New variable (set to
"skipped" if the client passed "-fstrict-aliasing" option to CFLAGS
else set to "yes" if GCC supports "-fno-strict-aliasing" option,
otherwise set to "no").
* configure.ac (CFLAGS): Append "-fno-strict-aliasing" if
ac_cv_fno_strict_aliasing is "yes" (only if GCC).
Ivan Maidanski [Thu, 15 Dec 2011 12:02:38 +0000 (16:02 +0400)]
Add configure option to compile all library .c files into single gc.o
* Makefile.am (SINGLE_GC_OBJ): Test new AM conditional.
* Makefile.am (libgc_la_SOURCES): Put only extra/gc.c entry here if
SINGLE_GC_OBJ.
* Makefile.am (EXTRA_DIST): Add extra/gc.c only if not SINGLE_GC_OBJ.
* configure.ac (single-obj-compilation): New AC "enable" argument
(turning on compilation of single extra/gc.c file instead of all .c
files from GC base folder).
* configure.ac (SINGLE_GC_OBJ): New AM conditional.
Ivan Maidanski [Tue, 13 Dec 2011 11:37:59 +0000 (15:37 +0400)]
configure: Do not pass '-Wextra' option to GCC if unsupported
* configure.ac (WEXTRA): New variable (set to "-Wextra" if the latter
is supported by GCC, otherwise to "-W").
* configure.ac (CFLAGS): Use WEXTRA variable (only if GCC).
Ivan Maidanski [Wed, 16 Nov 2011 15:57:17 +0000 (19:57 +0400)]
Remove unused 'destructor' parameter in 'specific' GC_key_create
function (add '_inner' suffix to the function name and create
GC_key_create proxy macro)
* include/private/specific.h (GC_key_create): Rename to
GC_key_create_inner; remove "destructor" parameter.
* specific.c (GC_key_create): Likewise.
* include/private/specific.h (GC_key_create): New macro redirecting
to GC_key_create_inner function.
Ivan Maidanski [Tue, 15 Nov 2011 16:29:45 +0000 (20:29 +0400)]
Support GC_Create/ExitThread, GC_begin/endthreadex for Cygwin and
win32-pthread
* include/gc.h (GC_CreateThread, GC_ExitThread, GC_uintptr_t,
GC_beginthreadex, GC_endthreadex): Also declare (and redirect) for
GC_PTHREADS during GC build or if the client includes windows.h before
gc.h file; add a comment.
* win32_threads.c (thread_args, GC_win32_start_inner, GC_win32_start,
GC_CreateThread, GC_ExitThread, GC_beginthreadex, GC_endthreadex):
Also define for GC_PTHREADS.
Ivan Maidanski [Tue, 15 Nov 2011 10:44:29 +0000 (14:44 +0400)]
Fix thread_local_alloc GC_malloc[_atomic] for USE_CUSTOM_SPECIFIC TLS
platforms (e.g., Solaris)
* thread_local_alloc.c (GC_malloc, GC_malloc_atomic): Test result of
GC_getspecific() for NULL in all cases except for USE_COMPILER_TLS and
USE_WIN32_COMPILER_TLS (i.e., no-op implementation of GC_getspecific).
Ivan Maidanski [Fri, 11 Nov 2011 12:18:13 +0000 (16:18 +0400)]
Resolve minor warnings in tests (reported by GCC with '-pedantic' option)
* tests/disclaim_test.c (pair_dct, pair_new): Explicitly cast
a pointer argument of GC_printf to void* to match %p format specifier.
* tests/test.c (cons, print_int_list, run_one_test, check_heap_stats):
Likewise.
Ivan Maidanski [Mon, 7 Nov 2011 07:30:44 +0000 (11:30 +0400)]
Refactor GC_move_disappearing_link() code;
make GC_move_disappearing_link(link,link) return GC_SUCCESS
* finalize.c (GC_move_disappearing_link): Rename "from", "to"
arguments to "link" and "new_link", respectively.
* include/gc.h (GC_move_disappearing_link): Likewise.
* finalize.c (GC_move_disappearing_link): Rename "to_curr_dl",
"from_index", "to_index" local variables to "new_dl", "curr_index",
"new_index", respectively.
* finalize.c (GC_move_disappearing_link): Add curr_hidden_link,
new_hidden_link local variables to evaluate GC_HIDE_POINTER(link) and
GC_HIDE_POINTER(new_link) only once.
* finalize.c (GC_move_disappearing_link): Reformat code.
* finalize.c (GC_move_disappearing_link): Do not ABORT in case of
unaligned "link", return GC_NOT_FOUND instead (similar to
GC_unregister_disappearing_link behavior).
* finalize.c (GC_move_disappearing_link): If new_link is equal to
link then return GC_SUCCESS instead of GC_DUPLICATE.
* include/gc.h (GC_move_disappearing_link, GC_NOT_FOUND): Refine and
update documentation comment.
* tests/test.c (mktree): Add "new_link" local variable; add
GC_move_disappearing_link invocations; apply
GC_unregister_disappearing_link to "new_link".
Ivan Maidanski [Fri, 7 Oct 2011 14:33:50 +0000 (18:33 +0400)]
Do not define internal GC_parse_map_entry() unless really used.
* include/private/gc_priv.h (GC_parse_map_entry): Do not declare
unless USE_PROC_FOR_LIBRARIES.
* os_dep.c (GC_parse_map_entry): Test USE_PROC_FOR_LIBRARIES macro
in addition to DYNAMIC_LOADING (in condition whether to define this
function).