platform/upstream/libgc.git
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 agoRemove 'sig' argument of GC_suspend_handler_inner
Ivan Maidanski [Thu, 19 Nov 2015 22:22:39 +0000 (01:22 +0300)]
Remove 'sig' argument of GC_suspend_handler_inner
(Code refactoring)

* pthread_stop_world.c (GC_suspend_handler_inner): Rename "sig_arg"
argument to "dummy"; mark it as GC_ATTR_UNUSED.
* pthread_stop_world.c (GC_suspend_handler): Pass NULL instead of sig
to GC_suspend_handler_inner.
* pthread_stop_world.c (GC_suspend_handler): Move sig check from
GC_suspend_handler_inner.

8 years agoAllow specific TLS attributes for GC_thread_key
Ivan Maidanski [Tue, 17 Nov 2015 08:39:29 +0000 (11:39 +0300)]
Allow specific TLS attributes for GC_thread_key

* doc/README.macros (GC_ATTR_TLS_FAST): Document.
* include/private/thread_local_alloc.h (GC_ATTR_TLS_FAST): New macro
(empty by default).
* include/private/thread_local_alloc.h (GC_thread_key): Use
GC_ATTR_TLS_FAST.
* thread_local_alloc.c (GC_thread_key): Likewise.

8 years agoFix USE_COMPILER_TLS macro duplicate description in README
Ivan Maidanski [Tue, 17 Nov 2015 21:43:25 +0000 (00:43 +0300)]
Fix USE_COMPILER_TLS macro duplicate description in README

* doc/README.macros (USE_COMPILER_TLS): Remove duplicate description.

9 years agoDocument GC_register_my_thread returned value
Ivan Maidanski [Wed, 11 Nov 2015 08:20:21 +0000 (11:20 +0300)]
Document GC_register_my_thread returned value

* include/gc.h (GC_register_my_thread): Refine comment (about returned
value).

9 years agoAvoid unstructured procfs on Solaris
Rainer Orth [Thu, 27 Aug 2015 11:26:18 +0000 (11:26 +0000)]
Avoid unstructured procfs on Solaris
(Cherry-picked commit f9711f5 from 'gcc_boehmgc' branch.)

* os_dep.c [PROC_VDB] (GC_dirty_init): Use /proc/<pid>/pagedata
instead of PIOCOPENPD; remove fd local variable; increase buf[] size.

9 years agoDo no declare kernel_id field of GC_Thread_Rep for 64-bit Android
Ivan Maidanski [Thu, 29 Oct 2015 21:08:44 +0000 (00:08 +0300)]
Do no declare kernel_id field of GC_Thread_Rep for 64-bit Android

* include/private/pthread_support.h (GC_Thread_Rep): Do not declare
kernel_id field unless USE_TKILL_ON_ANDROID (instead of
PLATFORM_ANDROID).
* pthread_support.c (GC_new_thread, GC_remove_all_threads_but_me): Do
not set kernel_id field unless USE_TKILL_ON_ANDROID.

9 years agoABORT_ARGn log details at INFO level (Android)
Ivan Maidanski [Mon, 26 Oct 2015 21:08:01 +0000 (00:08 +0300)]
ABORT_ARGn log details at INFO level (Android)

* include/private/gc_priv.h (ABORT_ARG1, ABORT_ARG2, ABORT_ARG3): Use
GC_INFOLOG_PRINTF instead of GC_COND_LOG_PRINTF.

9 years agoRemove item from TODO file about resuming parallel markers
Ivan Maidanski [Mon, 26 Oct 2015 05:29:32 +0000 (08:29 +0300)]
Remove item from TODO file about resuming parallel markers

9 years agoCheck DATASTART is less than DATAEND even assertions off
Ivan Maidanski [Mon, 26 Oct 2015 05:25:54 +0000 (08:25 +0300)]
Check DATASTART is less than DATAEND even assertions off

* dyn_load.c (GC_register_dynamic_libraries_dl_iterate_phdr):
Abort with the appropriate message if DATASTART is NULL or greater than
DATAEND (same for DATASTART2 and DATAEND2).
* os_dep.c (GC_init_linux_data_start, GC_register_data_segments):
Likewise.
* os_dep.c (GC_init_linux_data_start, GC_register_data_segments):
Remove assertion about DATASTART and DATAEND.
* os_dep.c (GC_init_linux_data_start): Code refactoring.

