]> granicus.if.org Git - gc/log
gc
6 years agoNew API function (get_size_map_at) to get content of size_map table
Ivan Maidanski [Wed, 14 Feb 2018 08:48:57 +0000 (11:48 +0300)]
New API function (get_size_map_at) to get content of size_map table

* include/gc.h (GC_get_size_map_at): Declare public function.
* misc.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (GC_get_size_map_at):
Implement function
* tests/test.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (check_heap_stats):
Add dummy testing of GC_get_size_map_at.

6 years agoConvert cord source files to valid C++ code
Ivan Maidanski [Wed, 14 Feb 2018 08:26:45 +0000 (11:26 +0300)]
Convert cord source files to valid C++ code

Issue #206 (bdwgc).

* cord/cordbscs.c (Concatenation, Function, Generic): Define struct
outside union (i.e. the union just uses them).
* cord/cordbscs.c (CORD_cat_char_star, CORD_from_fn_inner,
CORD_substr_checked): Cast GC_MALLOC_ATOMIC() result to char*.
* cord/cordprnt.c (CORD_vsprintf): Likewise.
* cord/cordxtra.c (CORD_cat_char, CORD_to_char_star,
CORD_from_char_star, CORD_ec_flush_buf): Likewise.
* cord/cordbscs.c (CORD_substr_checked): Remove register keyword for
"result" local variable.

6 years agoChange pointer arguments of push_all[_eager]/conditional API to void* type
Jay Krell [Mon, 12 Feb 2018 21:34:21 +0000 (00:34 +0300)]
Change pointer arguments of push_all[_eager]/conditional API to void* type

Receiving void* instead of char* is easier to use, as it requires
no casting.

A small downside of this change is that anyone using decltype(GC_push)
in C++ function signatures would get a different name mangling.

* include/gc_mark.h (GC_push_all, GC_push_all_eager,
GC_push_conditional): Change type of bottom and top arguments from
char* to void*.
* mark.c (GC_push_all, GC_push_conditional, GC_push_all_eager):
Likewise.
* include/private/gc_priv.h (GC_PUSH_ALL_SYM): Cast away volatile
qualifier for &sym.
* mark.c (GC_push_all): Remove "register" keyword for length local
variable.
* mark.c [!GC_DISABLE_INCREMENTAL] (GC_push_selected): Remove unneeded
casts for GC_push_all arguments.
* mark.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager):
Change type of bottom and top arguments from ptr_t to void*.
* mark_rts.c [WRAP_MARK_SOME && PARALLEL_MARK]
(GC_push_conditional_eager): Likewise.
* mark_rts.c (GC_PUSH_CONDITIONAL): Remove unneeded casts for
GC_push_all and GC_push_conditional arguments.

6 years agoAvoid potential race between realloc and clear_hdr_marks/reclaim_generic
Hans Boehm [Mon, 12 Feb 2018 08:24:54 +0000 (11:24 +0300)]
Avoid potential race between realloc and clear_hdr_marks/reclaim_generic

GC_realloc might be changing the block size while GC_reclaim_block
or GC_clear_hdr_marks is examining it.  The change to the size field
is benign, in that GC_reclaim (and GC_clear_hdr_marks) would work
correctly with either value, since we are not changing the number
of objects in the block.  But seeing a half-updated value (though
unlikely to occur in practice) could be probably bad.
Using unordered atomic accesses on the size and hb_descr fields would
solve the issue.

* mallocx.c [AO_HAVE_store] (GC_realloc): Use AO_store() to update
hhdr->hb_sz and hhdr->hb_descr; add static assert that size of
hhdr->hb_sz matches that of AO_t; add comment.
* mallocx.c [!AO_HAVE_store] (GC_realloc): Add LOCK/UNLOCK around
hb_sz and hb_descr fields assignment.
* mark.c [AO_HAVE_load] (GC_clear_hdr_marks): Use AO_load() to get
hhdr->hb_sz value; add comment.
* reclaim.c (IS_PTRFREE_SAFE): New macro (uses AO_load() if available).
* reclaim.c (GC_reclaim_generic, GC_reclaim_block): Replace
(hhdr)->hb_descr==0 with IS_PTRFREE_SAFE(hhdr).

6 years agoRevert 'Workaround TSan false positive about clear_hdr_marks/realloc race'
Ivan Maidanski [Fri, 9 Feb 2018 15:40:20 +0000 (18:40 +0300)]
Revert 'Workaround TSan false positive about clear_hdr_marks/realloc race'

This reverts commit 20468dd131d82be7422aea3c7383ec9201452fce.

Because it is not a false positive.  And we are lying to the compiler
about the value not changing asynchronously, which is never good.
The proper solution could be use of atomic accesses (even unordered)
on the size field.

6 years agoTravis CI: Test compiling GC/cord tests as C++ ones by Makefile.direct
Ivan Maidanski [Fri, 9 Feb 2018 08:27:36 +0000 (11:27 +0300)]
Travis CI: Test compiling GC/cord tests as C++ ones by Makefile.direct

6 years agoFix build of cord tests as C++ files (Makefile.direct)
Ivan Maidanski [Fri, 9 Feb 2018 08:17:29 +0000 (11:17 +0300)]
Fix build of cord tests as C++ files (Makefile.direct)

* Makefile.direct (cords): Do not depend on cord/cordtest.
* Makefile.direct (cord): Remove.
* Makefile.direct (cord/cordbscs.o, cord/cordxtra.o, cord/cordprnt.o):
Do not depend on cord target (folder); add "mkdir cord" (ignoring
errors) before moving .o file to "cord" folder.

6 years agoFix 'anonymous type with no linkage used to declare variable' C++ error
Ivan Maidanski [Fri, 9 Feb 2018 08:07:03 +0000 (11:07 +0300)]
Fix 'anonymous type with no linkage used to declare variable' C++ error
(fix of commit 8086c72)

Issue #201 (bdwgc).

* tests/test.c (A): Give some name to struct.
* tools/setjmp_t.c (a): Likewise.

6 years agoReplace GC_MALLOC(sizeof T) with GC_NEW(T) in tests
Ivan Maidanski [Fri, 9 Feb 2018 07:55:32 +0000 (10:55 +0300)]
Replace GC_MALLOC(sizeof T) with GC_NEW(T) in tests
(code refactoring)

* tests/realloc_test.c (main): Replace (T*)GC_MALLOC(sizeof(T)) with
GC_NEW(T).
* tests/test.c (small_cons, mktree, run_one_test): Likewise.

6 years agoConvert remaining GC tests to valid C++ code
Ivan Maidanski [Thu, 8 Feb 2018 08:56:44 +0000 (11:56 +0300)]
Convert remaining GC tests to valid C++ code
(fix of commit 8086c72)

Issue #201 (bdwgc).

* tests/disclaim_bench.c (testobj_new): Replace GC_MALLOC(sizeof T)
with GC_NEW(T).
* tests/staticrootslib.c (libsrl_mktree): Likewise.
* tests/trace_test.c (mktree): Likewise.
* tests/disclaim_bench.c (testobj_new): Cast GC_finalized_malloc()
result to testobj_t.
* tests/disclaim_bench.c (main): Cast GC_MALLOC() result to testobj_t*.
* tests/disclaim_test.c (pair_dct): Cast obj to pair_t.
* tests/disclaim_test.c (pair_dct): Cast cd to pair_t.
* tests/disclaim_test.c (GC_finalized_malloc): Cast
GC_finalized_malloc() result to pair_t.
* tests/staticrootslib.c (root_nz): Cast element to struct treenode*.
* tests/staticrootstest.c (root_nz): Likewise.
* tests/staticrootslib.c (libsrl_mktree): Cast GC_MALLOC_ATOMIC()
result to struct treenode*.
* tests/trace_test.c (mktree): Likewise.
* tests/staticrootstest.c (init_staticroot): Cast libsrl_init() result
to char*.
* tests/thread_leak_test.c (main): Cast malloc() result to int*.

6 years agoFix arg type of continue_reclaim prototype after the definition update
Ivan Maidanski [Thu, 8 Feb 2018 08:51:00 +0000 (11:51 +0300)]
Fix arg type of continue_reclaim prototype after the definition update
(fix of commit e794f1e)

* include/private/gc_priv.h (GC_continue_reclaim): Change type of sz
argument from size_t to word (matching the function definition).

6 years agoFix arguments delimiter in pcr_interface.c (PCR)
Ivan Maidanski [Thu, 8 Feb 2018 08:45:57 +0000 (11:45 +0300)]
Fix arguments delimiter in pcr_interface.c (PCR)

* extra/pcr_interface.c (GC_enumerate_block): Replace ';' with ',' in
the arguments list.

6 years agoChange type of hb_sz field (of hblkhdr) from size_t to word
Ivan Maidanski [Thu, 8 Feb 2018 08:41:45 +0000 (11:41 +0300)]
Change type of hb_sz field (of hblkhdr) from size_t to word

This is needed to make the size of hb_sz to be the same as of AO_t.

