1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00
Commit graph

55 commits

Author SHA1 Message Date
Andy Wingo
8918165c40 Compile current-module as intrinsic call
* libguile/fluids.c (scm_i_fluid_ref): New internal function.
  (scm_fluid_ref): Use scm_i_fluid_ref.
* libguile/intrinsics.h:
* libguile/intrinsics.c (current_module): New intrinsic.
* libguile/modules.c (scm_i_current_module): New internal function.
  (scm_current_module): Use new internal function.
* module/language/cps/reify-primitives.scm (compute-known-primitives):
  Add current-module as an intrinsic primitive.
* module/system/vm/assembler.scm (define-scm<-thread-intrinsic):
  (current-module): Arrange to compile to intrinsic call.
2018-06-27 14:57:51 +02:00
Andy Wingo
1234bb1850 Update license notices in all C files
Update to newest recommended license notices from the FSF.  Everything
stays LGPLv3+ except guile-readline which is GPLv3+.
2018-06-20 20:07:34 +02:00
Andy Wingo
791eb0c01a Remove (C) from copyright statements
As the FSF advises, 'There is no legal significance to using the
three-character sequence “(C)”, but it does no harm.'  It does take up
space though!  For that reason, we remove it here from our C files.
2018-06-20 19:17:06 +02:00
Andy Wingo
97cc65fee4 Rename __scm.h to scm.h
* libguile/scm.h: Rename.  Update all includers.
2018-06-20 16:33:33 +02:00
Andy Wingo
c495b44714 Remove Emacs local variables comments in Guile source
The .dir-locals.el file in the repository is sufficient for Emacs
users.