9 years agoWorkaround invalid '_end' symbol on Android clang 3.5+
Ivan Maidanski [Fri, 23 Oct 2015 09:24:21 +0000 (12:24 +0300)]
Workaround invalid '_end' symbol on Android clang 3.5+

* include/gc.h (GC_INIT_CONF_ROOTS): Handle Android clang (3.5-3.6)
case when "_end" symbol has incorrect address but "__end__" is defined
(by bfd linker only); declare "__end__" symbol as weak.
* include/private/gcconfig.h (DATAEND): Redefine for Android/clang;
define __end__ as weak symbol.
* os_dep.c (_end): Remove declaration (declared in gcconfig.h).
* os_dep.c (GC_init_linux_data_start): Define new local variable
(data_end); set it to DATAEND; use it instead of _end.

9 years agoFix lock assert violation in GC_gcollect_inner if GC_ALWAYS_MULTITHREADED
Ivan Maidanski [Wed, 21 Oct 2015 23:50:00 +0000 (02:50 +0300)]
Fix lock assert violation in GC_gcollect_inner if GC_ALWAYS_MULTITHREADED

* alloc.c (GC_expand_hp): Do not hold the allocation lock when calling
GC_init.
* malloc.c (GC_alloc_large, GC_generic_malloc_inner): Likewise.
* mallocx.c (GC_generic_malloc_many): Likewise.
* misc.c (GC_enable_incremental): Likewise.
* misc.c (GC_init): Surround GC_gcollect_inner call with LOCK/UNLOCK
(only if GC_ASSERTIONS and GC_ALWAYS_MULTITHREADED otherwise
redundant).

9 years agoWorkaround 'unresolved __tls_get_addr' error for Android NDK Clang
Ivan Maidanski [Wed, 21 Oct 2015 23:01:33 +0000 (02:01 +0300)]
Workaround 'unresolved __tls_get_addr' error for Android NDK Clang

* include/private/thread_local_alloc.h (USE_COMPILER_TLS): Do not
define for Android Clang (any CPU arch); update comment.

9 years agoAdd assertion on lock status to GC_alloc_large and its callers
Ivan Maidanski [Wed, 21 Oct 2015 22:52:39 +0000 (01:52 +0300)]
Add assertion on lock status to GC_alloc_large and its callers
(code refactoring)

* alloc.c (GC_try_to_collect_inner): Remove comment about expected
lock status; add assertion about holding the allocation lock.
* finalize.c (GC_grow_table): Likewise.
* malloc.c (GC_alloc_large, GC_alloc_large_and_clear,
GC_generic_malloc_inner, GC_generic_malloc_inner_ignore_off_page):
Likewise.
* misc.c (GC_new_free_list_inner): Likewise.

9 years agoFix lock assertion violation in GC_new_thread if GC_ALWAYS_MULTITHREADED
Ivan Maidanski [Tue, 20 Oct 2015 21:48:56 +0000 (00:48 +0300)]
Fix lock assertion violation in GC_new_thread if GC_ALWAYS_MULTITHREADED

* include/private/gc_priv.h (GC_start_mark_threads_inner): Define macro
(or declare function depending on CAN_HANDLE_FORK).
* misc.c (GC_init): Surround GC_thr_init call with LOCK/UNLOCK (only
if GC_ASSERTIONS and GC_ALWAYS_MULTITHREADED otherwise redundant);
call GC_start_mark_threads_inner (if PARALLEL_MARK).
* pthread_support.c (GC_mark_thread): Update comment.
* win32_threads.c (GC_mark_thread): Likewise.
* pthread_support.c (start_mark_threads): Remove macro (moved to
gc_priv.h); rename function to GC_start_mark_threads_inner; replace
"static" to GC_INNER; check assertion on GC_fl_builder_count only if
the markers should actually be started; move the check for disabled
parallel markers (available_markers_m1) from GC_thr_init (make it
unconditional).
* win32_threads.c (start_mark_threads): Likewise.
* win32_threads.c (GC_start_mark_threads_inner): Add assertion about
the lock status.
* pthread_support.c (GC_thr_init): Remove comment about expected lock
status; add assertion about holding the lock (duplicating that in
GC_new_thread); remove start_mark_threads call (moved to GC_init).
* win32_threads.c (GC_thr_init): Likewise.