* allchblk.c [USE_MUNMAP] (GC_unmap_old): Cast hhdr->hb_sz to size_t
when passed to GC_unmap().
* allchblk.c (GC_allochblk_nth): Cast hhdr->hb_sz to signed_word when
assigned to size_avail.
* allchblk.c [USE_MUNMAP] (GC_allochblk_nth): Cast hhdr->hb_sz to
size_t when passed to GC_remap().
* alloc.c (GC_set_fl_marks, GC_clear_fl_marks): Change type of sz and
bit_no local variables from size_t/unsigned to word.
* dbg_mlc.c (GC_check_heap_block): Likewise.
* backgraph.c [MAKE_BACK_GRAPH] (per_object_helper): Cast hhdr->hb_sz
to size_t; change type of i local variables from int to size_t.
* checksums.c [CHECKSUMS] (GC_on_free_list): Change type of sz local
variable from size_t to word.
* mark.c (GC_push_marked, GC_push_unconditionally, GC_block_was_dirty):
Likewise.
* reclaim.c (GC_reclaim_small_nonempty_block,
GC_disclaim_and_reclaim_or_free_small_block, GC_reclaim_block,
GC_n_set_marks): Likewise.
* checksums.c [CHECKSUMS] (GC_add_block): Remove bytes local variable
(to avoid casting of hhdr->hb_sz).
* dbg_mlc.c (GC_debug_free): Change type of i and obj_sz local
variables from size_t to word.
* dbg_mlc.c (GC_check_leaked): Likewise.
* extra/pcr_interface.c (GC_enumerate_block): Change type of sz local
variable from int to size_t.
* extra/pcr_interface.c (GC_enumerate_block): Cast hhdr->hb_sz to
size_t when assigned to sz.
* mallocx.c (GC_realloc): Likewise.
* mark.c (GC_set_hdr_marks): Likewise.
* reclaim.c (GC_do_enumerate_reachable_objects): Likewise.
* include/private/gc_pmark.h [MARK_BIT_PER_OBJ] (PUSH_CONTENTS_HDR):
Cast hhdr->hb_sz to size_t in assignment of obj_displ.
* include/private/gc_priv.h (struct hblkhdr): Change type of hb_sz from
size_t to word.
* include/private/gc_priv.h (MARK_BIT_NO): Cast offset argument to word
instead of unsigned.
* malloc.c (GC_free): Cast hhdr->hb_sz to size_t.
* mallocx.c (GC_get_kind_and_size): Likewise.
* mark.c (GC_clear_hdr_marks): Likewise.
* misc.c (GC_size): Likewise.
* misc.c (GC_do_blocking): Remove redundant cast of hhdr->hb_sz.
* reclaim.c (GC_reclaim_clear, GC_reclaim_uninit,
GC_disclaim_and_reclaim, GC_continue_reclaim): Change type of sz
argument from size_t to word.
* typd_mlc.c (GC_array_mark_proc): Change type of sz and nwords local
variables from size_t to word.

6 years agoTravis CI: Test compilation of C tests as C++ ones
Ivan Maidanski [Thu, 8 Feb 2018 07:02:19 +0000 (10:02 +0300)]
Travis CI: Test compilation of C tests as C++ ones

Issue #201 (bdwgc).

6 years agoConvert cord tests to valid C++ code
Ivan Maidanski [Thu, 8 Feb 2018 06:57:23 +0000 (09:57 +0300)]
Convert cord tests to valid C++ code

Issue #201 (bdwgc).

* cord/tests/de.c (main): Cast buf to char* when passed to setvbuf().
* cord/tests/de_win.c (de_error): Change "char*" to "const char*" for
the argument (because ISO C++ forbids converting a string constant to
char*).
* cord/tests/de_win.h (de_error): Likewise.
* cord/tests/de_win.c (WinMain): Change type of hAccel local variable
from HANDLE to HACCEL; cast GetStockObject(WHITE_BRUSH) result to
HBRUSH type.
* cord/tests/de_win.c (plain_chars, control_chars): Cast
GC_MALLOC_ATOMIC() result to char*.
* cord/tests/de_win.c (WndProc): Change type of hInstance static
variable from HANDLE to HINSTANCE.

6 years agoCompile some GC tests as C++ to test extern 'C' in header files
Jay Krell [Thu, 8 Feb 2018 06:26:03 +0000 (09:26 +0300)]
Compile some GC tests as C++ to test extern 'C' in header files

Issue #201 (bdwgc).

* tests/CMakeLists.txt (SET_SOURCE_FILES_PROPERTIES): Add to treat
leak_test.c and test.c as C++ files.

6 years agoPut GC internal function prototypes in tests into extern 'C' block
Ivan Maidanski [Thu, 8 Feb 2018 06:02:14 +0000 (09:02 +0300)]
Put GC internal function prototypes in tests into extern 'C' block

Issue #201 (bdwgc).

* tests/disclaim_test.c [__cplusplus] (GC_random): Wrap the function
declaration into extern "C".
* tests/test.c [__cplusplus] [GC_AMIGA_FASTALLOC && AMIGA]
(GC_amiga_free_all_mem): Likewise.

6 years agoPut variable/function declarations into extern 'C' in cord headers
Ivan Maidanski [Wed, 7 Feb 2018 22:53:46 +0000 (01:53 +0300)]
Put variable/function declarations into extern 'C' in cord headers

Issue #201 (bdwgc).

* include/cord.h: Wrap variable and function declarations (but not
included headers).
* include/cord_pos.h: Likewise.
* include/ec.h: Likewise.

6 years agoMake uniform the comment for the end of extern 'C' block
Ivan Maidanski [Wed, 7 Feb 2018 22:46:14 +0000 (01:46 +0300)]
Make uniform the comment for the end of extern 'C' block
(code refactoring)

* include/gc_backptr.h [__cplusplus]: Adjust (make uniform) comment
for the end of extern "C" block.
* include/gc_gcj.h [__cplusplus]: Likewise.
* include/gc_mark.h [__cplusplus]: Likewise.
* include/gc_typed.h [__cplusplus]: Likewise.
* include/javaxfc.h [__cplusplus]: Likewise.

6 years agoPut variable/function declarations into extern 'C' in headers
Jay Krell [Wed, 7 Feb 2018 22:36:49 +0000 (01:36 +0300)]
Put variable/function declarations into extern 'C' in headers

Issue #201 (bdwgc).

Extern "C" should be only around declarations, not includes.
In particular, do not include 3rd-party headers (as well as our own
files as they could include others).

* include/gc.h [GC_PTHREADS]: Do not wrap include gc_pthread_redirects.h
into extern "C" block.
* include/gc_disclaim.h: Wrap variable and function declarations (but
not included headers).
* include/gc_inline.h: Likewise.
* include/gc_pthread_redirects.h [!GC_PTHREAD_REDIRECTS_ONLY]: Likewise.
* include/private/darwin_semaphore.h: Likewise.
* include/private/darwin_stop_world.h: Likewise.
* include/private/dbg_mlc.h: Likewise.
* include/private/gc_atomic_ops.h [GC_BUILTIN_ATOMIC]: Likewise.
* include/private/gc_hdrs.h: Likewise.
* include/private/gc_locks.h [THREADS]: Likewise.
* include/private/gc_pmark.h: Likewise.
* include/private/gc_priv.h: Likewise.
* include/private/gcconfig.h: Likewise.
* include/private/pthread_stop_world.h: Likewise.
* include/private/pthread_support.h [GC_PTHREADS && !GC_WIN32_THREADS]:
Likewise.
* include/private/specific.h: Likewise.
* include/private/thread_local_alloc.h [THREAD_LOCAL_ALLOC]: Likewise.

6 years agoCollapse multiple BCOPY_EXISTS macro definitions
Ivan Maidanski [Wed, 7 Feb 2018 08:52:11 +0000 (11:52 +0300)]
Collapse multiple BCOPY_EXISTS macro definitions
(code refactoring)

* include/private/gc_priv.h (BCOPY_EXISTS): Collapse multiple
definitions (and use "#elif").

6 years agoAdd GC prefix to _MSVC_DBG_H macro
Ivan Maidanski [Wed, 7 Feb 2018 08:25:09 +0000 (11:25 +0300)]
Add GC prefix to _MSVC_DBG_H macro
(code refactoring)

* include/private/msvc_dbg.h (_MSVC_DBG_H): Rename to GC_MSVC_DBG_H.
* include/private/msvc_dbg.h [__cplusplus]: Adjust indentation.

