summaryrefslogtreecommitdiff
path: root/misc.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Recycle soft_vdb_buf if soft-dirty bit not supported by kernelIvan Maidanski2021-09-111-1/+1
| | | | | | | | | | | | | Issue #265 (bdwgc). * alloc.c (add_to_heap_inner): Add assertion that GC_init_headers is called already. * misc.c (GC_init): Call GC_init_headers() before GC_dirty_init() one (to allow GC_scratch_recycle_inner() calls during GC_dirty_init). * os_dep.c [SOFT_VDB] (soft_dirty_init): Add assertion that soft_vdb_buf is null on entry; replace TODO item with GC_scratch_recycle_no_gww() call (setting soft_vdb_buf to null) if detect_soft_dirty_supported() failed.
* Update copyright information in alloc.c and other modified files (2021)Ivan Maidanski2021-09-091-1/+1
| | | | | | | | | | | | | | | | | | | | | * README.QUICK (Copyright): Update year (2019 to 2020). * README.md (Copyright): Likewise. * alloc.c (Copyright, GC_copyright): Likewise. * configure.ac (Copyright): Likewise. * include/private/gc_priv.h (Copyright): Likewise. * mark.c (Copyright): Likewise. * misc.c (Copyright): Likewise. * os_dep.c (Copyright): Likewise. * pthread_support.c (Copyright): Likewise. * win32_threads.c (Copyright): Likewise. * CMakeLists.txt: Update (add Ivan Maidanski). * dyn_load.c (Copyright): Likewise. * include/private/gc_alloc_ptrs.h (Copyright): Likewise. * include/private/gcconfig.h (Copyright): Likewise. * mallocx.c (Copyright): Likewise. * mark_rts.c (Copyright): Likewise. * reclaim.c (Copyright): Likewise. * tests/test.c (Copyright): Likewise.
* Fix assertion violation in LOCK called before GC_thr_initIvan Maidanski2021-07-261-1/+2
| | | | | | | | (fix of commit d8fd1a291) * misc.c [(GC_PTHREADS || GC_WIN32_THREADS) && LINT2] (GC_init): Do not wrap GC_thr_init() into LOCK/UNLOCK if GC_ASSERTIONS and GC_ALWAYS_MULTITHREADED.
* Eliminate 't->flags not atomically updated' code defect FPIvan Maidanski2021-07-241-1/+7
| | | | | | | | | | | | | | | | | The reported defects are false positives because: - GC_thr_init() is called from GC_init() w/o the GC lock because GC_init is called only during initialization (i.e. no other threads running) - t is set in the 1st LOCK section but t->flags field is accessed in the 2nd one in [GC_]pthread_join/detach() because thread id may already have been recycled in the later section but the GC_thread object pointed by t is guaranteed to survive until deleted explicitly. * misc.c [(GC_PTHREADS || GC_WIN32_THREADS) && LINT2] (GC_init): Wrap GC_thr_init() call into LOCK/UNLOCK. * pthread_support.c [!SN_TARGET_ORBIS && !SN_TARGET_PSP2] (pthread_join, pthread_detach): Pass GC_lookup_thread() result thru COVERT_DATAFLOW().
* Eliminate 'accessing GC_dont_gc without lock' in GC_init code defect FPIvan Maidanski2021-07-241-1/+5
| | | | | | | | | * allchblk.c (GC_allochblk): Add assertion that GC lock is held on entrance. * new_hblk.c (GC_new_hblk): Likewise. * pthread_support.c (GC_unregister_my_thread_inner): Likewise. * misc.c [LINT2] (GC_init): Call GC_disable() instead of setting GC_dont_gc directly.
* Replace SN_TARGET_ORBIS to PLATFORM_* and GC_NO_* macrosTim Cannell2021-07-141-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (cherry-pick of 6a86542, 366aaf6, f3b34f4 from Unity-Technologies/bdwgc) SN_TARGET_ORBIS macro is replaced (almost) with GC_NO_CAN_CALL_ATFORK, GC_NO_FREEBSD, GC_NO_NOSYS, GC_NO_TYPES, PLATFORM_GC_REG_STORAGE_SIZE, PLATFORM_GETMEM, PLATFORM_MACH_DEP, PLATFORM_STOP_WORLD, PLATFORM_WRITE ones. * alloc.c [!MACOS && !MSWINCE && !SN_TARGET_PSP2]: Test GC_NO_TYPES macro instead of SN_TARGET_ORBIS. * misc.c [!MSWIN32 && !MSWINCE && !OS2 && !MACOS && !GC_ANDROID_LOG && !NN_PLATFORM_CTR && !NINTENDO_SWITCH && !SN_TARGET_PSP2 && !AMIGA && !MSWIN32 && !MSWIN_XBOX1 && !__CC_ARM]: Likewise. * dyn_load.c [MACOS && !SN_TARGET_PSP2 && !_WIN32_WCE && !__CC_ARM]: Likewise. * extra/gc.c [PLATFORM_MACH_DEP]: Do not include mach_dep.c file. * extra/gc.c [PLATFORM_STOP_WORLD]: Do not include pthread_stop_world.c file. * include/gc_config_macros.h [__DragonFly__ || __FreeBSD_kernel__ || __FreeBSD__]: Do not define GC_FREEBSD_THREADS if GC_NO_FREEBSD. * include/private/gc_locks.h [GC_PTHREADS]: Do not test SN_TARGET_ORBIS macro. * include/private/gc_priv.h [!HBLKSIZE && (LARGE_CONFIG || !SMALL_CONFIG)]: Likewise. * include/private/gcconfig.h [USE_MUNMAP && !MUNMAP_THRESHOLD] (MUNMAP_THRESHOLD): Likewise. * include/private/gcconfig.h [GC_THREADS] (THREADS): Likewise. * include/private/gcconfig.h [(__FreeBSD__ || __DragonFly__ || __FreeBSD_kernel__) && !FREEBSD] (FREEBSD): Test GC_NO_FREEBSD macro instead of SN_TARGET_ORBIS. * include/private/gcconfig.h [(__arm || __arm__ || __thumb__) && !NACL && !LINUX && !NETBSD && !FREEBSD && !OPENBSD && !DARWIN && !_WIN32 && !__CEGCC__ && !NN_PLATFORM_CTR && !SN_TARGET_PSP2 && !SYMBIAN] (NOSYS): Test GC_NO_NOSYS macro instead of SN_TARGET_ORBIS. * include/private/gcconfig.h [SN_TARGET_ORBIS && (__amd64__ || __x86_64__)] (X86_64): Do not define. * include/private/gcconfig.h [X86_64]: Test PLATFORM_GETMEM macro instead of SN_TARGET_ORBIS. * include/private/gcconfig.h [X86_64 && PLATFORM_GETMEM] (OS_TYPE): Update value. * include/private/gcconfig.h [X86_64 && PLATFORM_GETMEM]: Include pthread.h. * include/private/gcconfig.h [X86_64 && PLATFORM_GETMEM]: Declare platform_get_stack_bottom() instead of ps4_get_stack_bottom(). * include/private/gcconfig.h [X86_64 && PLATFORM_GETMEM] (STACKBOTTOM): Use platform_get_stack_bottom(). * include/private/gcconfig.h [CAN_HANDLE_FORK && !CAN_CALL_ATFORK !HOST_TIZEN && !HURD] (CAN_CALL_ATFORK): Test GC_NO_CAN_CALL_ATFORK macro instead of SN_TARGET_ORBIS. * include/private/gcconfig.h [GC_PRIVATE_H]: Test PLATFORM_GETMEM macro instead of SN_TARGET_ORBIS. * include/private/gcconfig.h [GC_PRIVATE_H && PLATFORM_GETMEM] (platform_get_mem): Declare (instead of ps4_get_mem). * include/private/gcconfig.h [GC_PRIVATE_H && PLATFORM_GETMEM] (GET_MEM): Use platform_get_mem(). * include/private/pthread_stop_world.h [!GC_OPENBSD_UTHREADS && !NACL && !SN_TARGET_PSP2] (thread_stop_info.last_stop_count): Test PLATFORM_STOP_WORLD macro instead of SN_TARGET_ORBIS. * pthread_stop_world.c [GC_PTHREADS && !GC_WIN32_THREADS && !GC_DARWIN_THREADS]: Likewise. * include/private/pthread_stop_world.h [!NACL]: Test PLATFORM_HAVE_GC_REG_STORAGE_SIZE macro instead of SN_TARGET_ORBIS. * include/private/pthread_stop_world.h [!NACL && PLATFORM_HAVE_GC_REG_STORAGE_SIZE] (ORBIS_GC_REG_STORAGE_SIZE): Do not define. * include/private/pthread_stop_world.h [!NACL && PLATFORM_HAVE_GC_REG_STORAGE_SIZE] (thread_stop_info.registers): Use PLATFORM_GC_REG_STORAGE_SIZE instead of ORBIS_GC_REG_STORAGE_SIZE. * mach_dep.c [!SN_TARGET_PSP2]: Test PLATFORM_MACH_DEP macro instead of SN_TARGET_ORBIS. * misc.c [THREADS && !PCR && !SN_TARGET_PSP2] (GC_allocate_ml): Test GC_DEFN_ALLOCATE_ML macro instead of SN_TARGET_ORBIS. * misc.c [!MSWIN32 && !MSWINCE && !OS2 && !MACOS && !GC_ANDROID_LOG && !NN_PLATFORM_CTR && !NINTENDO_SWITCH] (GC_write): Test PLATFORM_WRITE macro instead of SN_TARGET_ORBIS.
* Add assertions that GC_page_size is initializedIvan Maidanski2020-09-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | * alloc.c (GC_expand_hp_inner): Assert that GC_page_size is non-zero. * backgraph.c (new_back_edges, push_in_progress): Likewise. * headers.c (GC_scratch_alloc): Likewise. * mark.c (GC_wait_for_markers_init): Likewise. * misc.c [GC_READ_ENV_FILE && (MSWIN32 || MSWINCE || CYGWIN32)] (GC_envfile_init): Likewise. * os_dep.c [!OS2 && GWW_VDB] (detect_GetWriteWatch): Likewise. * os_dep.c [MSWIN32] (GC_least_described_address): Likewise. * os_dep.c [MMAP_SUPPORTED && !MSWIN_XBOX1] (GC_unix_mmap_get_mem): Likewise. * os_dep.c [MMAP_SUPPORTED && !USE_MMAP] (GC_unix_sbrk_get_mem): Likewise. * os_dep.c [MSWINCE] (GC_wince_get_mem): Likewise. * os_dep.c [USE_MUNMAP] (GC_unmap_start): Likewise. * os_dep.c [!GC_DISABLE_INCREMENTAL && MPROTECT_VDB && !DARWIN] (GC_write_fault_handler): Likewise. * os_dep.c [!GC_DISABLE_INCREMENTAL && MPROTECT_VDB] (GC_protect_heap, GC_remove_protection): Likewise. * os_dep.c [!GC_DISABLE_INCREMENTAL && MPROTECT_VDB && DARWIN] (catch_exception_raise): Likewise.
* Update copyright information in alloc.c and other modified files (2020)Ivan Maidanski2020-08-011-0/+1
| | | | | | | | | | | | | | | | | * README.QUICK (Copyright): Update year (2019 to 2020). * README.md (Copyright): Likewise. * alloc.c (Copyright, GC_copyright): Likewise. * gc_badalc.cc (Copyright): Likewise. * include/gc.h (Copyright): Likewise. * finalize.c (Copyright): Update (add Ivan Maidanski). * include/gc_config_macros.h (Copyright): Likewise. * include/private/gc_priv.h (Copyright): Likewise. * mark.c (Copyright): Likewise. * misc.c (Copyright): Likewise. * os_dep.c (Copyright): Likewise. * pthread_stop_world.c (Copyright): Likewise. * pthread_support.c (Copyright): Likewise. * win32_threads.c (Copyright): Likewise.
* Eliminate 'nonnull argument fl compared to NULL' compiler warningIvan Maidanski2020-07-191-1/+1
| | | | | | | (fix of commit 9249fe9ee) * misc.c (GC_new_kind_inner): Use NONNULL_ARG_NOT_NULL() in assertion that fl is really non-null.
* Add assertion on free-list argument and result of GC_new_kindIvan Maidanski2020-07-181-0/+2
| | | | | * misc.c (GC_new_kind_inner): Add assertion that fl is non-null; add assertion that result is non-zero (positive).
* Move definition of GC_n_mark_procs and GC_n_kinds from mark.c to misc.cIvan Maidanski2020-06-211-0/+4
| | | | | | | (code refactoring) * mark.c (GC_n_mark_procs, GC_n_kinds): Move variable definition to misc.c.
* Eliminate 'cast between incompatible func types' warnings for FARPROC varsIvan Maidanski2020-04-191-6/+6
| | | | | | | | | | | | | | | | | | | | | Direct conversion of GetProcAddress() result (of FARPROC type) to the required functional type is performed by casting the result to word type first. * misc.c [MSGBOX_ON_ERROR && DONT_USE_USER32_DLL] (GC_win32_MessageBoxA): Cast pfn to word type first. * win32_threads.c [WOW64_THREAD_CONTEXT_WORKAROUND] (GC_thr_init): Likewise. * misc.c [GC_WIN32_THREADS && !GC_PTHREADS && !MSWINRT_FLAVOR && !MSWINCE] (GC_init): Change pfn type to FARPROC; cast pfn to word type first and, then, to the required functional type. * os_dep.c [!OS2 && GWW_VDB] (GetWriteWatch_func): Change type to FARPROC. * os_dep.c [!OS2 && GWW_VDB] (GC_GWW_AVAILABLE): Compare GetWriteWatch_func to 0 instead of NULL. * os_dep.c [GWW_VDB] (detect_GetWriteWatch, GC_gww_read_dirty): Cast GetWriteWatch_func to word type first and, then, to the required functional type.
* Enable CONSOLE_LOG for MS VC (MSWIN32)Ivan Maidanski2020-04-111-1/+12
| | | | | | | | | | | | | (fix of commit c2b191639) * misc.c [CONSOLE_LOG && MSWIN32 && _MSC_VER]: Include io.h. * misc.c [CONSOLE_LOG && MSWIN32 && !SMALL_CONFIG && _MSC_VER] (GC_init): Use _open (with 2 arguments) instead of open(). * misc.c [(!MSWIN32 || CONSOLE_LOG) && !MSWINCE && !OS2 && !MACOS && !GC_ANDROID_LOG && !NN_PLATFORM_CTR && !NINTENDO_SWITCH && !ECOS && !SN_TARGET_ORBIS && !SN_TARGET_PSP2 && !NOSYS && !GC_SOLARIS_THREADS && _MSC_VER] (GC_write): Use _write instead of write(); cast len-bytes_written to unsigned.
* Revert 'Call GC_thr_init only once'Ivan Maidanski2020-02-111-1/+1
| | | | | | This reverts commit 03a3fbbdd5cff52360facdfcc9f86adbdc111245. GC_thr_initialized is a static variable on Windows.
* Call GC_thr_init only onceIvan Maidanski2020-02-111-1/+1
| | | | | | | | | | | | | (code refactoring) GC_thr_init() is now called only if GC_thr_initialized; "if(GC_thr_initialized)return" statement is removed from GC_thr_init. * misc.c [GC_PTHREADS || GC_WIN32_THREADS] (GC_init): Do not call GC_thr_init() if GC_thr_initialized. * pthread_support.c (GC_thr_init): Remove return if GC_thr_initialized; add GC_ASSERT that GC_thr_initialized is false. * win32_threads.c (GC_thr_init): Likewise.
* Fix abort in GC_printf when gctest is built as WinMain executable (Cygwin)Ivan Maidanski2019-11-091-2/+12
| | | | | | | | | * misc.c [!NACL && (CYGWIN32 || CONSOLE_LOG && MSWIN32)] (GC_printf): If WRITE(GC_stdout) failed but GC_stdout is GC_DEFAULT_STDOUT_FD then ignore the failure. * misc.c [!NACL && (CYGWIN32 || CONSOLE_LOG && MSWIN32)] (GC_log_printf): If WRITE(GC_log) failed but GC_log is GC_DEFAULT_STDERR_FD then ignore the failure.
* Fix 'write to GC log failed' error (Cygwin)Ivan Maidanski2019-10-291-5/+12
| | | | | | | | | | | | Issue #293 (bdwgc). * misc.c [!(MSWIN32 && !CONSOLE_LOG || MSWINCE) && !OS2 && !MACOS && !GC_ANDROID_LOG && !NN_PLATFORM_CTR && !NINTENDO_SWITCH && !SN_TARGET_ORBIS && !SN_TARGET_PSP2]: Include errno.h. * misc.c [!(MSWIN32 && !CONSOLE_LOG || MSWINCE) && !OS2 && !MACOS && !GC_ANDROID_LOG && !NN_PLATFORM_CTR && !NINTENDO_SWITCH && !ECOS && !SN_TARGET_ORBIS && !SN_TARGET_PSP2] (GC_write): Retry write() result is -1 and errno is EAGAIN.
* Workaround 'condition appendToFile is always false' cppcheck false positiveIvan Maidanski2019-09-261-1/+6
| | | | | | | * misc.c [(MSWIN32 && !CONSOLE_LOG || MSWINCE) && !MSWINRT_FLAVOR && NO_GETENV_WIN32 && CPPCHECK] (GC_CreateLogFile): Define appendToFile as macro (to FALSE) instead of a local variable; undefine appendToFile at the function.
* Collapse multiple includes of windows.hIvan Maidanski2019-09-141-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | (code refactoring) * dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32]: Do not define WIN32_LEAN_AND_MEAN and NOSERVICE macros; do not include windows.h. * include/private/gc_locks.h [GC_WIN32_THREADS && !USE_PTHREAD_LOCKS]: Likewise. * include/private/gc_priv.h [!NO_CLOCK && !BSD_TIME && (MSWIN32 || MSWINCE || WINXP_USE_PERF_COUNTER)]: Likewise. * include/private/thread_local_alloc.h [!USE_PTHREAD_SPECIFIC && !USE_COMPILER_TLS && !USE_WIN32_COMPILER_TLS && USE_WIN32_SPECIFIC]: Likewise. * mallocx.c [MSWINCE]: Likewise. * misc.c [MSWIN32 || MSWINCE || CYGWIN32 && GC_READ_ENV_FILE]: Likewise. * os_dep.c [MSWIN32 || MSWINCE || CYGWIN32]: Likewise. * tests/test.c [MSWIN32 || MSWINCE]: Likewise. * tools/setjmp_t.c [!OS2 && (MSWIN32 || MSWINCE || CYGWIN32)]: Likewise. * win32_threads.c [GC_WIN32_THREADS]: Likewise. * include/private/gc_priv.h [MSWIN32 || MSWINCE || CYGWIN32] (WIN32_LEAN_AND_MEAN, NOSERVICE): Define macro (before include windows.h). * include/private/gc_priv.h [MSWIN32 || MSWINCE || CYGWIN32]: Inclde windows.h and winbase.h before include gc_locks.h (instead of just before GC_sysinfo declaration).
* New macro (CONSOLE_LOG) to enable logging to console on Win32Ivan Maidanski2019-09-121-23/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The macro is effective only on the Win32 (MSWIN32) target. It changes the logging facility to be the same as on Cygwin and other Unix-like targets. * doc/README.macros (CONSOLE_LOG): Document new macro. * include/private/gc_priv.h [THREADS && MSWIN32 && CONSOLE_LOG] (GC_write_cs): Do not declare. * include/private/gc_priv.h [THREADS && MSWIN32 && CONSOLE_LOG && GC_ASSERTIONS] (GC_write_disabled): Likewise. * misc.c [CONSOLE_LOG && MSWIN32]: Include fcntl.h, sys/types.h, sys/stat.h. * misc.c [GC_WIN32_THREADS && MSWIN32 && CONSOLE_LOG] (GC_write_cs): Do not define. * win32_threads.c [GC_ASSERTIONS && MSWIN32 && CONSOLE_LOG] (GC_write_disabled): Likewise. * misc.c [MSWIN32 && CONSOLE_LOG] (GC_stdout, GC_stderr, GC_log): Define STATIC variable (of int type). * misc.c [GC_WIN32_THREADS && MSWIN32 && CONSOLE_LOG] (GC_init): Do not call InitializeCriticalSection(&GC_write_cs); handle GC_LOG_FILE and GC_ONLY_LOG_TO_FILE environment variables. * misc.c [GC_WIN32_THREADS && MSWIN32 && CONSOLE_LOG] (GC_deinit): Do not call DeleteCriticalSection(&GC_write_cs). * misc.c [MSWIN32 && CONSOLE_LOG] (IF_NEED_TO_LOCK, getWinRTLogPath, GC_CreateLogFile): Do not define. * misc.c [!PCR && !SMALL_CONFIG && !GC_ANDROID_LOG && GC_WIN32_THREADS && GC_ASSERTIONS MSWIN32 && CONSOLE_LOG] (GC_default_on_abort): Do not use GC_write_disabled. * win32_threads.c [MSWIN32 && CONSOLE_LOG] (GC_stop_world): Do not use GC_write_disabled and GC_write_cs.
* Do not define GC_write_cs for Xbox One targetIvan Maidanski2019-09-111-2/+1
| | | | | | | | | | | | | | | (fix of commit d16debf3e) Issue #173 (bdwgc). GC_write_cs is not used in GC_write thus there is no need to define and use it in GC_stop_world. * include/private/gc_priv.h [THREADS && MSWIN_XBOX1] (GC_write_cs): Do not declare. * misc.c [THREADS && MSWIN_XBOX1] (GC_write_cs): Do not define. * win32_threads.c (GC_stop_world): Call EnterCriticalSection() and LeaveCriticalSection() only if MSWIN32 or MSWINCE.
* Fix a typo in GC_init commentIvan Maidanski2019-08-291-1/+1
| | | | | * misc.c [USE_PROC_FOR_LIBRARIES && GC_LINUX_THREADS] (GC_init): Fix typo in comment ("will").
* New macro (NO_MSGBOX_ON_ERROR) to avoid message box on GC abort (Win32)Ivan Maidanski2019-07-051-4/+3
| | | | | | | | | | | | NO_MSGBOX_ON_ERROR macro disables Win32 MessageBox() invocation. * doc/README.macros (NO_MSGBOX_ON_ERROR): Document. * include/private/gcconfig.h [!MSGBOX_ON_ERROR && !NO_MSGBOX_ON_ERROR && !SMALL_CONFIG && MSWIN32 && !MSWINRT_FLAVOR && !MSWIN_XBOX1] (MSGBOX_ON_ERROR): Define new macro. * misc.c (GC_win32_MessageBoxA): Define only if MSGBOX_ON_ERROR. * misc.c [!PCR && !SMALL_CONFIG] (GC_default_on_abort): Do not call GC_win32_MessageBoxA() unless MSGBOX_ON_ERROR is defined.
* Do not use Manual VDB mode if C malloc is redirectedIvan Maidanski2019-06-211-1/+3
| | | | | | | | (fix of commit 06009b0a0) * misc.c [!GC_DISABLE_INCREMENTAL && (REDIRECT_MALLOC || REDIRECT_MALLOC_IN_HEADER)] (GC_init, GC_enable_incremental): Do not set GC_manual_vdb to true.
* New API standalone functions to acquire and release the allocator lockIvan Maidanski2019-05-301-0/+12
| | | | | | | | | | | | | | | | | Issue #282 (bdwgc). Public GC_alloc_lock() and GC_alloc_unlock() are introduced to simplify dealing with the GC lock compared to GC_call_with_alloc_lock(). * include/gc.h [GC_THREADS] (GC_alloc_lock, GC_alloc_unlock): Declare new API function. * include/gc.h [!GC_THREADS] (GC_alloc_lock, GC_alloc_unlock): Define as a no-op macro. * misc.c [THREADS] (GC_alloc_lock, GC_alloc_unlock): Define API function. * tests/test.c (reachable_objs_count_enumerator): Remove function. * tests/test.c (check_heap_stats): Call GC_alloc_lock(); call GC_enumerate_reachable_objects_inner() directly; call GC_alloc_unlock().
* Add API functions to get and set the stack bottom of each threadBrian J. Cardiff2019-05-061-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #277 (bdwgc). This API is useful to support coroutines. * include/gc.h (GC_get_my_stackbottom, GC_set_stackbottom): New API function declaration. * misc.c [!THREADS] (GC_set_stackbottom, GC_get_my_stackbottom): New function definition. * pthread_support.c [GC_PTHREADS && !GC_WIN32_THREADS] (GC_set_stackbottom, GC_get_my_stackbottom): Likewise. * win32_threads.c [GC_WIN32_THREADS] (GC_set_stackbottom, GC_get_my_stackbottom): Likewise. * tests/test.c (struct thr_hndl_sb_s): Define. * tests/test.c (set_stackbottom): New function (which calls GC_set_stackbottom). * tests/test.c (run_one_test): Define thr_hndl_sb local variable; call GC_get_my_stackbottom() and set_stackbottom(). * win32_threads.c [GC_WIN32_THREADS && I386] (struct GC_Thread_Rep): Add initial_stack_base field. * win32_threads.c [GC_WIN32_THREADS && I386] (GC_record_stack_base, GC_call_with_gc_active): Set initial_stack_base field. * win32_threads.c [GC_WIN32_THREADS && I386] (GC_push_stack_for): Handle the case when GetThreadContext() might return stale register values, thread stack_base != initial_stack_base but the stack is not inside the TIB stack (use context.Esp but call WARN); add TODO.
* Replace 'stack base' with 'stack bottom' in the documentationIvan Maidanski2019-04-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * README.md (The C Interface to the Allocator): Outline that stack base means its bottom; remove a note that client should set GC_stackbottom on HP PA machines manually. * doc/README.macros (USE_GET_STACKBASE_FOR_MAIN): Rename "stack base" to "stack bottom". * doc/porting.md (Adding Platforms to gcconfig.h): Likewise. * doc/porting.md (Adding Platforms to gcconfig.h): Rename "cool end of the stack" to "cold end of the stack"; refine documentation about STACKBOTTOM. * include/private/gcconfig.h (STACKBOTTOM): Rename "cool end" to "cold end" in comment. * include/gc.h (GC_stackbottom): Likewise. * include/private/gcconfig.h (LINUX_STACKBOTTOM): Rename "stack base" to "stack bottom" in comment. * include/gc.h (GC_stack_base, GC_call_with_stack_base): Likewise. * include/gc.h [GC_THREADS] (GC_register_my_thread): Likewise. * misc.c [!THREADS] (GC_call_with_gc_active): Likewise. * os_dep.c [LINUX_STACKBOTTOM] (GC_linux_main_stack_base): Likewise. * os_dep.c (GC_get_stack_base): Likewise. * pthread_support.c (GC_call_with_gc_active): Likewise. * win32_threads.c (GC_call_with_gc_active): Likewise.
* Refine do_blocking() documentation in gc.hIvan Maidanski2019-04-251-8/+0
| | | | | | | | * include/gc.h (GC_do_blocking): Refine comment (copy part of comment from misc.c, add information that GC should be initialized and the current thread should be registered). * misc.c (GC_do_blocking): Remove title comment (as it duplicates the one in gc.h).
* Allow GC_PAUSE_TIME_TARGET environment variable values smaller than 5 msIvan Maidanski2019-04-121-5/+2
| | | | | | | | All time limit values starting from 1 ms are now accepted. * misc.c [!GC_DISABLE_INCREMENTAL] (GC_init): Do not set GC_time_limit if NO_CLOCK; allow all non-zero time_limit values (instead of >4); do not call WARN() if time_limit value is incorrect.
* Fix GetThreadContext stale register values use if WoW64 (Win32)Hamayama2019-02-081-27/+1
| | | | | | | | | | | | | | | | | | | | | Issue #262 (bdwgc). * misc.c [MSWIN32 && !MSWINRT_FLAVOR && !MSWIN_XBOX1] (GC_win32_MessageBoxA): Do not define unless SMALL_CONFIG. * misc.c [MSWIN32 && !_WIN64 && GC_WIN32_THREADS && CHECK_NOT_WOW64] (GC_init): Do not call IsWow64Process() and GC_win32_MessageBoxA(). * win32_threads.c [I386] (isWow64): New static variable. * win32_threads.c [I386] (GC_push_stack_for): If isWow64 then set also CONTEXT_EXCEPTION_REQUEST and CONTEXT_SEGMENTS bits in ContextFlags; if isWow64, and CONTEXT_EXCEPTION_REPORTING and CONTEXT_EXCEPTION_ACTIVE are set on return from GetThreadContext then call GetThreadSelectorEntry and use StackLimit of FS selector to set sp local variable (instead of context.Esp); add comment. * win32_threads.c [I386 && DEBUG_THREADS] (GC_push_stack_for): Call GC_log_printf() to report TIB stack limit/base and the case when CONTEXT_EXCEPTION_REQUEST is not supported. * win32_threads.c [I386] (GC_thr_init): Set isWow64 by IsWow64Process() if the later is available.
* Replace "msecs" with "ms" in all comments and messagesIvan Maidanski2019-01-061-1/+1
| | | | | | | | | | | | | | | | | | * README.md (Bugs): Replace "msecs" with "ms". * doc/README.environment (GC_PAUSE_TIME_TARGET): Likewise. * doc/gcdescr.md (Generational Collection and Dirty Bits): Likewise. * alloc.c [!NO_CLOCK] (full_gc_total_time): Replace "msecs" with "ms" in comment. * cord/tests/de.c [WIN32] (beep): Likewise. * pthread_support.c [USE_SPIN_LOCK] (GC_lock): Likewise. * alloc.c [!GC_DISABLE_INCREMENTAL && !NO_CLOCK] (GC_timeout_stop_func): Replace "msecs" with "ms" in the printed string. * alloc.c [!NO_CLOCK] (GC_try_to_collect_inner, GC_stopped_mark, GC_finish_collection): Likewise. * misc.c [!NO_CLOCK] (GC_dump_named): Likewise. * reclaim.c [!NO_CLOCK] (GC_reclaim_all): Likewise. * tests/test.c [!NO_CLOCK] (check_heap_stats): Likewise.
* Workaround 'argument dummy to GC_noop1 is always 1' cppcheck false positiveIvan Maidanski2018-12-201-1/+5
| | | | | | * misc.c [!ALWAYS_SMALL_CLEAR_STACK && !STACK_NOT_SCANNED && !ASM_CLEAR_CODE && CPPCHECK] (GC_clear_stack_inner): Pass dummy[0] instead of address of dummy variable.
* Fix 'collecting from unknown thread' abort in leak-finding mode for Win32Ivan Maidanski2018-11-231-1/+1
| | | | | | | | | | | (fix of commit 8e6460052) * include/private/gc_priv.h [THREADS] (GC_in_thread_creation): Declare not only for pthreads. * misc.c [!DONT_USE_ATEXIT && THREADS] (GC_exit_check): Set GC_in_thread_creation to true before calling GC_gcollect for windows threads as well. * win32_threads.c (GC_in_thread_creation): Change STATIC to GC_INNER.
* Fix deadlocks in write and suspend handlers if AO test-and-set is emulatedIvan Maidanski2018-11-201-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This could be tested with -D AO_USE_PTHREAD_DEFS passed to CFLAGS. * configure.ac (AO_TRYLINK_CFLAGS): New variable. * configure.ac [$with_libatomic_ops!=none && $need_atomic_ops_asm!=true] (BASE_ATOMIC_OPS_EMULATED): New AC_DEFINE (defined in case of failure of AC_TRY_LINK of a code snippet calling AO_test_and_set_acquire, AO_CLEAR, AO_compiler_barrier, AO_store, AO_load, AO_char_store, AO_char_load, AO_store_release, AO_load_acquire); use AO_TRYLINK_CFLAGS; add comment. * include/private/gcconfig.h [BASE_ATOMIC_OPS_EMULATED] (MPROTECT_VDB): Undefine. * mark.c [AO_CLEAR] (GC_noop6): Do not call AO_compiler_barrier() if BASE_ATOMIC_OPS_EMULATED. * misc.c [!GC_DISABLE_INCREMENTAL] (GC_init, GC_enable_incremental): Do not set GC_manual_vdb if BASE_ATOMIC_OPS_EMULATED. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (ao_load_acquire_async, ao_load_async, ao_store_release_async, ao_store_async): New macro; undefine it after the usage. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_store_stack_ptr): Use ao_store_async() instead of AO_store(). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_handler_inner): Use ao_load[_acquire]_async() and ao_store_release_async() instead of AO_load[_acquire]() and AO_store_release(), respectively. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (suspend_self_inner): Use ao_load_acquire_async() instead of AO_load_acquire().
* Workaround 'local address assignment to a global variable' CSA warningIvan Maidanski2018-11-131-4/+4
| | | | | | | | | | | | | | | * include/gc.h [(!__GNUC__ || __INTEL_COMPILER) && LINT2] (GC_reachable_here): Transform ptr in the same way as COVERT_DATAFLOW() does. * mach_dep.c (GC_with_callee_saves_pushed): Transform the argument of GC_noop1() by COVERT_DATAFLOW(). * misc.c [!ASM_CLEAR_CODE] (GC_clear_stack_inner): Likewise. * misc.c (GC_call_with_stack_base, GC_call_with_gc_active): Likewise. * pthread_support.c (GC_call_with_gc_active): Likewise. * win32_threads.c (GC_call_with_gc_active): Likewise. * misc.c (GC_call_with_gc_active): Transform &stacksect by COVERT_DATAFLOW() when storing to GC_stackbottom. * pthread_support.c (GC_call_with_gc_active): Likewise.
* Fix 'too wide non-owner permissions are set for resource' code defectIvan Maidanski2018-11-121-1/+1
| | | | | | | | | * misc.c [(UNIX_LIKE && !GC_ANDROID_LOG || CYGWIN32 || SYMBIAN) && !SMALL_CONFIG] (GC_init): Pass 0644 permissions mode instead of 0666 to open (create) a log file. * os_dep.c [MMAP_SUPPORTED && !USE_MMAP_ANON && SYMBIAN] (GC_unix_mmap_get_mem): Pass 0644 mode instead of 0666 to open "zero" file.
* Eliminate 'casting signed to bigger unsigned int' CSA warningIvan Maidanski2018-11-121-3/+3
| | | | | | | | | | | | | | | | | | * cord/cordprnt.c (CORD_vsprintf): Cast prec, width, max_size, res local variables to unsigned. * cord/tests/cordtest.c (test_basics): Change type of i local variable from int to size_t; cast c local variable to unsigned char. * dbg_mlc.c (GC_store_debug_info_inner): Do not cast linenum parameter. * include/private/dbg_mlc.h (oh.oh_string, oh.oh_int): Refine comment. * include/private/dbg_mlc.h (oh.oh_int): Change type from word to signed_word. * misc.c [!GC_GET_HEAP_USAGE_NOT_NEEDED] (fill_prof_stats): Cast GC_markers_m1 to signed_word first. * misc.c (GC_init): Cast space_divisor local variable to unsigned (instead of word). * misc.c [!MSWIN32 && !MSWINCE && !OS2 && !MACOS && !GC_ANDROID_LOG] (GC_write): Cast bytes_written local variable to unsigned (instead of size_t).
* Document assertion in the setters that used to return old valueIvan Maidanski2018-11-071-7/+9
| | | | | | | | (code refactoring) * misc.c (GC_set_finalize_on_demand, GC_set_java_finalization, GC_set_dont_expand, GC_set_no_dls, GC_set_max_retries, GC_set_dont_precollect, GC_set_time_limit): Add comment about GC_ASSERT.
* Enable compilation without C runtime (Win32)Michael DeRoy2018-10-291-1/+1
| | | | | | | | | | | | | | | | | (part of commit 193af77 from Unity-Technologies/bdwgc) * include/private/gcconfig.h [MSWIN32 && !__GNUC__ && !NO_WRAP_MARK_SOME] (WRAP_MARK_SOME): Do not define if NO_CRT. * mach_dep.c [!HAVE_BUILTIN_UNWIND_INIT && NO_CRT && MSWIN32] (GC_with_callee_saves_pushed): Call RtlCaptureContext() instead of setjmp(). * misc.c [MSWIN32 && _MSC_VER && _DEBUG] (GC_write): Do not call MultiByteToWideChar() and OutputDebugStringW() if NO_CRT. * win32_threads.c [NO_CRT] (GC_NO_THREADS_DISCOVERY): Define. * win32_threads.c [!__GNUC__] (GC_win32_start_inner): Do not use __try and __finally if NO_CRT. * win32_threads.c [!CYGWIN32 && !MSWINCE && !MSWIN_XBOX1] (GC_beginthreadex): Do not define if NO_CRT.
* Fix lock assertion violation in get_index if GC_ALWAYS_MULTITHREADEDIvan Maidanski2018-10-241-3/+3
| | | | | | | (fix of commit d5c65315b) * misc.c [GC_ASSERTIONS && GC_ALWAYS_MULTITHREADED] (GC_init): Move up LOCK() call to precede GC_expand_hp_inner() call.
* Replace some FIXME items with TODO onesIvan Maidanski2018-08-311-1/+1
| | | | | | | | | | | | | | | | | | (code refactoring) * alloc.c (GC_maybe_gc, GC_collect_a_little_inner, GC_finish_collection): Replace FIXME item with TODO one. * gcj_mlc.c (maybe_finalize): Likewise. * include/gc.h [!GC_DEBUG || !__GNUC__] (GC_PTR_ADD): Likewise. * include/private/gcconfig.h [X86_64 && LINUX && __GLIBC__ && !__UCLIBC__] (GETCONTEXT_FPU_EXCMASK_BUG): Likewise. * mach_dep.c (GC_with_callee_saves_pushed): Likewise. * mark_rts.c (GC_push_current_stack): Likewise. * misc.c [MSWIN32 || MSWINCE] (WRITE): Likewise. * os_dep.c [ECOS] (ecos_gc_memory): Likewise. * os_dep.c (GC_get_stack_base, GC_page_was_ever_dirty): Likewise. * reclaim.c (GC_reclaim_clear): Likewise. * include/private/gcconfig.h [OPENBSD && m68k]: Remove FIXME item.
* New API to turn on manual VDB at runtimeIvan Maidanski2018-08-151-6/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Manual VDB is now enabled by GC_set_manual_vdb_allowed(1) if called before entering the GC incremental mode. * alloc.c (GC_allocobj): Expand TRUE_INCREMENTAL macro. * darwin_stop_world.c [MPROTECT_VDB] (GC_stop_world, GC_start_world): Use GC_auto_incremental instead of GC_incremental. * mark.c (alloc_mark_stack): Likewise. * mark.c [PROC_VDB] (GC_push_all): Likewise. * mark.c [!NEED_FIXUP_POINTER && THREADS && MPROTECT_VDB] (GC_push_all_stack): Likewise. * pthread_support.c [CAN_HANDLE_FORK && GC_DARWIN_THREADS && MPROTECT_VDB] (GC_atfork_prepare): Likewise. * win32_threads.c [MPROTECT_VDB && !CYGWIN32] (GC_register_my_thread_inner): Likewise. * win32_threads.c [MPROTECT_VDB] (UNPROTECT_THREAD): Likewise. * doc/gcdescr.md (Generational Collection and Dirty Bits): Update documentation for the manual VDB. * include/gc.h (GC_end_stubborn_change): Update comment. * mark_rts.c (GC_push_all_stack_partially_eager): Likewise. * include/gc.h (GC_set_manual_vdb_allowed, GC_get_manual_vdb_allowed): New public function. * include/private/gc_priv.h (GC_grungy_pages, GC_dirty_pages): Define for all VDB modes. * include/private/gc_priv.h (GC_auto_incremental, GC_manual_vdb): Define. * include/private/gc_priv.h [!GC_DISABLE_INCREMENTAL] (GC_dirty): Use GC_manual_vdb instead of GC_incremental. * include/private/gcconfig.h (GWW_VDB, MPROTECT_VDB, PCR_VDB): Do not undefine if MANUAL_VDB. * mallocx.c (GC_generic_malloc_many): Always allocate a single object (and call GC_dirty_inner/REACHABLE_AFTER_DIRTY) if GC_manual_vdb. * misc.c [!CAN_HANDLE_FORK && DARWIN && MPROTECT_VDB && !THREADS && !SMALL_CONFIG] (GC_set_handle_fork): Do not ABORT if GC_manual_vdb. * misc.c [!SMALL_CONFIG] (manual_vdb_allowed): New static variable. * misc.c [!SMALL_CONFIG] (GC_set_manual_vdb_allowed, GC_get_manual_vdb_allowed): Implement. * misc.c [!CHECKSUMS && !SMALL_CONFIG] (GC_init, GC_enable_incremental): Set GC_manual_vdb and GC_incremental to true if manual_vdb_allowed; do not call GC_dirty_init if manual_vdb_allowed. * os_dep.c: Update comment about MANUAL_VDB. * os_dep.c [MANUAL_VDB] (GC_dirty_init, async_set_pht_entry_from_index): Remove. * os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_manual_vdb): Define global variable. * os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_dirty_inner): Define regardless of the VDB mode; add FIXME. * os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_read_dirty, GC_page_was_dirty, GC_remove_protection): Implement for the case of GC_manual_vdb is true; do not depend on MANUAL_VDB. * tests/disclaim_test.c [TEST_MANUAL_VDB] (main): Call GC_set_manual_vdb_allowed(1) before GC_INIT. * tests/staticrootslib.c [TEST_MANUAL_VDB] (libsrl_init): Likewise. * tests/test_cpp.cc [TEST_MANUAL_VDB] (main): Likewise. * tests/test.c (INIT_MANUAL_VDB_ALLOWED): New macro. * tests/test.c (GC_COND_INIT): Invoke INIT_MANUAL_VDB_ALLOWED (before GC_OPT_INIT). * tests/test.c [!SMALL_CONFIG] (main): Call GC_get_manual_vdb_allowed.
* Fix more compilation issues for XboxOneJonas Echterhoff2018-08-011-4/+5
| | | | | | | | | | | | (part of commit c6e7e36 from Unity-Technologies/bdwgc) Issue #173 (bdwgc). * include/private/gc_priv.h [!CPPCHECK && !PCR && MSWIN_XBOX1 && !DebugBreak] (DebugBreak): Define to __debugbreak. * misc.c [MSWIN32] (GC_win32_MessageBoxA): Do not define if MSWIN_XBOX1. * misc.c [!PCR && !SMALL_CONFIG && MSWIN32] (GC_default_on_abort): Do not call GC_win32_MessageBoxA() if MSWINRT_FLAVOR or MSWIN_XBOX1.
* Export stop/start_world_external only for multi-threaded buildsIvan Maidanski2018-07-281-6/+21
| | | | | | | | | | | | | | | | | | | | | | (fix of commit bb91f03) Issue #173 (bdwgc). Also, update GC_world_stopped value in GC_stop_world_external and GC_start_world_external. * include/gc.h (GC_stop_world_external, GC_start_world_external): Do not declare unless GC_THREADS; add comment. * misc.c (GC_stop_world_external, GC_start_world_external): Do not define unless THREADS; add assertion that GC is initialized. * misc.c [THREADS && THREAD_LOCAL_ALLOC] (GC_stop_world_external): Set GC_world_stopped to true after STOP_WORLD; add assertion that the world is not stopped. * misc.c [THREADS && THREAD_LOCAL_ALLOC] (GC_start_world_external): Set GC_world_stopped to false before START_WORLD; add assertion that the world is stopped. * tests/test.c [GC_PTHREADS && CPPCHECK] (main): Add UNTESTED for GC_stop_world_external and GC_start_world_external.
* New API to stop and start the GC world externallyJonas Echterhoff2018-07-271-0/+12
| | | | | | | | | | (part of commits 39e14be, 05e3377 from Unity-Technologies/bdwgc) Issue #173 (bdwgc). * include/gc.h (GC_stop_world_external, GC_start_world_external): Declare new API function. * misc.c (GC_stop_world_external, GC_start_world_external): Implement.
* Fix 'collecting from unknown thread' abort in leak-finding modeIvan Maidanski2018-06-081-1/+7
| | | | | | | | | * include/private/gc_priv.h [GC_PTHREADS && !GC_WIN32_THREADS] (GC_in_thread_creation): Move variable declaration from pthread_support.h. * misc.c [!DONT_USE_ATEXIT && GC_PTHREADS && !GC_WIN32_THREADS] (GC_exit_check): Set GC_in_thread_creation to TRUE before GC_gcollect call.
* Never return null pointer by C++ operator new (gc_cpp)Ivan Maidanski2018-06-011-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now, in case of the allocation failure, new and new[] operators throw bad_alloc (or abort the application if an ancient compiler is used). * gc_cpp.cc (GC_NEW_DELETE_NEED_THROW): Remove. * gc_cpp.cc (GC_DECL_NEW_THROW, GC_DECL_DELETE_THROW): Move macro definition to gc_cpp.h. * gc_cpp.cc [GC_NEW_DELETE_NEED_THROW]: Do not include "new" header. * gc_cpp.cc [!_MSC_VER] (operator new): Call GC_OP_NEW_OOM_CHECK() for the allocation result. * gc_cpp.cc [!_MSC_VER && GC_OPERATOR_NEW_ARRAY && !CPPCHECK] (operator new[]): Likewise. * include/gc.h (GC_abort_on_oom): Declare new API function. * include/gc_cpp.h [!GC_NEW_DELETE_THROW_NOT_NEEDED && (GC_GNUC_PREREQ(4,2) || __BORLANDC__>=0x0550 || _MSC_VER>1020 || __WATCOMC__>=1050)] (GC_NEW_DELETE_NEED_THROW): Define macro. * include/gc_cpp.h [GC_NEW_DELETE_NEED_THROW]: Include "new" header. * include/gc_cpp.h (GC_OP_NEW_OOM_CHECK): New internal macro (throws bad_alloc or cals GC_abort_on_oom). * include/gc_cpp.h (gc::new(size_t), gc::new(size_t,GCPlacement), new): Add GC_DECL_NEW_THROW; call GC_OP_NEW_OOM_CHECK() for the allocation result. * include/gc_cpp.h [GC_OPERATOR_NEW_ARRAY] (gc::new[](size_t), gc::new[](size_t,GCPlacement, new[]): Likewise. * misc.c (GC_abort_on_oom): Implement function. * tests/test.c [CPPCHECK] (main): Call UNTESTED(GC_abort_on_oom).
* Remove stubborn objects allocation code completelyIvan Maidanski2018-05-151-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (code refactoring) * README.md (Incremental/Generational Collection): Remove information about stubborn objects; add information about GC_end_stubborn_change usage. * alloc.c [STUBBORN_ALLOC] (GC_finish_collection): Do not call GC_clean_changing_list. * checksums.c (NSUMS, GC_check_dirty): Remove comment related to stubborn objects. * checksums.c [STUBBORN_ALLOC] (GC_on_free_list): Remove. * doc/README.macros (STUBBORN_ALLOC): Likewise. * include/private/gc_priv.h [STUBBORN_ALLOC] (GC_sobjfreelist, GC_arrays._sobjfreelist, GC_changed_pages, GC_arrays._changed_pages, GC_prev_changed_pages, GC_arrays._prev_changed_pages): Likewise. * include/private/gc_priv.h (GC_read_changed, GC_page_was_changed, GC_clean_changing_list, GC_stubborn_init): Likewise. * tests/test.c (stubborn_count): Likewise. * checksums.c (GC_n_changed_errors): Likewise. * checksums.c [STUBBORN_ALLOC] (GC_update_check_page, GC_check_dirty): Do not update GC_n_changed_errors value. * checksums.c (GC_check_dirty): Do not check/print GC_n_changed_errors value. * configure.ac (checksums): Update help message (remove information about stubborn objects). * dbg_mlc.c (GC_print_obj, GC_debug_end_stubborn_change, GC_debug_realloc, GC_debug_generic_or_special_malloc): Do not handle STUBBORN object kind specially. * mallocx.c (GC_generic_or_special_malloc, GC_realloc): Likewise. * mark.c [!GC_DISABLE_INCREMENTAL] (GC_push_next_marked_dirty): Likewise. * dbg_mlc.c [STUBBORN_ALLOC] (GC_debug_malloc_stubborn): Redirect to GC_debug_malloc; remove GC_ATTR_MALLOC. * dbg_mlc.c [STUBBORN_ALLOC] (GC_debug_change_stubborn): Change to no-op. * doc/README.amiga (WHATS NEW): Do not reference GC_malloc_stubborn. * doc/README.macros (CHECKSUMS): Update (remove information about stubborn objects). * doc/gcdescr.md (Allocation, Generational Collection and Dirty Bits): Likewise. * doc/gcinterface.md (C/C++ Interface): Likewise. * doc/leak.md (Using the Garbage Collector as Leak Detector): Likewise. * doc/gcdescr.md (Generational Collection and Dirty Bits): Add information about MANUAL_VDB. * include/gc.h (GC_malloc, GC_free, GC_realloc): Update comment (remove information about stubborn objects). * malloc.c (GC_generic_malloc_inner): Likewise. * tests/test.c (reverse_test_inner): Likewise. * include/gc.h (GC_malloc_stubborn, GC_debug_malloc_stubborn): Add GC_ATTR_DEPRECATED; remove GC_ATTR_MALLOC and GC_ATTR_ALLOC_SIZE. * include/gc.h (GC_MALLOC_STUBBORN, GC_NEW_STUBBORN): Redirect to normal GC_MALLOC/NEW; add comment that stubborn objects allocation is deprecated. * include/gc.h [GC_DEBUG] (GC_CHANGE_STUBBORN): Redirect to GC_change_stubborn (not GC_debug_change_stubborn). * include/gc.h (GC_change_stubborn): Add GC_ATTR_DEPRECATED. * include/gc.h [!CPPCHECK] (GC_debug_change_stubborn): Likewise. * include/gc.h (GC_change_stubborn, GC_debug_change_stubborn): Remove GC_ATTR_NONNULL. * include/gc.h (GC_end_stubborn_change): Add comment related to usage when the library is built with MANUAL_VDB defined. * include/gc.h [_AMIGA && !GC_AMIGA_MAKINGLIB] (GC_malloc_stubborn): Remove macro. * include/private/gc_priv.h (STUBBORN_ALLOC): Remove comment. * include/private/gc_priv.h (STUBBORN): Replace with GC_N_KINDS_INITIAL_VALUE definition. * mark.c (GC_obj_kinds): Remove initialization for STUBBORN_ALLOC element. * mark.c (GC_N_KINDS_INITIAL_VALUE): Move to gc_priv.h. * mark.c (GC_n_rescuing_pages): Define only if GC_DISABLE_INCREMENTAL. * mark.c [STUBBORN_ALLOC] (GC_initiate_gc): Do not call GC_read_changed. * misc.c [STUBBORN_ALLOC] (GC_init): Do not call GC_stubborn_init. * stubborn.c (GC_malloc_stubborn): Remove GC_ATTR_MALLOC. * tests/test.c [!VERY_SMALL_CONFIG] (cons): Replace GC_MALLOC_STUBBORN with GC_MALLOC call; update collectable_count instead of stubborn_count. * tests/test.c (check_heap_stats): Do not print stubborn_count value.
* Avoid multiple 'getcontext failed' warnings if getcontext is brokenIvan Maidanski2018-04-261-0/+10
| | | | | | | | | | | | | | | | Issue #133 (bdwgc). * mach_dep.c [!HAVE_PUSH_REGS && UNIX_LIKE && !NO_GETCONTEXT] (GC_with_callee_saves_pushed): Define getcontext_works static variable; do not call getcontext() if getcontext_works < 0; add comment; set getcontext_works to 1 or -1 (depending whether getcontext is working) if getcontext_works is zero. * misc.c [THREADS && UNIX_LIKE && !NO_GETCONTEXT] (callee_saves_pushed_dummy_fn): New static function (empty). * misc.c [THREADS && UNIX_LIKE && !NO_GETCONTEXT] (GC_init): Call GC_with_callee_saves_pushed(callee_saves_pushed_dummy_fn) if GC_dont_gc or GC_dont_precollect (otherwise it is called by GC_gcollect_inner); add comment.
* Avoid potential data race during GC_dump executionIvan Maidanski2018-04-101-17/+23
| | | | | | | | | | | | | | * include/gc.h (GC_dump): Separate declaration from GC_dump_named; add comment that it acquires the lock. * include/gc.h (GC_dump_named): Refine comment (add note that the lock is not acquired by this function). * include/private/gc_priv.h (GC_dump): Remove commented out declaration. * include/private/gc_priv.h [!NO_DEBUGGING] (COND_DUMP): Call GC_dump_named(NULL) instead of GC_dump(). * misc.c (GC_init) [GC_ASSERTIONS && GC_ALWAYS_MULTITHREADED]: Call COND_DUMP while holding the allocation lock. * misc.c [!NO_DEBUGGING] (GC_dump): Place LOCK/UNLOCK around GC_dump_named() call.