summaryrefslogtreecommitdiff
path: root/mach_dep.c
Commit message (Collapse)AuthorAgeFilesLines
* Include stdio.h and stdlib.h only from gc_priv.hIvan Maidanski2022-09-261-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | (refactoring) * allchblk.c: Do not include stdio.h directly. * alloc.c: Likewise. * dyn_load.c [(DYNAMIC_LOADING || MSWIN32 || MSWINCE || CYGWIN32) && !PCR]: Likewise. * mach_dep.c [!PLATFORM_MACH_DEP && !SN_TARGET_PSP2]: Likewise. * malloc.c: Likewise. * mallocx.c: Likewise. * mark.c: Likewise. * mark_rts.c: Likewise. * misc.c: Likewise. * new_hblk.c: Likewise. * os_dep.c: Likewise. * reclaim.c: Likewise. * tests/disclaim_bench.c: Likewise. * tests/gctest.c: Likewise. * dbg_mlc.c [KEEP_BACK_PTRS && !LINT2]: Do not include stdlib.h directly. * dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32]: Likewise. * os_dep.c [HAIKU]: Likewise. * pthread_support.c [GC_PTHREADS && !GC_WIN32_THREADS]: Likewise. * tests/disclaim_bench.c: Likewise. * tests/gctest.c [!mips || !SYSTYPE_BSD43]: Likewise. * thread_local_alloc.c: Likewise. * include/private/gc_priv.h: Include stdio.h.
* Adjust naming of Win32/64 and x86/64 words in comments and documentationIvan Maidanski2022-09-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ChangeLog: Replace i386 and X86 to x86; replace x86_64 and amd64 to x64; replace "Win32 pthreads" to pthreads-win32; lower case win32s, x86, x64; replace win32 to Win32; replace "MS Windows" to Windows (in documentation and comments). * NT_MAKEFILE: Likewise. * README.md: Likewise. * configure.ac: Likewise. * cord/tests/de_win.c: Likewise. * doc/README.macros: Likewise. * doc/README.solaris2: Likewise. * doc/README.win32: Likewise. * doc/README.win64: Likewise. * doc/debugging.md: Likewise. * doc/leak.md: Likewise. * doc/overview.md: Likewise. * doc/porting.md: Likewise. * extra/msvc_dbg.c: Likewise. * finalize.c: Likewise. * include/gc/cord.h: Likewise. * include/gc/gc.h: Likewise. * include/private/gc_priv.h: Likewise. * include/private/gcconfig.h: Likewise. * include/private/pthread_stop_world.h: Likewise. * mach_dep.c: Likewise. * mark.c: Likewise. * mark_rts.c: Likewise. * misc.c: Likewise. * os_dep.c: Likewise. * tools/threadlibs.c: Likewise. * win32_threads.c: Likewise. * cord/tests/de.c (WIN32): Remove misleading comment. * misc.c (GC_enable_incremental): Change comment about win32s to TODO item.
* Support 32-bit mode on E2KIvan Maidanski2022-07-251-2/+2
| | | | | | | | | | | Issue #456 (bdwgc). * include/private/gcconfig.h [E2K && !__LP64__] (CPP_WORDSZ): Define to 64 (instead of 32). * include/private/gcconfig.h [E2K && !__LP64__] (ALIGNMENT): Define to 4 (instead of 8). * mach_dep.c [E2K] (GC_get_procedure_stack): Change type of new_sz and stack_ofs local variables from word to unsigned long long.
* Fix EINVAL returned by E2K_READ_PROCEDURE_STACK_EX sub-functionIvan Maidanski2022-07-151-17/+18
| | | | | | | | | | | (fix of commit d3f5bdc3e) * mach_dep.c [E2K] (GC_get_procedure_stack): Remove assertion that buf_sz is multiple of word size (because new_size is passed to the syscall); call E2K_GET_PROCEDURE_STACK_SIZE sub-function of the syscall right before E2K_READ_PROCEDURE_STACK_EX one to check that the procedure stack size has not changed since the previous call of GC_get_procedure_stack(NULL,0); add comment.
* Do not use assembly in GC_get_procedure_stack (E2K)Ivan Maidanski2022-07-141-60/+21
| | | | | | | | | | | | | | | | | | | | | | | | | Issue #411 (bdwgc). Use E2K_GET_PROCEDURE_STACK_SIZE and E2K_READ_PROCEDURE_STACK_EX sub-functions (of access_hw_stacks syscall) instead of the legacy E2K_READ_PROCEDURE_STACK one which required computation of ps_index manually. * mach_dep.c [E2K] (VA_SIZE, E2K_PSHTP_SIZE, VLIW_CMD_BRACES_PREFIX, get_stack_index): Remove macro. * mach_dep.c [E2K] (GC_get_procedure_stack): Initialize new_sz only if buf is null; define stack_ofs local variable instead of ps; add assertion that buf_sz (and new_sz) is multiple of word size; use E2K_GET_PROCEDURE_STACK_SIZE sub-function instead of E2K_READ_PROCEDURE_STACK to get H/W procedure stack size; do not use get_stack_index(); use E2K_READ_PROCEDURE_STACK_EX sub-function (with stack_ofs=0) instead of E2K_READ_PROCEDURE_STACK to read H/W procedure stack from the given stack_ofs; print buf_sz (in addition to errno) in case of error and not EAGAIN. * mach_dep.c [E2K && LOG_E2K_ALLOCS] (GC_get_procedure_stack): Remove code. * mach_dep.c [E2K && THREADS] (GC_alloc_and_get_procedure_stack): Add TODO item.
* Update copyright information in alloc.c and other modified files (2022)Ivan Maidanski2022-05-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * CMakeLists.txt: Update year in copyright comment (2021 to 2022). * alloc.c: Likewise. * configure.ac: Likewise. * dyn_load.c: Likewise. * include/private/gc_priv.h: Likewise. * include/private/gcconfig.h: Likewise. * mallocx.c: Likewise. * mark.c: Likewise. * mark_rts.c: Likewise. * misc.c: Likewise. * os_dep.c: Likewise. * pthread_support.c: Likewise. * reclaim.c: Likewise. * tests/gctest.c: Likewise. * win32_threads.c: Likewise. * LICENSE: Update year (2021 to 2022). * allchblk.c: Add copyright line in header comment. * darwin_stop_world.c: Likewise. * dbg_mlc.c: Likewise. * gcj_mlc.c: Likewise. * headers.c: Likewise. * include/gc/gc_inline.h: Likewise. * include/gc/gc_mark.h: Likewise. * include/private/gc_locks.h: Likewise. * include/private/gc_pmark.h: Likewise. * include/private/pthread_stop_world.h: Likewise. * include/private/pthread_support.h: Likewise. * mach_dep.c: Likewise. * malloc.c: Likewise. * thread_local_alloc.c: Likewise. * typd_mlc.c: Likewise. * finalize.c: Update year in copyright comment (2020 to 2022). * include/gc/gc.h: Likewise. * pthread_stop_world.c: Likewise.
* Remove extra space after comma in license termsIvan Maidanski2022-05-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (reformatting) * CMakeLists.txt: Remove an extra space after comma in license header comment. * Makefile.am: Likewise. * allchblk.c: Likewise. * alloc.c: Likewise. * backgraph.c: Likewise. * blacklst.c: Likewise. * checksums.c: Likewise. * configure.ac: Likewise. * cord/cordbscs.c: Likewise. * cord/cordprnt.c: Likewise. * cord/cordxtra.c: Likewise. * cord/tests/cordtest.c: Likewise. * cord/tests/de.c: Likewise. * cord/tests/de_cmds.h: Likewise. * cord/tests/de_win.c: Likewise. * cord/tests/de_win.h: Likewise. * cord/tests/de_win.rc: Likewise. * darwin_stop_world.c: Likewise. * dbg_mlc.c: Likewise. * dyn_load.c: Likewise. * extra/gc.c: Likewise. * extra/msvc_dbg.c: Likewise. * extra/pcr_interface.c: Likewise. * extra/real_malloc.c: Likewise. * finalize.c: Likewise. * fnlz_mlc.c: Likewise. * gc_badalc.cc: Likewise. * gc_cpp.cc: Likewise. * gc_dlopen.c: Likewise. * gcj_mlc.c: Likewise. * headers.c: Likewise. * include/gc/cord.h: Likewise. * include/gc/cord_pos.h: Likewise. * include/gc/ec.h: Likewise. * include/gc/gc.h: Likewise. * include/gc/gc_backptr.h: Likewise. * include/gc/gc_config_macros.h: Likewise. * include/gc/gc_disclaim.h: Likewise. * include/gc/gc_gcj.h: Likewise. * include/gc/gc_inline.h: Likewise. * include/gc/gc_mark.h: Likewise. * include/gc/gc_pthread_redirects.h: Likewise. * include/gc/gc_tiny_fl.h: Likewise. * include/gc/gc_typed.h: Likewise. * include/gc/gc_version.h: Likewise. * include/gc/javaxfc.h: Likewise. * include/gc/leak_detector.h: Likewise. * include/include.am: Likewise. * include/private/darwin_semaphore.h: Likewise. * include/private/darwin_stop_world.h: Likewise. * include/private/dbg_mlc.h: Likewise. * include/private/gc_alloc_ptrs.h: Likewise. * include/private/gc_atomic_ops.h: Likewise. * include/private/gc_hdrs.h: Likewise. * include/private/gc_locks.h: 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: Likewise. * include/private/specific.h: Likewise. * include/private/thread_local_alloc.h: Likewise. * m4/gc_set_version.m4: Likewise. * mach_dep.c: Likewise. * malloc.c: Likewise. * mallocx.c: Likewise. * mark.c: Likewise. * mark_rts.c: Likewise. * misc.c: Likewise. * new_hblk.c: Likewise. * obj_map.c: Likewise. * os_dep.c: Likewise. * pthread_start.c: Likewise. * pthread_stop_world.c: Likewise. * pthread_support.c: Likewise. * ptr_chck.c: Likewise. * reclaim.c: Likewise. * specific.c: Likewise. * tests/atomicops.c: Likewise. * tests/cpp.cc: Likewise. * tests/disclaim.c: Likewise. * tests/disclaim_bench.c: Likewise. * tests/gctest.c: Likewise. * tests/tests.am: Likewise. * tests/weakmap.c: Likewise. * thread_local_alloc.c: Likewise. * tools/setjmp_t.c: Likewise. * tools/threadlibs.c: Likewise. * typd_mlc.c: Likewise. * win32_threads.c: Likewise. * LICENSE: Remove an extra space after comma in license terms.
* Document GC_with_callee_saves_pushed betterIvan Maidanski2022-04-111-0/+2
| | | | | * mach_dep.c (GC_with_callee_saves_pushed): Add comment that it could be called with or without GC lock, or even from a signal handler.
* Use mmap to allocate procedure stack buffers on E2KIvan Maidanski2022-02-041-2/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (fix of commit 990dcdba1) Issue #411 (bdwgc). This commit prevents stack overflow in case of a big procedure stack to be saved. If a procedure stack requires less than 1 memory page for the buffer, then the buffer is still allocated on the local stack. * include/private/gc_priv.h [E2K] (PS_ALLOCA_BUF, ALLOCA_SAFE_LIMIT, FREE_PROCEDURE_STACK_LOCAL): Define macro. * include/private/gc_priv.h [E2K] (PROCEDURE_STACK_ALLOCA_AND_STORE): Rename to GET_PROCEDURE_STACK_LOCAL; update comment; modify implementation to call GC_mmap_procedure_stack_buf (and GC_unmap_procedure_stack_buf) if size > ALLOCA_SAFE_LIMIT. * include/private/gc_priv.h [E2K] (GC_mmap_procedure_stack_buf, GC_unmap_procedure_stack_buf): Declare function. * include/private/gc_priv.h [E2K && THREADS] (GC_alloc_and_get_procedure_stack): Refine comment. * mach_dep.c [E2K]: Include sys/mman.h. * mach_dep.c [E2K] (GC_mmap_procedure_stack_buf, GC_unmap_procedure_stack_buf): Implement. * mark_rts.c [E2K && !THREADS] (GC_push_current_stack): Rename PROCEDURE_STACK_ALLOCA_AND_STORE to GET_PROCEDURE_STACK_LOCAL; call FREE_PROCEDURE_STACK_LOCAL() when bs_lo is not needed. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && E2K] (GC_suspend_handler_inner, GC_push_all_stacks): Likewise.
* Fix recursive malloc during pthread_create (E2K)Ivan Maidanski2022-02-011-26/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (fix of commit 9ddbbae8e) Issue #411 (bdwgc). Use of malloc/free inside an asynchronous signal is not safe and may lead to a crash inside malloc, e.g. if the signal occurs when malloc is called from pthread_create. Also, malloc cannot be used by the code executed during stop-the-world if the collector is built with enabled malloc redirection. This commit replaces malloc/free used to get procedure (register) stack with alloca or GC_INTERNAL_MALLOC (the latter is not used during stop-the-world). This commit also prevents accessing freed procedure stack buffers from GC_push_all_stacks when the world is not stopped. * include/private/gc_priv.h [E2K] (GC_get_procedure_stack): Change the arguments to accept buf and its size; update the comment. * include/private/gc_priv.h [E2K] (PROCEDURE_STACK_ALLOCA_AND_STORE): Define macro. * include/private/gc_priv.h [E2K && THREADS] (GC_alloc_and_get_procedure_stack): New function declaration. * include/private/pthread_support.h [E2K || IA64] (GC_Thread_Rep.backing_store_end): Add comment. * mach_dep.c [E2K] (GC_get_procedure_stack): Change the implementation to according to the updated declaration (do allocate the buffer internally); remove FIXME. * mach_dep.c [E2K && THREADS] (GC_alloc_and_get_procedure_stack): Implement. * mark_rts.c [!THREADS] (GC_push_current_stack): Use PROCEDURE_STACK_ALLOCA_AND_STORE() instead of GC_get_procedure_stack(); do no call free(). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && E2K] (GC_push_all_stacks): Likewise. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && E2K] (GC_store_stack_ptr): Do not declare bs_lo and stack_size local variables; do not call GC_get_procedure_stack(). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && E2K] (GC_suspend_handler_inner): Declare bs_lo and stack_size local variables; call PROCEDURE_STACK_ALLOCA_AND_STORE(); set backing_store_end and backing_store_ptr fields of me (and clear these fields before function return); do not call free(). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && E2K] (GC_push_all_stacks): Define is_stopped local variable; move stack_size local variable declaration to the innermost scope (where it is used); do not call GC_push_all_register_sections() if the procedure stack buffer has been already freed. * pthread_support.c (first_thread): Update comment; move upper to be before GC_push_thread_structures. * pthread_support.c [E2K] (GC_push_thread_structures): Push also first_thread.backing_store_end. * pthread_support.c [E2K] (GC_do_blocking_inner, GC_call_with_gc_active): Do no declare bs_lo local variable; call GC_alloc_and_get_procedure_stack (holding the lock) instead of GC_get_procedure_stack; call GC_INTERNAL_FREE() instead of free(); update comment.
* Revert "Free E2K procedure stack in a single function"Ivan Maidanski2022-01-301-4/+0
| | | | | | This reverts commit 8c2f91a8065d9fb7b238d5c3709bc95dcc727566. There is a simpler solution - the buffer is allocated on stack (mostly).
* Revert "Support malloc redirection on E2K (single-threaded mode only)"Ivan Maidanski2022-01-301-35/+8
| | | | | | This reverts commit 9027a0b429ad3f2f3f0eb77210f22c4a1d21ee4a. There is a simpler solution (which also works for the multi-threaded case) - allocate the buffers on the stack.
* Support malloc redirection on E2K (single-threaded mode only)Ivan Maidanski2022-01-191-8/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #413 (bdwgc). * include/private/gc_priv.h [E2K_USE_SCRATCH] (GC_e2k_ps_buffer, GC_e2k_ps_capacity): Define macro. * include/private/gcconfig.h [E2K && LINUX && REDIRECT_MALLOC && !GC_LINUX_THREADS] (E2K_USE_SCRATCH): Likewise. * include/private/gc_priv.h [E2K_USE_SCRATCH] (_GC_arrays): Add _e2k_ps_buffer and _e2k_ps_capacity fields; add comment. * include/private/gcconfig.h [E2K && LINUX && REDIRECT_MALLOC && GC_LINUX_THREADS && !CPPCHECK]: Issue an error directive. * mach_dep.c [E2K && E2K_USE_SCRATCH] (GC_free_procedure_stack): Do not call free(); assert that buf is non-null but GC_e2k_ps_buffer is null; set GC_e2k_ps_buffer to buf. * mach_dep.c [E2K && E2K_USE_SCRATCH] (GC_get_procedure_stack): Initialize buf local variable to GC_e2k_ps_buffer; initialize buf_sz local variable to GC_e2k_ps_capacity; clear GC_e2k_ps_buffer value; change FIXME item to TODO one; pass buf to GC_scratch_recycle_no_gww() instead of free(); call GC_scratch_alloc() instead of malloc(). * mach_dep.c [E2K && LOG_E2K_ALLOCS] (GC_get_procedure_stack): Call GC_log_printf() to print buf_sz, new_sz and GC_gc_no values if errno is ENOMEM. * mach_dep.c [E2K] (GC_get_procedure_stack): Ensure buf_sz<new_sz (instead of buf_sz!=new_sz) after the loop; return new_sz instead of buf_sz.
* Free E2K procedure stack in a single functionIvan Maidanski2022-01-171-0/+4
| | | | | | | | | | | | | | | | | | | | | (refactoring) Issue #413 (bdwgc). * include/private/gc_priv.h [E2K] (GC_get_procedure_stack): Document that the function mgiht be called from a signal handler. * include/private/gc_priv.h [E2K] (GC_free_procedure_stack): New function prototype. * mach_dep.c [E2K] (GC_free_procedure_stack): Implement (just call free() for now). * mark_rts.c [!THREADS && !IA64 && E2K] (GC_push_current_stack): Call GC_free_procedure_stack() instead of free(). * pthread_stop_world.c [E2K] (GC_suspend_handler_inner): Likewise. * pthread_stop_world.c [E2K] (GC_push_all_stacks): Likewise. * pthread_support.c [E2K] (GC_do_blocking_inner, GC_call_with_gc_active): Likewise. * pthread_stop_world.c [E2K] (GC_push_all_stacks): Move stack_size local variable declaration to the innermost scope of its usage.
* Fix stb asm instruction placement in E2K get_stack_indexIlya Kurdyukov2022-01-131-3/+11
| | | | | | | | | | | | | | | | (fix of commit 9ddbbae8e) Issue #411 (bdwgc). The stb and rbranch instructions in get_stack_index() must be packed into the same VLIW command (because MLOCK must be activated by stb from the same VLIW command; "rbranch X" is short for "ibranch X? %%MLOCK"). * mach_dep.c [E2K] (VLIW_CMD_BRACES_PREFIX): Define macro; undefine it near undef of get_stack_index. * mach_dep.c [E2K] (get_stack_index): Group stb and rbranch into one VLIW command; prefix "{" and "}" with VLIW_CMD_BRACES_PREFIX (to workaround asm code generation issue in clang-9); remove FIXME.
* Simplify get_stack_index implementation for E2KIlya Kurdyukov2022-01-121-42/+24
| | | | | | | | | | | | | | (refactoring) Issue #411 (bdwgc). * mach_dep.c [E2K] (e2k_rwap_lo_fields, e2k_rwap_lo_u, e2k_rwap_hi_fields, e2k_rwap_hi_u): Remove type definition. * mach_dep.c [E2K] (get_stack_index): Change type of psp_lo and psp_hi local variables to word; do not initialize val local variable; simplify asm code; add FIXME about placing stb and rbranch into one VLIW command; extract bits from psp_lo and psp_hi not using structs. * mach_dep.c [E2K] (get_stack_index): Undefine after last usage.
* Define GC_save_regs_ret_val variable only if used (IA64)Ivan Maidanski2022-01-121-4/+3
| | | | | | | | | | (refactoring) * mach_dep.c [IA64] (GC_save_regs_ret_val): Do not define variable if SPARC or THREADS. * mach_dep.c [IA64 || SPARC] (GC_with_callee_saves_pushed): Do not store result of GC_save_regs_in_stack() to GC_save_regs_ret_val if SPARC or THREADS.
* Support Elbrus 2000 (Linux/e2k)Ilya Kurdyukov2022-01-121-2/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (a port of altlinux libgc-e2k.patch (8ed786c)) Issue #411 (bdwgc). * include/gc/gc.h [__GNUC__ && !__INTEL_COMPILER && __e2k__] (GC_reachable_here): Specify "r" contraint for ptr. * include/gc/gc.h [__e2k__] (GC_stack_base): Declare reg_base field. * include/private/gc_priv.h [E2K] (GC_push_all_register_sections, GC_save_regs_in_stack, GC_get_procedure_stack): Declare. * include/private/gc_priv.h [E2K && __ptr64__] (LOAD_TAGGED_VALUE): Define macro. * include/private/gc_priv.h (LOAD_WORD_OR_CONTINUE): Likewise. * include/private/gcconfig.h [LINUX && __e2k__] (E2K, mach_type_known): Likewise. * include/private/gcconfig.h [E2K] (MACH_TYPE, CPP_WORDSZ, ALIGNMENT, HBLKSIZE): Likewise. * include/private/gcconfig.h [E2K && LINUX] (DATASTART): Likewise. * mach_dep.c [E2K] (VA_SIZE, E2K_PSHTP_SIZE, get_stack_index): Likewise. * include/private/gcconfig.h [GC_GNUC_PREREQ(2,8)] (HAVE_BUILTIN_UNWIND_INIT): Do not define if E2K. * include/private/gcconfig.h [E2K && LINUX] (__dso_handle): Declare extern variable. * include/private/pthread_support.h [E2K] (GC_Thread_Rep): Declare backing_store_end and backing_store_ptr fields. * mach_dep.c [E2K]: Include errno.h, sys/syscall.h, asm/e2k_syswork.h. * mach_dep.c [E2K] (e2k_rwap_lo_fields, e2k_rwap_hi_fields): Declare struct. * mach_dep.c [E2K] (e2k_rwap_lo_u, e2k_rwap_hi_u): Declare union. * mach_dep.c [E2K] (GC_get_procedure_stack, GC_save_regs_in_stack): Implement. * mach_dep.c [E2K] (GC_with_callee_saves_pushed): Call GC_save_regs_in_stack() (not saving the result). * mark.c (GC_mark_from, GC_push_all_eager): Use LOAD_WORD_OR_CONTINUE() instead of direct dereference of current_p. * mark.c [!SMALL_CONFIG] (GC_mark_from): Do not prefetch if E2K. * mark_rts.c [E2K] (GC_push_all_register_sections): Implement but ignore traced_stack_sect (add TODO item). * mark_rts.c [!THREADS && E2K] (GC_push_current_stack): Call GC_get_procedure_stack() and GC_push_all_register_sections(). * misc.c [E2K] (GC_call_with_stack_base): Initialize reg_base to 0. * misc.c [!THREADS && E2K] (GC_do_blocking_inner, GC_get_my_stackbottom): Likewise. * os_dep.c [((HAVE_PTHREAD_ATTR_GET_NP || HAVE_PTHREAD_GETATTR_NP) && THREADS || !HAVE_GET_STACK_BASE) && E2K] (GC_get_stack_base): Likewise. * pthread_support.c [E2K] (GC_get_my_stackbottom): Likewise. * pthread_stop_world.c [E2K] (GC_suspend_handler): Call GC_with_callee_saves_pushed(). * pthread_stop_world.c [E2K] (GC_store_stack_ptr): Call GC_save_regs_in_stack() and GC_get_procedure_stack(). * pthread_stop_world.c [E2K] (GC_suspend_handler_inner): Call free(me->backing_store_end) before return. * pthread_stop_world.c [E2K] (GC_push_all_stacks): Declare bs_lo, bs_hi, stack_size local variables; call GC_save_regs_in_stack() and GC_get_procedure_stack() (and free() at the end) for self thread; call GC_push_all_register_sections(). * pthread_support.c [E2K] (GC_do_blocking_inner): Call GC_save_regs_in_stack(); add FIXME.
* Fix capital case of setjmp_test and gctest in README and commentsIvan Maidanski2021-10-181-1/+1
| | | | | | | | | | | | | * Makefile.direct (HOSTCFLAGS): Start setjmp_test word with lower case in comment. * README.md (Installation and Portability): Likewise. * mach_dep.c (GC_with_callee_saves_pushed): Likewise. * tools/setjmp_t.c (main): Likewise. * Makefile.direct (setjmp_test): Start gctest word with lower case in comment. * OS2_MAKEFILE (CFLAGS): Likewise. * README.md (Installation and Portability): Likewise. * SMakefile.amiga (finalize.o): Likewise.
* Change EMSCRIPTEN macro for internal use to no-underscore formatIvan Maidanski2021-08-301-1/+1
| | | | | | | | | | | | | | (refactoring) * include/private/gcconfig.h [__EMSCRIPTEN__] (EMSCRIPTEN): New macro. * include/private/gcconfig.h [I386]: Check EMSCRIPTEN macro instead of __EMSCRIPTEN__. * mach_dep.c [!HAVE_PUSH_REGS] (GC_with_callee_saves_pushed): Likewise. * os_dep.c [!ECOS && !NOSYS && !SYMBIAN]: Likewise. * os_dep.c [USE_MUNMAP && !USE_WINALLOC && !SN_TARGET_PS3 && !AIX && !CYGWIN32 && !HAIKU && !HPUX] (GC_unmap): Likewise. * os_dep.c [!THREADS]: Likewise. * tests/test.c (reverse_test_inner): Likewise.
* Replace SN_TARGET_ORBIS to PLATFORM_* and GC_NO_* macrosTim Cannell2021-07-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* Emscripten single-threaded support (detect stack base, push registers)Nguyen Thai Ngoc Duy2021-06-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #354 (bdwgc). This adds a bit more in os_dep.c in order to scan the stack and registers, which is possible if we enable ASYNCIFY (note, this adds quite some overhead). gctest almost passes with this, except for the test code that involves a_get(). * configure.ac (emscripten): Define (based __EMSCRIPTEN__ macro presence). * configure.ac [emscripten] (gc_cflags): Append ASYNCIFY[_STACK_SIZE] (to set stack size to 128 KB). * configure.ac [emscripten] (EMSCRIPTEN): Define AM variable. * configure.ac [emscripten] (THREADS): Set to "no" by default. * doc/README.emscripten: New file. * include/private/gcconfig.h [I386 && __EMSCRIPTEN__] (STACK_NOT_SCANNED): Remove it, along with the comment. * include/private/gcconfig.h [I386 && __EMSCRIPTEN__] (USE_MMAP_ANON, STACK_GROWS_DOWN): Define macro. * mach_dep.c [!SN_TARGET_ORBIS && !SN_TARGET_PSP2 && !HAVE_PUSH_REGS && __EMSCRIPTEN__] (GC_with_callee_saves_pushed): Do nothing before fn call. * os_dep.c [__EMSCRIPTEN__]: Include emscripten.h. * os_dep.c [__EMSCRIPTEN__] (emscripten_stack_base): New static variable. * os_dep.c [__EMSCRIPTEN__] (scan_stack_cb): New static function. * os_dep.c [!THREADS && __EMSCRIPTEN__] (scan_regs_cb): Likewise. * os_dep.c [__EMSCRIPTEN__] (GC_get_main_stack_base): Implement. * os_dep.c [!THREADS && __EMSCRIPTEN__] (GC_default_push_other_roots): Likewise. * os_dep.c [__EMSCRIPTEN__] (GET_MAIN_STACKBASE_SPECIAL): Define macro. * os_dep.c [USE_MUNMAP && !USE_WINALLOC && !SN_TARGET_PS3 && __EMSCRIPTEN__]: Do not call mmap or mprotect. * tests/test.c [__EMSCRIPTEN__] (reverse_test_inner): Do not call check_ints(a_get(),1,49); add FIXME. * tests/tests.am [EMSCRIPTEN] (check_PROGRAMS): Add gctest.html. * tests/tests.am [EMSCRIPTEN] (gctest_html_SOURCES, gctest_html_LDADD, gctest_html_LDFLAGS): Define variable.
* Workaround 'local address assignment to a global variable' CSA warningIvan Maidanski2018-11-131-1/+1
| | | | | | | | | | | | | | | * 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.
* Eliminate 'uninitialized var' cppcheck false positive in mach_dep, os_depIvan Maidanski2018-11-091-3/+3
| | | | | | | | * mach_dep.c (GC_with_callee_saves_pushed): Change type of "context" local variable from void* volatile to volatile ptr_t. * os_dep.c [(SVR4 || AIX || DGUX || (LINUX && SPARC)) && !PCR] (GC_SysVGetDataStart): Change type of "result" local variable from char* volatile to volatile ptr_t.
* Enable compilation without C runtime (Win32)Michael DeRoy2018-10-291-0/+3
| | | | | | | | | | | | | | | | | (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.
* 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.
* Fix syntax of conditional operator in with_callee_saves_pushedIvan Maidanski2018-04-261-1/+1
| | | | | | | | | | (fix of commit b594132) Issue #133 (bdwgc). * mach_dep.c [!HAVE_PUSH_REGS && UNIX_LIKE && !NO_GETCONTEXT] (GC_with_callee_saves_pushed): Fix syntax of ?: operator (add missing '?' symbol).
* Avoid multiple 'getcontext failed' warnings if getcontext is brokenIvan Maidanski2018-04-261-6/+12
| | | | | | | | | | | | | | | | 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.
* Eliminate C++ warnings about deprecated register keyword (GC source)Jay Krell2018-02-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-2/+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-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* Place no_sanitize attributes in a GCC-compliant wayIvan Maidanski2017-11-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove lint-specific codeIvan Maidanski2017-03-221-10/+0
| | | | | | | | | | | | | | | Note: cppcheck and CSA replace lint tool. * Makefile.direct (lint): Remove. * dyn_load.c [SOLARISDL && !USE_PROC_FOR_LIBRARIES && LINT] (_DYNAMIC): Remove. * dyn_load.c [IRIX5 || (USE_PROC_FOR_LIBRARIES && !LINUX)] (GC_register_dynamic_libraries): Remove comment about a false warning reported by lint. * mach_dep.c [ASM_CLEAR_CODE && LINT] (GC_clear_stack_inner): Remove. * tests/test.c (typed_test): Call GC_make_descriptor unconditionally. * tests/test.c (run_one_test): Set y to fail_proc1 unconditionally. * tests/test.c (main): Do not check whether LINT is defined.
* Fix 'context local variable might be clobbered by setjmp' compiler warningIvan Maidanski2016-12-061-1/+1
| | | | | * mach_dep.c (GC_with_callee_saves_pushed): Mark "context" local variable as volatile (to prevent it from potential clobbering).
* Support AddressSanitizer and MemorySanitizer (clang)Ivan Maidanski2016-11-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | * include/private/gc_priv.h (GC_ATTR_NO_SANITIZE_ADDR, GC_ATTR_NO_SANITIZE_MEMORY): New macro. * include/private/gcconfig.h [__has_feature(address_sanitizer)] (ADDRESS_SANITIZER): New macro. * include/private/gcconfig.h [__has_feature(memory_sanitizer)] (MEMORY_SANITIZER): Likewise. * mach_dep.c (GC_with_callee_saves_pushed): Use GC_ATTR_NO_SANITIZE_ADDR attribute. * mark.c (GC_mark_from, GC_push_all_eager): Likewise. * mark.c (GC_mark_from, GC_push_all_eager): Use GC_ATTR_NO_SANITIZE_MEMORY attribute. * os_dep.c [ADDRESS_SANITIZER && (UNIX_LIKE || NEED_FIND_LIMIT || MPROTECT_VDB)] (__asan_default_options): New function. * os_dep.c [(NEED_FIND_LIMIT || UNIX_LIKE) && CPPCHECK && ADDRESS_SANITIZER] (GC_set_and_save_fault_handler): Reference __asan_default_options. * os_dep.c [MPROTECT_VDB && !DARWIN && CPPCHECK && ADDRESS_SANITIZER] (GC_dirty_init): Likewise. * tests/test.c [MEMORY_SANITIZER] (check_heap_stats): Increase max_heap_sz by 25% (to avoid "Unexpected heap growth" error if MSan is used). * tests/test_cpp.cc [ADDRESS_SANITIZER || MEMORY_SANITIZER] (main): Call GC_FREE(a) instead of delete a; add comment.
* Workaround 'Uninitialized variable' cppcheck errorsIvan Maidanski2016-10-181-2/+5
| | | | | | | | | | | | | * extra/AmigaOS.c [GC_AMIGA_DS] (GC_register_data_segments): Initialize myseglist outside conditional statement. * mach_dep.c [GETCONTEXT_FPU_EXCMASK_BUG && X86_64] (GC_with_callee_saves_pushed): Call GC_noop1(&old_fcw) (before asm fstcw) if CPPCHECK. * mach_dep.c [!HAVE_BUILTIN_UNWIND_INIT] (GC_with_callee_saves_pushed): Replace regs with &regs. * os_dep.c [!MSWIN32 && !GC_OPENBSD_THREADS && ...] (GC_get_main_stack_base): Set result to NULL if CPPCHECK but none of HEURISTIC* and *STACKBOTTOM defined.
* Workaround 'unused variable' cppcheck style warningsIvan Maidanski2016-10-171-3/+7
| | | | | | | | * include/private/gc_locks.h [PCR && THREADS] (DCL_LOCK_STATE): Define to empty if CPPCHECK. * mach_dep.c [MACOS && __MWERKS__ && POWERPC] (getRegisters): Declare as external of CPPCHECK (as cppcheck does not recognize "asm" in function declaration).
* Fix 'syntax error' reported by cppcheck for mach_depIvan Maidanski2016-10-121-1/+1
| | | | | | | The error is reported at line containing "asm". * mach_dep.c [MACOS && M68K && THINK_C] (GC_push_regs): Do not define if CPPCHECK.
* Workaround missing getcontext() in Docker osrf/ubuntu_32bitIvan Maidanski2016-08-111-29/+40
| | | | | | | | * mach_dep.c [NO_GETCONTEXT] (GC_with_callee_saves_pushed): Call WARN instead of ABORT if getcontext() failed; do not set context variable if getcontext() failed; fallback to other register retrieval methods (__builtin_unwind_init or setjmp) if context variable is NULL. * mach_dep.c (GC_with_callee_saves_pushed): Reformat code.
* Fix 'arg parameter might be clobbered by setjmp' compiler warningIvan Maidanski2016-07-011-1/+1
| | | | | * mach_dep.c (GC_with_callee_saves_pushed): Make "arg" parameter volatile (to prevent it from potential clobbering).
* Code refactoring of Emscripten platform support (single-threaded)Ivan Maidanski2014-07-131-6/+8
| | | | | | | | | | | | | | | | | | * alloc.c (min_bytes_allocd): Test STACK_NOT_SCANNED macro instead of __EMSCRIPTEN__ (stack size to scan is zero if STACK_NOT_SCANNED). * include/private/gcconfig.h (ALIGNMENT): Remove duplicate definition for _EMSCRIPTEN__. * include/private/gcconfig.h (STACK_NOT_SCANNED): New macro defined for __EMSCRIPTEN__ target (in addition to OS_TYPE, CPP_WORDSZ, ALIGNMENT, DATASTART, DATAEND). * mach_dep.c (GC_push_regs): Test STACK_NOT_SCANNED macro instead of __EMSCRIPTEN__ (push nothing if STACK_NOT_SCANNED). * mark_rts.c (GC_push_roots): Test STACK_NOT_SCANNED macro instead of __EMSCRIPTEN__ (do not call GC_push_regs_and_stack if STACK_NOT_SCANNED); mark cold_gc_frame argument as potentially unused. * misc.c (GC_clear_stack): Test STACK_NOT_SCANNED macro instead of __EMSCRIPTEN__ (do not clear stack if STACK_NOT_SCANNED). * misc.c (GC_clear_stack): Reformat code.
* Add support for emscripten platformJonathan Chambers2014-07-031-0/+5
|
* Fix typos in commentsOndrej Bilka2013-07-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * blacklst.c: Fix typo ("even though"). * cord/cordbscs.c: Fix typo ("exponentially"). * cord/cordxtra.c: Fix typo ("represented"). * dyn_load.c: Fix typos ("uncollectible", "occurred"). * extra/AmigaOS: Fix typos ("specific", "necessary", "always", "effectiveness"). * finalize.c: Fix typo ("descendants"). * include/cord.h: Fix typo ("idiosyncrasies"). * include/gc.h: Fix typo ("collectible"). * include/gc_allocator.h: Fix typos ("allocator", "[un]collectible"). * mach_dep.c: Fix typo ("erroneously"). * malloc.c: Fix typos ("[un]collectible", "pointer-free", "initialization"). * mallocx.c: Fix typos ("largely", "pointer-free", "uncollectible"). * mark.c: Fix typos ("[un]collectible", "even though"). * misc.c: Fix typo ("erroneously"). * os_dep.c: Fix typos ("non-addressable", "happening", "pointer-free"). * tests/test.c: Fix typos ("uncollectible", "reversed"). * tests/test_cpp.cc: Fix typos ("[un]collectible"). * typd_mlc.c: Fix typo ("copyright"). * win32_threads.c: Fix typos ("optimization", "uncollectible").
* Move 'include setjmp.h' from mach_dep.c to gc_priv.hIvan Maidanski2012-09-291-1/+0
| | | | | | * include/private/gc_priv.h: Include setjmp.h unconditionally (since SETJMP/LONGJMP is always defined). * mach_dep.c: Remove redundant include setjmp.h.
* Fix a typo in comment of GC_with_callee_saves_pushedIvan Maidanski2012-09-291-1/+1
| | | | * mach_dep.c (GC_with_callee_saves_pushed): Fix a typo in comment.
* Do not define _setjmp/_longjmp macros in mach_dep.c (code refactoring)Ivan Maidanski2012-09-291-5/+1
| | | | | | | * mach_dep.c (_setjmp, _longjmp): Remove unused macro definition (if OS2, or CX_UX or __CC_ARM). * mach_dep.c (GC_with_callee_saves_pushed): Use setjmp instead of _setjmp also for OS2, CX_UX and __CC_ARM.
* Fix all address-of-dummy operations by adding volatileIvan Maidanski2012-08-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * alloc.c (min_bytes_allocd, GC_stopped_mark): Use volatile for 'dummy' local variable (used to get 'sp' value) to prevent any harmful optimizations (e.g., some Mac OS X clang releases might turn a conditional expression that uses 'dummy' address into a constant). * dyn_load.c (GC_cond_add_roots): Likewise. * mach_dep.c (GC_with_callee_saves_pushed): Likewise. * misc.c (GC_clear_stack_inner, GC_init, GC_call_with_stack_base): Likewise. * os_dep.c (GC_get_stack_base, GC_get_main_stack_base, async_set_pht_entry_from_index): Likewise. * pthread_stop_world.c (nacl_pre_syscall_hook, __nacl_suspend_thread_if_needed): Likewise. * pthread_support.c (GC_thr_init): Likewise. * ptr_chck.c (GC_on_stack): Likewise. * tools/setjmp_t.c (main): Likewise. * win32_threads.c (GC_push_stack_for): Likewise. * dyn_load.c (dummy): Change variable type from char to int. * include/private/gcconfig.h: Update comment about GC_stackbottom initialization. * os_dep.c (GC_get_stack_base): Remove 'sp' local variable. * os_dep.c (GC_get_main_stack_base): Define and use volatile 'dummy' variable (instead of 'result') to get 'sp' value (revert part of commit bddc75f). * os_dep.c (GC_get_stack_base): Add missing cast of 'dummy' address (only if NEED_FIND_LIMIT). * pthread_stop_world.c (GC_suspend_handler_inner): Define and use volatile 'dummy' variable (instead of 'me') to get 'sp' value (revert part of commit 31fc0f6). * pthread_stop_world.c (nacl_pre_syscall_hook, __nacl_suspend_thread_if_needed): Rename 'local_dummy' to 'dummy' local variable.
* Minor code refactoring regarding HAVE_BUILTIN_UNWIND_INITIvan Maidanski2012-04-171-5/+1
| | | | | | | | * include/private/gcconfig.h (HAVE_BUILTIN_UNWIND_INIT): Do not define for Darwin/ppc and RTEMS. * mach_dep.c (GC_with_callee_saves_pushed): Remove target-specific checks for Darwin/ppc and RTEMS as HAVE_BUILTIN_UNWIND_INIT is not defined in that case.
* Replace pointer relational comparisons with non-pointer onesIvan Maidanski2012-03-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * allchblk.c (GC_dump_regions, GC_allochblk_nth): Cast pointers to word type in relational (less-greater) comparisons. * alloc.c (GC_add_to_heap, GC_print_heap_sects, GC_expand_hp_inner): Likewise. * backgraph.c (ensure_struct, add_back_edges): Likewise. * blacklst.c (GC_number_stack_black_listed): Likewise. * checksums.c (GC_checksum, GC_check_dirty): Likewise. * darwin_stop_world.c (GC_push_all_stacks): Likewise. * dbg_mlc.c (GC_get_back_ptr_info, GC_print_smashed_obj, GC_check_heap_block): Likewise. * dyn_load.c (sort_heap_sects, GC_register_map_entries, GC_register_dynlib_callback, GC_register_dynamic_libraries_dl_iterate_phdr, GC_register_dynamic_libraries, GC_cond_add_roots): Likewise. * finalize.c (GC_ignore_self_finalize_mark_proc): Likewise. * headers.c (GC_scratch_alloc, GC_install_counts, GC_remove_counts): Likewise. * include/private/gc_pmark.h (PUSH_OBJ, PUsH_CONTENTS_HDR, GC_PUSH_ONE_STACK, GC_PUSH_ONE_HEAP, GC_mark_stack_empty): Likewise. * include/private/gc_priv.h (MAKE_COOLER, COOLER_THAN): Likewise. * mach_dep.c (GC_with_callee_saves_pushed): Likewise. * malloc.c (calloc, free): Likewise. * mark.c (GC_mark_some_inner, GC_mark_from, GC_steal_mark_stack, GC_return_mark_stack, GC_do_local_mark, GC_mark_local, GC_push_all, GC_push_selected, GC_push_all_eager, GC_push_marked1, GC_push_marked2, GC_push_marked4, GC_push_marked, GC_push_unconditionally): Likewise. * mark_rts.c (GC_is_static_root, GC_add_roots_inner, GC_remove_roots_inner, GC_is_tmp_root, GC_exclude_static_roots_inner, GC_push_conditional_with_exclusions, GC_push_all_register_sections, GC_push_all_stack_sections, GC_push_all_stack_partially_eager, GC_push_all_stack_part_eager_sections, GC_push_current_stack): Likewise. * misc.c (GC_clear_stack_inner, GC_clear_stack, GC_base, GC_call_with_gc_active): Likewise. * new_hblk.c (GC_build_fl_clear2, GC_build_fl_clear4, GC_build_fl2, GC_build_fl4, GC_build_fl): Likewise. * os_dep.c (GC_enclosing_mapping, GC_text_mapping, tiny_sbrk, GC_find_limit_openbsd, GC_skip_hole_openbsd, GC_find_limit_with_bound, GC_get_main_stack_base, GC_get_stack_base, GC_least_described_address, GC_register_root_section, GC_register_data_segments, GC_unmap_start, GC_gww_read_dirty, GC_remove_protection, GC_protect_heap, GC_unprotect_range, GC_read_dirty, GC_page_was_dirty, GC_save_callers, GC_print_callers): Likewise. * pcr_interface.c (GC_enumerate_block): Likewise. * pthread_support.c (GC_is_thread_tsd_valid, GC_segment_is_thread_stack, GC_greatest_stack_base_below, GC_call_with_gc_active): Likewise. * ptr_chck.c (GC_same_obj, GC_is_valid_displacement, GC_on_stack, GC_is_visible): Likewise. * reclaim.c (GC_reclaim_clear, GC_reclaim_uninit, GC_disclaim_and_reclaim, GC_reclaim_check, GC_start_reclaim): Likewise. * tests/test.c (cons): Likewise. * tools/setjmp_t.c (main): Likewise. * typd_mlc.c (GC_typed_mark_proc): Likewise. * win32_threads.c (GC_is_thread_tsd_valid, GC_call_with_gc_active, GC_push_stack_for, GC_get_next_stack): Likewise. * extra/msvc_dbg.c (GetDescriptionFromAddress, GetDescriptionFromStack): Cast pointers to GC_ULONG_PTR in relational comparisons. * include/gc.h (GC_DATASTART, GC_DATAEND): Cast pointers to GC_word in relational comparisons. * misc.c (GC_init): Remove static assertion on ((ptr_t)-1 > 0) since no longer required; add the comment. * pcr_interface.c: Expand tabs to spaces.
* Integrate ancient 'pcbeard' GC port for MacOS 9 ClassicPatrick C. Beard2012-01-231-7/+34
| | | | | | | * include/private/gc_priv.h (bcopy, bzero, BCOPY_EXISTS): Add definition for ancient MacOS/ppc. * mach_dep.c (PushMacRegisters): Add implementation for MacOS/ppc. * mach_dep.c (GC_push_regs): Fix to work on MacOS/ppc.