6 years agoInitial support of WinRT
Jonathan Chambers [Tue, 6 Feb 2018 08:59:25 +0000 (11:59 +0300)]
Initial support of WinRT
(part of commit 9379c66 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* include/private/gc_priv.h [MSWIN32] (GET_TIME): Use GetTickCount64
if MSWINRT_FLAVOR (instead of GetTickCount).
* include/private/gcconfig.h [_MSC_VER && _M_IX86>=300
|| _WIN32 && !__CYGWIN__ && !SYMBIAN && _M_ARM] (ARM32): Define macro.
* include/private/gcconfig.h [(_MSC_VER && _M_IX86>=300
|| _WIN32 && !__CYGWIN__ && !SYMBIAN) && !_XBOX_ONE
&& WINAPI_FAMILY==WINAPI_FAMILY_APP] (MSWINRT_FLAVOR): Likewise.
* include/private/gcconfig.h [MSWINRT_FLAVOR] (NO_GETENV): Likewise.
* include/private/gcconfig.h [X86_64 && MSWIN32] (DATAEND): Do not
define if already defined.
* misc.c [MSWIN32] (GC_win32_MessageBoxA): Do not define if
MSWINRT_FLAVOR.
* misc.c [MSWIN32] (GC_init): Call
InitializeCriticalSectionAndSpinCount() directly if MSWINRT_FLAVOR
(instead of using GetProcAddress).
* misc.c [MSWIN32 && MSWINRT_FLAVOR]: Include windows.storage.h.
* misc.c [MSWIN32 && MSWINRT_FLAVOR] (RoGetActivationFactory): Declare.
* misc.c [MSWIN32 && MSWINRT_FLAVOR] (getWinRTLogPath): New static
function.
* misc.c [MSWIN32 && MSWINRT_FLAVOR] (GC_CreateLogFile): Use
getWinRTLogPath().
* os_dep.c [GWW_VDB && MSWINRT_FLAVOR] (detect_GetWriteWatch): Use
memInfo.AllocationBase to get hK32.
* os_dep.c [USE_WINALLOC && !MSWIN_XBOX1] (GC_win32_get_mem,
GC_win32_free_heap): Do not use GlobalAlloc and GlobalFree if
MSWINRT_FLAVOR.

6 years agoConvert tests to valid C++ code
Jay Krell [Sun, 4 Feb 2018 08:35:26 +0000 (03:35 -0500)]
Convert tests to valid C++ code

Issue #201 (bdwgc).

* tests/leak_test.c (main): Add explicit casts of void* pointer
(returned by malloc) to the types of the variables the relevant
pointers are assigned to.
* tests/realloc_test.c (main): Likewise.
* tests/smash_test.c (main): Likewise.
* tests/test.c (run_one_test): Likewise.
* tests/test.c (typed_test): Rename "new" local variable to "newP".

6 years agoUpdate AUTHORS file (add Jay Krell)
Ivan Maidanski [Mon, 5 Feb 2018 07:14:09 +0000 (10:14 +0300)]
Update AUTHORS file (add Jay Krell)

6 years agoFix typo in comment in specific.h
Jay Krell [Mon, 5 Feb 2018 07:06:59 +0000 (10:06 +0300)]
Fix typo in comment in specific.h

* include/private/specific.h (tse): Fix a typo ("thread") in comment.

6 years agoDo not push 'cpsr' register on Darwin/arm
Ivan Maidanski [Fri, 2 Feb 2018 17:37:30 +0000 (20:37 +0300)]
Do not push 'cpsr' register on Darwin/arm

ARM cpsr stands for Control Program State Register.
It cannot contain a pointer.

* darwin_stop_world.c [ARM32] (GC_stack_range_for): Ignore cpsr
register; update comment.

6 years agoDo not push frame pointer on Darwin/arm and Darwin/arm64
Jonathan Chambers [Fri, 2 Feb 2018 17:29:20 +0000 (20:29 +0300)]
Do not push frame pointer on Darwin/arm and Darwin/arm64
(part of commit 9379c66 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK && ARM32]
(GC_stack_range_for): Pass r[7] (instead of sp register) to
GC_FindTopOfStack().
* darwin_stop_world.c [ARM32] (GC_stack_range_for): Do not push r[7]
register (as it holds frame pointer on iOS); add comment.
* darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK && AARCH64]
(GC_stack_range_for): Pass fp (instead of sp) register to
GC_FindTopOfStack().
* darwin_stop_world.c [AARCH64] (GC_stack_range_for): Do not push fp
register.

6 years agoImplement FindTopOfStack(0) for ARM and AArch64 (Darwin)
Jonathan Chambers [Fri, 2 Feb 2018 08:46:19 +0000 (11:46 +0300)]
Implement FindTopOfStack(0) for ARM and AArch64 (Darwin)
(part of commit 9379c66 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK && (ARM32 || AARCH64)]
(GC_FindTopOfStack): Set proper frame value (using asm instruction)
if stack_start is zero (instead of ABORT).

6 years agoAlways fail if FindTopOfStack(0) is not implemented but called (Darwin)
Ivan Maidanski [Fri, 2 Feb 2018 08:32:10 +0000 (11:32 +0300)]
Always fail if FindTopOfStack(0) is not implemented but called (Darwin)

* darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK] (GC_FindTopOfStack):
Initialize frame local variable first (to stack_start).
* darwin_stop_world.c [!DARWIN_DONT_PARSE_STACK && !POWERPC]
(GC_FindTopOfStack): Call ABORT with the appropriate message (instead
of GC_ASSERT) if stack_start iz zero.

6 years agoDefine macro to specify the environment file name extension (Win32/WinCE)
Ivan Maidanski [Fri, 2 Feb 2018 08:07:52 +0000 (11:07 +0300)]
Define macro to specify the environment file name extension (Win32/WinCE)
(code refactoring)

* misc.c [GC_READ_ENV_FILE] (GC_ENV_FILE_EXT): New macro.
* misc.c [GC_READ_ENV_FILE && (MSWIN32 || MSWINCE || CYGWIN32)]
(GC_envfile_init): Use GC_ENV_FILE_EXT instead of ".gc.env".

6 years agoDefine ABORT() using _CrtDbgBreak (if available) on Windows host
Ivan Maidanski [Thu, 1 Feb 2018 22:21:57 +0000 (01:21 +0300)]
Define ABORT() using _CrtDbgBreak (if available) on Windows host

Issue #173 (bdwgc).

* include/private/gc_priv.h [!CPPCHECK && !PCR && !NO_DEBUGGING
&& (MSWIN32 || MSWINCE)] (ABORT): Use _CrtDbgBreak() instead of
DebugBreak() if _CrtDbgBreak, _DEBUG and _MSC_VER macros are defined.