* libguile/__scm.h:
* libguile/alist.c:
* libguile/alist.h:
* libguile/array-handle.c:
* libguile/array-handle.h:
* libguile/array-map.c:
* libguile/array-map.h:
* libguile/arrays.c:
* libguile/arrays.h:
* libguile/async.c:
* libguile/async.h:
* libguile/backtrace.c:
* libguile/backtrace.h:
* libguile/bitvectors.c:
* libguile/bitvectors.h:
* libguile/boolean.c:
* libguile/boolean.h:
* libguile/chars.c:
* libguile/chars.h:
* libguile/chooks.c:
* libguile/chooks.h:
* libguile/continuations.c:
* libguile/continuations.h:
* libguile/control.c:
* libguile/conv-integer.i.c:
* libguile/debug-malloc.h:
* libguile/debug.c:
* libguile/debug.h:
* libguile/deprecation.c:
* libguile/deprecation.h:
* libguile/dynl.c:
* libguile/dynl.h:
* libguile/dynstack.c:
* libguile/dynstack.h:
* libguile/dynwind.c:
* libguile/dynwind.h:
* libguile/eq.c:
* libguile/eq.h:
* libguile/error.c:
* libguile/error.h:
* libguile/eval.c:
* libguile/eval.h:
* libguile/evalext.c:
* libguile/evalext.h:
* libguile/expand.c:
* libguile/expand.h:
* libguile/extensions.c:
* libguile/extensions.h:
* libguile/feature.c:
* libguile/feature.h:
* libguile/filesys.c:
* libguile/filesys.h:
* libguile/fluids.c:
* libguile/fluids.h:
* libguile/foreign.c:
* libguile/fports.c:
* libguile/fports.h:
* libguile/frames.c:
* libguile/frames.h:
* libguile/gc-inline.h:
* libguile/gc.c:
* libguile/gc.h:
* libguile/generalized-arrays.c:
* libguile/generalized-arrays.h:
* libguile/generalized-vectors.c:
* libguile/generalized-vectors.h:
* libguile/gettext.c:
* libguile/gettext.h:
* libguile/goops.c:
* libguile/goops.h:
* libguile/gsubr.c:
* libguile/gsubr.h:
* libguile/guardians.c:
* libguile/guardians.h:
* libguile/guile.c:
* libguile/hash.c:
* libguile/hash.h:
* libguile/hashtab.c:
* libguile/hashtab.h:
* libguile/hooks.c:
* libguile/hooks.h:
* libguile/i18n.c:
* libguile/i18n.h:
* libguile/init.c:
* libguile/init.h:
* libguile/instructions.c:
* libguile/instructions.h:
* libguile/intrinsics.c:
* libguile/intrinsics.h:
* libguile/ioext.c:
* libguile/ioext.h:
* libguile/iselect.h:
* libguile/keywords.c:
* libguile/keywords.h:
* libguile/list.c:
* libguile/list.h:
* libguile/load.c:
* libguile/load.h:
* libguile/loader.c:
* libguile/loader.h:
* libguile/macros.c:
* libguile/macros.h:
* libguile/mallocs.c:
* libguile/mallocs.h:
* libguile/memmove.c:
* libguile/memoize.c:
* libguile/memoize.h:
* libguile/modules.c:
* libguile/modules.h:
* libguile/net_db.c:
* libguile/net_db.h:
* libguile/null-threads.c:
* libguile/null-threads.h:
* libguile/numbers.c:
* libguile/numbers.h:
* libguile/objprop.c:
* libguile/objprop.h:
* libguile/options.c:
* libguile/options.h:
* libguile/pairs.c:
* libguile/pairs.h:
* libguile/poll.c:
* libguile/poll.h:
* libguile/ports.c:
* libguile/ports.h:
* libguile/posix.c:
* libguile/posix.h:
* libguile/print.c:
* libguile/print.h:
* libguile/procprop.c:
* libguile/procprop.h:
* libguile/procs.c:
* libguile/procs.h:
* libguile/programs.c:
* libguile/programs.h:
* libguile/promises.c:
* libguile/promises.h:
* libguile/pthread-threads.h:
* libguile/random.c:
* libguile/random.h:
* libguile/rdelim.c:
* libguile/rdelim.h:
* libguile/read.c:
* libguile/read.h:
* libguile/regex-posix.c:
* libguile/regex-posix.h:
* libguile/rw.c:
* libguile/rw.h:
* libguile/scmsigs.c:
* libguile/scmsigs.h:
* libguile/script.c:
* libguile/script.h:
* libguile/simpos.c:
* libguile/simpos.h:
* libguile/smob.c:
* libguile/smob.h:
* libguile/snarf.h:
* libguile/socket.c:
* libguile/socket.h:
* libguile/sort.c:
* libguile/sort.h:
* libguile/srcprop.c:
* libguile/srcprop.h:
* libguile/stackchk.c:
* libguile/stackchk.h:
* libguile/stacks.c:
* libguile/stacks.h:
* libguile/stime.c:
* libguile/stime.h:
* libguile/strerror.c:
* libguile/strings.c:
* libguile/strings.h:
* libguile/strorder.c:
* libguile/strorder.h:
* libguile/strports.c:
* libguile/strports.h:
* libguile/struct.c:
* libguile/struct.h:
* libguile/symbols.c:
* libguile/symbols.h:
* libguile/syntax.c:
* libguile/syscalls.h:
* libguile/tags.h:
* libguile/threads.c:
* libguile/threads.h:
* libguile/throw.c:
* libguile/throw.h:
* libguile/trees.h:
* libguile/unicode.c:
* libguile/unicode.h:
* libguile/uniform.c:
* libguile/uniform.h:
* libguile/values.c:
* libguile/values.h:
* libguile/variable.c:
* libguile/variable.h:
* libguile/vectors.c:
* libguile/vectors.h:
* libguile/version.c:
* libguile/vm-engine.c:
* libguile/vm-expand.h:
* libguile/vm.c:
* libguile/vm.h:
* libguile/vports.c:
* libguile/vports.h:
* libguile/weak-list.h:
* libguile/weak-set.c:
* libguile/weak-set.h:
* libguile/weak-table.c:
* libguile/weak-table.h:
* libguile/weak-vector.c:
* libguile/weak-vector.h: Remove needless trailing comments.
2018-06-20 14:32:28 +02:00
Andy Wingo
5534c2817e Remove useless "classes: h_files" from Guile headers.
* libguile/__scm.h:
* libguile/alist.h:
* libguile/array-handle.h:
* libguile/array-map.h:
* libguile/arrays.h:
* libguile/async.h:
* libguile/backtrace.h:
* libguile/bitvectors.h:
* libguile/boolean.h:
* libguile/chars.h:
* libguile/chooks.h:
* libguile/continuations.h:
* libguile/debug-malloc.h:
* libguile/debug.h:
* libguile/deprecation.h:
* libguile/dynl.h:
* libguile/dynstack.h:
* libguile/dynwind.h:
* libguile/eq.h:
* libguile/error.h:
* libguile/eval.h:
* libguile/evalext.h:
* libguile/expand.h:
* libguile/extensions.h:
* libguile/feature.h:
* libguile/filesys.h:
* libguile/fluids.h:
* libguile/fports.h:
* libguile/gc-inline.h:
* libguile/gc.h:
* libguile/generalized-arrays.h:
* libguile/generalized-vectors.h:
* libguile/gettext.h:
* libguile/goops.h:
* libguile/gsubr.h:
* libguile/guardians.h:
* libguile/hash.h:
* libguile/hashtab.h:
* libguile/hooks.h:
* libguile/i18n.h:
* libguile/init.h:
* libguile/inline.h:
* libguile/ioext.h:
* libguile/iselect.h:
* libguile/keywords.h:
* libguile/list.h:
* libguile/load.h:
* libguile/macros.h:
* libguile/mallocs.c:
* libguile/mallocs.h:
* libguile/memoize.h:
* libguile/modules.h:
* libguile/net_db.h:
* libguile/null-threads.h:
* libguile/numbers.h:
* libguile/objprop.h:
* libguile/options.h:
* libguile/pairs.h:
* libguile/poll.h:
* libguile/ports.h:
* libguile/posix-w32.h:
* libguile/posix.h:
* libguile/print.h:
* libguile/procprop.h:
* libguile/procs.h:
* libguile/promises.h:
* libguile/pthread-threads.h:
* libguile/random.h:
* libguile/rdelim.h:
* libguile/read.h:
* libguile/regex-posix.h:
* libguile/rw.h:
* libguile/scmsigs.h:
* libguile/script.h:
* libguile/simpos.h:
* libguile/smob.h:
* libguile/snarf.h:
* libguile/socket.h:
* libguile/sort.h:
* libguile/srcprop.h:
* libguile/stackchk.h:
* libguile/stacks.h:
* libguile/stime.h:
* libguile/strings.h:
* libguile/strorder.h:
* libguile/strports.h:
* libguile/struct.h:
* libguile/symbols.h:
* libguile/syscalls.h:
* libguile/tags.h:
* libguile/threads.h:
* libguile/throw.h:
* libguile/trees.h:
* libguile/unicode.h:
* libguile/uniform.h:
* libguile/values.h:
* libguile/variable.h:
* libguile/vectors.h:
* libguile/vports.h:
* libguile/weak-list.h:
* libguile/weak-set.h:
* libguile/weak-table.h:
* libguile/weak-vector.h: Remove "classes: h_files".  Reformat
  copyrights if needed.