9 years agoConsistently set type of DATASTART/END to ptr_t
Ivan Maidanski [Thu, 15 Oct 2015 22:38:08 +0000 (01:38 +0300)]
Consistently set type of DATASTART/END to ptr_t
(code refactoring)

* dyn_load.c (GC_register_map_entries,
GC_register_dynamic_libraries_dl_iterate_phdr): Remove redundant
casting to ptr_t of DATASTART, DATAEND, DATAEND2.
* os_dep.c (GC_register_data_segments): Likewise.
* include/private/gcconfig.h (DATAEND, DATASTART): Add cast to ptr_t
where missing.

9 years agoConsistently use outermost parentheses for DATASTART/END, STACKBOTTOM
Ivan Maidanski [Thu, 15 Oct 2015 20:49:06 +0000 (23:49 +0300)]
Consistently use outermost parentheses for DATASTART/END, STACKBOTTOM
(code refactoring)

* include/private/gcconfig.h (DATASTART, DATAEND, STACKBOTTOM,
DATAEND2): Add outermost parentheses where missing; remove space in
cast.

9 years agoNaCl/arm initial support
Elijah Taylor [Thu, 31 Jan 2013 22:00:58 +0000 (14:00 -0800)]
NaCl/arm initial support
(Apply part of commit 21f0df7 from 'mono_libgc' branch.)

Conflicts:
* include/private/gc_locks.h
* include/private/gcconfig.h
* pthread_stop_world.c

9 years agoNaCl runtime fixes
Elijah Taylor [Thu, 31 Jan 2013 20:04:20 +0000 (12:04 -0800)]
NaCl runtime fixes
(Apply commit b328e88 from 'mono_libgc' branch.)

* fix compile/runtime issues caused by upstream changes
* add NaCl glibc support
* various changes to support running tests in NaCl glibc
from 'make check'

Conflicts:
* dyn_load.c
* include/private/gcconfig.h
* misc.c
* pthread_stop_world.c
* pthread_support.c

9 years agoNaCl GC improvements (fix volatile for vars accessed by syscall hooks)
Elijah Taylor [Thu, 31 Jan 2013 20:48:49 +0000 (12:48 -0800)]
NaCl GC improvements (fix volatile for vars accessed by syscall hooks)
(Apply part of commit 204bcc6 from 'mono_libgc' branch.)

Conflicts:
* pthread_stop_world.c
* pthread_support.c

9 years agoDefine GC_LINUX_THREADS, NO_EXECUTE_PERMISSION in configure for NaCl
Elijah Taylor [Fri, 17 Dec 2010 00:26:34 +0000 (16:26 -0800)]
Define GC_LINUX_THREADS, NO_EXECUTE_PERMISSION in configure for NaCl
(Apply part of commit 14b353e from 'mono_libgc' branch.)

* configure.ac: Handle *-*-nacl* (define GC_LINUX_THREADS and
NO_EXECUTE_PERMISSION).

9 years agoFix gc.mak regarding msvc_dbg and test (MSVC)
Ivan Maidanski [Wed, 30 Sep 2015 21:46:06 +0000 (00:46 +0300)]
Fix gc.mak regarding msvc_dbg and test (MSVC)

* gc.mak (CLEAN, BSC32_SBRS, LINK32_OBJS): Rename msvc_dbg.* to
msvc_dbg.copied.* file names.
* gc.mak (CLEAN): Erase msvc_dbg.copied.c, test.copied.c.
* gc.mak (msvc_dbg.copied.c): New rule.
* gc.mak (CLEAN, LINK32_OBJS, BSC32_SBRS, test.c): Rename test.* to
test.copied.* file names.
* gc.mak (CPP_PROJ): Add /D for "ALL_INTERIOR_POINTERS".