6 years agoFix 'undefined reference to __builtin_unwind_init' linker error (ArmCC)
Jonathan Chambers [Thu, 1 Feb 2018 21:35:49 +0000 (00:35 +0300)]
Fix 'undefined reference to __builtin_unwind_init' linker error (ArmCC)
(part of commit 9379c66 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* include/private/gcconfig.h (HAVE_BUILTIN_UNWIND_INIT): Do not define
if __ARMCC_VERSION.

6 years agoAvoid SIGSEGV during GC_INIT on some Android devices
Jonathan Chambers [Thu, 1 Feb 2018 08:53:34 +0000 (11:53 +0300)]
Avoid SIGSEGV during GC_INIT on some Android devices
(part of commit 9379c66 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* include/gc.h [(HOST_ANDROID || __ANDROID__) && !GC_NOT_DLL]
(GC_INIT_CONF_ROOTS): Define to empty unless IGNORE_DYNAMIC_LOADING;
add comment.

6 years agoInitial support of Sony PlayStation Portable 2
Jonathan Chambers [Thu, 1 Feb 2018 08:17:24 +0000 (11:17 +0300)]
Initial support of Sony PlayStation Portable 2
(part of commit 9379c66 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* alloc.c [!MACOS && !MSWINCE && !SN_TARGET_ORBIS && !__CC_ARM]:
Do not include sys/types.h if SN_TARGET_PSP2.
* dyn_load.c [!MACOS && !_WIN32_WCE && !SN_TARGET_ORBIS && !__CC_ARM]:
Likewise.
* os_dep.c [!OS2 && !PCR && !AMIGA && !MACOS && !MSWINCE
&& !SN_TARGET_ORBIS && !__CC_ARM]: Likewise.
* include/gc_config_macros.h [SN_TARGET_PSP2] (GC_THREADS): Define
macro.
* include/private/gcconfig.h [SN_TARGET_PSP2] (mach_type_known):
Likewise.
* include/private/gcconfig.h [ARM32 && SN_TARGET_PSP2] (NO_HANDLE_FORK,
DATASTART, DATAEND, STACKBOTTOM): Likewise.
* include/private/gcconfig.h [SN_TARGET_PSP2] (THREADS, GET_MEM):
Likewise.
* include/private/gc_locks.h [GC_PTHREADS && !GC_WIN32_THREADS
&& !SN_TARGET_ORBIS]: Do not include gc_atomic_ops.h if SN_TARGET_PSP2.
* include/private/gc_locks.h [SN_TARGET_PSP2]: Include psp2-support.h.
* include/private/gc_locks.h [SN_TARGET_PSP2] (GC_allocate_ml_PSP2):
Declare GC_EXTERN variable.
* include/private/gc_locks.h [SN_TARGET_PSP2] (UNCOND_LOCK,
UNCOND_UNLOCK): Define (using GC_allocate_ml_PSP2 instead of
GC_allocate_ml).
* include/private/gc_priv.h [!HBLKSIZE && (LARGE_CONFIG
|| !SMALL_CONFIG) && SN_TARGET_PSP2] (CPP_LOG_HBLKSIZE): Define to 16
(instead of 12).
* include/private/gcconfig.h [ARM32] (NOSYS): Do not define if
SN_TARGET_PSP2.
* os_dep.c (SBRK_ARG_T, OPT_MAP_ANON, GC_unix_mmap_get_mem,
GC_unix_sbrk_get_mem, GC_unix_get_mem): Likewise.
* pthread_support.c (GC_pthread_join, GC_pthread_detach,
GC_pthread_create): Likewise.
* include/private/gcconfig.h [ARM32 && SN_TARGET_PSP2]
(psp2_get_stack_bottom): Declare external function.
* include/private/gcconfig.h [SN_TARGET_PSP2] (psp2_get_mem): Likewise.
* include/private/gcconfig.h [USE_MUNMAP && !MUNMAP_THRESHOLD
&& SN_TARGET_PSP2] (MUNMAP_THRESHOLD): Define to 2.
* mach_dep.c: Skip everything in this file if SN_TARGET_PSP2.
* pthread_stop_world.c: Likewise.
* misc.c [SN_TARGET_PSP2] (GC_allocate_ml_PSP2): Define global varible
(instead of GC_allocate_ml).
* misc.c [!MSWIN32 && !MSWINCE && !OS2 && !MACOS && !GC_ANDROID_LOG
&& !NN_PLATFORM_CTR && !NINTENDO_SWITCH && !AMIGA && !SN_TARGET_ORBIS
&& !__CC_ARM]: Do not include unistd.h if SN_TARGET_PSP2.
* misc.c [SN_TARGET_PSP2] (GC_write): Define to no-op.
* pthread_support.c: Do not include sys/mman.h if SN_TARGET_PSP2.

6 years agoRemove ARM32 macro duplicate definition for Nintendo in gcconfig.h
Ivan Maidanski [Wed, 31 Jan 2018 21:39:25 +0000 (00:39 +0300)]
Remove ARM32 macro duplicate definition for Nintendo in gcconfig.h
(fix of commit 9718229)

Issue #173 (bdwgc).

* include/private/gcconfig.h [NN_PLATFORM_CTR] (ARM32): Remove macro
duplicate definition.

6 years agoNew macro ALWAYS_SMALL_CLEAR_STACK to avoid clearing large stack sections
Jonathan Chambers [Wed, 31 Jan 2018 08:45:26 +0000 (11:45 +0300)]
New macro ALWAYS_SMALL_CLEAR_STACK to avoid clearing large stack sections
(a cherry-pick of commit 95f5767 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

Avoid clearing large sections of the stack.  It was clearing
up to 16k which may not be available in cases of small stacks or stack
overflow situations (for some targets).

* misc.c [ALWAYS_SMALL_CLEAR_STACK] (GC_clear_stack): Do only BZERO for
dummy where dummy is a local array of length SMALL_CLEAR_SIZE.

6 years agoDo not define clear_stack_inner and next_random_no if not used
Ivan Maidanski [Wed, 31 Jan 2018 08:11:31 +0000 (11:11 +0300)]
Do not define clear_stack_inner and next_random_no if not used
(code refactoring of commits 4eaea0afab850e1c9b)

* misc.c (SMALL_CLEAR_SIZE): Do not define if already defined; define
even if THREADS is not defined.
* misc.c [STACK_NOT_SCANNED] (GC_clear_stack): Standalone definition
(just return arg).
* misc.c (BIG_CLEAR_SIZE, GC_stack_last_cleared, GC_min_sp,
GC_high_water, GC_bytes_allocd_at_reset, DEGRADE_RATE,
GC_clear_stack_inner, next_random_no): Do not define if
STACK_NOT_SCANNED.
* misc.c [!STACK_NOT_SCANNED] (CLEAR_SIZE): Do not define if
ASM_CLEAR_CODE.
* misc.c (GC_stack_last_cleared, GC_min_sp, GC_high_water,
GC_bytes_allocd_at_reset, GC_clear_stack_inner, next_random_no,
GC_clear_stack): Adjust indentation.

6 years agoWorkaround 'address of auto-variable returned' cppcheck error
Ivan Maidanski [Tue, 30 Jan 2018 08:11:45 +0000 (11:11 +0300)]
Workaround 'address of auto-variable returned' cppcheck error

* mark_rts.c [CPPCHECK] (GC_approx_sp): Use __builtin_frame_address.
* mark_rts.c (GC_approx_sp): Replace GC_GNUC_PREREQ(4,0) with
__GNUC__>=4; add TODO item.

6 years agoInitial support of Xbox One (DURANGO) target
Jonathan Chambers [Tue, 30 Jan 2018 07:32:38 +0000 (10:32 +0300)]
Initial support of Xbox One (DURANGO) target
(part of commit 9379c66 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* include/private/gc_priv.h [THREADS && MSWIN_XBOX1] (GC_write_cs):
Declare.
* include/private/gcconfig.h [(_MSC_VER && _M_IX86 >= 300 || _WIN32)
&& _XBOX_ONE] (MSWIN_XBOX1): Define (instead of MSWIN32).
* include/private/gcconfig.h [X86_64 && MSWIN_XBOX1] (NO_GETENV,
DATASTART, DATAEND, STACKBOTTOM, GETPAGESIZE, USE_MMAP, PROT_NONE,
PROT_READ, PROT_WRITE, PROT_EXEC, MAP_PRIVATE, MAP_FIXED, MAP_FAILED):
Define.
* include/private/gcconfig.h [X86_64 && MSWIN_XBOX1]
(durango_get_stack_bottom): Declare external function.
* include/private/gcconfig.h [USE_MUNMAP && !MUNMAP_THRESHOLD
&& MSWIN_XBOX1] (MUNMAP_THRESHOLD): Define to 2; update comment.
* include/private/gcconfig.h [GC_WIN32_THREADS && !CYGWIN32
&& !MSWIN32 && !MSWINCE]: Do not issue #error if MSWIN_XBOX1.
* include/private/gcconfig.h [MSWIN_XBOX1] (durango_get_mem): Declare
function.
* include/private/gcconfig.h [MSWIN_XBOX1] (GET_MEM): Define.
* mark_rts.c [DYNAMIC_LOADING] (GC_cond_register_dynamic_libraries):
Do not call GC_remove_tmp_roots and GC_register_dynamic_libraries
if MSWIN_XBOX1 (set GC_no_dls to true instead).
* misc.c [MSWIN_XBOX1 && THREADS] (GC_write_cs): Define variable.
* misc.c [!MSWIN32 && !MSWINCE && !OS2 && !MACOS && !GC_ANDROID_LOG
&& !NN_PLATFORM_CTR && !NINTENDO_SWITCH && !AMIGA && !SN_TARGET_ORBIS
&& !__CC_ARM]: Do not include unistd.h if MSWIN_XBOX1.
* os_dep.c [!OS2 && !PCR && !AMIGA && !MACOS && !MSWINCE
&& !SN_TARGET_ORBIS && !__CC_ARM && !MSWIN32]: Likewise.
* os_dep.c [MMAP_SUPPORTED && MSWIN_XBOX1] (durango_get_mem): Define
new internal function.
* os_dep.c [!MSWINCE && USE_WINALLOC] (GLOBAL_ALLOC_TEST,
GC_mem_top_down, GC_win32_get_mem, GC_win32_free_heap): Do not define
if MSWIN_XBOX1.
* win32_threads.c [!CYGWIN32 && !MSWINCE] (GC_beginthreadex): Likewise.
* os_dep.c [USE_MUNMAP && !NN_PLATFORM_CTR && !MSWIN32 && !MSWINCE]:
Do not include unistd.h, sys/mman.h, sys/stat.h, sys/types.h if
MSWIN_XBOX1.
* win32_threads.c [GC_ASSERTIONS] (GC_write_disabled): Define only if
MSWIN32 or MSWINCE.
* win32_threads.c [GC_ASSERTIONS] (GC_stop_world): Do not use
GC_write_disabled if MSWIN_XBOX1.
* win32_threads.c [PARALLEL_MARK && !GC_PTHREADS_PARAMARK
&& MSWIN_XBOX1] (GC_start_mark_threads_inner): Use CreateThread()
instead of _beginthreadex().

6 years agoInitial support of Orbis target
Jonathan Chambers [Sun, 28 Jan 2018 07:13:10 +0000 (10:13 +0300)]
Initial support of Orbis target
(part of commit 9379c66 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* alloc.c [!MACOS && !MSWINCE && !__CC_ARM]: Do not include
sys/types.h if SN_TARGET_ORBIS.
* dyn_load.c [!MACOS && !_WIN32_WCE && !__CC_ARM]: Likewise.
* include/gc_config_macros.h [SN_TARGET_ORBIS] (GC_THREADS): Define.
* include/gc_config_macros.h [__FreeBSD__] (GC_FREEBSD_THREADS): Do
not define if SN_TARGET_ORBIS.
* include/private/gcconfig.h [__FreeBSD__ || __DragonFly__
|| __FreeBSD_kernel__] (FREEBSD): Likewise.
* include/private/gcconfig.h [!LINUX && !NETBSD && !FREEBSD
&& !OPENBSD && !DARWIN && !_WIN32 && !__CEGCC__ && !NN_PLATFORM_CTR
!NN_BUILD_TARGET_PLATFORM_NX && !SYMBIAN] (NOSYS): Likewise.
* include/private/gc_locks.h [THREADS && GC_PTHREADS
&& !GC_WIN32_THREADS]: Do not include gc_atomic_ops.h if
SN_TARGET_ORBIS.
* include/private/gc_locks.h [SN_TARGET_ORBIS && GC_PTHREADS]
(USE_PTHREAD_LOCKS): Define.
* include/private/gc_priv.h [SN_TARGET_ORBIS] (CPP_LOG_HBLKSIZE):
Define to 16 (instead of 12).
* include/private/gcconfig.h [SN_TARGET_ORBIS && (__amd64__
|| __x86_64__)] (X86_64): Define.
* include/private/gcconfig.h [X86_64] (CACHE_LINE_SIZE): Do not define
if already defined.
* include/private/gcconfig.h [X86_64 && SN_TARGET_ORBIS] (DATASTART,
DATAEND, STACKBOTTOM): Define.
* include/private/gcconfig.h [X86_64 && SN_TARGET_ORBIS]: Include
pthread.h.
* include/private/gcconfig.h [X86_64 && SN_TARGET_ORBIS]
(ps4_get_stack_bottom): Declare.
* include/private/gcconfig.h [USE_MUNMAP && !MUNMAP_THRESHOLD
&& SN_TARGET_ORBIS] (MUNMAP_THRESHOLD): Define to 2.
* include/private/gcconfig.h [SN_TARGET_ORBIS] (THREADS): Define.
* pthread_support.c: Do not include sys/mman.h, sys/time.h,
sys/types.h, fcntl.h if SN_TARGET_ORBIS.
* pthread_support.c (GC_pthread_join, GC_pthread_detach,
GC_pthread_create): Do not define if SN_TARGET_ORBIS.

6 years agoRemove duplicate definition of ALIGNMENT macro for OpenBSD/arm
Ivan Maidanski [Sat, 27 Jan 2018 07:38:44 +0000 (10:38 +0300)]
Remove duplicate definition of ALIGNMENT macro for OpenBSD/arm
(code refactoring)

* include/private/gcconfig.h [ARM32 && OPENBSD] (ALIGNMENT): Remove
(as it is already defined for ARM32).

6 years agoInitial support of Nintendo platform
Jonathan Chambers [Sat, 27 Jan 2018 07:24:12 +0000 (10:24 +0300)]
Initial support of Nintendo platform
(part of commit 9379c66 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* include/gc_config_macros.h [(!GC_WIN32_THREADS || GC_WIN32_PTHREADS
|| __CYGWIN32__ || __CYGWIN__) && GC_THREADS] (GC_PTHREADS): Do not
define if NN_PLATFORM_CTR or NN_BUILD_TARGET_PLATFORM_NX.
* include/private/gc_priv.h [NN_PLATFORM_CTR] (CLOCK_TYPE, GET_TIME,
MS_TIME_DIFF): Define macro.
* include/private/gc_priv.h [!PCR && (NN_PLATFORM_CTR
|| NINTENDO_SWITCH)] (STOP_WORLD, START_WORLD): Likewise.
* include/private/gcconfig.h [NN_PLATFORM_CTR] (ARM32,
mach_type_known): Likewise.
* include/private/gcconfig.h [NN_BUILD_TARGET_PLATFORM_NX]
(NINTENDO_SWITCH, mach_type_known): Likewise.
* include/private/gcconfig.h [NN_PLATFORM_CTR] (DATASTART, DATAEND,
STACKBOTTOM): Likewise.
* include/private/gcconfig.h [NINTENDO_SWITCH] (NO_HANDLE_FORK,
DATASTART, DATAEND, STACKBOTTOM): Likewise.
* include/private/gcconfig.h [NN_PLATFORM_CTR || NINTENDO_SWITCH]
(THREADS): Likewise.
* include/private/gcconfig.h [NINTENDO_SWITCH] (GET_MEM):
Likewise.
* misc.c [NN_PLATFORM_CTR || NINTENDO_SWITCH] (WRITE): Likewise.
* include/private/gc_priv.h [NN_PLATFORM_CTR] (n3ds_get_system_tick
n3ds_convert_tick_to_ms): Declare external function.
* include/private/gc_priv.h [!PCR && (NN_PLATFORM_CTR
|| NINTENDO_SWITCH)] (GC_stop_world, GC_start_world): Declare.
* include/private/gcconfig.h [NN_PLATFORM_CTR] (Image$$ZI$$ZI$$Base,
Image$$ZI$$ZI$$Limit, n3ds_get_stack_bottom): Likewise.
* include/private/gcconfig.h [NINTENDO_SWITCH] (__bss_end,
switch_get_stack_bottom): Likewise.
* include/private/gcconfig.h [NINTENDO_SWITCH] (switch_get_mem):
Likewise.
* misc.c [NN_PLATFORM_CTR] (n3ds_log_write): Likewise.
* misc.c [NINTENDO_SWITCH] (switch_log_write): Likewise.
* include/private/gcconfig.h [__aarch64__ && !LINUX && !DARWIN
&& !FREEBSD] (NOSYS): Do not define if NN_BUILD_TARGET_PLATFORM_NX.
* include/private/gcconfig.h [(__arm || __arm__ || __thumb__)
&& !NACL && !LINUX && !NETBSD && !FREEBSD && !OPENBSD && !DARWIN
&& !_WIN32 && !__CEGCC__ && !SYMBIAN] (NOSYS): Do not define
if NN_PLATFORM_CTR or NN_BUILD_TARGET_PLATFORM_NX.
* misc.c [!OS2 && !MACOS && !GC_ANDROID_LOG && !MSWIN32 && !MSWINCE]
(GC_stdout, GC_stderr, GC_log, GC_set_log_fd): Do not define if
NN_PLATFORM_CTR or NINTENDO_SWITCH.
* misc.c [NN_PLATFORM_CTR] (GC_init): Call GC_get_main_stack_base()
to set GC_stackbottom.
* os_dep.c (SBRK_ARG_T, OPT_MAP_ANON, GC_unix_mmap_get_mem,
GC_unix_sbrk_get_mem, GC_unix_get_mem): Do not define if
NINTENDO_SWITCH.
* os_dep.c [USE_MUNMAP]: Do not include unistd.h, sys/mman.h,
sys/stat.h, sys/types.h if NN_PLATFORM_CTR.
* os_dep.c [NN_PLATFORM_CTR || NINTENDO_SWITCH]
(GC_default_push_other_roots): Redirect to GC_push_all_stacks.

6 years agoUpdate ChangeLog file
Ivan Maidanski [Fri, 26 Jan 2018 13:36:06 +0000 (16:36 +0300)]
Update ChangeLog file

6 years agoUpdate ChangeLog file (v7.6 changes only)
Ivan Maidanski [Fri, 26 Jan 2018 11:30:43 +0000 (14:30 +0300)]
Update ChangeLog file (v7.6 changes only)
(a cherry-pick of commit 62d9d038 from 'release-7_6')

6 years agoDefine HEURISTIC2 when STACKBOTTOM is not defined for OpenBSD
Peter Wang [Thu, 25 Jan 2018 22:35:20 +0000 (01:35 +0300)]
Define HEURISTIC2 when STACKBOTTOM is not defined for OpenBSD
(fix of commit ef879a9)

Issue #198 (bdwgc).

* include/private/gcconfig.h [(POWERPC || SPARC || I386 || MIPS
|| HP_PA || ALPHA || ARM32 || SH && !SH4 || X86_64) && OPENBSD
&& !GC_OPENBSD_THREADS && !USRSTACK] (HEURISTIC2): Define.
* include/private/gcconfig.h [SH && !SH4 && OPENBSD]: Reformat code.

6 years agoRun command passed to if_not_there directly from Makefile.direct
Ivan Maidanski [Wed, 24 Jan 2018 16:19:30 +0000 (19:19 +0300)]
Run command passed to if_not_there directly from Makefile.direct

Issue #199 (bdwgc).

if_not_there tool is modified to accept a single argument (file name).

* Makefile.direct (base_lib, cords, test_cpp, c++, mach_dep.o, mark_rts.o,
cord/cordtest, cord/de, gctest): Replace "if_not_there <file> <command>"
with "if_not_there <file> || <command>".
* Makefile.direct (c++): Add dependency on $(UTILS).
* Makefile.direct (gctest): Remove double spaces.
* tools/if_not_there.c: Update header comment.
* tools/if_not_there.c (main): Allow both 2 and 3 command-line arguments;
return 2 if the file does not exist and argc is 2; update the printed
usage message.

6 years agoFix 'undeclared identifier USRSTACK' compiler error on OpenBSD-6.2
Peter Wang [Wed, 24 Jan 2018 14:37:23 +0000 (17:37 +0300)]
Fix 'undeclared identifier USRSTACK' compiler error on OpenBSD-6.2

Issue #198 (bdwgc).

USRSTACK macro is defined in <machine/vmparam.h> but that is protected
by "ifdef _KERNEL" in <uvm/uvm_param.h>.

* include/private/gcconfig.h [POWERPC && OPENBSD && !GC_OPENBSD_THREADS]
(STACKBOTTOM): Add comment.
* include/private/gcconfig.h [(POWERPC || SPARC || I386 || MIPS
|| HP_PA || ALPHA || ARM32 || SH && !SH4 || X86_64) && OPENBSD
&& !GC_OPENBSD_THREADS] (STACKBOTTOM): Define only if USRSTACK is
defined.
* include/private/gcconfig.h [MIPS && OPENBSD]: Reformat code.

6 years agoUpdate ChangeLog file
Ivan Maidanski [Wed, 24 Jan 2018 14:10:55 +0000 (17:10 +0300)]
Update ChangeLog file

6 years agoUpdate AUTHORS file
Ivan Maidanski [Tue, 23 Jan 2018 15:01:37 +0000 (18:01 +0300)]
Update AUTHORS file

6 years agoInitial support of Haiku/amd64
Calvin Buckley [Tue, 23 Jan 2018 14:54:59 +0000 (17:54 +0300)]
Initial support of Haiku/amd64
(port of commit e52f300 from 'mono_libgc')

* configure.ac [THREADS=posix && host=*-*-haiku*] (GC_THREADS,
_REENTRANT, PARALLEL_MARK, THREAD_LOCAL_ALLOC): Define macro.
* include/gc_config_macros.h [GC_THREADS && __HAIKU__]
(GC_HAIKU_THREADS): Likewise.
* include/private/gcconfig.h [__HAIKU__ && _X86_] (I386, HAIKU,
mach_type_known): Likewise.
* include/private/gcconfig.h [__HAIKU__ && __amd64__] (X86_64, HAIKU,
mach_type_known): Likewise.
* include/private/gcconfig.h [I386 && HAIKU] (DYNAMIC_LOADING,
MPROTECT_VDB): Likewise.
* include/private/gcconfig.h [X86_64 && HAIKU] (OS_TYPE, GETPAGESIZE,
DATASTART, DYNAMIC_LOADING, MPROTECT_VDB): Likewise.
* include/private/gcconfig.h [HAIKU] (UNIX_LIKE, GET_MEM): Likewise.
* os_dep.c [MPROTECT_VDB && !DARWIN && !MSWIN32 && !MSWINCE
&& HAIKU] (CODE_OK): Likewise.
* dyn_load.c [HAIKU] (GC_register_dynamic_libraries): Implement.
* os_dep.c [HAIKU] (GC_haiku_get_mem): Likewise.
* include/private/gcconfig.h (BEOS): Rename to HAIKU.
* os_dep.c (BEOS): Likewise.
* include/private/gcconfig.h [I386 && HAIKU] (OS_TYPE): Change value
to "HAIKU".
* include/private/gcconfig.h [X86_64 && HAIKU]: Include OS.h; declare
etext symbol.
* include/private/gcconfig.h [HAIKU] (GC_haiku_get_mem): Declare
prototype.
* os_dep.c [(NEED_FIND_LIMIT || UNIX_LIKE) && HAIKU] (old_segv_act):
Define static variable.
* os_dep.c [(NEED_FIND_LIMIT || UNIX_LIKE) && HAIKU]
(GC_set_and_save_fault_handler): Use old_segv_act; call
sigaction(SIGSEGV).
* os_dep.c [NEED_FIND_LIMIT || (USE_PROC_FOR_LIBRARIES && THREADS)]
(GC_reset_fault_handler): Likewise.
* os_dep.c [MPROTECT_VDB && !DARWIN && !USE_WINALLOC && HAIKU]: Do not
include sys/syscall.h.
* pthread_support.c [GC_HAIKU_THREADS] (GC_get_nprocs): Define function.

6 years agoUse HOST_ANDROID define instead of PLATFORM_ANDROID
Zoltan Varga [Tue, 23 Jan 2018 02:38:02 +0000 (05:38 +0300)]
Use HOST_ANDROID define instead of PLATFORM_ANDROID
(a cherry-pick of commit 5d819c8 from 'mono_libgc')

* doc/README.macros (PLATFORM_ANDROID): Rename to HOST_ANDROID.
* dyn_load.c: Rename PLATFORM_ANDROID to HOST_ANDROID.
* include/gc.h: Likewise.
* include/gc_config_macros.h: Likewise.
* include/private/gcconfig.h: Likewise.
* include/private/thread_local_alloc.h: Likewise.
* os_dep.c: Likewise.
* pthread_support.c: Likewise.
* tests/initsecondarythread.c: Likewise.
* tests/test.c: Likewise.
* tools/threadlibs.c: Likewise.

6 years agoRename PLATFORM_TIZEN macro to HOST_TIZEN
Ivan Maidanski [Tue, 23 Jan 2018 02:22:22 +0000 (05:22 +0300)]
Rename PLATFORM_TIZEN macro to HOST_TIZEN
(code refactoring of commit a3a5949)

* include/private/gcconfig.h (PLATFORM_TIZEN): Rename to HOST_TIZEN.

6 years agoUpdate ChangeLog file (v7.6 changes only)
Ivan Maidanski [Wed, 24 Jan 2018 13:29:26 +0000 (16:29 +0300)]
Update ChangeLog file (v7.6 changes only)
(a cherry-pick of commit 82a81eed from 'release-7_6')

6 years agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Mon, 22 Jan 2018 06:34:28 +0000 (09:34 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)
(a cherry-pick of commit 357a28b8 from 'release-7_4')

6 years ago.gitignore: Ignore 'cords' marker file (generated by Makefile.direct)
Ivan Maidanski [Wed, 24 Jan 2018 13:13:26 +0000 (16:13 +0300)]
.gitignore: Ignore 'cords' marker file (generated by Makefile.direct)

6 years agoFix 'cords' parallel build in Makefile.direct
Ivan Maidanski [Tue, 23 Jan 2018 16:28:21 +0000 (19:28 +0300)]
Fix 'cords' parallel build in Makefile.direct

* Makefile.direct (cords): Create empty "cords" file after the last
if_not_there command is executed.
* Makefile.direct (clean): Remove "cords" file.

6 years agoDelete dont_ar_* build intermediate files on make clean (Makefile.direct)
Ivan Maidanski [Tue, 23 Jan 2018 15:31:44 +0000 (18:31 +0300)]
Delete dont_ar_* build intermediate files on make clean (Makefile.direct)

* Makefile.direct (clean): Add "rm dont_ar_*"; reorder items.

6 years ago.gitignore: Ignore dont_ar_* files (generated by Makefile.direct)
Ivan Maidanski [Tue, 23 Jan 2018 15:18:55 +0000 (18:18 +0300)]
.gitignore: Ignore dont_ar_* files (generated by Makefile.direct)

6 years agoFix libgc version which was changed in a linkage breaking way (master)
Ivan Maidanski [Thu, 18 Jan 2018 22:18:31 +0000 (01:18 +0300)]
Fix libgc version which was changed in a linkage breaking way (master)

Issue #197 (bdwgc).

* Makefile.am (LIBGC_VER_INFO): Change from 5:0:3 to 5:0:4 (to bring
SONAME back to libgc.so.1).

6 years agoUpdate AUTHORS file (add Gustavo Giraldez)
Ivan Maidanski [Thu, 18 Jan 2018 21:55:08 +0000 (00:55 +0300)]
Update AUTHORS file (add Gustavo Giraldez)

6 years agoFix GC allocation mutex in child after a fork
Gustavo Giraldez [Thu, 18 Jan 2018 21:52:25 +0000 (00:52 +0300)]
Fix GC allocation mutex in child after a fork

Even though after a fork the child only inherits the single thread
that called the fork(), if another thread in the parent was attempting
to lock the mutex while being held in fork_child_prepare(), the mutex
will be left in an inconsistent state in the child after the UNLOCK().
This is the case, at least, in Mac OS X and leads to an unusable GC in
the child which will block when attempting to perform any GC operation
that acquires the mutex.

* pthread_support.c [CAN_HANDLE_FORK && USE_PTHREAD_LOCKS]
(fork_child_proc): Add assertion (after UNLOCK) that the lock is not
held actually, and, then, re-initialize GC_allocate_ml; add comments.

6 years agoPass CFLAGS_FOR_PIC value to CFLAGS in Makefile.direct
Paul Bone [Thu, 18 Jan 2018 08:42:05 +0000 (11:42 +0300)]
Pass CFLAGS_FOR_PIC value to CFLAGS in Makefile.direct
(part of commit 91bf29b1a from Mercury-Language/bdwgc)

* Makefile.direct (CFLAGS): Add comment.
* Makefile.direct (CFLAGS, SPECIALCFLAGS): Add $(CFLAGS_FOR_PIC).

6 years agoUpdate AUTHORS file (add Alexis Laferriere)
Ivan Maidanski [Thu, 18 Jan 2018 08:12:23 +0000 (11:12 +0300)]
Update AUTHORS file (add Alexis Laferriere)

6 years agoTreat Android platform as Linux (CMake)
Alexis Laferriere [Mon, 30 Oct 2017 18:54:02 +0000 (14:54 -0400)]
Treat Android platform as Linux (CMake)

* CMakeLists.txt (HOST): Replace "android" string (if present) to
"linux".

6 years agoSupport threads for DragonFly in configure
Ivan Maidanski [Wed, 17 Jan 2018 22:14:27 +0000 (01:14 +0300)]
Support threads for DragonFly in configure

* configure.ac [THREADS=posix && host=*-*-dragonfly*] (GC_THREADS,
_REENTRANT, PARALLEL_MARK, THREAD_LOCAL_ALLOC): Define similar
to *-*-freebsd*.

6 years agoFix missing EOLn output in threadlibs tool
Ivan Maidanski [Wed, 17 Jan 2018 21:46:38 +0000 (00:46 +0300)]
Fix missing EOLn output in threadlibs tool

* tools/threadlibs.c [GC_OSF1_THREADS] (main): Print "\n" after "-lrt".

6 years agoDo not declare dl_iterate_phdr as weak for DragonFly
Ivan Maidanski [Wed, 17 Jan 2018 08:45:56 +0000 (11:45 +0300)]
Do not declare dl_iterate_phdr as weak for DragonFly

* dyn_load.c [!USE_PROC_FOR_LIBRARIES && __DragonFly__]
(HAVE_DL_ITERATE_PHDR, DL_ITERATE_PHDR_STRONG): Define.

6 years agoFix threadlibs tool to output '-lpthread' for DragonFly
Ivan Maidanski [Wed, 17 Jan 2018 08:43:09 +0000 (11:43 +0300)]
Fix threadlibs tool to output '-lpthread' for DragonFly

* tools/threadlibs.c [GC_FREEBSD_THREADS && (__DragonFly__
|| !__FREEBSD_version)] (main): Print "-lpthread" (as well as for
__FREEBSD_version >= 500000).

6 years agoChange compiler invocation example in gc.man to use dynamic libgc
Ivan Maidanski [Wed, 17 Jan 2018 07:46:56 +0000 (10:46 +0300)]
Change compiler invocation example in gc.man to use dynamic libgc

* doc/gc.man (SYNOPSIS): Replace gc.a to -lgc option in the compiler
(cc) invocation example.

6 years agoAdd note of set_free_space_divisor, set_warn_proc ABI change after gc-7.1
Ivan Maidanski [Wed, 17 Jan 2018 07:42:04 +0000 (10:42 +0300)]
Add note of set_free_space_divisor, set_warn_proc ABI change after gc-7.1

Issue #197 (bdwgc).

GC_set_free_space_divisor() and GC_set_warn_proc() used to return
some value.  But starting from version 7.1alpha2, these API functions
do not return any value.

* include/gc.h (GC_set_free_space_divisor, GC_set_warn_proc): Add
comment that the setter used to returned the old value in gc-7.1 (and
previous versions).

6 years agoPrevent DATASTART redefinition for NaCl
Ivan Maidanski [Mon, 15 Jan 2018 23:22:37 +0000 (02:22 +0300)]
Prevent DATASTART redefinition for NaCl
(fix commit 9738a14)

* include/private/gcconfig.h [NACL] (NO_PTHREAD_GETATTR_NP): Define.
* include/private/gcconfig.h [I386 && NACL] (OS_TYPE, etext, DATASTART,
_end, DATAEND, STACK_GRAN, HEURISTIC1, NO_PTHREAD_GETATTR_NP,
GETPAGESIZE, MAX_NACL_GC_THREADS): Remove.

6 years agoRemove Android-specific code in gcconfig.h for M68K
Ivan Maidanski [Mon, 15 Jan 2018 23:05:34 +0000 (02:05 +0300)]
Remove Android-specific code in gcconfig.h for M68K

* include/private/gcconfig.h [M68K && LINUX && __ELF__]
(SEARCH_FOR_DATA_START): Do not check PLATFORM_ANDROID macro.

6 years agoTravis CI: Fix ASan build with Clang-4.0 (add sudo)
Ivan Maidanski [Mon, 15 Jan 2018 22:19:01 +0000 (01:19 +0300)]
Travis CI: Fix ASan build with Clang-4.0 (add sudo)

6 years agoInitial support of TIZEN platform
Jonathan Chambers [Mon, 15 Jan 2018 22:03:05 +0000 (01:03 +0300)]
Initial support of TIZEN platform
(part of commit 9379c66 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* include/private/gcconfig.h [TIZEN] (PLATFORM_TIZEN): New macro.
* include/private/gcconfig.h [I386 && LINUX && __ELF__
&& PLATFORM_TIZEN] (SEARCH_FOR_DATA_START, GC_NO_SIGSETJMP): Define.
* include/private/gcconfig.h [ARM32 && LINUX && __ELF__
&& PLATFORM_TIZEN] (SEARCH_FOR_DATA_START): Likewise.
* include/private/gcconfig.h [PLATFORM_TIZEN && !GETPAGESIZE]
(GETPAGESIZE): Define to sysconf(_SC_PAGESIZE).
* include/private/gcconfig.h [CAN_HANDLE_FORK] (CAN_CALL_ATFORK): Do
not define if PLATFORM_TIZEN.

6 years agoFix global operator delete definition for C++14 in gc_cpp
Ivan Maidanski [Mon, 15 Jan 2018 05:20:02 +0000 (08:20 +0300)]
Fix global operator delete definition for C++14 in gc_cpp

Issue #195 (bdwgc).

Sized variants of global operator delete should be defined along with
the non-sized ones.  Otherwise compiler might invoke the one from the
standard library (as observed in e.g. Cygwin) leading to a crash.

* gc_cpp.cc [!_MSC_VER && __cplusplus>201103L] (operator delete):
Define sized variant (the size argument is ignored for now).
* gc_cpp.cc [!_MSC_VER && __cplusplus>201103L && GC_OPERATOR_NEW_ARRAY
&& !CPPCHECK] (operator delete[]): Likewise.

6 years agoFix last_reclaimed..gc_no interval comparison to threshold in unmap_old
Ivan Maidanski [Sun, 14 Jan 2018 07:51:06 +0000 (10:51 +0300)]
Fix last_reclaimed..gc_no interval comparison to threshold in unmap_old
(fix commit 14c324f8b)

* allchblk.c [USE_MUNMAP] (GC_unmap_old): Replace
(unsigned short)GC_gc_no-hb_last_reclaimed to
(unsigned short)(GC_gc_no-hb_last_reclaimed) to handle
value wrapping in hb_last_reclaimed (and the truncated GC_gc_no)
correctly.

6 years agoImplement memory unmapping for Sony PS/3
Jonathan Chambers [Sun, 14 Jan 2018 07:23:34 +0000 (10:23 +0300)]
Implement memory unmapping for Sony PS/3
(part of commit 9379c66 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* os_dep.c [USE_MUNMAP && !MSWIN32 && !MSWINCE && SN_TARGET_PS3]:
Include sys/mman.h instead of sys/memory.h.
* os_dep.c [USE_MUNMAP && !USE_WINALLOC && SN_TARGET_PS3]
(GC_unmap): Call ps3_free_mem() instead of mmap().

6 years agoRemove obsolete advice about linking with _DYNAMIC=0 (Linux)
Peter Wang [Fri, 12 Jan 2018 16:50:47 +0000 (19:50 +0300)]
Remove obsolete advice about linking with _DYNAMIC=0 (Linux)

Issue #196 (bdwgc).

The mentioned GCC option is not needed since gc-5.0alpha3 (when
_DYNAMIC symbol was declared as weak in dyn_load.c).
Even more, the advice is problematic for Alpine Linux (and probably
other systems using musl) as building a program with gcc -static
produces a binary containing a _DYNAMIC symbol with a non-zero address,
and forcing the address to 0 causes a crash during GC initialization.

* doc/README.linux: Remove note that static executable should be
linked with the gcc option "-Wl,-defsym,_DYNAMIC=0".

6 years agoReduce the default MUNMAP_THRESHOLD value to 2 for Sony PS/3
Jonathan Chambers [Fri, 12 Jan 2018 16:18:46 +0000 (19:18 +0300)]
Reduce the default MUNMAP_THRESHOLD value to 2 for Sony PS/3
(part of commit 9379c66 from Unity-Technologies/bdwgc)

Issue #173 (bdwgc).

* include/private/gcconfig.h [USE_MUNMAP && !MUNMAP_THRESHOLD
&& SN_TARGET_PS3] (MUNMAP_THRESHOLD): Define to 2; add comment.

6 years agoAdd check that gc_cpp operator delete is called (test_cpp)
Ivan Maidanski [Thu, 11 Jan 2018 23:57:32 +0000 (02:57 +0300)]
Add check that gc_cpp operator delete is called (test_cpp)

Issue #195 (bdwgc).

* tests/test_cpp.cc (GC_CHECKED_DELETE): New macro.
* tests/test_cpp.cc (main): Use GC_CHECKED_DELETE() instead of operator
delete (where it is expected that the operator defined in gc_cpp.c/h
is called).

6 years agoNew field (expl_freed_bytes_since_gc) in public prof_stats_s
Ivan Maidanski [Thu, 11 Jan 2018 22:08:37 +0000 (01:08 +0300)]
New field (expl_freed_bytes_since_gc) in public prof_stats_s

* include/gc.h (GC_prof_stats_s): Add expl_freed_bytes_since_gc field
(to the end of the structure).
* misc.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (fill_prof_stats): Store
GC_bytes_freed value to pstats->expl_freed_bytes_since_gc.

6 years agoNew API function (get_expl_freed_bytes_since_gc)
Ivan Maidanski [Thu, 11 Jan 2018 21:56:36 +0000 (00:56 +0300)]
New API function (get_expl_freed_bytes_since_gc)

Note: this function could be used in test_cpp to check that the proper
operator delete is called.

* include/gc.h (GC_get_expl_freed_bytes_since_gc): New function
prototype.
* mallocx.c (GC_get_expl_freed_bytes_since_gc): New function definition
(which returns GC_bytes_freed).

7 years agoPrevent multiple sem_post calls for a thread in suspend_handler
Ivan Maidanski [Thu, 28 Dec 2017 08:37:57 +0000 (11:37 +0300)]
Prevent multiple sem_post calls for a thread in suspend_handler
(fix commit af409e4bd)

Issue #181 (bdwgc).

* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& THREAD_SANITIZER] (GC_suspend_handler_inner): Call pthread_sigmask()
after last_stop_count update (thus preventing duplicate sem_post() call
in case of GC_suspend_handler_inner is re-entered (if GC_retry_signals);
refine comment.

7 years agoDo not call sem_getvalue in stop_world if one thread exists
Ivan Maidanski [Thu, 28 Dec 2017 08:18:25 +0000 (11:18 +0300)]
Do not call sem_getvalue in stop_world if one thread exists

* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_world):
Do not call sem_getvalue() if n_live_threads is zero (matters only if
GC_retry_signals).

7 years agoAdd assertion for suspend_ack_sem in start_world
Ivan Maidanski [Thu, 28 Dec 2017 08:04:40 +0000 (11:04 +0300)]
Add assertion for suspend_ack_sem in start_world

This is to check that sem_post() is not called twice for a thread
(to stop) in GC_suspend_handler.

* pthread_stop_world.c [!NACL && GC_ASSERTIONS && !GC_OPENBSD_UTHREADS]
(GC_start_world): Add assertion that GC_suspend_ack_sem has zero value.

7 years agoTravis CI: Test GC_NETBSD_THREADS_WORKAROUND
Ivan Maidanski [Wed, 27 Dec 2017 08:13:31 +0000 (11:13 +0300)]
Travis CI: Test GC_NETBSD_THREADS_WORKAROUND

7 years agoAllow GC_NETBSD_THREADS_WORKAROUND macro manual definition
Ivan Maidanski [Thu, 28 Dec 2017 07:48:28 +0000 (10:48 +0300)]
Allow GC_NETBSD_THREADS_WORKAROUND macro manual definition

* include/private/gcconfig.h [GC_NETBSD_THREADS]
(GC_NETBSD_THREADS_WORKAROUND): Define; copy comment from
pthread_stop_world.c.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& GC_NETBSD_THREADS] (GC_NETBSD_THREADS_WORKAROUND): Remove.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]
(GC_restart_ack_sem): Define only if GC_NETBSD_THREADS_WORKAROUND.

7 years agoFix error code in abort message if sem_wait failed in start_world (NetBSD)
Ivan Maidanski [Wed, 27 Dec 2017 08:09:48 +0000 (11:09 +0300)]
Fix error code in abort message if sem_wait failed in start_world (NetBSD)

* pthread_stop_world.c [GC_NETBSD_THREADS_WORKAROUND] (GC_start_world):
Print errno instead of the value returned by sem_wait if the latter has
failed; remove "code" local variable.

7 years agoTravis CI: Do not use 'trusty' build environment
Ivan Maidanski [Mon, 25 Dec 2017 07:57:58 +0000 (10:57 +0300)]
Travis CI: Do not use 'trusty' build environment

7 years agoUpdate ChangeLog file
Ivan Maidanski [Mon, 25 Dec 2017 07:30:13 +0000 (10:30 +0300)]
Update ChangeLog file

7 years agoUpdate ChangeLog file (add gc-7.4.8 release date)
Ivan Maidanski [Fri, 22 Dec 2017 21:05:41 +0000 (00:05 +0300)]
Update ChangeLog file (add gc-7.4.8 release date)

7 years agoUpdate ChangeLog file (add gc-7.2i release date)
Ivan Maidanski [Thu, 21 Dec 2017 21:40:34 +0000 (00:40 +0300)]
Update ChangeLog file (add gc-7.2i release date)

7 years agoUpdate ChangeLog file (v7.6 changes only)
Ivan Maidanski [Tue, 19 Dec 2017 21:53:44 +0000 (00:53 +0300)]
Update ChangeLog file (v7.6 changes only)

7 years agoUpdate ChangeLog file (v7.2 - v7.4 changes only)
Ivan Maidanski [Tue, 19 Dec 2017 08:10:23 +0000 (11:10 +0300)]
Update ChangeLog file (v7.2 - v7.4 changes only)
(Cherry-pick commit b15b52be from 'release-7_4' branch.)

7 years agoRemove duplicate check whether MPROTECT_VDB is defined
Ivan Maidanski [Sun, 17 Dec 2017 07:42:17 +0000 (10:42 +0300)]
Remove duplicate check whether MPROTECT_VDB is defined
(fix commit db26b7e4b)

* tests/test.c [GC_PTHREADS && MPROTECT_VDB && !REDIRECT_MALLOC
&& !MAKE_BACK_GRAPH && !USE_PROC_FOR_LIBRARIES && !NO_INCREMENTAL]
(main): Remove duplicate defined(MPROTECT_VDB).

7 years agoWorkaround TSan hang in free_inner when called from at-fork child handler
Ivan Maidanski [Fri, 15 Dec 2017 07:15:05 +0000 (10:15 +0300)]
Workaround TSan hang in free_inner when called from at-fork child handler

* pthread_support.c [CAN_HANDLE_FORK] (GC_remove_all_threads_but_me):
Do not call GC_INTERNAL_FREE(p) if THREAD_SANITIZER and CAN_CALL_ATFORK;
add comment.

7 years agoEliminate UBSan warning of overflow during descr subtraction in mark_from
Ivan Maidanski [Thu, 14 Dec 2017 21:54:04 +0000 (00:54 +0300)]
Eliminate UBSan warning of overflow during descr subtraction in mark_from

There is no unsigned overflow because descr has a negative value
actually when it is subtracted from type_descr.

* mark.c (GC_mark_from): Cast descr to signed_word
in (type_descr-(descr+...)).

7 years agoWorkaround TSan false positive in remove_all_threads_but_me
Ivan Maidanski [Thu, 14 Dec 2017 07:24:34 +0000 (10:24 +0300)]
Workaround TSan false positive in remove_all_threads_but_me

* pthread_support.c [CAN_HANDLE_FORK] (store_to_threads_table): New
static function (defined with GC_ATTR_NO_SANITIZE_THREAD attribute
if CAN_CALL_ATFORK); add comment.
* pthread_support.c [CAN_CALL_ATFORK] (GC_remove_all_threads_but_me):
Call store_to_threads_table instead of GC_threads[hv]=me.

7 years agoDo not add no_sanitize_thread to fork at-handlers if no pthread_atfork
Ivan Maidanski [Thu, 14 Dec 2017 06:53:18 +0000 (09:53 +0300)]
Do not add no_sanitize_thread to fork at-handlers if no pthread_atfork
(fix commit 3a52469)

* pthread_support.c [THREAD_SANITIZER] (GC_wait_for_gc_completion): Do
not skip I_HOLD_LOCK() assertion unless CAN_CALL_ATFORK.
* pthread_support.c [CAN_HANDLE_FORK && GC_ASSERTIONS]
(fork_prepare_proc, fork_parent_proc, fork_child_proc): Do not add
GC_ATTR_NO_SANITIZE_THREAD attribute unless CAN_CALL_ATFORK.