2018-06-20 14:26:16 +02:00
Andy Wingo
6f294ecc75 Devolve more validate macros
* libguile.h: Add chooks.h.
* libguile/Makefile.am: Add chooks.h and chooks.c.
* libguile/chooks.c:
* libguile/chooks.h: New files, for the C implementation of hooks.
  Broken out to avoid cycles in gc.h includes.
* libguile/gc.h:
* libguile/gc.c (scm_i_gc_admin_mutex, scm_i_sweep_mutex): Remove unused
  mutexes.  Include chooks instead of hooks in the main header.
* libguile/deprecated.h (scm_gc_running_p): Deprecate this macro always
  defined to 0.
  (SCM_VALIDATE_VECTOR_OR_DVECTOR): Deprecate this weird one too.
* libguile/array-map.c: Add procs.h include.
* libguile/threads.h:
* libguile/vm.c:
* libguile/r6rs-ports.c: Add smob.h include.
* libguile/atomic.h (SCM_VALIDATE_ATOMIC_BOX): Devolve.
* libguile/deprecation.c (scm_c_issue_deprecation_warning): Remove use
  of scm_gc_running_p.
* libguile/error.c (scm_error_scm): Remove use of scm_gc_running_p.
* libguile/filesys.h (SCM_VALIDATE_DIR)
* libguile/fluids.h (SCM_VALIDATE_FLUID)
* libguile/fports.h (SCM_VALIDATE_FPORT, SCM_VALIDATE_OPFPORT)
* libguile/generalized-arrays.h (SCM_VALIDATE_ARRAY)
* libguile/hooks.h (SCM_VALIDATE_HOOK)
* libguile/keywords.h (SCM_VALIDATE_KEYWORD)
* libguile/ports.h (SCM_VALIDATE_PORT, SCM_VALIDATE_INPUT_PORT)
  (SCM_VALIDATE_OUTPUT_PORT, SCM_VALIDATE_OPINPORT)
  (SCM_VALIDATE_OPENPORT, SCM_VALIDATE_OPPORT, SCM_VALIDATE_OPOUTPORT)
