summaryrefslogtreecommitdiff
path: root/pthread_stop_world.c
Commit message (Collapse)AuthorAgeFilesLines
* Workaround 'if condition is the same as the previous one' cppcheck warningsIvan Maidanski2019-01-151-8/+8
| | | | | | | | | | * alloc.c [THREAD_LOCAL_ALLOC] (GC_stopped_mark): Set GC_world_stopped to FALSE after GC_on_collection_event(GC_EVENT_PRE_START_WORLD). * alloc.c [THREAD_LOCAL_ALLOC] (GC_stopped_mark): Collapse adjacent "if" statements. * mark.c [!GC_DISABLE_INCREMENTAL] (GC_initiate_gc): Likewise. * pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS && !GC_NETBSD_THREADS_WORKAROUND] (GC_start_world): Likewise.
* Fix deadlocks in write and suspend handlers if AO test-and-set is emulatedIvan Maidanski2018-11-201-10/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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().
* Use macro to operate on a flag residing in GC_stop_countIvan Maidanski2018-11-071-10/+14
| | | | | | | | | | | | (code refactoring of commit 295a2f24e) * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (THREAD_RESTARTED): New macro. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_count): Refine comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_handler_inner, GC_stop_world, GC_restart_all): Use THREAD_RESTARTED.
* Prevent a deadlock in suspend_thread and after process forkingIvan Maidanski2018-09-271-5/+14
| | | | | | | | | | | | | | | | | | (fix of commit 0c0e4cd) Issue #235 (bdwgc). * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): Remove unneeded comment for AO_store_release() call; invoke GC_acquire_dirty_lock() and GC_release_dirty_lock() only if GC_manual_vdb; add comment for GC_acquire_dirty_lock() call. * pthread_stop_world.c [NACL] (GC_suspend_all): If GC_manual_vdb then call GC_acquire_dirty_lock() and GC_release_dirty_lock() around the code which ensures parking of threads. * pthread_support.c [CAN_HANDLE_FORK] (fork_prepare_proc): Call GC_acquire_dirty_lock(). * pthread_support.c [CAN_HANDLE_FORK] (fork_parent_proc, fork_child_proc): Call GC_release_dirty_lock().
* Fix concurrent bitmap update in GC_dirtyIvan Maidanski2018-09-251-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #235 (bdwgc). * darwin_stop_world.c [!GC_NO_THREADS_DISCOVERY] (GC_suspend_thread_list): Call GC_acquire_dirty_lock and GC_release_dirty_lock around thread_suspend(). * darwin_stop_world.c (GC_stop_world): Likewise. * include/private/gc_priv.h (set_pht_entry_from_index_safe): Remove unused macro. * include/private/gc_priv.h [THREADS] (GC_acquire_dirty_lock, GC_release_dirty_lock): Define new macro; move comment from win32_threads.c. * include/private/gc_priv.h [THREADS && !GC_DISABLE_INCREMENTAL] (GC_fault_handler_lock): Declare global variable (even if not MPROTECT_VDB). * os_dep.c [!GC_DISABLE_INCREMENTAL] (async_set_pht_entry_from_index): Define even if not MPROTECT_VDB; reformat comments. * os_dep.c [!GC_DISABLE_INCREMENTAL && AO_HAVE_test_and_set_acquire] (GC_fault_handler_lock): Likewise. * os_dep.c [THREADS && AO_HAVE_test_and_set_acquire] (async_set_pht_entry_from_index): Use GC_acquire_dirty_lock and GC_release_dirty_lock; remove wrong comment. * os_dep.c [THREADS && !AO_HAVE_test_and_set_acquire] (currently_updating, async_set_pht_entry_from_index): Remove incorrect implementation. * os_dep.c [!GC_DISABLE_INCREMENTAL] (GC_dirty_inner): Call async_set_pht_entry_from_index instead of set_pht_entry_from_index; remove FIXME. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): Refine comment for AO_store_release call; call GC_acquire_dirty_lock and GC_release_dirty_lock around a block of RAISE_SIGNAL() and sem_wait(). * pthread_stop_world.c [GC_OPENBSD_UTHREADS] (GC_suspend_all): Call GC_acquire_dirty_lock and GC_release_dirty_lock around pthread_suspend_np(). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS] (GC_suspend_all): Add comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_world): If GC_manual_vdb then call GC_acquire_dirty_lock and GC_release_dirty_lock around a block of GC_suspend_all() and suspend_restart_barrier(); add comment. * win32_threads.c (GC_suspend): Use GC_acquire_dirty_lock and GC_release_dirty_lock (regardless of MPROTECT_VDB).
* Use THREAD_EQUAL consistently to compare pthread_t valuesIvan Maidanski2018-04-201-1/+1
| | | | | | | | | | (code refactoring) * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): Use THREAD_EQUAL() to compare pthread_t values. * pthread_support.c (GC_unregister_my_thread): Likewise. * specific.c [USE_CUSTOM_SPECIFIC] (GC_remove_specific_after_fork, GC_slow_getspecific): Likewise.
* Do not resend the restart signal to threads that are already restartedIvan Maidanski2018-04-051-13/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | (fix of commit 3498427) Issue #181 (bdwgc). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_count): Update comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_handler_inner): Add assertion that my_stop_count is even. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_handler_inner): Mask lowest bit of last_stop_count when checking for the duplicate signal. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_handler_inner): If GC_retry_signals then set the lowest bit of last_stop_count (by AO_store_release) after the second sem_post() call; add comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_all): Add comment for last_stop_count check. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_world): Increment GC_stop_count by 2 (instead of by one). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_restart_all): If GC_retry_signals and last_stop_count has the same value as GC_stop_count+1 then do not increment n_live_threads and do not send the restart signal to the thread.
* Replace GC_NO_RETRY_SIGNALS environment variable with GC_RETRY_SIGNALS=0Ivan Maidanski2018-04-031-6/+10
| | | | | | | | | * doc/README.environment (GC_NO_RETRY_SIGNALS): Remove. * doc/README.environment (GC_RETRY_SIGNALS): Document "0" value. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_init): Declare str local variable; do not check GC_NO_RETRY_SIGNALS environment variable; refine comment; set GC_retry_signals to false if the value of GC_RETRY_SIGNALS environment variable is "0".
* Handle pthread restart signals loss if retry_signalsIvan Maidanski2018-04-031-10/+21
| | | | | | | | | | | | | | | | | | | | | | | Issue #181 (bdwgc). * doc/README.environment (GC_RETRY_SIGNALS, GC_NO_RETRY_SIGNALS): Update documentation (support of restart signals loss, try signals if compiled with ASan/MSan/TSan). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_retry_signals): Set true also if ADDRESS_SANITIZER or MEMORY_SANITIZER. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && !GC_NETBSD_THREADS_WORKAROUND] (GC_suspend_handler_inner): Call sem_post(GC_suspend_ack_sem) at the function end if GC_retry_signals; update comment about the RESTART signal loss. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && !GC_OPENBSD_UTHREADS] (GC_start_world): Call resend_lost_signals(GC_restart_all) and update n_live_threads value. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && !GC_OPENBSD_UTHREADS && !GC_NETBSD_THREADS_WORKAROUND] (GC_start_world): Call suspend_restart_barrier() if GC_retry_signals. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_init): Update the message logged if GC_retry_signals.
* Fix a typo in WARN message of resend_lost_signalsIvan Maidanski2018-04-031-1/+1
| | | | | | | | | (fix of commit c2e9583) Issue #181 (bdwgc). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (resend_lost_signals): Fix typo ("stopping") in WARN message.
* Define static resend_lost_signals(), restart_all() in pthread_stop_worldIvan Maidanski2018-04-021-101/+114
| | | | | | | | | | | | | | | | | | | | | (code refactoring) Issue #181 (bdwgc). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ASSERTIONS] (suspend_restart_barrier): Check that the count of GC_suspend_ack_sem is zero at the end of the function. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (resend_lost_signals): New static function (the code is moved from GC_stop_world). * pthread_stop_world.c [DEBUG_THREADS] (GC_suspend_all): Move the assignment of GC_stopping_thread and GC_stopping_pid to GC_stop_world. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_world): Call resend_lost_signals() if GC_retry_signals. * pthread_stop_world.c [!NACL] (GC_restart_all): New static function (the code is moved from GC_start_world). * pthread_stop_world.c [!NACL] (GC_start_world): Declare n_live_threads local variable; call GC_restart_all.
* Unblock only GC signals in suspend_handler (TSan)Ivan Maidanski2018-03-301-2/+6
| | | | | | | | | Issue #181 (bdwgc). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && THREAD_SANITIZER] (GC_suspend_handler_inner): Replace pthread_sigmask(SIG_SETMASK) to pthread_sigmask(SIG_UNBLOCK) with the set with GC_sig_suspend and GC_sig_thr_restart signals.
* Acknowledge thread restart from suspend_handler (NetBSD)Ivan Maidanski2018-03-291-42/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #181 (bdwgc). Also, one sem_t variable is used to acknowledge both thread suspends and restarts. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_ack_sem): Add comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_NETBSD_THREADS_WORKAROUND] (GC_restart_ack_sem): Remove static variable. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_NETBSD_THREADS_WORKAROUND] (GC_suspend_handler_inner): Call sem_post(&GC_suspend_ack_sem) at the end of the handler (just before RESTORE_CANCEL). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (suspend_restart_barrier): New static function. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_NETBSD_THREADS_WORKAROUND] (GC_restart_handler): Do not call sem_post(&GC_restart_ack_sem). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_world): Remove i, code local variables; call suspend_restart_barrier instead of sem_wait calls in a loop. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_NETBSD_THREADS_WORKAROUND] (GC_start_world): Likewise. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_NETBSD_THREADS_WORKAROUND] (GC_stop_init): Remove sem_init(&GC_restart_ack_sem) call.
* Minimize delay between sem_post and sigsuspend in suspend_handler if TSanIvan Maidanski2018-03-291-6/+5
| | | | | | | | | | | | | | (fix of commit af409e4) Issue #181 (bdwgc). This change is to do as less as possible (even in case of TSan usage) between the sem_post and sigsuspend calls in GC_suspend_handler_inner (to match the relevant comment after sigsuspend call). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && THREAD_SANITIZER] (GC_suspend_handler_inner): Move sigemptyset() and pthread_sigmask() calls to be just before sem_post() call.
* Explicitly unblock GC signals on GC initializationIvan Maidanski2018-03-231-1/+6
| | | | | | | | | | | | | | | | | | Issue #175 (bdgwc). Note: NO_SIGNALS_UNBLOCK_IN_MAIN macro is to be defined manually to turn off this feature (for a reason). * include/private/gcconfig.h [GC_NO_PTHREAD_SIGMASK] (NO_SIGNALS_UNBLOCK_IN_MAIN): New macro. * pthread_stop_world.c [GC_PTHREADS && !GC_WIN32_THREADS && !GC_DARWIN_THREADS && !SN_TARGET_ORBIS && !SN_TARGET_PSP2 && !NACL && !GC_OPENBSD_UTHREADS && !NO_SIGNALS_UNBLOCK_IN_MAIN] (GC_unblock_gc_signals): Define. * pthread_stop_world.c [GC_PTHREADS && !GC_WIN32_THREADS && !GC_DARWIN_THREADS && !SN_TARGET_ORBIS && !SN_TARGET_PSP2 && !NACL && !GC_OPENBSD_UTHREADS && !NO_SIGNALS_UNBLOCK_IN_MAIN] (GC_stop_init): Call GC_unblock_gc_signals; add comment.
* Wrap remaining extern symbols in .c files into EXTERN_C_BEGIN/ENDIvan Maidanski2018-03-021-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #206 (bdwgc). * dyn_load.c [SOLARISDL && !USE_PROC_FOR_LIBRARIES] (_DYNAMIC): Move the extern symbol declaration out of a function body. * os_dep.c [!PCR && !MACOS && REDIRECT_MALLOC && GC_SOLARIS_THREADS] (sbrk): Likewise. * dyn_load.c [SOLARISDL && !USE_PROC_FOR_LIBRARIES] (_DYNAMIC): Wrap into EXTERN_C_BEGIN/END block. * dyn_load.c [__ELF__ && LINUX && HOST_ANDROID || HAVE_DL_ITERATE_PHDR] (dl_iterate_phdr): Likewise. * dyn_load.c [!USE_PROC_FOR_LIBRARIES] (_DYNAMIC): Likewise. * dyn_load.c [ALPHA && OSF1 || HPUX] (sys_errlist, sys_nerr, errno): Likewise. * os_dep.c [SEARCH_FOR_DATA_START && (LINUX || HURD)] (__data_start, data_start): Likewise. * os_dep.c [SEARCH_FOR_DATA_START && LINUX && HOST_ANDROID] (_etext, __dso_handle): Likewise. * os_dep.c [NETBSD && __ELF__] (environ): Likewise. * os_dep.c [OPENBSD && THREADS] (__syscall): Likewise. * os_dep.c [LINUX_STACKBOTTOM && USE_LIBC_PRIVATES] (__libc_stack_end): Likewise. * os_dep.c [LINUX_STACKBOTTOM && USE_LIBC_PRIVATES && IA64] (__libc_ia64_register_backing_store_base): Likewise. * os_dep.c [SYMBIAN] (GC_get_main_symbian_stack_base): Likewise. * os_dep.c [!PCR && !MACOS && REDIRECT_MALLOC && GC_SOLARIS_THREADS] (sbrk): Likewise. * os_dep.c [MMAP_SUPPORTED && SYMBIAN] (GC_get_private_path_and_zero_file): Likewise. * pthread_stop_world.c [USE_TKILL_ON_ANDROID] (tkill): Likewise. * pthread_stop_world.c [NACL] (nacl_interface_query): Likewise. * pthread_support.c [PTHREAD_REGISTER_CANCEL_WEAK_STUBS] (__pthread_register_cancel, __pthread_unregister_cancel): Likewise. * pthread_support.c [PTHREAD_REGISTER_CANCEL_WEAK_STUBS] (__pthread_register_cancel, __pthread_unregister_cancel): Use "void" to denote empty arguments list.
* Fix linkage of javaxfc.h symbols for the case of compilation as C++ codeIvan Maidanski2018-03-011-0/+1
| | | | | | | | | Issue #206 (bdwgc). The functions should be declared (as extern "C") before the definition. * finalize.c [!GC_NO_FINALIZATION]: Include javaxfc.h. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD]: Likewise.
* Always include gc_atomic_ops.h unless threads are disabledIvan Maidanski2018-02-261-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | (code refactoring) * include/private/gc_atomic_ops.h [!GC_BUILTIN_ATOMIC]: Issue #error if AO_HAVE_load or AO_HAVE_store is not defined after include atomic_ops.h. * include/private/gc_locks.h: Do not include gc_atomic_ops.h. * include/private/specific.h: Likewise. * pthread_stop_world.c: Likewise. * tests/test.c [THREADS && (GC_BUILTIN_ATOMIC || PARALLEL_MARK || !GC_WIN32_THREADS)]: Likewise. * thread_local_alloc.c: Likewise. * typd_mlc.c [GC_FORCE_INCLUDE_ATOMIC_OPS || GC_BUILTIN_ATOMIC]: Likewise. * win32_threads.c [(GC_DLL || GC_INSIDE_DLL) && !THREAD_LOCAL_ALLOC && !GC_NO_THREADS_DISCOVERY && !MSWINCE && !GC_PTHREADS]: Likewise. * include/private/gc_priv.h [THREADS && !SN_TARGET_ORBIS && !SN_TARGET_PSP2]: Include gc_atomic_ops.h (after GC_INLINE definition). * include/private/gc_priv.h (counter_t): Do not define. * include/private/gc_priv.h (hblkhdr): Change type of hb_n_marks to either volatile AO_t (if PARALLEL_MARK) or size_t * mark.c (GC_noop6): Check AO_CLEAR macro presence instead of GC_PTHREADS and !GC_WIN32_THREADS or PARALLEL_MARK. * tests/test_atomic_ops.c [_WIN32 || _MSC_VER || __CYGWIN__ || __MINGW32__] (main): Do not skip the test.
* Eliminate C++ warnings about deprecated register keyword (GC source)Jay Krell2018-02-221-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #206 (bdwgc). * blacklst.c (GC_number_stack_black_listed, total_stack_black_listed): Remove register keyword for local variables. * dyn_load.c [IRIX5 || USE_PROC_FOR_LIBRARIES && !LINUX] (GC_register_dynamic_libraries): Likewise. * extra/pcr_interface.c [PCR] (GC_enumerate_block): Likewise. * finalize.c (GC_grow_table): Likewise. * headers.c (alloc_hdr, GC_init_headers, GC_remove_counts, GC_prev_block): Likewise. * include/private/gc_pmark.h (PUSH_OBJ): Likewise. * mach_dep.c [!HAVE_PUSH_REGS && !HAVE_BUILTIN_UNWIND_INIT] (GC_with_callee_saves_pushed): Likewise. * mark.c (clear_marks_for_block): Likewise. * mark_rts.c [MSWIN32 || MSWINCE || CYGWIN32] (GC_add_roots_inner): Likewise. * mark_rts.c [!NO_DEBUGGING] (GC_is_tmp_root): Likewise. * os_dep.c [GWW_VDB || MPROTECT_VDB || PROC_VDB || MANUAL_VDB] (GC_page_was_dirty): Likewise. * os_dep.c [CHECKSUMS && GWW_VDB || PROC_VDB] (GC_or_pages, GC_page_was_ever_dirty): Likewise. * os_dep.c (GC_write_fault_handler): Likewise. * os_dep.c [PROC_VDB] (GC_read_dirty): Likewise. * os_dep.c [MPROTECT_VDB && DARWIN] (catch_exception_raise): Likewise. * os_dep.c [SAVE_CALL_CHAIN && NARGS>0] (GC_save_callers): Likewise. * pthread_stop_world.c [!NACL] (GC_start_world): Likewise. * pthread_support.c (GC_delete_thread, GC_delete_gc_thread): Likewise. * typd_mlc.c (GC_push_complex_descriptor): Likewise. * win32_threads.c (GC_delete_gc_thread_no_free, GC_delete_thread): Likewise.
* Initial support of Sony PlayStation Portable 2Jonathan Chambers2018-02-011-1/+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.
* Initial support of Orbis targetJonathan Chambers2018-01-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* Prevent multiple sem_post calls for a thread in suspend_handlerIvan Maidanski2017-12-281-7/+8
| | | | | | | | | | | | (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.
* Do not call sem_getvalue in stop_world if one thread existsIvan Maidanski2017-12-281-1/+1
| | | | | | * 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).
* Add assertion for suspend_ack_sem in start_worldIvan Maidanski2017-12-281-0/+7
| | | | | | | | 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.
* Allow GC_NETBSD_THREADS_WORKAROUND macro manual definitionIvan Maidanski2017-12-281-4/+2
| | | | | | | | | | * 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.
* Fix error code in abort message if sem_wait failed in start_world (NetBSD)Ivan Maidanski2017-12-271-4/+2
| | | | | | * 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.
* Really prevent hang in sem_wait in stop_world if compiled with TSanIvan Maidanski2017-12-121-11/+4
| | | | | | | | | | | | | | | | (fix commit af409e4) Issue #181 (bdwgc). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && THREAD_SANITIZER] (GC_retry_signals): Initialize to TRUE. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_store_stack_ptr): Update comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): Likewise. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && THREAD_SANITIZER] (GC_stop_world): Do not use sem_trywait+sleep workaround (not needed if GC_retry_signals).
* Add a sanity check that load_acquire and store_release are availableIvan Maidanski2017-11-291-0/+6
| | | | | | | * pthread_stop_world.c [(!AO_HAVE_load_acquire || !AO_HAVE_store_release) && !CPPCHECK]: Issue error that libatomic_ops does not define AO_load_acquire and/or AO_store_release so the client should manually define AO_REQUIRE_CAS macro.
* Improve comment in store_stack_ptr in pthread_stop_world.cIvan Maidanski2017-11-291-3/+3
| | | | | | | (fix commit a194093) * pthread_stop_world.c (GC_store_stack_ptr): Refine comment about the atomic primitives usage.
* Remove explicit case of TRUE/FALSE to AO_t in suspend/resume_threadIvan Maidanski2017-11-291-2/+2
| | | | | | | | (fix commit ce09fd5) * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD && !GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_thread, GC_resume_thread): Do not case TRUE/FALSE to AO_t explicitly.
* Fix lack of barriers to synchronize memory for suspend_handlerIvan Maidanski2017-11-241-6/+11
| | | | | | | | | | | | | pthread_kill is not on the list of functions which synchronize memory. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_world_is_stopped): Reformat comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_handler_inner): Use AO_load_acquire instead of AO_load to fetch the value of GC_stop_count; add comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_start_world): Use AO_store_release instead of AO_store to reset GC_world_is_stopped; add comment.
* Eliminate TSan false positive related to stop_info.stack_ptr accessIvan Maidanski2017-11-241-17/+23
| | | | | | | | | | | * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_store_stack_ptr): New inline function definition (move the code from GC_suspend_handler_inner but stop_info.stack_ptr is now stored atomically); add comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_handler_inner): Call GC_store_stack_ptr(). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_push_all_stacks): Use AO_load to fetch p->stop_info.stack_ptr.
* Fix data race in last_stop_count access (suspend_handler_inner)Ivan Maidanski2017-11-231-8/+3
| | | | | | | | | | | | | | | * include/private/pthread_stop_world.h [!GC_OPENBSD_UTHREADS] (thread_stop_info.last_stop_count): Do not define if NACL; change the type from word to AO_t; add volatile qualifier; fix a typo in comment ("GC_stop_count"). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (update_last_stop_count): Remove. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_handler_inner): Replace update_last_stop_count() call with AO_store_release(&me->stop_info.last_stop_count,my_stop_count). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_all): Replace p->stop_info.last_stop_count with AO_load(&p->stop_info.last_stop_count).
* Fix data race in GC_suspend/resume_threadIvan Maidanski2017-11-231-11/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | * include/private/pthread_support.h [GC_ENABLE_SUSPEND_THREAD && !GC_DARWIN_THREADS && !GC_OPENBSD_UTHREADS && !NACL] (GC_Thread_Rep.suspended_ext): New field. * include/private/pthread_support.h (SUSPENDED_EXT): Remove macro. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD && !GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_handler_inner): Replace me->flags & SUSPENDED_EXT with AO_load(&me->suspended_ext). * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD && !GC_OPENBSD_UTHREADS && !NACL] (suspend_self_inner): Replace me->flags & SUSPENDED_EXT with AO_load_acquire(&me->suspended_ext). * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD && !GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_thread): Replace t->flags & SUSPENDED_EXT with t->suspended_ext; replace t->flags|=SUSPENDED_EXT with AO_store_release(&t->suspended_ext, TRUE); add comment. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD && !GC_OPENBSD_UTHREADS && !NACL] (GC_resume_thread): Replace t->flags&=~SUSPENDED_EXT with AO_store(&t->suspended_ext, FALSE). * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD && !GC_OPENBSD_UTHREADS && !NACL] (GC_is_thread_suspended, GC_suspend_all, GC_start_world): Replace t->flags & SUSPENDED_EXT with t->suspended_ext. * pthread_support.c (GC_register_my_thread): Remove assertion that uses SUSPENDED_EXT.
* Revert 'Workaround TSan false positives in suspend/resume_thread'Ivan Maidanski2017-11-231-16/+1
| | | | | | This reverts commit 918500dcd5f629391e442f68620873909c733ea7. Because it just hides the data race issues in GC_suspend/resume_thread.
* Workaround TSan false positive in lookup_thread called by suspend_handlerIvan Maidanski2017-11-221-5/+22
| | | | | | | | | | | | | | | * include/private/pthread_support.h (THREAD_TABLE_INDEX): Move the macro from pthread_support.c file. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && THREAD_SANITIZER] (GC_lookup_thread_async): New static function (same implementation as of GC_lookup_thread but with GC_ATTR_NO_SANITIZE_THREAD attribute); add comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && !THREAD_SANITIZER] (GC_lookup_thread_async): Define as macro. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_handler_inner): Call GC_lookup_thread_async() instead of GC_lookup_thread(); move the corresponding comment to GC_lookup_thread_async.
* Place no_sanitize attributes in a GCC-compliant wayIvan Maidanski2017-11-211-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now the attributes precede the function prototypes (the format is: <attribute> void f(void) <body>). * finalize.c (GC_should_invoke_finalizers): Move GC_ATTR_NO_SANITIZE_THREAD attribute to the beginning of the function prototype (even before GC_API, GC_INNER or static). * malloc.c (fill_size_map): Likewise. * mark.c (GC_noop1, GC_mark_from, GC_push_all_eager): Likewise. * mark.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager): Likewise. * misc.c [THREADS] (next_random_no): Likewise. * os_dep.c [MPROTECT_VDB && THREADS && AO_HAVE_test_and_set_acquire] (async_set_pht_entry_from_index): Likewise. * os_dep.c [MPROTECT_VDB] (is_header_found_async): Likewise. * pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS] (update_last_stop_count): Likewise. * pthread_stop_world.c [!NACL && !GC_OPENBSD_UTHREADS && GC_ENABLE_SUSPEND_THREAD] (set_suspended_ext_flag, GC_resume_thread): Likewise. * pthread_support.c [THREAD_SANITIZER && (USE_SPIN_LOCK || !NO_PTHREAD_TRYLOCK)] (is_collecting): Likewise. * pthread_support.c [USE_SPIN_LOCK] (set_last_spins_and_high_spin_max, reset_spin_max): Likewise. * mark.c (GC_mark_from, GC_push_all_eager): Move GC_ATTR_NO_SANITIZE_ADDR, GC_ATTR_NO_SANITIZE_MEMORY attributes to the beginning of the function prototype. * mach_dep.c (GC_with_callee_saves_pushed): Likewise. * mark.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager): Likewise.
* Workaround hangs in sigsuspend and sem_wait if compiled with TSanIvan Maidanski2017-11-171-1/+18
| | | | | | | | | | | | | Issue #181 (bdwgc). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && THREAD_SANITIZER] (GC_suspend_handler_inner): Call pthread_sigmask(SIG_SETMASK) with an empty set (thus unmask all signals); add comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && THREAD_SANITIZER] (GC_stop_world): Call sem_trywait() repeatedly (with a delay of 100 microseconds) while getting EAGAIN error (instead of a sem_wait call).
* Revert 'Workaround a hang in sigsuspend if compiled with Thread Sanitizer'Ivan Maidanski2017-11-171-9/+0
| | | | | | | This reverts commit 04fd7b5309596423e4342502d3123028d836d551. Because it does not avoid hangs in all cases when stopping the world. A better solution is to re-enable signals in the suspend handler.
* Workaround a hang in sigsuspend if compiled with Thread SanitizerIvan Maidanski2017-11-131-0/+9
| | | | | | | | Issue #181 (bdwgc). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && THREAD_SANITIZER] (GC_suspend_handler_inner): Use sched_yield() instead of sigsuspend(&suspend_handler_mask); add TODO item.
* Workaround TSan false positives in suspend/resume_threadIvan Maidanski2017-11-131-2/+17
| | | | | | | | | | | | * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (set_suspended_ext_flag): New static function (with GC_ATTR_NO_SANITIZE_THREAD attribute); add comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): Call set_suspended_ext_flag() instead of t->flags|=SUSPENDED_EXT. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_resume_thread): Add GC_ATTR_NO_SANITIZE_THREAD attribute; add comment.
* Workaround Thread Sanitizer (TSan) false positive warnings (partially)Ivan Maidanski2017-10-201-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch covers only data race false positive warnings reported in async_set_pht_entry_from_index, GC_clear_stack, GC_invoke_finalizers, GC_lock, GC_noop1, GC_notify_or_invoke_finalizers, GC_pthread_create, GC_suspend_handler_inner, I_DONT_HOLD_LOCK. * finalize.c (GC_should_invoke_finalizers): Add GC_ATTR_NO_SANITIZE_THREAD. * mark.c (GC_noop1): Likewise. * os_dep.c [MPROTECT_VDB && THREADS && AO_HAVE_test_and_set_acquire] (async_set_pht_entry_from_index): Likewise. * finalize.c (GC_invoke_finalizers, GC_notify_or_invoke_finalizers): Call GC_should_invoke_finalizers() instead of GC_fnlz_roots.finalize_now!=NULL. * include/private/gc_locks.h [(GC_WIN32_THREADS && !USE_PTHREAD_LOCKS || GC_PTHREADS) && GC_ASSERTIONS && THREAD_SANITIZER] (I_DONT_HOLD_LOCK): Define to TRUE; add comment. * include/private/gc_locks.h [!GC_ALWAYS_MULTITHREADED && THREAD_SANITIZER] (set_need_to_lock): Do not set GC_need_to_lock if already set; add comment. * include/private/gc_priv.h [!GC_ATTR_NO_SANITIZE_THREAD] (GC_ATTR_NO_SANITIZE_THREAD): New macro. * include/private/gcconfig.h [__has_feature && __has_feature(thread_sanitizer)] (THREAD_SANITIZER): Define. * misc.c [THREADS] (next_random_no): New static function (with GC_ATTR_NO_SANITIZE_THREAD). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (update_last_stop_count): Likewise. * pthread_support.c [THREAD_SANITIZER && (USE_SPIN_LOCK || !NO_PTHREAD_TRYLOCK)] (is_collecting): Likewise. * pthread_support.c [USE_SPIN_LOCK] (set_last_spins_and_high_spin_max, reset_spin_max): Likewise. * misc.c [THREADS] (GC_clear_stack): Remove random_no static variable; use next_random_no() instead of ++random_no%13. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_handler_inner): Call update_last_stop_count() instead of me->stop_info.last_stop_count=my_stop_count. * pthread_support.c [USE_SPIN_LOCK || !NO_PTHREAD_TRYLOCK] (SPIN_MAX): Define only if not yet. * pthread_support.c [USE_SPIN_LOCK || !NO_PTHREAD_TRYLOCK] (GC_collecting): Initialize to FALSE instead of 0. * pthread_support.c [!(THREAD_SANITIZER && (USE_SPIN_LOCK || !NO_PTHREAD_TRYLOCK))] (is_collecting): Define as a macro. * pthread_support.c [USE_SPIN_LOCK] (low_spin_max, high_spin_max, spin_max, last_spins): Move definition out of GC_lock(). * pthread_support.c (GC_lock): Use is_collecting(), set_last_spins_and_high_spin_max() and reset_spin_max().
* Fix deadlock in GC_suspend_thread when thread is rebuilding free listIvan Maidanski2017-07-211-2/+14
| | | | | | | | | | | (fix commits 62097c3, 59e2bcf) * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): Move DISABLE_CANCEL() upper to cover also GC_wait_for_reclaim() and RAISE_SIGNAL() calls. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD && PARALLEL_MARK] (GC_suspend_thread): If GC_parallel then call GC_wait_for_reclaim() holding the allocation lock before RAISE_SIGNAL() call; add comment.
* Specify that unused select() result is intentionalIvan Maidanski2017-07-201-1/+1
| | | | | | | (fix commit 62097c3) * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_brief_async_signal_safe_sleep): Cast select() result to void.
* Fix deadlock in GC_suspend_thread when thread is finishedIvan Maidanski2017-07-121-6/+6
| | | | | | | | (fix commits 62097c3, 59e2bcf) * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): Do not call RAISE_SIGNAL() and sem_wait() if thread has FINISHED flag set; do not handle ESRCH error result of RAISE_SIGNAL(); add comment.
* Workaround 'waiting while holding lock' code defect in stop_world (Unix)Ivan Maidanski2017-05-181-1/+6
| | | | | | * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && LINT2] (GC_stop_world): Redefine WAIT_UNIT to 1; call sched_yield() instead of usleep(); add comment.
* Workaround 'obsolescent usleep called' cppcheck warning (POSIX)Ivan Maidanski2017-03-071-1/+13
| | | | | | * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL]: Include time.h. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_world): Use nanosleep() instead of usleep() if CPPCHECK.
* Fix 'size of tv is unknown' error in brief_async_signal_safe_sleep (musl)Mikael Djurfeldt2017-03-031-0/+2
| | | | | | | | | (fix commits 62097c3, 9f48082) Include <sys/time.h> to get struct timeval defined and select() declared. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD]: Include sys/time.h before GC_brief_async_signal_safe_sleep definition.
* Add AO primitives implementation to GC based on C11 atomic intrinsicIvan Maidanski2017-01-251-1/+2
| | | | | | | | | | | | | | | | | | | | * Makefile.direct (SRCS): Add include/private/gc_atomic_ops.h. * include/include.am (dist_noinst_HEADERS): Likewise. * include/private/gc_atomic_ops.h: New file; define needed AO entities if GC_BUILTIN_ATOMIC, otherwise include atomic_ops.h. * include/private/gc_locks.h [THREADS && GC_PTHREADS && !GC_WIN32_THREADS]: Include gc_atomic_ops.h instead of atomic_ops.h. * include/private/gc_priv.h [PARALLEL_MARK || THREADS && MPROTECT_VDB]: Likewise. * include/private/specific.h: Likewise. * pthread_stop_world.c: Include private/gc_atomic_ops.h instead of atomic_ops.h. * tests/subthread_create.c: Likewise. * thread_local_alloc.c [THREAD_LOCAL_ALLOC && GC_GCJ_SUPPORT]: Likewise. * typd_mlc.c [GC_FORCE_INCLUDE_ATOMIC_OPS || GC_BUILTIN_ATOMIC]: Likewise. * win32_threads.c [GC_DLL && !GC_NO_THREADS_DISCOVERY && !MSWINCE]: Likewise.
* Workaround 'value of macro unknown' cppcheck info messagesIvan Maidanski2016-10-241-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The messages are eliminated for the macros: __int64, _SIGRTMIN, ARM_THREAD_STATE32, ARM_UNIFIED_THREAD_STATE, FIXUP_POINTER, GC_COLLECT_AT_MALLOC, GC_FREE_SPACE_DIVISOR, GC_FULL_FREQ, GC_INITIAL_HEAP_SIZE, GC_MAX_RETRIES, GC_MAXIMUM_HEAP_SIZE, GC_MIN_MARKERS, GC_SIG_SUSPEND, GC_SIG_THR_RESTART, GC_TIME_LIMIT, HEURISTIC2_LIMIT, MAP_ANONYMOUS, RTLD_DI_LINKMAP, SAVE_CALL_COUNT, SIZE_MAX. * alloc.c (GC_full_freq, GC_free_space_divisor, GC_time_limit): Define to default immediate value if CPPCHECK. * darwin_stop_world.c [ARM32 && ARM_THREAD_STATE32] (GC_ARM_UNIFIED_THREAD_STATE): New macro (defined to ARM_UNIFIED_THREAD_STATE unless CPPCHECK). * darwin_stop_world.c [ARM32 && ARM_THREAD_STATE32] (GC_stack_range_for): Use GC_ARM_UNIFIED_THREAD_STATE; do not use value of ARM_THREAD_STATE32 if CPPCHECK. * dyn_load.c [!USE_PROC_FOR_LIBRARIES] (GC_RTLD_DI_LINKMAP): New macro (defined to RTLD_DI_LINKMAP unless CPPCHECK). * dyn_load.c [!USE_PROC_FOR_LIBRARIES] (GC_FirstDLOpenedLinkMap): Use GC_RTLD_DI_LINKMAP. * include/gc.h (GC_word, GC_signed_word): Do not define to __int64 if CPPCHECK. * include/gc.h (GC_INIT_CONF_MAX_RETRIES, GC_INIT_CONF_FREE_SPACE_DIVISOR, GC_INIT_CONF_FULL_FREQ, GC_INIT_CONF_TIME_LIMIT, GC_INIT_CONF_SUSPEND_SIGNAL, GC_INIT_CONF_THR_RESTART_SIGNAL, GC_MAXIMUM_HEAP_SIZE, GC_INITIAL_HEAP_SIZE): Define to empty if CPPCHECK. * include/private/gc_priv.h [SIZE_MAX] (GC_SIZE_MAX): Do not define to SIZE_MAX if CPPCHECK. * include/private/gc_priv.h [DARWIN && ARM32 && ARM_UNIFIED_THREAD_STATE] (GC_MACH_THREAD_STATE): Do not define to ARM_UNIFIED_THREAD_STATE if CPPCHECK. * include/private/gc_priv.h [GC_PTHREADS && _SIGRTMIN] (SIG_SUSPEND): Do not define to _SIGRTMIN if CPPCHECK. * pthread_stop_world.c [!SIG_THR_RESTART && _SIGRTMIN] (SIG_THR_RESTART): Likewise. * include/private/gcconfig.h [SAVE_CALL_CHAIN && SAVE_CALL_COUNT] (NFRAMES): Define to immediate value (do not use value of SAVE_CALL_COUNT) if CPPCHECK. * include/private/gcconfig.h [!FIXUP_POINTER && POINTER_MASK] (FIXUP_POINTER): Define to a sample expression (not using values of POINTER_MASK and POINTER_SHIFT) if CPPCHECK. * malloc.c [GC_COLLECT_AT_MALLOC] (GC_dbg_collect_at_malloc_min_lb): Define to sample value (not using value of GC_COLLECT_AT_MALLOC) if CPPCHECK. * misc.c [GC_INITIAL_HEAP_SIZE] (GC_init): Define to default immediate value if CPPCHECK. * os_dep.c [!BEOS && !OS2 && !SWIN32 && !GC_OPENBSD_THREADS && !STACKBOTTOM && HEURISTIC2_LIMIT] (GC_get_main_stack_base): Do not use value of HEURISTIC2_LIMIT if CPPCHECK. * os_dep.c [USE_MMAP_ANON && MAP_ANONYMOUS] (OPT_MAP_ANON): Do not use value of MAP_ANONYMOUS if CPPCHECK. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD && !GC_TIME_LIMIT] (GC_TIME_LIMIT): Do not define. * pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_brief_async_signal_safe_sleep): Do not use value of GC_TIME_LIMIT if CPPCHECK. * pthread_support.c [PARALLEL_MARK && GC_MIN_MARKERS] (GC_thr_init): Do not use value of GC_MIN_MARKERS if CPPCHECK. * win32_threads.c [PARALLEL_MARK && GC_MIN_MARKERS] (GC_thr_init): Likewise. * tests/test.c [GC_DEBUG && SAVE_CALL_CHAIN && SAVE_CALL_COUNT] (check_heap_stats): Use NFRAMES instead of SAVE_CALL_COUNT (i.e. do not use value of SAVE_CALL_COUNT).