9 years ago.gitignore: Ignore .copied.c, .dll.manifest, idb, ilk files (MSVC)
Ivan Maidanski [Wed, 23 Sep 2015 07:43:53 +0000 (10:43 +0300)]
.gitignore: Ignore .copied.c, .dll.manifest, idb, ilk files (MSVC)

9 years agoFix race (and potential deadlock) at marker threads initialization
Ivan Maidanski [Tue, 22 Sep 2015 05:42:40 +0000 (08:42 +0300)]
Fix race (and potential deadlock) at marker threads initialization

* include/private/gc_priv.h (GC_wait_for_markers_init): New prototype.
* mark.c (GC_wait_for_markers_init): New function (if PARALLEL_MARK).
* pthread_support.c (GC_mark_thread): Notify start_mark_threads()
about completion of marker data initialization.
* win32_threads.c (GC_mark_thread): Likewise.
* pthread_support.c (start_mark_threads): Add assertion about
GC_fl_builder_count; call GC_wait_for_markers_init.
* win32_threads.c (start_mark_threads): Likewise.
* win32_threads.c (GC_mark_thread): Reformat code.

9 years agoFix 'value truncated' compiler warning in CORD_cat (MS VC)
Ivan Maidanski [Fri, 18 Sep 2015 22:26:36 +0000 (01:26 +0300)]
Fix 'value truncated' compiler warning in CORD_cat (MS VC)

* cord/cordbscs.c (CORD_cat_char_star, CORD_cat): Cast "lenx" to
unsigned char (to workaround false compiler warning about value
truncation).

9 years agoFix compilation for Android clang/arm with bfd linker
Ivan Maidanski [Wed, 16 Sep 2015 22:18:36 +0000 (01:18 +0300)]
Fix compilation for Android clang/arm with bfd linker

* include/private/thread_local_alloc.h (USE_COMPILER_TLS): Do not
define if ARM32 (and PLATFORM_ANDROID and __clang__); update comment.

9 years agoEnable thread-local storage for Android Clang
Ivan Maidanski [Wed, 16 Sep 2015 09:14:34 +0000 (12:14 +0300)]
Enable thread-local storage for Android Clang

* include/private/thread_local_alloc.h (USE_COMPILER_TLS): Define for
Android NDK clang3.6+ arm/arm64/x86/x86_64 (NDK r10e); update comment.

9 years agowindows-untested: Fix paths to msvc_dbg.c/h
Ivan Maidanski [Tue, 15 Sep 2015 07:49:01 +0000 (10:49 +0300)]
windows-untested: Fix paths to msvc_dbg.c/h

* windows-untested/vc60/gc.dsp (SOURCE): Fix paths to msvc_dbg.c and
msvc_dbg.h.
* windows-untested/vc60/libgc.dsp (SOURCE): Likewise.
* windows-untested/vc60/libgcmt.dsp (SOURCE): Likewise.
* windows-untested/vc60/libgcmt.dsp (File RelativePath): Likewise.
* windows-untested/vc70/libgc.vcproj (File RelativePath): Likewise.
* windows-untested/vc70/libgcmt.vcproj (File RelativePath): Likewise.
* windows-untested/vc71/gc.vcproj (File RelativePath): Likewise.
* windows-untested/vc71/libgc.vcproj (File RelativePath): Likewise.
* windows-untested/vc71/libgcmt.vcproj (File RelativePath): Likewise.

9 years agoUpdate AUTHORS file
Ivan Maidanski [Tue, 15 Sep 2015 07:15:35 +0000 (10:15 +0300)]
Update AUTHORS file

9 years agoFix typos in README for ews4800
Terrell Russell [Mon, 14 Sep 2015 18:48:41 +0000 (14:48 -0400)]
Fix typos in README for ews4800

* doc/README.ews4800: Fix typos ("information", "vendor", "the").

9 years agoUpdate compiler options in gc.mak (Win32)
Ivan Maidanski [Mon, 14 Sep 2015 08:25:03 +0000 (11:25 +0300)]
Update compiler options in gc.mak (Win32)

* gc.mak (CFG): Fix info about default configuration.
* gc.mak (CPP_PROJ): Replace deprecated /GX option with /EHsc; remove
deprecated /YX option; add /D _CRT_SECURE_NO_DEPRECATE option (to
suppress warning about vsprintf usage).

