summaryrefslogtreecommitdiff
path: root/libguile/threads.h
Commit message (Expand)AuthorAgeFilesLines
* Fix support for threads already known to GC...* libguile/threads.h (scm_i_thread): Add bool tracking whether the thread needs to be unregistered from libgc. * libguile/threads.c (guilify_self_1): Add needs_unregister arg. (on_thread_exit): Only unregister thread if the thread needs it. (scm_i_init_thread_for_guile): A thread needs unregistering if GC_register_my_thread succeeded. (scm_threads_prehistory): Don't unregister initial thread. Fixes #19523. Thanks to Anthonin Bonnefoy for the report. Andy Wingo2017-02-281-0/+3
* Remove thread-specific admin mutex...* libguile/threads.c (guilify_self_1): * libguile/threads.h (scm_i_thread): Remove unused thread "admin mutex". Andy Wingo2017-01-081-2/+0
* Reimplement dynamic states...There are two goals: one, to use less memory per dynamic state in order to allow millions of dynamic states to be allocated in light-weight threading scenarios. The second goal is to prevent dynamic states from being actively mutated in two threads at once. This second goal does mean that dynamic states object that escape into scheme are now copies that won't receive further updates; an incompatible change, but one which we hope doesn't affect anyone. * libguile/cache-internal.h: New file. * libguile/fluids.c (is_dynamic_state, get_dynamic_state) (save_dynamic_state, restore_dynamic_state, add_entry) (copy_value_table): New functions. (scm_i_fluid_print, scm_i_dynamic_state_print): Move up. (new_fluid): No need for a number. (scm_fluid_p: scm_is_fluid): Inline IS_FLUID uses. (fluid_set_x, fluid_ref): Adapt to dynamic state changes. (scm_fluid_set_x, scm_fluid_unset_x): Call fluid_set_x. (scm_swap_fluid): Rewrite in terms of fluid_ref and fluid_set. (swap_fluid): Use internal fluid_set_x. (scm_i_make_initial_dynamic_state): Adapt to dynamic state representation change. (scm_dynamic_state_p, scm_is_dynamic_state): Use new accessors. (scm_current_dynamic_state): Use make_dynamic_state. (scm_dynwind_current_dynamic_state): Use new accessor. * libguile/fluids.h: Remove internal definitions. Add new struct definition. * libguile/threads.h (scm_i_thread): Use scm_t_dynamic_state for dynamic state. * libguile/threads.c (guilify_self_1, guilify_self_2): (scm_i_init_thread_for_guile, scm_init_guile): (scm_call_with_new_thread): (scm_init_threads, scm_init_threads_default_dynamic_state): Adapt to scm_i_thread change. (scm_i_with_guile, with_guile): Remove "and parent" suffix. (scm_i_reset_fluid): Remove unneeded function. * doc/ref/api-scheduling.texi (Fluids and Dynamic States): Remove scm_make_dynamic_state docs. Update current-dynamic-state docs. * libguile/vm-engine.c (vm_engine): Update fluid-ref and fluid-set! inlined fast paths for dynamic state changes. * libguile/vm.c (vm_error_unbound_fluid): Remove now-unused function. * NEWS: Update. * module/ice-9/deprecated.scm (make-dynamic-state): New definition. * libguile/deprecated.h: * libguile/deprecated.c (scm_make_dynamic_state): Move here. * libguile/__scm.h (scm_t_dynamic_state): New typedef. * libguile/dynstack.h: * libguile/dynstack.c (scm_dynstack_push_fluid): (scm_dynstack_unwind_fluid): Take raw dynstate in these internal functions. * libguile/throw.c (catch): Adapt to dynstack changes. Andy Wingo2016-12-051-2/+1
* Deprecate dynamic roots...* libguile/root.h: * libguile/root.c: Remove these files. * libguile/deprecated.h: * libguile/deprecated.c (scm_internal_cwdr, scm_call_with_dynamic_root) (scm_dynamic_root, scm_apply_with_dynamic_root): Deprecate. Remove all root.h usage, which was vestigial. * module/ice-9/serialize.scm: Use (current-thread) instead of (dynamic-root). Andy Wingo2016-11-211-1/+0
* join-thread in Scheme...* module/ice-9/threads.scm (join-thread): Implement in Scheme. (call-with-new-thread): Arrange to record values in a weak table and signal the join cond. (with-mutex): Move up definition; call-with-new-thread needs it. (How was this working before?) * libguile/threads.c (guilify_self_1, guilify_self_2, do_thread_exit): Remove join queue management. * libguile/threads.c (scm_join_thread, scm_join_thread_timed): Call out to Scheme. (scm_init_ice_9_threads): Capture join-thread var. Andy Wingo2016-11-141-2/+0
* Refactor GC implications of thread sleep...* libguile/async.c (struct scm_thread_wake_data): Move definition here. (scm_i_setup_sleep): Remove "sleep_object". Caller now responsible for scm_remember_upto_here_1 as appropriate. (scm_system_async_mark_for_thread): Remove scm_remember_upto_here_1 call. * libguile/async.h (scm_i_setup_sleep): Adapt prototype. * libguile/threads.h (struct scm_thread_wake_data): Remove definition. * libguile/threads.c (block_self): Remove sleep_object argument. (scm_join_thread_timed, scm_timed_lock_mutex) (scm_timed_wait_condition_variable, scm_std_select): Adapt. Andy Wingo2016-11-131-6/+1
* scm_timed_lock_mutex replaces scm_lock_mutex_timed...* libguile/deprecated.h: * libguile/deprecated.c (scm_lock_mutex_timed): Deprecate. * libguile/threads.h: * libguile/threads.c (scm_timed_lock_mutex): New function. (scm_join_thread): Fix formatting. (scm_lock_mutex): Fix formatting and update to scm_timed_lock_mutex change. (scm_try_mutex): Update to scm_timed_lock_mutex. Andy Wingo2016-11-051-1/+1
* Back to simple unlock-mutex...* libguile/threads.c (scm_unlock_mutex): Bind to unlock-mutex. * libguile/threads.h: Remove scm_unlock_mutex_timed. * libguile/deprecated.h: Add scm_unlock_mutex_timed. * libguile/deprecated.c (scm_unlock_mutex_timed): Deprecate. * test-suite/tests/threads.test: Update unlock-mutex tests to use wait-condition-variable if they would wait on a cond. Andy Wingo2016-11-051-1/+0
* Replace scm_make_mutex_with_flags...* libguile/threads.c (enum fat_mutex_kind): New data type, replacing separate flags. (struct fat_mutex): Adapt. (make_fat_mutex): Fat mutexes can only be one of three kinds, not one of 4 kinds. (Recursive unowned mutexes are not a thing.) (scm_make_mutex): Adapt. (scm_make_mutex_with_kind): New function, replacing scm_make_mutex_with_flags. Still bound to make-mutex. (scm_make_recursive_mutex): Adapt. (fat_mutex_lock, fat_mutex_unlock): Adapt. * libguile/threads.h (scm_make_mutex_with_kind): New decl. * libguile/deprecated.h: * libguile/deprecated.c (scm_make_mutex_with_flags): Deprecate. Andy Wingo2016-11-051-1/+1
* Remove thread held pthread_mutex field...* libguile/threads.h (scm_i_thread): * libguile/threads.c (guilify_self_1, on_thread_exit) (scm_pthread_cond_wait, scm_pthread_cond_timedwait): The thread-local held_mutex field is no longer needed, now that we cancel threads via interrupts instead of pthread_cancel. Andy Wingo2016-11-051-1/+0
* Remove thread-local weak mutex set...* libguile/threads.h (scm_i_thread): * libguile/threads.c (guilify_self_1, do_thread_exit, fat_mutex_lock): Remove thread-local weak mutex set. Andy Wingo2016-11-051-1/+0
* Deprecate critical sections...* NEWS: Deprecate critical sections. * doc/ref/api-scheduling.texi (Critical Sections): Remove. * libguile/async.c: * libguile/async.h: * libguile/deprecated.c: * libguile/deprecated.h: * libguile/threads.c: * libguile/threads.h: Deprecate critical section API. Andy Wingo2016-11-011-2/+0
* Threads no longer track critical section level...* libguile/threads.h (scm_i_thread): * libguile/threads.c (guilify_self_1): Remove critical_section_level member of scm_i_thread. * libguile/async.c (scm_critical_section_end) (scm_critical_section_start): Remove bookkeeping. Andy Wingo2016-11-011-4/+0
* Remove thread cleanup facility...* NEWS: Add entry. * doc/ref/api-scheduling.texi (Threads): Remove thread-cleanup docs. * libguile/threads.c (guilify_self_1, do_thread_exit): (scm_set_thread_cleanup_x, scm_thread_cleanup): Remove these. * libguile/threads.h (scm_i_thread): Remove cleanup_handler. * module/ice-9/threads.scm: * module/ice-9/deprecated.scm (thread-cleanup, set-thread-cleanup!): Remove. * test-suite/tests/threads.test: Adapt to test cancel-thread return values and not test thread-cleanup procs. Andy Wingo2016-10-311-3/+0
* cancel-thread via asyncs, not pthread_cancel...* module/ice-9/threads.scm (cancel-tag): New variable. (cancel-thread): New Scheme function. (call-with-new-thread): Install a prompt around the thread. * libguile/threads.h (scm_i_thread): Remove cancelled member. * libguile/threads.c (scm_cancel_thread): Call out to Scheme. Always available, and works on the current thread too. (scm_set_thread_cleanup_x, scm_thread_cleanup): Adapt. (scm_init_ice_9_threads): Capture cancel-thread var. * doc/ref/api-scheduling.texi (Threads): Update. * NEWS: Update. Andy Wingo2016-10-271-1/+0
* Use atomics for async interrupts...* libguile/__scm.h (SCM_TICK): Always define as scm_async_tick(). * libguile/error.c (scm_syserror, scm_syserror_msg): * libguile/fports.c (fport_read, fport_write): * libguile/_scm.h (SCM_SYSCALL): Replace SCM_ASYNC_TICK with scm_async_tick (). (SCM_ASYNC_TICK, SCM_ASYNC_TICK_WITH_CODE) (SCM_ASYNC_TICK_WITH_GUARD_CODE): Remove internal definitions. We inline into vm-engine.c, the only place where it matters. * libguile/async.h: * libguile/async.c (scm_async_tick, scm_i_setup_sleep): (scm_i_reset_sleep, scm_system_async_mark_for_thread): * libguile/threads.h (struct scm_thread_wake_data): * libguile/threads.h (scm_i_thread): * libguile/threads.c (block_self, guilify_self_1, scm_std_select): Rewrite to use sequentially-consistent atomic references. * libguile/atomics-internal.h (scm_atomic_set_pointer): (scm_atomic_ref_pointer): New definitions. * libguile/finalizers.c (queue_finalizer_async): We can allocate, so just use scm_system_async_mark_for_thread instead of the set-cdr! shenanigans. * libguile/scmsigs.c (take_signal): * libguile/gc.c (queue_after_gc_hook): Adapt to new asyncs mechanism. Can't allocate but we're just manipulating the current thread when no other threads are running so we should be good. * libguile/vm-engine.c (VM_HANDLE_INTERRUPTS): Inline the async_tick business. Andy Wingo2016-10-261-7/+11
* Move thread bindings to (ice-9 threads)...* libguile/init.c (scm_i_init_guile): Don't call scm_init_thread_procs. * libguile/threads.c (scm_init_ice_9_threads): Rename from scm_init_thread_procs, make static. (scm_init_threads): Register scm_init_thread_procs extension. * libguile/threads.h (scm_init_thread_procs): Remove decl. * module/ice-9/boot-9.scm: Load (ice-9 threads), so that related side effects occur early. * module/ice-9/deprecated.scm (define-deprecated): Fix to allow deprecated bindings to appear in operator position. Export deprecated bindings. (define-deprecated/threads, define-deprecated/threads*): Trampoline thread bindings to (ice-9 threads). * module/ice-9/futures.scm: Use ice-9 threads. * module/ice-9/threads.scm: Load scm_init_ice_9_threads extension. Reorder definitions and imports so that the module circularity with (ice-9 futures) continues to work. * module/language/cps/intmap.scm: * module/language/cps/intset.scm: * module/language/tree-il/primitives.scm: Use (ice-9 threads). * module/language/cps/reify-primitives.scm: Reify current-thread in (ice-9 threads) module. * module/srfi/srfi-18.scm: Use ice-9 threads with a module prefix, and adapt all users. Use proper keywords in module definition form. * test-suite/tests/filesys.test (test-suite): * test-suite/tests/fluids.test (test-suite): * test-suite/tests/srfi-18.test: Use ice-9 threads. * NEWS: Add entry. * doc/ref/api-scheduling.texi (Threads): Update. * doc/ref/posix.texi (Processes): Move current-processor-count and total-processor-count docs to Threads. Andy Wingo2016-10-231-1/+0
* Add thread-local lock-free, TLS-free freelists....* libguile/bdw-gc.h: Remove a needless compatibility hack. * libguile/gc-inline.h: New file, implementing thread-local freelists providing faster allocation if we already have a scm_i_thread* pointer. Based on gc_inline.h from libgc. * libguile/threads.h (scm_i_thread): Add freelists here. * libguile/threads.c (guilify_self_1, guilify_self_2): Initialize freelists. * libguile/vm.c: Include gc-inline.h. * libguile/vm-engine.c: Rename current_thread to thread. Use scm_inline_cons instead of scm_cons, scm_inline_cell instead of scm_cell, and scm_inline_words instead of words. Andy Wingo2014-02-021-1/+5
* Merge commit '8571dbde639e0ee9885bad49c9e180474bd23646'...Conflicts: libguile/procprop.c Andy Wingo2013-11-281-0/+1
|\
| * Add mutex locking functions that also block asyncs....* libguile/async.h (scm_i_pthread_mutex_lock_block_asyncs, scm_i_pthread_mutex_unlock_unblock_asyncs): New macros. * libguile/threads.c (do_unlock_with_asyncs): New static helper. (scm_i_dynwind_pthread_mutex_lock_block_asyncs): New function. * libguile/threads.h (scm_i_dynwind_pthread_mutex_lock_block_asyncs): Add prototype. Mark H Weaver2013-11-231-0/+1
* | Remove unused scm_i_thread fields...* libguile/threads.h (scm_i_thread): * libguile/threads.c (guilify_self_1): Remove unused mark stack fields. Andy Wingo2013-11-221-5/+0
* | Remove last use of SCM vm...* libguile/threads.h (scm_i_thread): Hold a struct scm_vm*, not a SCM vm. * libguile/threads.c (guilify_self_2): * libguile/vm.c (make_vm): Adapt. Andy Wingo2013-11-211-1/+1
* | Merge remote-tracking branch 'origin/stable-2.0'...Conflicts: configure.ac libguile/deprecated.c libguile/deprecated.h libguile/filesys.h libguile/fluids.c libguile/fports.c libguile/gc.c libguile/guile.c libguile/numbers.c libguile/objcodes.c libguile/r6rs-ports.c libguile/smob.c libguile/socket.c libguile/threads.h module/language/scheme/decompile-tree-il.scm module/language/tree-il/peval.scm test-suite/tests/syncase.test Mark H Weaver2013-03-281-3/+4
|\|
| * Allow the SMOB mark procedures to be called when libgc uses parallel markers....Fixes <http://bugs.gnu.org/13611>. Reported by Mike Gran <spk121@yahoo.com>. * libguile/smob.c (current_mark_stack_pointer, current_mark_stack_limit): New variables. (smob_mark): Use CURRENT_MARK_STACK_POINTER and CURRENT_MARK_STACK_LIMIT instead of the same-named fields of `SCM_I_CURRENT_THREAD'. (scm_gc_mark): Likewise. (scm_smob_prehistory): Initialize CURRENT_MARK_STACK_LIMIT and CURRENT_MARK_STACK_POINTER. * libguile/threads.h (scm_i_thread): Add comment that `current_mark_stack_ptr' and `current_mark_stack_limit' are no longer used. Ludovic Courtès2013-03-011-3/+4
* | the dynamic stack is really a stack now, instead of a list...* libguile/dynstack.h: * libguile/dynstack.c: New files, implementing the dynamic stack as a true stack instead of a linked list. This lowers the cost of dynwinds: frames, winders, prompts, with-fluids, and dynamic-wind. For the most part, we allocate these items directly on the stack. * libguile/dynwinds.h: * libguile/dynwinds.c: Adapt all manipulators of the wind stack to use interfaces from dynstack.c. Remove heap-allocated winder and frame object types. (scm_dowinds, scm_i_dowinds): Remove these. The first was exported, but it was not a public interface. * libguile/continuations.c: * libguile/continuations.h (scm_t_contregs): Continuation objects reference scm_t_dynstack* values now. Adapt to the new interfaces. * libguile/control.c: * libguile/control.h: There is no longer a scm_tc7_prompt kind of object that can be allocated on the heap. Instead, the prompt flags, key, and registers are pushed on the dynwind stack. (The registers are still on the heap.) Also, since the vm_cont will reference the dynwinds, make the partial continuation stub take just one extra arg, instead of storing the intwinds separately in the object table. * libguile/fluids.c: * libguile/fluids.h: No more with-fluids objects; instead, the fluids go on the dynstack. The values still have to be on the heap, though. (scm_prepare_fluids, scm_swap_fluids): New internal functions, replacing scm_i_make_with_fluids and scm_i_swap_with_fluids. * libguile/print.c: Remove prompt and with-fluids printers. * libguile/tags.h: Revert prompt and with-fluids tc7 values to what they were before they were allocated. * libguile/vm-i-system.c (partial_cont_call): Just pop the vmcont, the intwinds will not be passed as a second arg. Rewind the dynamic stack from within the VM, so that any rewinder sees valid prompt entries. (call_cc, tail_call_cc): Adapt to pass the dynstack to scm_i_vm_capture_stack. (prompt, wind, unwind, wind_fluids, unwind_fluids): Adapt to the new interfaces. * libguile/vm.h (scm_i_capture_current_stack): Rename from scm_i_vm_capture_continuation. (scm_i_vm_capture_stack): Take a dynstack as an argument. * libguile/vm.c (vm_reinstate_partial_continuation): Don't wind here, as that could result in winders seeing invalid prompts. * libguile/eval.c: * libguile/root.c: * libguile/stacks.c: * libguile/threads.c: * libguile/threads.h: * libguile/throw.c: Adapt other users of dynwinds to use the dynstack. Andy Wingo2012-03-031-7/+5
* | Revert "add pthread_atfork helpers to our threading shims"...This reverts commit 2f745b64a1eb06e9e175a1b497d5270bebff9097. Andy Wingo2012-02-231-5/+1
* | add pthread_atfork helpers to our threading shims...* libguile/null-threads.h: * libguile/pthread-threads.h (SCM_DEFINE_ATFORK_HANDLERS_FOR_MUTEX) (scm_i_pthread_atfork): Define a pthread_atfork shim, and a helper to declare procedures to lock and unlock a mutex. * libguile/threads.h (SCM_PTHREAD_ATFORK_LOCK_STATIC_MUTEX): New macro, causes the snarfer to emit a pthread_atfork call to lock a mutex, if threads are enabled. Andy Wingo2012-02-171-1/+5
* | Merge remote-tracking branch 'origin/stable-2.0'...Conflicts: libguile/debug.h module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm module/language/tree-il/peval.scm module/language/tree-il/primitives.scm Andy Wingo2012-01-301-4/+0
|\|
| * Revert "Universally-unique gensyms"...This reverts commit ad432bc8317c33899efc29854550b67f3d7babf7. Not all gensyms need to be universally-unique: most of them just need to be unique within some portion of a Guile session. We'll take a different tack on this problem in the next commit. Andy Wingo2012-01-261-4/+0
* | Merge commit '3d51e57cfb0404db568a6adfde2a346d3fd9907e'...Conflicts: libguile/foreign.c libguile/hashtab.c module/ice-9/psyntax-pp.scm module/language/tree-il/compile-glil.scm Andy Wingo2012-01-301-0/+4
|\|
| * Universally-unique gensyms...* libguile/symbols.c (scm_gensym): Make the gensym counter a 128-bit thread-local, initialized to a random number upon the first call to `gensym' within a given thread. This counter is rendered as a 22 byte suffix of mostly base64 digits. * libguile/threads.h (scm_i_thread): Add a thread-local gensym_counter. * libguile/threads.c (guilify_self_1): Initialize gensym_counter to NULL. Mark H Weaver2012-01-211-0/+4
* | Merge remote-tracking branch 'origin/stable-2.0'...Conflicts: configure.ac libguile/fluids.c libguile/gc.c libguile/gc.h libguile/objcodes.c libguile/procprop.c libguile/vm.c module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm Andy Wingo2011-12-011-1/+1
|\|
| * optional default-value arg to make-fluid...* libguile/fluids.c (grow_dynamic_state, new_fluid): Arrange for the default value in the dynamic-state vector to be SCM_UNDEFINED instead of SCM_BOOL_F. If the value in the dynamic-state is #f, default to a value attached to the fluid instead. This allows useful default values. (scm_make_fluid_with_default): New function, allows the user to specify a default value for the fluid. Defaults to #f. Bound to `make-fluid' on the Scheme side. (scm_make_unbound_fluid): Use SCM_UNDEFINED as the default in all threads. (scm_fluid_unset_x): Also unset the default value. Not sure if this is the right thing. (fluid_ref): Update to the new default-value strategy. * libguile/threads.c (scm_i_reset_fluid): Reset to SCM_UNDEFINED. * libguile/threads.h: Remove extra arg to scm_i_reset_fluid. * libguile/vm-i-system.c (fluid-ref): Update to new default-value strategy. * module/ice-9/vlist.scm (block-growth-factor): Default to 2 in all threads. Fixes http://debbugs.gnu.org/10093. Andy Wingo2011-11-231-1/+1
* | Merge remote-tracking branch 'local-2.0/stable-2.0'Andy Wingo2011-06-161-0/+1
|\|
| * fix initial values of reallocated fluids...* libguile/threads.h: * libguile/threads.c (scm_i_reset_fluid): New internal function, resets the binding of a fluid for all threads. Needed for fluid GC. * libguile/fluids.c (new_fluid): Call scm_i_reset_fluid here. Andy Wingo2011-06-161-0/+1
* | remove SCM_THREAD_SWITCHING_CODE...* libguile/deprecated.h (SCM_THREAD_SWITCHING_CODE): * libguile/threads.h: Remove SCM_THREAD_SWITCHING_CODE, adding in a deprecation note. * libguile/__scm.h (SCM_TICK): Remove SCM_THREAD_SWITCHING_CODE. Andy Wingo2011-05-151-3/+0
|/
* Move `{total,current}-processor-count' outside of `posix.c'....* libguile/posix.c (scm_total_processor_count, scm_current_processor_count): Move to... * libguile/threads.c: ... here. * libguile/posix.h (scm_total_processor_count, scm_current_processor_count): Move declarations to... * libguile/threads.h: ... here. * test-suite/tests/posix.test ("nproc"): Move tests to... * test-suite/tests/threads.test: ... here. Ludovic Courtès2011-04-251-0/+3
* threading / with_guile refactor to use more GC_stack_base...* libguile/init.h: * libguile/init.c (scm_i_init_guile): Change arg to this internal function from SCM_STACKITEM* to void*. Actually it's a struct GC_stack_base*. * libguile/bdw-gc.h: Don't do pthread redirects, because we don't want to affect applications' pthread_* bindings. * libguile/pthread-threads.h (scm_i_pthread_create) (scm_i_pthread_detach, scm_i_pthread_exit, scm_i_pthread_cancel) (scm_i_pthread_sigmask): Do pthread redirects here, in this internal header. * libguile/threads.h: Remove declaration of internal scm_i_with_guile_and_parent. Remove declaration of undefined scm_threads_init_first_thread. Make declaration of internal scm_threads_prehistory actually internal, and take a void* (actually a struct GC_stack_base*). * libguile/threads.c (GC_get_stack_base): Implement a shim if this function is unavailable, and fold in the implementations of get_thread_stack_base. (GC_call_with_stack_base): Actually implement. (guilify_self_1): Take a GC_stack_base* as an arg. (scm_i_init_thread_for_guile): Likewise, and set up libgc for registration of other threads. (scm_init_guile): Use GC_get_stack_base instead of our own guesswork. (with_guile_and_parent, scm_i_with_guile_and_parent): Rework to trampoline through a GC_call_with_stack_base. (scm_threads_prehistory): Pass the "base" arg on to guilify_self_1. Andy Wingo2011-03-251-7/+1
* fix thread cleanup...* libguile/threads.h: Always declare a scm_i_thread_key, for cleanup purposes, in the BUILDING_LIBGUILE case. * libguile/threads.c (scm_i_thread_key): Init with a cleanup handler, so any guile-specific info for a thread can be cleaned up reliably. (guilify_self_1): Always set the thread key. (do_thread_exit_trampoline, on_thread_exit): Enter guile-mode for the guile-mode cleanup handler, and trampoline through a gc_call_with_stack_base for reasons explained in the code. (init_thread_key, scm_i_init_thread_for_guile): Always init the key. (scm_i_with_guile_and_parent): No need for pthread_cancel cleanup handlers, as the pthread key destructor will take care of that for us. (really_launch): Remove needless pthread_exit call with incorrect comment. Andy Wingo2011-03-181-1/+4
* scm_with_guile calls GC_call_with_gc_active...* configure.ac: Check for GC_call_with_gc_active. * libguile/threads.h (scm_i_thread): Remove "top", as it's not used. * libguile/threads.c (with_gc_inactive, with_gc_active): Define shims to GC_do_blocking and GC_call_with_gc_active. (scm_i_init_thread_for_guile): Don't do thread base adjustment here, do it in scm_i_with_guile_and_parent. The previous logic would never be run. (scm_i_with_guile_and_parent): If we enter Guile mode, leave it too. Take care of adjusting the thread stack base here too. Also, call with_gc_active. (scm_without_guile): Refactor. Andy Wingo2011-01-221-2/+1
* remove debug frames...* libguile/debug.h (scm_t_debug_frame): Remove this type, as it was internal to the old evaluator. (SCM_EVALFRAME, SCM_APPLYFRAME, SCM_VOIDFRAME, SCM_MACROEXPF) (SCM_TAILREC, SCM_TRACED_FRAME, SCM_ARGS_READY, SCM_DOVERFLOW) (SCM_MAX_FRAME_SIZE, SCM_FRAMETYPE) (SCM_EVALFRAMEP, SCM_APPLYFRAMEP, SCM_VOIDFRAMEP, SCM_MACROEXPFP) (SCM_TAILRECP, SCM_TRACED_FRAME_P, SCM_ARGS_READY_P, SCM_OVERFLOWP) (SCM_SET_MACROEXP, SCM_SET_TAILREC, SCM_SET_TRACED_FRAME) (SCM_SET_ARGSREADY, SCM_SET_OVERFLOW) (SCM_CLEAR_MACROEXP, SCM_CLEAR_TRACED_FRAME, SCM_CLEAR_ARGSREADY): Remove macro accessors to scm_t_debug_frame. (SCM_DEBUGOBJP, SCM_DEBUGOBJ_FRAME, SCM_SET_DEBUGOBJ_FRAME): (scm_debug_object_p, scm_make_debugobj): Remove debugobj accessors. (scm_i_unmemoize_expr): Remove unused declaration. * libguile/debug.c (scm_debug_options): No more max limit on frame sizes. (scm_start_stack): Just call out to scm_vm_call_with_new_stack. (scm_debug_object_p, scm_make_debugobj, scm_init_debug): No more debugobj smob type. * libguile/deprecated.h: * libguile/deprecated.c (scm_i_deprecated_last_debug_frame) (scm_last_debug_frame): Remove deprecated debug-frame bits. * libguile/stacks.c (scm_make_stack): Rework this function and its dependents to only walk VM frames. (scm_stack_id): Call out to the holder of the VM frame in question, which should be a VM or a VM continuation, for the stack ID. Currently this bit is stubbed out. (scm_last_stack_frame): Removed. It seems this is mainly useful for a debugger, and we need to rewrite the debugger to work on the Scheme level. * test-suite/tests/continuations.test ("continuations"): Remove test for last-stack-frame. * libguile/continuations.h (struct scm_t_contregs): * libguile/continuations.c (scm_make_continuation): (copy_stack_and_call, scm_i_with_continuation_barrier): No need to save and restore debug frames. * libguile/threads.h (scm_i_thread): Don't track debug frames. (scm_i_last_debug_frame, scm_i_set_last_debug_frame): Remove macro accessors. * libguile/threads.c (guilify_self_1): Don't track debug frames. * libguile/throw.c: No need to track debug frames in a jmpbuf. * libguile/vm-engine.c (vm_engine, VM_PUSH_DEBUG_FRAMES): Don't push debug frames. * libguile/vm.h: * libguile/vm.c (scm_vm_call_with_new_stack): New function. Currently stubbed out though. Andy Wingo2009-12-031-4/+0
* Use TLS when available for `SCM_I_CURRENT_THREAD'....* acinclude.m4 (GUILE_THREAD_LOCAL_STORAGE): New macro. * configure.ac: Use it. * libguile/__scm.h (SCM_THREAD_LOCAL): New macro. * libguile/gen-scmconfig.c (main): Define `SCM_HAVE_THREAD_STORAGE_CLASS'. * libguile/gen-scmconfig.h.in (SCM_I_GSC_HAVE_THREAD_STORAGE_CLASS): New. * libguile/threads.c (scm_i_current_thread)[SCM_HAVE_THREAD_STORAGE_CLASS]: New. (SET_CURRENT_THREAD): New macro. (guilify_self_1, on_thread_exit, init_thread_key): Use it. * libguile/threads.h (scm_i_current_thread)[SCM_HAVE_THREAD_STORAGE_CLASS]: New declaration. (SCM_I_CURRENT_THREAD)[SCM_HAVE_THREAD_STORAGE_CLASS]: New macro. (init_thread_key_once, init_thread_key): Conditionalize on `!defined SCM_HAVE_THREAD_STORAGE_CLASS'. (scm_i_init_thread_for_guile): Update accordingly. Ludovic Courtès2009-10-091-3/+12
* Arrange so that `SCM_I_CURRENT_THREAD' is not accessed outside of libguile....* libguile/__scm.h (scm_async_tick): New declaration. (SCM_ASYNC_TICK)[!BUILDING_LIBGUILE]: Use `scm_async_tick ()'. * libguile/async.c (scm_critical_section_start, scm_critical_section_end, scm_async_tick): New functions. * libguile/async.h (scm_i_critical_section_mutex): Made internal. (scm_critical_section_start, scm_critical_section_end): New declarations. (SCM_CRITICAL_SECTION_START, SCM_CRITICAL_SECTION_END)[!BUILDING_LIBGUILE]: Use the same-named function (lower-case). * libguile/stackchk.h (SCM_STACK_OVERFLOW_P): Conditionalize on `BUILDING_LIBGUILE'. * libguile/threads.h (SCM_I_CURRENT_THREAD, scm_i_dynwinds, scm_i_set_dynwinds, scm_i_last_debug_frame, scm_i_set_last_debug_frame): Conditionalize on `BUILDING_LIBGUILE'. Ludovic Courtès2009-10-091-7/+12
* Fix spurious `throw from within critical section' errors...The crux of this problem was that the thread doing a throw, and so checking scm_i_critical_section_level, was different from the thread that was in a critical section. * libguile/async.h (scm_i_critical_section_level): Removed, replaced by per-thread critical_section_level. (SCM_CRITICAL_SECTION_START, SCM_CRITICAL_SECTION_END): Use per-thread critical_section_level. * libguile/continuations.c (scm_dynthrow): Check per-thread critical_section_level. * libguile/threads.c (guilify_self_1): Init per-thread critical_section_level. (scm_i_critical_section_level): Removed. * libguile/threads.h (scm_i_thread): New critical_section_level field. * libguile/throw.c (scm_ithrow): Check per-thread critical_section_level. Neil Jerram2009-09-301-0/+3
* Merge branch 'master' into boehm-demers-weiser-gc...Conflicts: libguile/Makefile.am libguile/bytevectors.c libguile/gc-card.c libguile/gc-mark.c libguile/programs.c libguile/srcprop.c libguile/srfi-14.c libguile/symbols.c libguile/threads.c libguile/unif.c libguile/vm.c Ludovic Courtès2009-08-281-1/+1
|\
| * Avoid clash with system setjmp/longjmp on IA64...Problem was that if an application includes both libguile.h and the system's setjmp.h, and is compiled on IA64, it gets compile errors because of jmp_buf, setjmp and longjmp being multiply defined. * libguile/__scm.h (__ia64__): Define scm_i_jmp_buf, SCM_I_SETJMP and SCM_I_LONGJMP instead of jmp_buf, setjmp and longjmp. (all other platforms): Map scm_i_jmp_buf, SCM_I_SETJMP and SCM_I_LONGJMP to jmp_buf, setjmp and longjmp. * libguile/continuations.c (scm_make_continuation): Use `SCM_I_SETJMP' instead of `setjmp'. (copy_stack_and_call): Use `SCM_I_LONJMP' instead of `longjmp'. (scm_ia64_longjmp): Use type `scm_i_jmp_buf' instead of `jmp_buf'. * libguile/continuations.h (scm_t_contregs): Use type `scm_i_jmp_buf' instead of `jmp_buf'. * libguile/threads.c (suspend): Use `SCM_I_SETJMP' instead of `setjmp'. * libguile/threads.h (scm_i_thread): Use type `scm_i_jmp_buf' instead of `jmp_buf'. * libguile/throw.c (JBJMPBUF, make_jmpbuf, jmp_buf_and_retval): Use type `scm_i_jmp_buf' instead of `jmp_buf'. (scm_c_catch): Use `SCM_I_SETJMP' instead of `setjmp'. (scm_ithrow): Use `SCM_I_LONGJMP' instead of `longjmp'. Neil Jerram2009-08-211-1/+1
* | Merge branch 'master' into boehm-demers-weiser-gc...Conflicts: lib/Makefile.am libguile/Makefile.am libguile/frames.c libguile/gc-card.c libguile/gc-freelist.c libguile/gc-mark.c libguile/gc-segment.c libguile/gc_os_dep.c libguile/load.c libguile/macros.c libguile/objcodes.c libguile/programs.c libguile/strings.c libguile/vm.c m4/gnulib-cache.m4 m4/gnulib-comp.m4 m4/inline.m4 Ludovic Courtès2009-08-181-6/+7
|\|
| * Change Guile license to LGPLv3+...(Not quite finished, the following will be done tomorrow. module/srfi/*.scm module/rnrs/*.scm module/scripts/*.scm testsuite/*.scm guile-readline/* ) Neil Jerram2009-06-171-6/+7
* | Merge branch 'master' into boehm-demers-weiser-gc...Conflicts: libguile/continuations.c libguile/gc-freelist.c libguile/gc-mark.c libguile/symbols.c libguile/threads.c module/ice-9/boot-9.scm Ludovic Courtès2009-03-221-0/+1
|\|
| * Merge commit 'ab878b0f8e675a741a7dd56f52638a7cc0419907' into vm-checkAndy Wingo2009-03-171-1/+1
| |\