* libguile/procs.h (SCM_VALIDATE_PROC)
* libguile/random.h (SCM_VALIDATE_RSTATE)
* libguile/regex-posix.h (SCM_VALIDATE_RGXP)
* libguile/stacks.h (SCM_VALIDATE_STACK, SCM_VALIDATE_FRAME)
* libguile/strports.h (SCM_VALIDATE_OPOUTSTRPORT)
* libguile/struct.h (SCM_VALIDATE_STRUCT SCM_VALIDATE_VTABLE)
* libguile/symbols.h (SCM_VALIDATE_SYMBOL)
* libguile/variable.h (SCM_VALIDATE_VARIABLE)
* libguile/vectors.h (SCM_VALIDATE_VECTOR SCM_VALIDATE_VECTOR_LEN):
  Devolve.
* libguile/validate.h: It's empty now!

hooks squish
2018-06-18 10:50:17 +02:00
Andy Wingo
fb8c91a35c Add thread local fluids
* libguile/fluids.h (struct scm_dynamic_state): Add thread_local_values
  table.  Thread locals are flushed to a separate thread-local table.
  The references are strong references since the table never escapes the
  thread.
  (scm_make_thread_local_fluid, scm_fluid_thread_local_p): New
  functions.
* libguile/fluids.c (FLUID_F_THREAD_LOCAL):
  (SCM_I_FLUID_THREAD_LOCAL_P): New macros.
  (restore_dynamic_state): Add comment about precondition.
  (save_dynamic_state): Flush thread locals.
  (scm_i_fluid_print): Print thread locals nicely.
  (new_fluid): Add flags arg.
  (scm_make_fluid, scm_make_fluid_with_default, scm_make_unbound_fluid):
  Adapt.
  (scm_make_thread_local_fluid, scm_fluid_thread_local_p): New
  functions.
  (fluid_set_x): Special flushing logic for thread-locals.
  (fluid_ref): Special cache miss logic for thread locals.
* libguile/stacks.c (scm_init_stacks):
* libguile/throw.c (scm_init_throw): %stacks and %exception-handler are
  thread-locals.
* libguile/threads.c (guilify_self_2): Init thread locals table.
* test-suite/tests/fluids.test ("dynamic states"): Add test.
* doc/ref/api-control.texi (Fluids and Dynamic States): Add link to
  Thread-Local Variables.
* doc/ref/api-scheduling.texi (Thread Local Variables): Update with real
  thread-locals.
* NEWS: Update.
2017-03-07 21:15:39 +01:00
Andy Wingo
498f3f9568 Avoid stacks in dynamically-bound values
* libguile/dynstack.h:
* libguile/dynstack.c (scm_dynstack_find_old_fluid_value): New
  function.
* libguile/fluids.c (saved_dynamic_state_ref): New helper.
  (scm_fluid_ref): Fix docstring.
  (scm_fluid_ref_star): New function allowing access to previous values
  for a fluid.
  (scm_dynamic_state_ref): New internal function.
* libguile/fluids.h: Add scm_fluid_ref_star and scm_dynamic_state_ref.
* libguile/stacks.c (scm_stack_id): Adapt to %stacks not being a chain.
* libguile/throw.c (catch, throw_without_pre_unwind): Adapt to
  %exception-handlers not being a chain.
* module/ice-9/boot-9.scm (catch, dispatch-exception): Instead of having
  %exception-handlers be a chain, use fluid-ref* to access the chain
  that is in place at the time the exception is thrown.  Prevents
  unintended undelimited capture of the current exception handler stack
  by a delimited "catch".
  (%start-stack): Similarly, don't be a chain.
* module/system/repl/debug.scm (frame->stack-vector):
* module/system/repl/error-handling.scm (call-with-error-handling):
* module/ice-9/save-stack.scm (save-stack): Adapt to %stacks not being a
  chain.
* test-suite/tests/exceptions.test ("delimited exception handlers"): Add
  tests.
* doc/ref/api-control.texi (Fluids and Dynamic States): Add docs.
2017-02-07 09:57:55 +01:00
Andy Wingo
aa84489d18 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.
2016-12-05 21:46:37 +01:00
Andy Wingo
dc2a560264 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).
2016-11-21 23:09:21 +01:00
Andy Wingo
98eaef1b50 Simplify dynstack API to only wind one fluid at a time
* libguile/dynstack.h (SCM_DYNSTACK_TYPE_WITH_FLUID): Rename from
  with-fluids.