9 years ago.gitignore: Ignore .exp and .sbr also in subfolders (MSVC)
Ivan Maidanski [Mon, 14 Sep 2015 07:41:44 +0000 (10:41 +0300)]
.gitignore: Ignore .exp and .sbr also in subfolders (MSVC)

9 years agoTurn off sigsetjmp workaround for Android/x86 starting from NDK r8e
Ivan Maidanski [Fri, 11 Sep 2015 08:57:54 +0000 (11:57 +0300)]
Turn off sigsetjmp workaround for Android/x86 starting from NDK r8e

* include/private/gcconfig.h (GC_NO_SIGSETJMP): Do not define for
Android/x86 if NDK r8e+; update comment.

9 years agoFix abort message in GC_move_long_link
Ivan Maidanski [Thu, 10 Sep 2015 23:16:42 +0000 (02:16 +0300)]
Fix abort message in GC_move_long_link

* finalize.c (GC_move_long_link): Fix function name in abort message.

9 years agoFix 'comparison of non-null parameter is always false' warning (Clang)
Ivan Maidanski [Thu, 10 Sep 2015 08:48:05 +0000 (11:48 +0300)]
Fix 'comparison of non-null parameter is always false' warning (Clang)

* alloc.c (GC_set_stop_func, GC_try_to_collect): Use
NONNULL_ARG_NOT_NULL to check argument marked as non-null (in
function declaration) is actually non-null.
* finalize.c (GC_general_register_disappearing_link,
GC_register_long_link, GC_move_disappearing_link, GC_move_long_link):
Likewise.
* misc.c (GC_set_warn_proc, GC_set_abort_func, GC_set_oom_fn): Likewise.
* include/private/gc_priv.h (NONNULL_ARG_NOT_NULL): New macro.

9 years agoAllow fork() automatic handling on Android with API level 21+
Ivan Maidanski [Thu, 10 Sep 2015 07:32:52 +0000 (10:32 +0300)]
Allow fork() automatic handling on Android with API level 21+

* include/private/gcconfig.h (CAN_CALL_ATFORK): Define also if
__ANDROID_API__ >= 21.

9 years agoConsistently use int[] type for '_end' symbol
Ivan Maidanski [Thu, 10 Sep 2015 07:23:00 +0000 (10:23 +0300)]
Consistently use int[] type for '_end' symbol
(code refactoring)

* include/private/gcconfig.h (_end): Change char[] type to int[] (for
remaining entries).

9 years agoWorkaround 'sa_sigaction member missing' compiler error (Android/x32)
Ivan Maidanski [Wed, 9 Sep 2015 22:36:30 +0000 (01:36 +0300)]
Workaround 'sa_sigaction member missing' compiler error (Android/x32)

Client should define NO_SA_SIGACTION to enable the workaround.

* include/private/gcconfig.h (NO_SA_SIGACTION): New macro (explicitly
define if SA_SIGINFO undefined).
* include/private/gcconfig.h (MPROTECT_VDB): Undefine if
NO_SA_SIGACTION unless DARWIN, MSWIN32 or MSWINCE.
* pthread_stop_world.c (GC_suspend_handler, GC_stop_init): Check
NO_SA_SIGACTION instead of SA_SIGINFO.

9 years agoSupport build for Android 64-bit (arm64, mips64, x86_64)
Ivan Maidanski [Wed, 9 Sep 2015 21:15:22 +0000 (00:15 +0300)]
Support build for Android 64-bit (arm64, mips64, x86_64)

* include/private/gcconfig.h (_end): Replace type from char[] to int[]
to avoid redefinition error (as it is also declared in gc.h) for
Linux/x86_64.
* include/private/gcconfig.h (NO_GETCONTEXT): Define for all Android
targets.
* include/private/gcconfig.h (USE_TKILL_ON_ANDROID): New macro
(defined only for 32-bit Android targets).
* pthread_stop_world.c (tkill, android_thread_kill, GC_suspend_all,
GC_start_world): Use USE_TKILL_ON_ANDROID instead of PLATFORM_ANDROID.

