diff --git a/libguile/async.c b/libguile/async.c index bf8701b6e..bd840762f 100644 --- a/libguile/async.c +++ b/libguile/async.c @@ -56,7 +56,7 @@ */ void -scm_i_async_push (scm_i_thread *t, SCM proc) +scm_i_async_push (scm_thread *t, SCM proc) { SCM asyncs; @@ -102,7 +102,7 @@ scm_i_async_push (scm_i_thread *t, SCM proc) /* Precondition: there are pending asyncs. */ SCM -scm_i_async_pop (scm_i_thread *t) +scm_i_async_pop (scm_thread *t) { while (1) { @@ -140,7 +140,7 @@ scm_i_async_pop (scm_i_thread *t) void scm_async_tick (void) { - scm_i_thread *t = SCM_I_CURRENT_THREAD; + scm_thread *t = SCM_I_CURRENT_THREAD; if (t->block_asyncs) return; @@ -163,7 +163,7 @@ struct scm_thread_wake_data { }; int -scm_i_prepare_to_wait (scm_i_thread *t, +scm_i_prepare_to_wait (scm_thread *t, struct scm_thread_wake_data *wake) { if (t->block_asyncs) @@ -183,13 +183,13 @@ scm_i_prepare_to_wait (scm_i_thread *t, } void -scm_i_wait_finished (scm_i_thread *t) +scm_i_wait_finished (scm_thread *t) { scm_atomic_set_pointer ((void **)&t->wake, NULL); } int -scm_i_prepare_to_wait_on_fd (scm_i_thread *t, int fd) +scm_i_prepare_to_wait_on_fd (scm_thread *t, int fd) { struct scm_thread_wake_data *wake; wake = scm_gc_typed_calloc (struct scm_thread_wake_data); @@ -205,7 +205,7 @@ scm_c_prepare_to_wait_on_fd (int fd) } int -scm_i_prepare_to_wait_on_cond (scm_i_thread *t, +scm_i_prepare_to_wait_on_cond (scm_thread *t, scm_i_pthread_mutex_t *m, scm_i_pthread_cond_t *c) { @@ -242,7 +242,7 @@ SCM_DEFINE (scm_system_async_mark_for_thread, "system-async-mark", 1, 1, 0, "signal handlers.") #define FUNC_NAME s_scm_system_async_mark_for_thread { - scm_i_thread *t; + scm_thread *t; struct scm_thread_wake_data *wake; if (SCM_UNBNDP (thread)) @@ -321,14 +321,14 @@ SCM_DEFINE (scm_noop, "noop", 0, 0, 1, static void increase_block (void *data) { - scm_i_thread *t = data; + scm_thread *t = data; t->block_asyncs++; } static void decrease_block (void *data) { - scm_i_thread *t = data; + scm_thread *t = data; if (--t->block_asyncs == 0) scm_async_tick (); } @@ -336,7 +336,7 @@ decrease_block (void *data) void scm_dynwind_block_asyncs (void) { - scm_i_thread *t = SCM_I_CURRENT_THREAD; + scm_thread *t = SCM_I_CURRENT_THREAD; scm_dynwind_rewind_handler (increase_block, t, SCM_F_WIND_EXPLICITLY); scm_dynwind_unwind_handler (decrease_block, t, SCM_F_WIND_EXPLICITLY); } @@ -344,7 +344,7 @@ scm_dynwind_block_asyncs (void) void scm_dynwind_unblock_asyncs (void) { - scm_i_thread *t = SCM_I_CURRENT_THREAD; + scm_thread *t = SCM_I_CURRENT_THREAD; if (t->block_asyncs == 0) scm_misc_error ("scm_with_unblocked_asyncs", "asyncs already unblocked", SCM_EOL); diff --git a/libguile/async.h b/libguile/async.h index 83a48ea06..412873cde 100644 --- a/libguile/async.h +++ b/libguile/async.h @@ -48,16 +48,16 @@ SCM_API void *scm_c_call_with_unblocked_asyncs (void *(*p) (void *d), void *d); SCM_API void scm_dynwind_block_asyncs (void); SCM_API void scm_dynwind_unblock_asyncs (void); -SCM_INTERNAL int scm_i_prepare_to_wait (scm_i_thread *, +SCM_INTERNAL int scm_i_prepare_to_wait (scm_thread *, struct scm_thread_wake_data *); -SCM_INTERNAL void scm_i_wait_finished (scm_i_thread *); -SCM_INTERNAL int scm_i_prepare_to_wait_on_fd (scm_i_thread *, int); -SCM_INTERNAL int scm_i_prepare_to_wait_on_cond (scm_i_thread *, +SCM_INTERNAL void scm_i_wait_finished (scm_thread *); +SCM_INTERNAL int scm_i_prepare_to_wait_on_fd (scm_thread *, int); +SCM_INTERNAL int scm_i_prepare_to_wait_on_cond (scm_thread *, scm_i_pthread_mutex_t *, scm_i_pthread_cond_t *); -SCM_INTERNAL void scm_i_async_push (scm_i_thread *t, SCM proc); -SCM_INTERNAL SCM scm_i_async_pop (scm_i_thread *t); +SCM_INTERNAL void scm_i_async_push (scm_thread *t, SCM proc); +SCM_INTERNAL SCM scm_i_async_pop (scm_thread *t); SCM_INTERNAL void scm_init_async (void); diff --git a/libguile/cache-internal.h b/libguile/cache-internal.h index dd1ea4390..abe86b784 100644 --- a/libguile/cache-internal.h +++ b/libguile/cache-internal.h @@ -27,7 +27,6 @@ #include "libguile/gc.h" #include "libguile/hash.h" -#include "libguile/threads.h" /* A simple cache with 8 entries. The cache entries are stored in a diff --git a/libguile/continuations.c b/libguile/continuations.c index 172168e61..467ae4ea9 100644 --- a/libguile/continuations.c +++ b/libguile/continuations.c @@ -124,7 +124,7 @@ continuation_print (SCM obj, SCM port, scm_print_state *state SCM_UNUSED) #endif static void -capture_auxiliary_stack (scm_i_thread *thread, scm_t_contregs *continuation) +capture_auxiliary_stack (scm_thread *thread, scm_t_contregs *continuation) { #if SCM_HAVE_AUXILIARY_STACK # if !(defined __ia64 or defined __ia64__) @@ -158,7 +158,7 @@ capture_auxiliary_stack (scm_i_thread *thread, scm_t_contregs *continuation) } static void -restore_auxiliary_stack (scm_i_thread *thread, scm_t_contregs *continuation) +restore_auxiliary_stack (scm_thread *thread, scm_t_contregs *continuation) { #if SCM_HAVE_AUXILIARY_STACK memcpy (thread->auxiliary_stack_base, continuation->auxiliary_stack, @@ -167,7 +167,7 @@ restore_auxiliary_stack (scm_i_thread *thread, scm_t_contregs *continuation) } SCM -scm_i_make_continuation (jmp_buf *registers, scm_i_thread *thread, SCM vm_cont) +scm_i_make_continuation (jmp_buf *registers, scm_thread *thread, SCM vm_cont) { SCM cont; scm_t_contregs *continuation; @@ -277,7 +277,7 @@ copy_stack_and_call (scm_t_contregs *continuation, { scm_t_dynstack *dynstack; scm_t_bits *joint; - scm_i_thread *thread = SCM_I_CURRENT_THREAD; + scm_thread *thread = SCM_I_CURRENT_THREAD; dynstack = SCM_VM_CONT_DATA (continuation->vm_cont)->dynstack; @@ -299,7 +299,7 @@ copy_stack_and_call (scm_t_contregs *continuation, static void scm_dynthrow (SCM cont) { - scm_i_thread *thread = SCM_I_CURRENT_THREAD; + scm_thread *thread = SCM_I_CURRENT_THREAD; scm_t_contregs *continuation = SCM_CONTREGS (cont); SCM_STACKITEM *dst = thread->continuation_base; SCM_STACKITEM stack_top_element; @@ -333,7 +333,7 @@ scm_i_with_continuation_barrier (scm_t_catch_body body, void *pre_unwind_handler_data) { SCM_STACKITEM stack_item; - scm_i_thread *thread = SCM_I_CURRENT_THREAD; + scm_thread *thread = SCM_I_CURRENT_THREAD; SCM old_controot; SCM_STACKITEM *old_contbase; SCM result; diff --git a/libguile/continuations.h b/libguile/continuations.h index 9e044c48c..94a791db1 100644 --- a/libguile/continuations.h +++ b/libguile/continuations.h @@ -68,7 +68,7 @@ typedef struct SCM_INTERNAL SCM scm_i_make_continuation (jmp_buf *registers, - scm_i_thread *thread, + scm_thread *thread, SCM vm_cont); SCM_INTERNAL void scm_i_reinstate_continuation (SCM cont) SCM_NORETURN; diff --git a/libguile/control.c b/libguile/control.c index 287f30f9e..df3a2dccd 100644 --- a/libguile/control.c +++ b/libguile/control.c @@ -219,7 +219,7 @@ static SCM scm_suspendable_continuation_p (SCM tag) { scm_t_dynstack_prompt_flags flags; - scm_i_thread *thread = SCM_I_CURRENT_THREAD; + scm_thread *thread = SCM_I_CURRENT_THREAD; jmp_buf *registers; if (scm_dynstack_find_prompt (&thread->dynstack, tag, &flags, diff --git a/libguile/deprecated.h b/libguile/deprecated.h index b1a15ba86..e9b6f03af 100644 --- a/libguile/deprecated.h +++ b/libguile/deprecated.h @@ -107,6 +107,8 @@ typedef uintptr_t scm_t_uintptr SCM_DEPRECATED_TYPE; typedef int64_t scm_t_int64 SCM_DEPRECATED_TYPE; typedef uint64_t scm_t_uint64 SCM_DEPRECATED_TYPE; typedef ptrdiff_t scm_t_ptrdiff SCM_DEPRECATED_TYPE; + +typedef struct scm_thread scm_i_thread SCM_DEPRECATED_TYPE; #undef SCM_DEPRECATED_TYPE void scm_i_init_deprecated (void); diff --git a/libguile/dynstack.c b/libguile/dynstack.c index 6a5d9c215..032545028 100644 --- a/libguile/dynstack.c +++ b/libguile/dynstack.c @@ -31,6 +31,7 @@ #include "eval.h" #include "fluids.h" #include "variable.h" +#include "threads.h" #include "dynstack.h" diff --git a/libguile/dynwind.c b/libguile/dynwind.c index c785c2bca..85bf5aabc 100644 --- a/libguile/dynwind.c +++ b/libguile/dynwind.c @@ -39,7 +39,7 @@ scm_dynamic_wind (SCM in_guard, SCM thunk, SCM out_guard) #define FUNC_NAME "dynamic-wind" { SCM ans; - scm_i_thread *thread = SCM_I_CURRENT_THREAD; + scm_thread *thread = SCM_I_CURRENT_THREAD; SCM_ASSERT (scm_is_true (scm_thunk_p (out_guard)), out_guard, SCM_ARG3, FUNC_NAME); @@ -60,7 +60,7 @@ scm_dynamic_wind (SCM in_guard, SCM thunk, SCM out_guard) void scm_dynwind_begin (scm_t_dynwind_flags flags) { - scm_i_thread *thread = SCM_I_CURRENT_THREAD; + scm_thread *thread = SCM_I_CURRENT_THREAD; scm_dynstack_push_frame (&thread->dynstack, flags); } @@ -75,7 +75,7 @@ void scm_dynwind_unwind_handler (void (*proc) (void *), void *data, scm_t_wind_flags flags) { - scm_i_thread *thread = SCM_I_CURRENT_THREAD; + scm_thread *thread = SCM_I_CURRENT_THREAD; scm_t_dynstack *dynstack = &thread->dynstack; scm_dynstack_push_unwinder (dynstack, flags, proc, data); @@ -85,7 +85,7 @@ void scm_dynwind_rewind_handler (void (*proc) (void *), void *data, scm_t_wind_flags flags) { - scm_i_thread *thread = SCM_I_CURRENT_THREAD; + scm_thread *thread = SCM_I_CURRENT_THREAD; scm_t_dynstack *dynstack = &thread->dynstack; scm_dynstack_push_rewinder (dynstack, 0, proc, data); diff --git a/libguile/eval.c b/libguile/eval.c index c8e738019..242759b27 100644 --- a/libguile/eval.c +++ b/libguile/eval.c @@ -436,7 +436,7 @@ eval (SCM x, SCM env) case SCM_M_CALL_WITH_PROMPT: { - scm_i_thread *t; + scm_thread *t; SCM k, handler, res; jmp_buf registers; const void *prev_cookie; diff --git a/libguile/finalizers.c b/libguile/finalizers.c index 9f7a8eae4..3d1126f5c 100644 --- a/libguile/finalizers.c +++ b/libguile/finalizers.c @@ -155,7 +155,7 @@ run_finalizers_async_thunk (void) static void queue_finalizer_async (void) { - scm_i_thread *t = SCM_I_CURRENT_THREAD; + scm_thread *t = SCM_I_CURRENT_THREAD; /* Could be that the current thread is is NULL when we're allocating in threads.c:guilify_self_1. In that case, rely on the diff --git a/libguile/fluids.c b/libguile/fluids.c index df0fd7430..db14f17a8 100644 --- a/libguile/fluids.c +++ b/libguile/fluids.c @@ -37,6 +37,7 @@ #include "pairs.h" #include "ports.h" #include "print.h" +#include "threads.h" #include "variable.h" #include "weak-table.h" @@ -508,7 +509,7 @@ scm_c_with_fluids (SCM fluids, SCM values, SCM (*cproc) (), void *cdata) { SCM ans; long flen, vlen, i; - scm_i_thread *thread = SCM_I_CURRENT_THREAD; + scm_thread *thread = SCM_I_CURRENT_THREAD; SCM_VALIDATE_LIST_COPYLEN (1, fluids, flen); SCM_VALIDATE_LIST_COPYLEN (2, values, vlen); @@ -545,7 +546,7 @@ scm_c_with_fluid (SCM fluid, SCM value, SCM (*cproc) (), void *cdata) #define FUNC_NAME "scm_c_with_fluid" { SCM ans; - scm_i_thread *thread = SCM_I_CURRENT_THREAD; + scm_thread *thread = SCM_I_CURRENT_THREAD; scm_dynstack_push_fluid (&thread->dynstack, fluid, value, thread->dynamic_state); @@ -616,7 +617,7 @@ SCM_DEFINE (scm_set_current_dynamic_state, "set-current-dynamic-state", 1,0,0, "and return the previous current dynamic state object.") #define FUNC_NAME s_scm_set_current_dynamic_state { - scm_i_thread *t = SCM_I_CURRENT_THREAD; + scm_thread *t = SCM_I_CURRENT_THREAD; SCM old = scm_current_dynamic_state (); SCM_ASSERT (is_dynamic_state (state), state, SCM_ARG1, FUNC_NAME); restore_dynamic_state (get_dynamic_state (state), t->dynamic_state); diff --git a/libguile/gc-inline.h b/libguile/gc-inline.h index 532b8297f..62fdb9eec 100644 --- a/libguile/gc-inline.h +++ b/libguile/gc-inline.h @@ -99,7 +99,7 @@ scm_inline_gc_alloc (void **freelist, size_t idx, scm_inline_gc_kind kind) } static inline void * -scm_inline_gc_malloc_pointerless (scm_i_thread *thread, size_t bytes) +scm_inline_gc_malloc_pointerless (scm_thread *thread, size_t bytes) { size_t idx = scm_inline_gc_bytes_to_freelist_index (bytes); @@ -111,7 +111,7 @@ scm_inline_gc_malloc_pointerless (scm_i_thread *thread, size_t bytes) } static inline void * -scm_inline_gc_malloc (scm_i_thread *thread, size_t bytes) +scm_inline_gc_malloc (scm_thread *thread, size_t bytes) { size_t idx = scm_inline_gc_bytes_to_freelist_index (bytes); @@ -123,13 +123,13 @@ scm_inline_gc_malloc (scm_i_thread *thread, size_t bytes) } static inline void * -scm_inline_gc_malloc_words (scm_i_thread *thread, size_t words) +scm_inline_gc_malloc_words (scm_thread *thread, size_t words) { return scm_inline_gc_malloc (thread, words * sizeof (void *)); } static inline SCM -scm_inline_cell (scm_i_thread *thread, scm_t_bits car, scm_t_bits cdr) +scm_inline_cell (scm_thread *thread, scm_t_bits car, scm_t_bits cdr) { SCM cell = SCM_PACK_POINTER (scm_inline_gc_malloc_words (thread, 2)); @@ -140,7 +140,7 @@ scm_inline_cell (scm_i_thread *thread, scm_t_bits car, scm_t_bits cdr) } static inline SCM -scm_inline_double_cell (scm_i_thread *thread, scm_t_bits car, scm_t_bits cbr, +scm_inline_double_cell (scm_thread *thread, scm_t_bits car, scm_t_bits cbr, scm_t_bits ccr, scm_t_bits cdr) { SCM cell = SCM_PACK_POINTER (scm_inline_gc_malloc_words (thread, 4)); @@ -154,7 +154,7 @@ scm_inline_double_cell (scm_i_thread *thread, scm_t_bits car, scm_t_bits cbr, } static inline SCM -scm_inline_words (scm_i_thread *thread, scm_t_bits car, uint32_t n_words) +scm_inline_words (scm_thread *thread, scm_t_bits car, uint32_t n_words) { SCM obj = SCM_PACK_POINTER (scm_inline_gc_malloc_words (thread, n_words)); @@ -164,7 +164,7 @@ scm_inline_words (scm_i_thread *thread, scm_t_bits car, uint32_t n_words) } static inline SCM -scm_inline_cons (scm_i_thread *thread, SCM x, SCM y) +scm_inline_cons (scm_thread *thread, SCM x, SCM y) { return scm_inline_cell (thread, SCM_UNPACK (x), SCM_UNPACK (y)); } diff --git a/libguile/gc.c b/libguile/gc.c index b43e2f490..5bbe1d968 100644 --- a/libguile/gc.c +++ b/libguile/gc.c @@ -543,7 +543,7 @@ queue_after_gc_hook (void * hook_data SCM_UNUSED, void *fn_data SCM_UNUSED, void *data SCM_UNUSED) { - scm_i_thread *t = SCM_I_CURRENT_THREAD; + scm_thread *t = SCM_I_CURRENT_THREAD; if (scm_is_false (SCM_CDR (after_gc_async_cell))) { diff --git a/libguile/intrinsics.c b/libguile/intrinsics.c index 72c649311..4adb67b8c 100644 --- a/libguile/intrinsics.c +++ b/libguile/intrinsics.c @@ -32,6 +32,7 @@ #include "modules.h" #include "numbers.h" #include "symbols.h" +#include "threads.h" #include "intrinsics.h" @@ -109,32 +110,32 @@ logsub (SCM x, SCM y) } static void -wind (scm_i_thread *thread, SCM winder, SCM unwinder) +wind (scm_thread *thread, SCM winder, SCM unwinder) { scm_dynstack_push_dynwind (&thread->dynstack, winder, unwinder); } static void -unwind (scm_i_thread *thread) +unwind (scm_thread *thread) { scm_dynstack_pop (&thread->dynstack); } static void -push_fluid (scm_i_thread *thread, SCM fluid, SCM value) +push_fluid (scm_thread *thread, SCM fluid, SCM value) { scm_dynstack_push_fluid (&thread->dynstack, fluid, value, thread->dynamic_state); } static void -pop_fluid (scm_i_thread *thread) +pop_fluid (scm_thread *thread) { scm_dynstack_unwind_fluid (&thread->dynstack, thread->dynamic_state); } static SCM -fluid_ref (scm_i_thread *thread, SCM fluid) +fluid_ref (scm_thread *thread, SCM fluid) { struct scm_cache_entry *entry; @@ -148,7 +149,7 @@ fluid_ref (scm_i_thread *thread, SCM fluid) } static void -fluid_set_x (scm_i_thread *thread, SCM fluid, SCM value) +fluid_set_x (scm_thread *thread, SCM fluid, SCM value) { struct scm_cache_entry *entry; @@ -161,14 +162,14 @@ fluid_set_x (scm_i_thread *thread, SCM fluid, SCM value) } static void -push_dynamic_state (scm_i_thread *thread, SCM state) +push_dynamic_state (scm_thread *thread, SCM state) { scm_dynstack_push_dynamic_state (&thread->dynstack, state, thread->dynamic_state); } static void -pop_dynamic_state (scm_i_thread *thread) +pop_dynamic_state (scm_thread *thread) { scm_dynstack_unwind_dynamic_state (&thread->dynstack, thread->dynamic_state); diff --git a/libguile/intrinsics.h b/libguile/intrinsics.h index e9a4fb3ca..434aad3be 100644 --- a/libguile/intrinsics.h +++ b/libguile/intrinsics.h @@ -25,7 +25,6 @@ #endif #include -#include typedef SCM (*scm_t_scm_from_scm_scm_intrinsic) (SCM, SCM); @@ -37,22 +36,22 @@ typedef uint64_t (*scm_t_u64_from_scm_intrinsic) (SCM); typedef int64_t (*scm_t_s64_from_scm_intrinsic) (SCM); typedef SCM (*scm_t_scm_from_u64_intrinsic) (uint64_t); typedef SCM (*scm_t_scm_from_s64_intrinsic) (int64_t); -typedef void (*scm_t_thread_intrinsic) (scm_i_thread*); -typedef void (*scm_t_thread_scm_intrinsic) (scm_i_thread*, SCM); -typedef void (*scm_t_thread_scm_scm_intrinsic) (scm_i_thread*, SCM, SCM); -typedef SCM (*scm_t_scm_from_thread_scm_intrinsic) (scm_i_thread*, SCM); +typedef void (*scm_t_thread_intrinsic) (scm_thread*); +typedef void (*scm_t_thread_scm_intrinsic) (scm_thread*, SCM); +typedef void (*scm_t_thread_scm_scm_intrinsic) (scm_thread*, SCM, SCM); +typedef SCM (*scm_t_scm_from_thread_scm_intrinsic) (scm_thread*, SCM); typedef SCM (*scm_t_scm_from_scm_u64_intrinsic) (SCM, uint64_t); typedef int (*scm_t_bool_from_scm_scm_intrinsic) (SCM, SCM); typedef enum scm_compare (*scm_t_compare_from_scm_scm_intrinsic) (SCM, SCM); -typedef void (*scm_t_thread_sp_intrinsic) (scm_i_thread*, union scm_vm_stack_element*); -typedef SCM (*scm_t_scm_from_thread_u32_intrinsic) (scm_i_thread*, uint32_t); -typedef uint32_t (*scm_t_u32_from_thread_u32_u32_intrinsic) (scm_i_thread*, uint32_t, uint32_t); -typedef void (*scm_t_thread_u32_u32_scm_u8_u8_intrinsic) (scm_i_thread*, uint32_t, +typedef void (*scm_t_thread_sp_intrinsic) (scm_thread*, union scm_vm_stack_element*); +typedef SCM (*scm_t_scm_from_thread_u32_intrinsic) (scm_thread*, uint32_t); +typedef uint32_t (*scm_t_u32_from_thread_u32_u32_intrinsic) (scm_thread*, uint32_t, uint32_t); +typedef void (*scm_t_thread_u32_u32_scm_u8_u8_intrinsic) (scm_thread*, uint32_t, uint32_t, SCM, uint8_t, uint8_t); typedef SCM (*scm_t_scm_from_scm_scm_scmp_sp_intrinsic) (SCM, SCM, SCM*, const union scm_vm_stack_element*); -typedef void (*scm_t_thread_scm_noreturn_intrinsic) (scm_i_thread*, SCM) SCM_NORETURN; +typedef void (*scm_t_thread_scm_noreturn_intrinsic) (scm_thread*, SCM) SCM_NORETURN; #define SCM_FOR_ALL_VM_INTRINSICS(M) \ M(scm_from_scm_scm, add, "add", ADD) \ diff --git a/libguile/load.c b/libguile/load.c index 79afb9c12..e9d3e6c64 100644 --- a/libguile/load.c +++ b/libguile/load.c @@ -52,6 +52,7 @@ #include "loader.h" #include "modules.h" #include "pairs.h" +#include "procs.h" #include "read.h" #include "srfi-13.h" #include "strings.h" diff --git a/libguile/memoize.c b/libguile/memoize.c index 115c85337..d9e614f62 100644 --- a/libguile/memoize.c +++ b/libguile/memoize.c @@ -98,7 +98,7 @@ do_unwind (void) static SCM do_push_fluid (SCM fluid, SCM val) { - scm_i_thread *thread = SCM_I_CURRENT_THREAD; + scm_thread *thread = SCM_I_CURRENT_THREAD; scm_dynstack_push_fluid (&thread->dynstack, fluid, val, thread->dynamic_state); return SCM_UNSPECIFIED; @@ -107,7 +107,7 @@ do_push_fluid (SCM fluid, SCM val) static SCM do_pop_fluid (void) { - scm_i_thread *thread = SCM_I_CURRENT_THREAD; + scm_thread *thread = SCM_I_CURRENT_THREAD; scm_dynstack_unwind_fluid (&thread->dynstack, thread->dynamic_state); return SCM_UNSPECIFIED; } @@ -115,7 +115,7 @@ do_pop_fluid (void) static SCM do_push_dynamic_state (SCM state) { - scm_i_thread *thread = SCM_I_CURRENT_THREAD; + scm_thread *thread = SCM_I_CURRENT_THREAD; scm_dynstack_push_dynamic_state (&thread->dynstack, state, thread->dynamic_state); return SCM_UNSPECIFIED; @@ -124,7 +124,7 @@ do_push_dynamic_state (SCM state) static SCM do_pop_dynamic_state (void) { - scm_i_thread *thread = SCM_I_CURRENT_THREAD; + scm_thread *thread = SCM_I_CURRENT_THREAD; scm_dynstack_unwind_dynamic_state (&thread->dynstack, thread->dynamic_state); return SCM_UNSPECIFIED; diff --git a/libguile/print.c b/libguile/print.c index b5b5ec6e6..6eed1bec1 100644 --- a/libguile/print.c +++ b/libguile/print.c @@ -61,6 +61,7 @@ #include "struct.h" #include "symbols.h" #include "syntax.h" +#include "threads.h" #include "values.h" #include "variable.h" #include "vectors.h" diff --git a/libguile/read.c b/libguile/read.c index 1e78e2b22..da21f615a 100644 --- a/libguile/read.c +++ b/libguile/read.c @@ -53,6 +53,7 @@ #include "ports-internal.h" #include "ports.h" #include "private-options.h" +#include "procs.h" #include "srcprop.h" #include "srfi-13.h" #include "srfi-4.h" diff --git a/libguile/scm.h b/libguile/scm.h index 99b20fc32..504d868d5 100644 --- a/libguile/scm.h +++ b/libguile/scm.h @@ -827,7 +827,7 @@ typedef int32_t scm_t_wchar; struct scm_frame; struct scm_vm; union scm_vm_stack_element; -typedef struct scm_i_thread scm_i_thread; /* FIXME: Rename. */ +typedef struct scm_thread scm_thread; diff --git a/libguile/scmsigs.c b/libguile/scmsigs.c index 797f26197..b4bd380be 100644 --- a/libguile/scmsigs.c +++ b/libguile/scmsigs.c @@ -100,7 +100,7 @@ static SCM signal_handler_asyncs; static SCM signal_handler_threads; /* The signal delivery thread. */ -scm_i_thread *scm_i_signal_delivery_thread = NULL; +scm_thread *scm_i_signal_delivery_thread = NULL; /* The mutex held when launching the signal delivery thread. */ static scm_i_pthread_mutex_t signal_delivery_thread_mutex = @@ -233,7 +233,7 @@ static SIGRETTYPE take_signal (int signum) { SCM cell = SCM_SIMPLE_VECTOR_REF (signal_handler_asyncs, signum); - scm_i_thread *t = SCM_I_CURRENT_THREAD; + scm_thread *t = SCM_I_CURRENT_THREAD; if (scm_is_false (SCM_CDR (cell))) { diff --git a/libguile/scmsigs.h b/libguile/scmsigs.h index 896876691..1837833c3 100644 --- a/libguile/scmsigs.h +++ b/libguile/scmsigs.h @@ -22,7 +22,7 @@ -#include "libguile/threads.h" +#include "libguile/scm.h" @@ -44,6 +44,6 @@ SCM_INTERNAL void scm_init_scmsigs (void); SCM_INTERNAL void scm_i_close_signal_pipe (void); SCM_INTERNAL void scm_i_ensure_signal_delivery_thread (void); -SCM_INTERNAL scm_i_thread *scm_i_signal_delivery_thread; +SCM_INTERNAL scm_thread *scm_i_signal_delivery_thread; #endif /* SCM_SCMSIGS_H */ diff --git a/libguile/script.c b/libguile/script.c index 7b054ab53..637e7060a 100644 --- a/libguile/script.c +++ b/libguile/script.c @@ -46,6 +46,7 @@ #include "read.h" #include "strings.h" #include "strports.h" +#include "throw.h" #include "version.h" #include "vm.h" diff --git a/libguile/stackchk.c b/libguile/stackchk.c index 6d2ea8f94..a9bf133c2 100644 --- a/libguile/stackchk.c +++ b/libguile/stackchk.c @@ -57,7 +57,7 @@ scm_stack_report () { SCM port = scm_current_error_port (); SCM_STACKITEM stack; - scm_i_thread *thread = SCM_I_CURRENT_THREAD; + scm_thread *thread = SCM_I_CURRENT_THREAD; scm_uintprint ((scm_stack_size (thread->continuation_base) * sizeof (SCM_STACKITEM)), diff --git a/libguile/stacks.c b/libguile/stacks.c index 1332d1d9e..db9120877 100644 --- a/libguile/stacks.c +++ b/libguile/stacks.c @@ -42,6 +42,7 @@ #include "strings.h" #include "struct.h" #include "symbols.h" +#include "threads.h" #include "vm.h" /* to capture vm stacks */ #include "stacks.h" diff --git a/libguile/symbols.c b/libguile/symbols.c index 3746cf6eb..b9d575778 100644 --- a/libguile/symbols.c +++ b/libguile/symbols.c @@ -43,6 +43,7 @@ #include "srfi-13.h" #include "strings.h" #include "strorder.h" +#include "threads.h" #include "variable.h" #include "vectors.h" #include "weak-set.h" diff --git a/libguile/threads.c b/libguile/threads.c index 69587ce52..0e438782e 100644 --- a/libguile/threads.c +++ b/libguile/threads.c @@ -80,7 +80,7 @@ thread_mark (GC_word *addr, struct GC_ms_entry *mark_stack_ptr, struct GC_ms_entry *mark_stack_limit, GC_word env) { int word; - struct scm_i_thread *t = (struct scm_i_thread *) addr; + struct scm_thread *t = (struct scm_thread *) addr; if (SCM_UNPACK (t->handle) == 0) /* T must be on the free-list; ignore. (See warning in @@ -251,7 +251,7 @@ thread_print (SCM exp, SCM port, scm_print_state *pstate SCM_UNUSED) unsigned long ul; uintmax_t um; } u; - scm_i_thread *t = SCM_I_THREAD_DATA (exp); + scm_thread *t = SCM_I_THREAD_DATA (exp); scm_i_pthread_t p = t->pthread; uintmax_t id; u.p = p; @@ -301,7 +301,7 @@ static int block_self (SCM queue, scm_i_pthread_mutex_t *mutex, const scm_t_timespec *waittime) { - scm_i_thread *t = SCM_I_CURRENT_THREAD; + scm_thread *t = SCM_I_CURRENT_THREAD; SCM q_handle; int err; @@ -356,13 +356,13 @@ scm_i_pthread_key_t scm_i_thread_key; itself in TLS (rather than a pointer to some malloc'd memory) is not possible since thread objects may live longer than the actual thread they represent. */ -SCM_THREAD_LOCAL scm_i_thread *scm_i_current_thread = NULL; +SCM_THREAD_LOCAL scm_thread *scm_i_current_thread = NULL; #endif /* SCM_HAVE_THREAD_STORAGE_CLASS */ static scm_i_pthread_mutex_t thread_admin_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER; -static scm_i_thread *all_threads = NULL; +static scm_thread *all_threads = NULL; static int thread_count; static SCM default_dynamic_state; @@ -372,7 +372,7 @@ static SCM default_dynamic_state; static void guilify_self_1 (struct GC_stack_base *base, int needs_unregister) { - scm_i_thread t; + scm_thread t; /* We must arrange for SCM_I_CURRENT_THREAD to point to a valid value before allocating anything in this thread, because allocation could @@ -404,7 +404,7 @@ guilify_self_1 (struct GC_stack_base *base, int needs_unregister) /* The switcheroo. */ { - scm_i_thread *t_ptr = &t; + scm_thread *t_ptr = &t; GC_disable (); t_ptr = GC_generic_malloc (sizeof (*t_ptr), thread_gc_kind); @@ -432,7 +432,7 @@ guilify_self_1 (struct GC_stack_base *base, int needs_unregister) static void guilify_self_2 (SCM dynamic_state) { - scm_i_thread *t = SCM_I_CURRENT_THREAD; + scm_thread *t = SCM_I_CURRENT_THREAD; t->guile_mode = 1; @@ -470,7 +470,7 @@ on_thread_exit (void *v) /* This handler is executed in non-guile mode. Note that although libgc isn't guaranteed to see thread-locals, for this thread-local that isn't an issue as we have the all_threads list. */ - scm_i_thread *t = (scm_i_thread *) v, **tp; + scm_thread *t = (scm_thread *) v, **tp; t->exited = 1; @@ -636,7 +636,7 @@ with_guile (struct GC_stack_base *base, void *data) { void *res; int new_thread; - scm_i_thread *t; + scm_thread *t; struct with_guile_args *args = data; new_thread = scm_i_init_thread_for_guile (base, args->dynamic_state); @@ -702,7 +702,7 @@ void * scm_without_guile (void *(*func)(void *), void *data) { void *result; - scm_i_thread *t = SCM_I_CURRENT_THREAD; + scm_thread *t = SCM_I_CURRENT_THREAD; if (t->guile_mode) { @@ -775,7 +775,7 @@ unprotect_launch_data (launch_data *data) static void * really_launch (void *d) { - scm_i_thread *t = SCM_I_CURRENT_THREAD; + scm_thread *t = SCM_I_CURRENT_THREAD; unprotect_launch_data (d); /* The thread starts with asyncs blocked. */ t->block_asyncs++; @@ -995,7 +995,7 @@ scm_lock_mutex (SCM mx) static inline SCM lock_mutex (enum scm_mutex_kind kind, struct scm_mutex *m, - scm_i_thread *current_thread, scm_t_timespec *waittime) + scm_thread *current_thread, scm_t_timespec *waittime) #define FUNC_NAME "lock-mutex" { scm_i_scm_pthread_mutex_lock (&m->lock); @@ -1066,7 +1066,7 @@ SCM_DEFINE (scm_timed_lock_mutex, "lock-mutex", 1, 1, 0, { scm_t_timespec cwaittime, *waittime = NULL; struct scm_mutex *m; - scm_i_thread *t = SCM_I_CURRENT_THREAD; + scm_thread *t = SCM_I_CURRENT_THREAD; SCM ret; SCM_VALIDATE_MUTEX (1, mutex); @@ -1132,7 +1132,7 @@ scm_try_mutex (SCM mutex) against the mutex kind. */ static inline void unlock_mutex (enum scm_mutex_kind kind, struct scm_mutex *m, - scm_i_thread *current_thread) + scm_thread *current_thread) #define FUNC_NAME "unlock-mutex" { scm_i_scm_pthread_mutex_lock (&m->lock); @@ -1173,7 +1173,7 @@ SCM_DEFINE (scm_unlock_mutex, "unlock-mutex", 1, 0, 0, (SCM mutex), #define FUNC_NAME s_scm_unlock_mutex { struct scm_mutex *m; - scm_i_thread *t = SCM_I_CURRENT_THREAD; + scm_thread *t = SCM_I_CURRENT_THREAD; SCM_VALIDATE_MUTEX (1, mutex); @@ -1296,7 +1296,7 @@ SCM_DEFINE (scm_make_condition_variable, "make-condition-variable", 0, 0, 0, static inline SCM timed_wait (enum scm_mutex_kind kind, struct scm_mutex *m, struct scm_cond *c, - scm_i_thread *current_thread, scm_t_timespec *waittime) + scm_thread *current_thread, scm_t_timespec *waittime) #define FUNC_NAME "wait-condition-variable" { scm_i_scm_pthread_mutex_lock (&m->lock); @@ -1405,7 +1405,7 @@ SCM_DEFINE (scm_timed_wait_condition_variable, "wait-condition-variable", 2, 1, scm_t_timespec waittime_val, *waittime = NULL; struct scm_cond *c; struct scm_mutex *m; - scm_i_thread *t = SCM_I_CURRENT_THREAD; + scm_thread *t = SCM_I_CURRENT_THREAD; SCM ret; SCM_VALIDATE_CONDVAR (1, cond); @@ -1520,7 +1520,7 @@ scm_std_select (int nfds, { fd_set my_readfds; int res, eno, wakeup_fd; - scm_i_thread *t = SCM_I_CURRENT_THREAD; + scm_thread *t = SCM_I_CURRENT_THREAD; struct select_args args; if (readfds == NULL) @@ -1684,7 +1684,7 @@ SCM_DEFINE (scm_all_threads, "all-threads", 0, 0, 0, of the way GC is done. */ int n = thread_count; - scm_i_thread *t; + scm_thread *t; SCM list = scm_c_make_list (n, SCM_UNSPECIFIED), *l; scm_i_pthread_mutex_lock (&thread_admin_mutex); @@ -1717,7 +1717,7 @@ int scm_c_thread_exited_p (SCM thread) #define FUNC_NAME s_scm_thread_exited_p { - scm_i_thread *t; + scm_thread *t; SCM_VALIDATE_THREAD (1, thread); t = SCM_I_THREAD_DATA (thread); return t->exited; @@ -1812,7 +1812,7 @@ scm_init_ice_9_threads (void *unused) void scm_init_threads () { - scm_tc16_thread = scm_make_smob_type ("thread", sizeof (scm_i_thread)); + scm_tc16_thread = scm_make_smob_type ("thread", sizeof (scm_thread)); scm_set_smob_print (scm_tc16_thread, thread_print); scm_tc16_mutex = scm_make_smob_type ("mutex", sizeof (struct scm_mutex)); diff --git a/libguile/threads.h b/libguile/threads.h index 9f0ccc5aa..5ed4c65d2 100644 --- a/libguile/threads.h +++ b/libguile/threads.h @@ -48,8 +48,8 @@ SCM_API scm_t_bits scm_tc16_condvar; struct scm_thread_wake_data; -struct scm_i_thread { - struct scm_i_thread *next_thread; +struct scm_thread { + struct scm_thread *next_thread; SCM handle; scm_i_pthread_t pthread; @@ -108,7 +108,7 @@ struct scm_i_thread { }; #define SCM_I_IS_THREAD(x) SCM_SMOB_PREDICATE (scm_tc16_thread, x) -#define SCM_I_THREAD_DATA(x) ((scm_i_thread *) SCM_SMOB_DATA (x)) +#define SCM_I_THREAD_DATA(x) ((scm_thread *) SCM_SMOB_DATA (x)) #define SCM_VALIDATE_THREAD(pos, a) \ scm_assert_smob_type (scm_tc16_thread, (a)) @@ -171,13 +171,13 @@ SCM_INTERNAL scm_i_pthread_key_t scm_i_thread_key; # ifdef SCM_HAVE_THREAD_STORAGE_CLASS -SCM_INTERNAL SCM_THREAD_LOCAL scm_i_thread *scm_i_current_thread; +SCM_INTERNAL SCM_THREAD_LOCAL scm_thread *scm_i_current_thread; # define SCM_I_CURRENT_THREAD (scm_i_current_thread) # else /* !SCM_HAVE_THREAD_STORAGE_CLASS */ # define SCM_I_CURRENT_THREAD \ - ((scm_i_thread *) scm_i_pthread_getspecific (scm_i_thread_key)) + ((scm_thread *) scm_i_pthread_getspecific (scm_i_thread_key)) # endif /* !SCM_HAVE_THREAD_STORAGE_CLASS */ diff --git a/libguile/throw.c b/libguile/throw.c index f91651df0..1ad7294f1 100644 --- a/libguile/throw.c +++ b/libguile/throw.c @@ -82,7 +82,7 @@ catch (SCM tag, SCM thunk, SCM handler, SCM pre_unwind_handler) { SCM eh, prompt_tag; SCM res; - scm_i_thread *t = SCM_I_CURRENT_THREAD; + scm_thread *t = SCM_I_CURRENT_THREAD; scm_t_dynstack *dynstack = &t->dynstack; scm_t_dynamic_state *dynamic_state = t->dynamic_state; jmp_buf registers; diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c index 0fdbf003e..920cf1f97 100644 --- a/libguile/vm-engine.c +++ b/libguile/vm-engine.c @@ -270,7 +270,7 @@ ((uintptr_t) (ptr) % alignof_type (type) == 0) static SCM -VM_NAME (scm_i_thread *thread, jmp_buf *registers, int resume) +VM_NAME (scm_thread *thread, jmp_buf *registers, int resume) { /* Instruction pointer: A pointer to the opcode that is currently running. */ diff --git a/libguile/vm.c b/libguile/vm.c index b3a680f47..7c301042b 100644 --- a/libguile/vm.c +++ b/libguile/vm.c @@ -185,7 +185,7 @@ scm_i_vm_capture_stack (union scm_vm_stack_element *stack_top, SCM scm_i_capture_current_stack (void) { - scm_i_thread *thread; + scm_thread *thread; struct scm_vm *vp; thread = SCM_I_CURRENT_THREAD; @@ -661,7 +661,7 @@ scm_i_call_with_current_continuation (SCM proc) #undef VM_USE_HOOKS #undef VM_NAME -typedef SCM (*scm_t_vm_engine) (scm_i_thread *current_thread, +typedef SCM (*scm_t_vm_engine) (scm_thread *current_thread, jmp_buf *registers, int resume); static const scm_t_vm_engine vm_engines[SCM_VM_NUM_ENGINES] = @@ -1076,13 +1076,13 @@ vm_expand_stack (struct scm_vm *vp, union scm_vm_stack_element *new_sp) } static uint32_t -frame_locals_count (scm_i_thread *thread) +frame_locals_count (scm_thread *thread) { return SCM_FRAME_NUM_LOCALS (thread->vm.fp, thread->vm.sp); } static void -thread_expand_stack (scm_i_thread *thread, union scm_vm_stack_element *new_sp) +thread_expand_stack (scm_thread *thread, union scm_vm_stack_element *new_sp) { vm_expand_stack (&thread->vm, new_sp); } @@ -1091,7 +1091,7 @@ thread_expand_stack (scm_i_thread *thread, union scm_vm_stack_element *new_sp) it seems to be necessary for perf; the inlined version avoids the needs to flush IP in the common case. */ static void -alloc_frame (scm_i_thread *thread, uint32_t nlocals) +alloc_frame (scm_thread *thread, uint32_t nlocals) { union scm_vm_stack_element *sp = thread->vm.fp - nlocals; @@ -1107,7 +1107,7 @@ alloc_frame (scm_i_thread *thread, uint32_t nlocals) } static uint32_t -compute_kwargs_npositional (scm_i_thread *thread, uint32_t nreq, uint32_t nopt) +compute_kwargs_npositional (scm_thread *thread, uint32_t nreq, uint32_t nopt) { uint32_t npositional, nargs; @@ -1129,7 +1129,7 @@ compute_kwargs_npositional (scm_i_thread *thread, uint32_t nreq, uint32_t nopt) } static void -bind_kwargs (scm_i_thread *thread, uint32_t npositional, uint32_t nlocals, +bind_kwargs (scm_thread *thread, uint32_t npositional, uint32_t nlocals, SCM kwargs, uint8_t strict, uint8_t allow_other_keys) { uint32_t nargs, nkw, n; @@ -1193,7 +1193,7 @@ bind_kwargs (scm_i_thread *thread, uint32_t npositional, uint32_t nlocals, } static SCM -cons_rest (scm_i_thread *thread, uint32_t base) +cons_rest (scm_thread *thread, uint32_t base) { SCM rest = SCM_EOL; uint32_t n = frame_locals_count (thread) - base; @@ -1206,7 +1206,7 @@ cons_rest (scm_i_thread *thread, uint32_t base) } static void -push_interrupt_frame (scm_i_thread *thread) +push_interrupt_frame (scm_thread *thread) { union scm_vm_stack_element *old_fp; size_t old_frame_size = frame_locals_count (thread); @@ -1256,10 +1256,10 @@ vm_return_to_continuation_inner (void *data_ptr) return NULL; } -static void reinstate_continuation_x (scm_i_thread *thread, SCM cont) SCM_NORETURN; +static void reinstate_continuation_x (scm_thread *thread, SCM cont) SCM_NORETURN; static void -reinstate_continuation_x (scm_i_thread *thread, SCM cont) +reinstate_continuation_x (scm_thread *thread, SCM cont) { scm_t_contregs *continuation = scm_i_contregs (cont); struct scm_vm *vp = &thread->vm; @@ -1301,7 +1301,7 @@ reinstate_continuation_x (scm_i_thread *thread, SCM cont) SCM scm_call_n (SCM proc, SCM *argv, size_t nargs) { - scm_i_thread *thread; + scm_thread *thread; struct scm_vm *vp; union scm_vm_stack_element *return_fp, *call_fp; /* Since nargs can only describe the length of a valid argv array in @@ -1371,7 +1371,7 @@ scm_call_n (SCM proc, SCM *argv, size_t nargs) #define VM_DEFINE_HOOK(n) \ { \ - scm_i_thread *t = SCM_I_CURRENT_THREAD; \ + scm_thread *t = SCM_I_CURRENT_THREAD; \ if (scm_is_false (t->vm.hooks[n])) \ t->vm.hooks[n] = scm_make_hook (SCM_I_MAKINUM (1)); \ return t->vm.hooks[n]; \ @@ -1550,7 +1550,7 @@ SCM_DEFINE (scm_call_with_stack_overflow_handler, "@code{call-with-stack-overflow-handler} was called.") #define FUNC_NAME s_scm_call_with_stack_overflow_handler { - struct scm_i_thread *t = SCM_I_CURRENT_THREAD; + struct scm_thread *t = SCM_I_CURRENT_THREAD; ptrdiff_t c_limit, stack_size; struct overflow_handler_data data; SCM new_limit, ret;