* libguile/dynstack.c (scm_dynstack_push_fluid):
  (scm_dynstack_unwind_fluid): Change API to only wind/unwind one
  fluid binding.
  (WITH_FLUID_WORDS): New define, always 2 words (fluid and value box).
  (WITH_FLUID_FLUID, WITH_FLUID_VALUE_BOX): New macros to get offsets of
  fluid and value box.
  (scm_dynstack_push_rewinder, scm_dynstack_push_unwinder): Use
  WINDER_WORDS.
  (scm_dynstack_push_dynwind): Use DYNWIND_WORDS.
  (scm_dynstack_wind_1): Update for scm_swap_fluid API change.

* libguile/fluids.h:
* libguile/fluids.c (scm_prepare_fluids): Remove; no longer needed.
  (scm_swap_fluid): Update to just swap one fluid binding.
  (scm_c_with_fluids, scm_c_with_fluid): Update to use
  scm_dynstack_push_fluid.

* libguile/memoize.c (do_push_fluid, do_pop_fluid): Adapt to API
  change.
* libguile/vm-engine.c (rtl_vm_engine): Change wind-fluids / unwind-fluids
  to push-fluid / pop-fluid, and actually enable.  Woo!

* libguile/vm-i-system.c (push-fluid, pop-fluid): Update to new API.
2013-06-28 20:01:35 +02:00
Andy Wingo
9ede013f68 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.
2012-03-03 17:06:02 +01:00
Andy Wingo
b2208d2e98 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
2011-12-01 23:31:50 +01:00
Andy Wingo
aafb4ed724 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.
2011-11-23 12:53:38 +01:00
Andy Wingo
dc7da0be90 refactor tc7 and tc16 checks
* libguile/tags.h (SCM_HAS_TYP7, SCM_HAS_TYP7S, SCM_HAS_TYP16): New
  macros.

* libguile/bytevectors.h (SCM_BYTEVECTOR_P):
* libguile/control.h (SCM_PROMPT_P):
* libguile/filesys.h (SCM_DIRP):
* libguile/fluids.h (SCM_WITH_FLUIDS_P, SCM_FLUID_P)
  (SCM_I_DYNAMIC_STATE_P):
* libguile/foreign.h (SCM_POINTER_P):
* libguile/fports.h (SCM_FPORTP):
* libguile/frames.h (SCM_VM_FRAME_P):
* libguile/hashtab.h (SCM_HASHTABLE_P):
* libguile/inline.h (scm_get_byte_or_eof):
* libguile/numbers.h (SCM_REALP, SCM_BIGP, SCM_COMPLEXP, SCM_FRACTIONP):
* libguile/objcodes.h (SCM_OBJCODE_P):
* libguile/ports.h (SCM_OUTPUT_PORT_P):
* libguile/programs.h (SCM_PROGRAM_P):
* libguile/smob.h (SCM_SMOB_PREDICATE):
* libguile/srfi-14.h (SCM_CHARSETP):
* libguile/strings.c (IS_STRING):
* libguile/strports.h (SCM_STRPORTP):
* libguile/symbols.h (scm_is_symbol):
* libguile/variable.h (SCM_VARIABLEP):
* libguile/vectors.h (SCM_I_IS_VECTOR, SCM_I_IS_NONWEAK_VECTOR):
* libguile/vm-i-system.c (call, tail-call, mv-call)
* libguile/vm.h (SCM_VM_P, SCM_VM_CONT_P):
* libguile/weak-set.c (SCM_WEAK_SET_P):
* libguile/weak-table.c (SCM_WEAK_TABLE_P):
* libguile/weak-vector.h (SCM_I_WVECTP): Use them.
2011-10-24 18:54:01 +02:00
Andy Wingo
e01163b5f1 rename make-undefined-fluid to make-unbound-fluid
* libguile/fluids.c (scm_make_unbound_fluid): Rename from
  scm_make_undefined_fluid.

* libguile/fluids.h:
* module/language/elisp/runtime.scm: Update referrers.
2010-12-17 13:10:03 +01:00
Brian Templeton
ef94624eaf unbound fluids
* libguile/fluids.c (scm_make_undefined_fluid, scm_fluid_unset_x)
  (scm_fluid_bound_p): New functions.

  (fluid_ref): New function; like scm_fluid_ref, but will not throw an
  error for unbound fluids.
  (scm_fluid_ref, swap_fluid): Use `fluid_ref'.

* libguile/fluids.h (scm_make_undefined_fluid, scm_fluid_unset_x)
  (scm_fluid_bound_p): New prototypes.

* libguile/vm-i-system.c (fluid_ref): If fluid is unbound, jump to
  `vm_error_unbound_fluid'.