9 years agoFix 'cast to pointer from integer' warning in GC_on_thread_event (64-bit)
Ivan Maidanski [Wed, 9 Sep 2015 20:55:37 +0000 (23:55 +0300)]
Fix 'cast to pointer from integer' warning in GC_on_thread_event (64-bit)

* pthread_stop_world.c (GC_suspend_all, GC_start_world): Cast thread_id
to pointer via word type on passing to GC_on_thread_event; add comment.

9 years agoSupport Android API level 21
Ivan Maidanski [Wed, 9 Sep 2015 08:42:43 +0000 (11:42 +0300)]
Support Android API level 21
(fix 'link_map redefinition' error on Android with API level 21+)

* dyn_load.c (link_map, r_debug): Do not define if android-21 (or
higher) API is used; update comment.

9 years agoFix (allow) thread local allocations from within pthread TLS destructors
Niklas Therning [Tue, 6 Jan 2015 22:32:43 +0000 (23:32 +0100)]
Fix (allow) thread local allocations from within pthread TLS destructors

Prevents the GC_thread_key from being cleared on thread exit until
after the thread has been unregistered by GC_unregister_my_thread_inner.

* include/private/thread_local_alloc.h (GC_remove_specific): Call
pthread_setspecific(key, NULL) if USE_PTHREAD_SPECIFIC; update comment.
* thread_local_alloc.c (reset_thread_key): New static function if
USE_PTHREAD_SPECIFIC); define (as macro) to 0 otherwise.
* thread_local_alloc.c (GC_init_thread_local): Pass reset_thread_key
(instead of 0) to GC_key_create.

9 years agoFix 'visibility attribute not supported' GCC warning (IBM AIX)
Ivan Maidanski [Wed, 2 Sep 2015 08:52:30 +0000 (11:52 +0300)]
Fix 'visibility attribute not supported' GCC warning (IBM AIX)

* configure.ac (enable_shared): Add -D GC_NO_VISIBILITY to CFLAGS if
not ac_cv_fvisibility_hidden.
* include/cord.h (CORD_API): Do not use visibility attribute if
GC_NO_VISIBILITY.
* include/gc_config_macros.h (GC_API): Likewise.
* include/private/gc_priv.h (GC_INNER, GC_API_OSCALL): Likewise.

9 years agoMerge branch 'toggleref'
Ivan Maidanski [Tue, 1 Sep 2015 06:59:25 +0000 (09:59 +0300)]
Merge branch 'toggleref'

9 years agoFix data race in GC_init_explicit_typing
Ivan Maidanski [Tue, 1 Sep 2015 06:57:38 +0000 (09:57 +0300)]
Fix data race in GC_init_explicit_typing

* typd_mlc.c: Force include atomic_ops.h if
GC_FORCE_INCLUDE_ATOMIC_OPS (by default it is included if
PARALLEL_MARK or pthreads are used).
* typd_mlc.c (GC_explicit_typing_initialized): Use AO_t if
AO_load_acquire() available.
* typd_mlc.c (GC_init_explicit_typing): Move locking (and
GC_explicit_typing_initialized access) outside to the caller
(GC_make_descriptor); remove comment; remove "register" keyword for
local variable.
* typd_mlc.c (GC_make_descriptor): Use AO_load_acquire (if available)
to fetch GC_explicit_typing_initialized value (to avoid data race and
avoid lock acquiring on each call).
* typd_mlc.c (GC_explicit_typing_initialized,
GC_malloc_explicitly_typed_ignore_off_page,
GC_calloc_explicitly_typed): Add assertion on
GC_explicit_typing_initialized is true.

9 years agoSupport FreeBSD/mips
Carlos J. Puga Medina [Sat, 29 Aug 2015 06:21:26 +0000 (09:21 +0300)]
Support FreeBSD/mips

* include/private/gcconfig.h (MIPS, mach_type_known, OS_TYPE,
ALIGNMENT, MPROTECT_VDB, SIG_SUSPEND, SIG_THR_RESTART, DYNAMIC_LOADING,
DATASTART_USES_BSDGETDATASTART): Define for FreeBSD/mips.
* os_dep.c (CODE_OK): Define to si->si_code==SEGV_ACCERR for
FreeBSD/mips.