* libguile/vm-engine.c (VM_NAME)[vm_error_unbound_fluid]: New error
  message.

* test-suite/tests/fluids.test ("unbound fluids")["fluid-ref of unbound
  fluid", "fluid-bound? of bound fluid", "fluid-bound? of unbound
  fluid", "unbound fluids can be set", "bound fluids can be unset"]: New
  tests.
2010-12-07 13:21:01 +01:00
Andy Wingo
6f8d7b12bb SCM_I_FLUID_P -> SCM_FLUID_P
* libguile/fluids.h (SCM_FLUID_P): Change from SCM_I_FLUID_P.
  (SCM_I_FLUID_NUM, SCM_I_DYNAMIC_STATE_P, SCM_I_DYNAMIC_STATE_FLUIDS):
  Wrap in BUILDING_LIBGUILE ifdef.
2010-07-17 13:31:06 +02:00
Andy Wingo
bbb2ecd1d1 add printers for prompts and with-fluids objects
* libguile/control.c:
* libguile/control.h (scm_i_prompt_print):
* libguile/fluids.c:
* libguile/fluids.h (scm_i_with_fluids_print):
* libguile/print.c (iprin1): Add printers for prompts and with-fluids
  objects.
2010-03-04 13:14:43 +01:00
Andy Wingo
5ef71027e4 fluids.h exposes more of its interface, internally at least
* libguile/fluids.h (SCM_I_FLUID_P, SCM_I_FLUID_NUM)
  (SCM_I_DYNAMIC_STATE_P, SCM_I_DYNAMIC_STATE_FLUIDS): Expose these
  predicates and accessors, internally at least.
* libguile/fluids.c (IS_FLUID, FLUID_NUM, IS_DYNAMIC_STATE)
  (DYNAMIC_STATE_FLUIDS): Implement in terms of the exposed macros.
2010-02-19 12:10:11 +01:00
Andy Wingo
bb0229b51d add with-fluids objects and primitive syntax
* libguile/tags.h (scm_tc7_with_fluids): Allocate a tc7 for
  "with-fluids" objects, which will only live on the dynamic stack (wind
  list), not in normal scheme-land.

* libguile/fluids.h (SCM_WITH_FLUIDS_P, SCM_WITH_FLUIDS_LEN)
  (SCM_WITH_FLUIDS_NTH_FLUID, SCM_WITH_FLUIDS_NTH_VAL)
  (SCM_WITH_FLUIDS_SET_NTH_VAL): Add some accessors.
* libguile/fluids.c (scm_i_make_with_fluids, scm_i_swap_with_fluids):
  New internal functions.
  (scm_c_with_fluids, scm_c_with_fluid): Push with-fluids objects on the
  dynwind list, not winders.

* libguile/dynwind.c (scm_i_dowinds): Add cases for winding and
  unwinding with-fluids objects.

* libguile/memoize.h (scm_sym_with_fluids, SCM_M_BEGIN): New public
  data.
* libguile/memoize.c (scm_m_with_fluids): Define with-fluids as a
  primitive syntax.
  (unmemoize): Add with-fluids case.

* libguile/eval.c (eval):
* module/ice-9/eval.scm (primitive-eval): Add with-fluids cases.

* test-suite/tests/fluids.test
  ("fluids not modified if nonfluid passed to with-fluids"): Enable a
  now-passing test.
2010-02-18 22:15:43 +01:00
Andy Wingo
45cf242872 add printer for dynamic-states
* libguile/fluids.c:
* libguile/fluids.h:
* libguile/print.c: Add dynamic-state printing infrastructure.
2009-12-05 10:55:37 +01:00
Andy Wingo
9ea31741da fluids are tc7 objects
If you're wondering what I'm doing, I'm trying to eventually reimplement
smobs in terms of structs, so that applicable smobs can just follow the
applicable struct dispatch path. But to do that I have to get structs
initialized before things that use smobs, which means transforming a
bunch of smobby things to tc7 things. But this transformation is good
for performance anyway, and we currently have a glut of unused tc7s,
so here we go...

* libguile/tags.h (scm_tc7_fluid, scm_tc7_dynamic_state): Fluids (and
  dynamic states) now have tc7s.

* libguile/fluids.h: Remove scm_fluids_prehistory, and add internal
  scm_i_fluid_print. Update a comment.

* libguile/fluids.c: Update for tc7 representation. Also remove the next
  pointers while we're at it, as they aren't used in the new BDW GC.

* libguile/eq.c (scm_equal_p): Remove the hashtable case. Hashtables
  could never be equal? before, I don't see why to add stubs doing the
  same thing now.

* libguile/print.c (iprin1):
* libguile/gc.c (scm_i_tag_name):
* libguile/evalext.c (scm_self_evaluating_p): Add fluid and
  dynamic_state cases.

* libguile/goops.h: Remove scm_class_hashtable; it will be static.
* libguile/goops.c: Make <hashtable> static, and add <fluid> and
  <dynamic-state> classes.

* libguile/hashtab.h:
* libguile/hashtab.c: Remove scm_i_hashtable_equal_p.

* libguile/init.c (scm_i_init_guile): Remove call to fluids_prehistory.
2009-12-05 10:52:18 +01:00
Ludovic Courtès
fbb857a472 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
2009-08-18 00:06:45 +02:00
Neil Jerram
53befeb700 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/*
)
2009-06-17 00:22:09 +01:00
Ludovic Courtès
8b039053b8 Remove GC-related code from fluids.
* libguile/fluids.c (all_dynamic_states, all_fluids): Remove.  Together,
  they prevented dynamic states and fluids to be collected.  Callers no
  longer use them.
  (resize_all_states): Remove.
  (grow_dynamic_state): New function.
  (next_fluid_num): Don't call `resize_all_states ()'.
  (scm_i_fluid_num, scm_i_fast_fluid_ref, scm_i_fast_fluid_set_x): Remove,
  as they broke encapsulation and would have needed duplication of the lazy
  dynamic state growing code.
  (scm_fluid_ref, scm_fluid_set_x): Lazily grow the dynamic state's fluid
  vector.
  (scm_fluids_prehistory): Don't set an `scm_after_sweep_c_hook'.

* libguile/fluids.h (SCM_FLUID_NUM, SCM_FAST_FLUID_REF, SCM_FAST_FLUID_SET_X,
  scm_i_fluid_num, scm_i_fast_fluid_set_x, scm_i_fast_fluid_ref): Remove.

* libguile/load.c (the_reader_fluid_num): Remove.
  (scm_primitive_load): Use `scm_fluid_ref ()' instead of
  `SCM_FAST_FLUID_REF ()'.
  (scm_init_load): Likewise.
2008-09-17 00:25:03 +02:00
Ludovic Courtès
102dbb6f6c Add `SCM_INTERNAL' macro, use it. 2008-05-31 23:21:02 +02:00
Kevin Ryde
2b829bbb3d merge from 1.8 branch 2006-04-17 00:05:42 +00:00
Marius Vollmer
661ae7ab6b Renamed the "frames" that are related to dynamic-wind to "dynamic
contexts.  Renamed all functions from scm_frame_ to scm_dynwind_.
Updated documentation.
2006-01-29 00:23:28 +00:00
Marius Vollmer
92205699d0 The FSF has a new address. 2005-05-23 19:57:22 +00:00
Marius Vollmer
9de87eea47 See ChangeLog from 2005-03-02. 2005-03-02 20:42:01 +00:00
Marius Vollmer
f5710d53b1 Use SCM_SMOB_* instead of SCM_CELL_* as appropriate. Use
SCM_SMOB_FLAGS and SCM_SET_SMOB_FLAGS instead of accessing the
zeroth word directly.  Use SCM_SMOB_PREDICATE as appropriate.
2004-05-06 16:43:14 +00:00
Marius Vollmer
bebd3fbadd * fluids.c (scm_c_with_fluids): Use frames instead of adding to
the wind chain explicitely.  Use scm_c_with_fluid for the common
case of only one fluid.
(scm_with_fluid): New.
(scm_c_with_fluid): Use frames instead of scm_c_with_fluids.

* fluids.h, fluids.c (scm_frame_fluid): New.
(scm_with_fluid): New.
(scm_i_swap_fluids, scm_i_swap_fluids_reverse): Removed.
2004-01-07 19:47:18 +00:00
Marius Vollmer
ef20bf705f (scm_frame_fluid): New. 2004-01-07 18:08:52 +00:00
Marius Vollmer
a52dbe0177 (scm_make_initial_fluids, scm_copy_fluids, scm_swap_fluids,
scm_swap_fluids_reverse): Renamed to scm_i_... since they are
internal.  Changed all uses.
2004-01-06 18:08:31 +00:00
Marius Vollmer
73be1d9e8e Changed license terms to the plain LGPL thru-out. 2003-04-05 19:15:35 +00:00
Marius Vollmer
33b001fd89 Prefixed each each exported symbol with SCM_API. 2001-11-02 00:19:12 +00:00
Dirk Herrmann
dee01b012c * Removed deprecated stuff.
* Some more renamings to SCM_<filename>_H.
2001-08-31 12:13:50 +00:00
Martin Grabmüller
58ade1022c * alist.c, arbiters.c, async.h, backtrace.h, boolean.c, chars.c,
chars.h, continuations.h, debug-malloc.h, dynl.c, feature.c,
	feature.h, filesys.h, fluids.h, fports.h, gc_os_dep.c,
	gdb_interface.h, gh_eval.c, gh_funcs.c, gh_io.c, gh_list.c,
	gh_predicates.c, gsubr.c, gsubr.h, guardians.h,
	guile-func-name-check.in, guile-snarf-docs-texi.in,
	guile-snarf-docs.in, guile-snarf.awk.in, guile-snarf.in,
	hashtab.h, iselect.h, keywords.h, lang.c, list.h, load.h,
	objprop.c, objprop.h, options.c, options.h, random.h,
	regex-posix.h, root.c, root.h, script.c, snarf.h, stackchk.c,
	strerror.c, strop.h, strports.h, threads.h, values.c, values.h,
	version.c, version.h: Updated copyright notice.
2001-07-19 21:08:49 +00:00
Thien-Thi Nguyen
a06e3a75b2 Remove "face-lift" comment. 2001-07-09 07:36:48 +00:00
Marius Vollmer
92c2555f69 replace "scm_*_t" with "scm_t_*". 2001-06-14 19:50:43 +00:00
Marius Vollmer
143e090215 (scm_internal_with_fluids): Deprecated.
(scm_c_with_fluids): Renamed from scm_internal_with_fluids.
(scm_c_with_fluid): New.
(scm_with_fluids): Use scm_c_with_fluids instead of
scm_internal_with_fluids.
2001-05-19 00:36:22 +00:00
Keisuke Nishida
e841c3e0c0 Smob-related creanup. 2000-12-08 17:32:56 +00:00
Mikael Djurfeldt
f2c9fcb07e Updated copyrights 2000-06-12 12:28:24 +00:00
Dirk Herrmann
47457e8a43 * Replace SCM_UNPACK_CAR appropriately.
* Only access cons cells via SCM_{SET}?C[AD]R.
* gc.c:  Remove unused struct member variable 'valid'.
2000-05-25 09:21:06 +00:00
Michael Livshin
89e00824a0 * *.[hc]: add Emacs magic at the end of file, to ensure GNU
indentation style.
2000-03-19 19:01:16 +00:00
Mikael Djurfeldt
f12677062e *** empty log message *** 2000-03-12 18:30:33 +00:00
Mikael Djurfeldt
413cb56ff4 * async.c, boolean.h, debug.c, dynl.c, dynwind.c, eval.c, eval.h,
feature.h, filesys.h, fluids.h, fports.c, fports.h, gc.c, gc.h,
  hash.c, keywords.h, macros.c, numbers.c, numbers.h, objects.c,
  objects.h, options.c, pairs.h, ports.c, ports.h, print.c,
  procs.h, ramap.c, read.c, smob.c, smob.h, srcprop.h, stacks.c,
  stacks.h, strports.c, struct.c, struct.h, tag.c, tags.h,
  throw.c, unif.c, unif.h, variable.h, vectors.h, weaks.c,
  weaks.h (SCM_SCM, SCM_BITS, SCM_CARBITS): Renamed from
  SCM_ASSCM, SCM_ASWORD, SCM_CARW).
2000-03-12 17:00:58 +00:00
Greg J. Badros
c209c88e54 *.[ch]: make a distinction between SCM as a generic
name for a Scheme object (now a void*), and SCM as 32 bit word for
storing tags and immediates (now a long int).  Introduced
SCM_ASWORD and SCM_ASSCM for conversion. Fixed various dubious
code in the process: arbiter.c (use macros), unif.c (scm_array_p),
2000-03-09 18:58:58 +00:00