Andy Wingo [Fri, 7 Feb 2014 14:26:18 +0000 (15:26 +0100)]
Andy Wingo [Fri, 7 Feb 2014 14:26:02 +0000 (15:26 +0100)]
Andy Wingo [Fri, 7 Feb 2014 14:25:49 +0000 (15:25 +0100)]
Andy Wingo [Fri, 7 Feb 2014 14:15:08 +0000 (15:15 +0100)]
Merge commit '
866af5da3d11ac4a9df44ee8c5b1781a0073c288'
Removes the special arity handler, and instead relies on the procedure
returning the correct number of values.
Andy Wingo [Fri, 7 Feb 2014 14:13:22 +0000 (15:13 +0100)]
Merge commit '
34e89877342f20fdb8a531ad78dab34cfd2b0843'
Conflicts:
module/Makefile.am
Andy Wingo [Fri, 7 Feb 2014 14:07:14 +0000 (15:07 +0100)]
Andy Wingo [Fri, 7 Feb 2014 14:06:26 +0000 (15:06 +0100)]
Andy Wingo [Fri, 7 Feb 2014 14:05:55 +0000 (15:05 +0100)]
Merge commit '
ca5e0414e96886177d883a249edd957d2331db65'
Conflicts:
module/language/tree-il/primitives.scm
Andy Wingo [Fri, 7 Feb 2014 14:01:33 +0000 (15:01 +0100)]
Merge commit '
60617d819d77a1b92ed6c557a0b49b8e9a8e97b9'
Conflicts:
libguile/continuations.c
libguile/eval.c
libguile/goops.c
libguile/instructions.c
Andy Wingo [Fri, 7 Feb 2014 13:51:42 +0000 (14:51 +0100)]
Merge commit '
f6ddf827f8f192af7a8cd255bd8374a0d38bbb74'
Conflicts:
module/ice-9/boot-9.scm
module/oop/goops.scm
Andy Wingo [Fri, 7 Feb 2014 13:43:42 +0000 (14:43 +0100)]
Andy Wingo [Fri, 7 Feb 2014 13:43:23 +0000 (14:43 +0100)]
Andy Wingo [Fri, 7 Feb 2014 13:42:40 +0000 (14:42 +0100)]
Merge commit '
8ca97482b01cf1a6aa538cc5a2d1f71fb60f080c'
Conflicts:
libguile/r6rs-ports.c
Andy Wingo [Fri, 7 Feb 2014 13:39:01 +0000 (14:39 +0100)]
Merge commit '
122f24cc8a3637ed42d7792ad1ff8ec0c49c58df'
Conflicts:
libguile/fports.c
libguile/ports.c
Andy Wingo [Fri, 7 Feb 2014 12:00:12 +0000 (13:00 +0100)]
Add weak-vector-length, weak-vector-ref, weak-vector-set!
* libguile/weak-vectors.h:
* libguile/weak-vectors.c (scm_is_weak_vector, scm_c_weak_vector_length):
(scm_c_weak_vector_ref, scm_c_weak_vector_set_x): New interfaces for
dealing with weak vectors from C.
(scm_weak_vector_length, scm_weak_vector_ref, scm_weak_vector_set_x):
New Scheme interfaces to weak vectors; to be used instead of
vector-length, vector-ref, etc.
* module/ice-9/weak-vector.scm: Export the new interfaces.
Daniel Llorens [Thu, 11 Apr 2013 11:03:45 +0000 (13:03 +0200)]
Fix bad uses of base and lbnd on rank 1 arrays
* libguile/array-map.c
- rafill, ramap, rafe, racp: object from SCM_I_ARRAY_V always
has base 0, lbnd 0 and inc 1; make use of this.
* libguile/arrays.c
- array_handle_ref, array_handle_set: idem.
- array_get_handle: sanity check.
* libguile/generalized-vectors.c
- scm_c_generalized_vector_ref, scm_c_generalized_vector_set_x:
pos should be base when idx is lbnd. Furthermore, pos should be signed and
have its overflow checked; do this by handling the job to
scm_c_array_ref_1, scm_c_array_set_1_x.
* libguile/generalized-vectors.h
- fix prototypes.
Daniel Llorens [Wed, 10 Apr 2013 13:28:52 +0000 (15:28 +0200)]
Reorder arrays.test
* test-suite/tests/arrays.test: dependence reordering: first sanity, then
make-array, then array-equal?, then make-shared-array, shared-array-root,
then the rest, many of which use make-shared-array.
Daniel Llorens [Wed, 10 Apr 2013 13:11:33 +0000 (15:11 +0200)]
Don't use scm_is_generalized_vector in transpose-array
* libguile/arrays.c (scm_transpose_array)
- Use scm_c_array_rank(), which contains an implicit is_array test.
- Handle the rank 0 case.
* test-suite/tests/arrays.test
- Add test for rank 0 case.
- Add failure test for non array argument.
Daniel Llorens [Wed, 10 Apr 2013 12:53:10 +0000 (14:53 +0200)]
Tests for transpose-array
* test-suite/tests/arrays.test: test transpose-array for ranks 1, 2, 3.
Daniel Llorens [Wed, 10 Apr 2013 11:48:13 +0000 (13:48 +0200)]
Don't use scm_is_generalized_vector in shared-array-root
* libguile/arrays.c: (scm_shared_array_root): replace check for
scm_is_generalized_vector.
Daniel Llorens [Wed, 10 Apr 2013 11:45:05 +0000 (13:45 +0200)]
Tests for shared-array-root
* test-suite/tests/arrays.test: check shared-array-root against
make-shared-array, array-contents.
Daniel Llorens [Tue, 9 Apr 2013 23:07:02 +0000 (01:07 +0200)]
Remove unnecessary conditions in array constructors
* libguile/arrays.c: (scm_make_type_array, scm_from_contigous_typed_array,
scm_from_contigous_array): Remove conditions known to be true.
Daniel Llorens [Tue, 9 Apr 2013 16:27:29 +0000 (18:27 +0200)]
Remove generalized-vectors.h includes
* libguile/srfi-4.c, libguile/uniform.h: ditto.
Andy Wingo [Thu, 6 Feb 2014 20:34:14 +0000 (21:34 +0100)]
Fix array-index-map refactor
* libguile/ramap.c (array_index_map_1): Fix to use array handle
properly.
Andy Wingo [Thu, 6 Feb 2014 10:43:39 +0000 (11:43 +0100)]
Array-map refactors
* libguile/array-map.c (scm_ra_matchp): Refactor logic a bit.
(array_index_map_1, array_index_map_n)
(scm_array_index_map_x): Internally refactor array-index-map! to use
separate implementations for rank 1 versus rank >1 arrays.
Daniel Llorens [Tue, 7 May 2013 23:54:29 +0000 (01:54 +0200)]
Don't use generalized-vector in array-map.c (II)
* libguile/array-map.c
- replace scm_is_generalized_vector by scm_is_array && !SCM_I_ARRAY_P.
- replace scm_c_generalized_vector_length by scm_c_array_length.
- remove header.
Daniel Llorens [Mon, 8 Apr 2013 11:34:41 +0000 (13:34 +0200)]
Don't use generalized-vector in array-map.c (I)
* array-map.c: (AREF, ASET): Rename from GVREF, GVSET and use rank-1
array accessors.
Daniel Llorens [Thu, 6 Feb 2014 10:17:47 +0000 (11:17 +0100)]
Don't use generalized-vector functions in uniform.c
* libguile/uniform.c (scm_is_uniform_vector): Replace
scm_is_generalized_vector and scm_generalized_vector_get_handle by
scm_is_array and manual rank check.
(scm_c_uniform_vector_length): Use scm_c_array_length.
(scm_c_uniform_vector_ref): Use scm_c_array_ref_1.
(scm_c_uniform_vector_set): Use scm_c_array_set_1_x.
(scm_uniform_vector_writable_elements): Use scm_array_get_handle, and
assert that the rank is 1.
* test-suite/test/arrays.test: Rename the uniform-vector-ref block to
uniform-vector. Exercise uniform-vector-length and shared arrays
remaining uniform.
Modifications by Andy Wingo <wingo@pobox.com>.
Andy Wingo [Thu, 6 Feb 2014 10:02:20 +0000 (11:02 +0100)]
Replace generalized-vector calls in array_handle_ref/set
* libguile/arrays.c: (array-handle-ref, array-handle-set): Use the
rank-1 array accessors.
Daniel Llorens [Tue, 9 Apr 2013 16:17:21 +0000 (18:17 +0200)]
Replace scm_c_generalized_vector_length in arrays.c
* libguile/arrays.c: (scm_array_contents, scm_make_shared_array):
arrays are known of rank 1 so replace by scm_c_array_length.
Daniel Llorens [Tue, 9 Apr 2013 16:09:49 +0000 (18:09 +0200)]
Replace scm_c_generalized_vector_length in random.c
* libguile/random.c: (random:solid-sphere!): array is of known
rank 1, so use scm_c_array_length() instead.
Daniel Llorens [Thu, 18 Apr 2013 13:10:29 +0000 (15:10 +0200)]
Tests for array-copy!, empty case
* test-suite/tests/ramap.test: test array-copy! with empty destination.
Fix uses of constant array as destination.
Mark H Weaver [Thu, 6 Feb 2014 04:40:25 +0000 (23:40 -0500)]
Remove outdated documentation of LTDL_LIBRARY_PATH.
* doc/ref/guile-invoke.texi (Environment Variables): Remove
documentation of 'LTDL_LIBRARY_PATH'.
Mark H Weaver [Thu, 6 Feb 2014 04:25:32 +0000 (23:25 -0500)]
Document 'equal?' in list of R6RS incompatibilities.
* doc/ref/r6rs.texi (R6RS Incompatibilities): Mention that 'equal?'
may not terminate when applied to cyclic datums.
Andy Wingo [Wed, 5 Feb 2014 21:52:00 +0000 (22:52 +0100)]
Various VM stack management fixes
* libguile/vm.c (vm_increase_sp): New interface, to increase the SP to
some new level, possibly expanding the stack.
(vm_push_sp, vm_restore_sp): Intefaces to vm_increase_sp.
(vm_return_to_continuation): Don't throw an error if there's not
enough space; instead, expand.
(vm_reinstate_partial_continuation): Use the new helper.
(return_unused_stack_to_os): Avoid off-by-one error (sp points to
valid memory.)
(scm_call_n): Never write beyond the sp.
Mark H Weaver [Tue, 4 Feb 2014 19:21:13 +0000 (14:21 -0500)]
REPL Server: Remove unneeded error case in 'run-server'.
* module/system/repl/server.scm (run-server): Remove case that handled
'interrupt' exceptions specially. It is no longer needed since
e6c8e6047ed2e772cc4e1fb5ad4d389e5c616feb (REPL Server: Don't establish
a SIGINT handler.)
Mark H Weaver [Tue, 4 Feb 2014 17:08:48 +0000 (12:08 -0500)]
REPL Server: Redirect warnings to client socket.
* module/system/repl/server.scm (serve-client): Use parameterize.
Redirect warnings to client socket.
Mark H Weaver [Tue, 4 Feb 2014 04:09:23 +0000 (23:09 -0500)]
Don't check HAVE_ALARM, which no longer exists.
* libguile/scmsigs.c (scm_alarm): Remove check for HAVE_ALARM.
Conditionalize only on HAVE_DECL_ALARM.
Mark H Weaver [Tue, 4 Feb 2014 02:04:39 +0000 (21:04 -0500)]
Update Gnulib to
v0.1-77-gd9361da
Mark H Weaver [Mon, 3 Feb 2014 02:13:47 +0000 (21:13 -0500)]
define-values: Blackhole 'dummy'; work around lack of toplevel hygiene.
* module/ice-9/boot-9.scm (define-values): Use 'generate-temporaries' to
generate a fresh name for 'dummy', to work around the lack of hygiene
for macro-introduced toplevel identifiers. Blackhole 'dummy' to avoid
keeping garbage alive. Add more comments.
Andy Wingo [Sun, 2 Feb 2014 22:19:22 +0000 (23:19 +0100)]
Add VM and compiler support for calls to known procedures
* module/language/cps.scm ($callk): New expression type, for calls to
known labels. Part of "low CPS".
* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/verify.scm: Adapt call sites.
* libguile/vm-engine.c (call-label, tail-call-label): New instructions.
Renumber the rest; this is an ABI change.
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION):
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
* doc/ref/compiler.texi (CPS in Guile): Document $callk.
Andy Wingo [Sun, 2 Feb 2014 18:15:48 +0000 (19:15 +0100)]
Remove code to run GC more frequently as process image size increased
* libguile/gc.c: Remove code that would try to run GC more frequently as
the process image size was increasing. Before, it was often the case
that the heap was the main component of image size, but with
expandable stacks and statically allocated data that is no longer
true. Also, once scm_gc_register_allocation was incorporated, we
don't need to be so conservative any more. It seems this code was
simply causing too many gc's to run. Removing it improves some
micro-benchmarks; time will tell.
Andy Wingo [Sun, 2 Feb 2014 15:04:58 +0000 (16:04 +0100)]
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 Wingo [Sun, 2 Feb 2014 10:43:03 +0000 (11:43 +0100)]
Add dead slot map cache
* libguile/vm.c (find_dead_slot_map, scm_i_vm_mark_stack): Use a little
cache for dead slot maps. Helps when marking very deep recursive
stacks.
Mark H Weaver [Sun, 12 Jan 2014 09:43:37 +0000 (04:43 -0500)]
Implement R7RS 'define-values'.
* module/ice-9/boot-9.scm (%define-values-arity-error): New procedure.
(define-values): New macro.
* doc/ref/api-binding.texi (Binding Multiple Values): Add docs.
* test-suite/tests/syntax.test: Add tests.
Mark H Weaver [Wed, 29 Jan 2014 07:20:01 +0000 (02:20 -0500)]
Implement SRFI-64 - A Scheme API for test suites.
* module/srfi/srfi-64.scm: New file.
* module/srfi/srfi-64/testing.scm: New file.
* module/Makefile.am: Add rule for srfi-64.go dependency on
srfi-64/testing.scm.
(SRFI_SOURCES): Add srfi/srfi-64.scm.
(NOCOMP_SOURCES): Add srfi/srfi-64/testing.scm.
* doc/ref/srfi-modules.texi (SRFI-64): New node.
* test-suite/tests/srfi-64.test: New file.
* test-suite/tests/srfi-64-test.scm: New file.
* test-suite/Makefile.am (SCM_TESTS): Add test-suite/tests/srfi-64.test.
(EXTRA_DIST): Add tests/srfi-64-test.scm.
Mark H Weaver [Mon, 27 Jan 2014 22:17:23 +0000 (17:17 -0500)]
Implement SRFI-43 Vector Library.
* module/srfi/srfi-43.scm: New file.
* module/Makefile.am (SRFI_SOURCES): Add module/srfi/srfi-43.scm.
* test-suite/tests/srfi-43.test: New file.
* test-suite/Makefile.am (SCM_TESTS): Add test-suite/tests/srfi-43.test.
* doc/ref/srfi-modules.texi (SRFI-43, SRFI-43 Constructors)
(SRFI-43 Predicates, SRFI-43 Selectors, SRFI-43 Iteration)
(SRFI-43 Searching, SRFI-43 Mutators, SRFI-43 Conversion): New nodes.
Mark H Weaver [Tue, 28 Jan 2014 22:44:22 +0000 (17:44 -0500)]
Compile numerical comparisons with more than 2 arguments to VM code.
* module/language/tree-il/primitives.scm (chained-comparison-expander):
New procedure.
(*primitive-expand-table*): Add primitive expanders for '<', '>',
'<=', '>=', and '='.
Andy Wingo [Fri, 31 Jan 2014 20:41:36 +0000 (21:41 +0100)]
Return unused parts of the stack to the OS
* libguile/vm.h (struct scm_vm): Reorder fields. Add "sp_max_since_gc"
field.
* libguile/vm-engine.c (ALLOC_FRAME, RESET_FRAME):
* libguile/vm.c (vm_return_to_continuation)
(vm_reinstate_partial_continuation, scm_call_n): In places where we
could increase the stack height, update sp_max_since_gc.
(vm_expand_stack): Relocate sp_max_since_gc on expansion.
(scm_bootstrap_vm): Record the page size using gnulib's getpagesize.
(return_unused_stack_to_os): New routine, run when marking stacks.
Andy Wingo [Fri, 31 Jan 2014 19:31:31 +0000 (20:31 +0100)]
Micro-optimization to scm_i_vm_mark_stack
* libguile/vm.c (scm_i_vm_mark_stack): Micro-optimize GC_MARK_AND_PUSH
to cache the plausible heap bounds locally.
Mark H Weaver [Fri, 31 Jan 2014 09:01:12 +0000 (04:01 -0500)]
Revert "Primitive expand numerical comparisons with more than 2 arguments."
This reverts commit
4dc4b86e858d391d20d0ea2551614a89fa3bd4d1.
Mark H Weaver [Tue, 28 Jan 2014 22:44:22 +0000 (17:44 -0500)]
Primitive expand numerical comparisons with more than 2 arguments.
* module/language/tree-il/primitives.scm (chained-comparison-expander):
New procedure.
(*primitive-expand-table*): Add primitive expanders for '<', '>',
'<=', '>=', and '='.
Mark H Weaver [Tue, 28 Jan 2014 21:54:10 +0000 (16:54 -0500)]
Add 'positive?' and 'negative?' as primitives.
* module/language/tree-il/primitives.scm (*interesting-primitive-names*)
(*effect-free-primitives*): Add 'positive?' and 'negative?'.
(*primitive-expand-table*): Add primitive expanders for 'positive?'
and 'negative?'.
Andy Wingo [Tue, 28 Jan 2014 21:28:08 +0000 (22:28 +0100)]
Minor for-each speedup
* module/ice-9/boot-9.scm (for-each): Minor speedup by unrolling
tortoise/hare loop.
Andy Wingo [Tue, 28 Jan 2014 21:28:08 +0000 (22:28 +0100)]
Minor for-each speedup
* module/ice-9/boot-9.scm (for-each): Minor speedup by unrolling
tortoise/hare loop.
Andy Wingo [Tue, 28 Jan 2014 20:56:54 +0000 (21:56 +0100)]
Unnecessary VM_HANDLE_INTERRUPTS elision
* libguile/vm-engine.c: Remove VM_HANDLE_INTERRUPTS before entering a
subr or foreign call. The bytecode stub will have already done so
when entering the stub, and the return sequence handles doing so
before returning.
Andy Wingo [Tue, 28 Jan 2014 20:31:17 +0000 (21:31 +0100)]
Fix tracing
* module/system/vm/trace.scm (print-return): Remove frame argument.
(trace-calls-to-procedure, trace-calls-in-procedure): Adapt callers.
* module/system/vm/traps.scm (trap-in-procedure, trap-frame-finish):
(trap-calls-to-procedure): Since the pop continuation hook is now
called after the continuation is popped, we need to check the right
frame. Fixes tail-calls in the trace root, and probably other things.
Andy Wingo [Sun, 26 Jan 2014 19:55:04 +0000 (20:55 +0100)]
More precise stack marking via .guile.frame-maps section
* module/language/cps/slot-allocation.scm (lookup-dead-slot-map)
(allocate-slots): For each non-tail call in a function, compute the
set of slots that are dead after the function has begun the call.
* module/language/cps/compile-bytecode.scm (compile-fun): Emit the
`dead-slot-map' macro instruction for non-tail calls.
* module/system/vm/assembler.scm (<asm>): Add `dead-slot-maps' member.
(dead-slot-map): New macro-instruction.
(link-frame-maps, link-dynamic-section, link-objects): Write dead
slots information into .guile.frame-maps sections of ELF files.
* module/system/vm/elf.scm (DT_GUILE_FRAME_MAPS): New definition.
* libguile/loader.h:
* libguile/loader.c (DT_GUILE_FRAME_MAPS, process_dynamic_segment):
(load_thunk_from_memory, register_elf): Arrange to parse
DT_GUILE_FRAME_MAPS out of the dynamic section.
(find_mapped_elf_image_unlocked, find_mapped_elf_image): New helpers.
(scm_find_mapped_elf_image): Refactor.
(scm_find_dead_slot_map_unlocked): New interface.
* libguile/vm.c (scm_i_vm_mark_stack): Mark the hottest frame
conservatively, as before. Otherwise use the dead slots map, if
available, to avoid marking data that isn't live.
Andy Wingo [Fri, 24 Jan 2014 12:15:31 +0000 (13:15 +0100)]
Add NEWS for Guile 2.2
* NEWS: Update for 2.1.1.
Andy Wingo [Fri, 24 Jan 2014 11:34:26 +0000 (12:34 +0100)]
Document top-level pseudo-hygiene
* doc/ref/api-macros.texi (Hygiene and the Top-Level): Add a section
documenting our pseudo-hygienic top-level names.
Mark H Weaver [Fri, 24 Jan 2014 05:21:17 +0000 (00:21 -0500)]
Implement SRFI-111 Boxes.
* module/srfi/srfi-111.scm: New file.
* module/Makefile.am (SRFI_SOURCES): Add srfi/srfi-111.scm.
* test-suite/tests/srfi-111.test: New file.
* test-suite/Makefile.am (SCM_TESTS): Add tests/srfi-111.test.
* doc/ref/srfi-modules.texi (SRFI-111): New node.
Mark H Weaver [Thu, 23 Jan 2014 16:37:36 +0000 (11:37 -0500)]
Fix thread-unsafe lazy initializations.
* libguile/backtrace.c (print_exception_var): New static variable.
(init_print_exception_var): New static function.
(scm_print_exception): Remove thread-unsafe lazy initialization.
Call 'init_print_exception_var' using 'scm_i_pthread_once'.
Use 'print_exception_var'.
* libguile/continuations.c (call_cc): New static variable.
(init_call_cc): New static function.
(scm_i_call_with_current_continuation): Remove thread-unsafe lazy
initialization. Call 'init_call_cc' using 'scm_i_pthread_once'.
* libguile/debug.c (local_eval_var): New static variable.
(init_local_eval_var): New static function.
(scm_local_eval): Remove lazy initialization using mutexes.
Call 'init_local_eval_var' using 'scm_i_pthread_once'.
Use 'scm_variable_ref' instead of 'SCM_VARIABLE_REF'.
* libguile/eval.c (map_var, for_each_var): New static variables.
(init_map_var, init_for_each_var): New static functions.
(scm_map, scm_for_each): Remove thread-unsafe lazy initializations.
Call 'init_map_var' (or 'init_for_each_var') using 'scm_i_pthread_once'.
Use 'map_var' (or 'for_each_var').
* libguile/frames.c (frame_arguments_var): New static variable.
(init_frame_arguments_var): New static function.
(scm_frame_arguments): Remove thread-unsafe lazy initialization.
Call 'init_frame_arguments_var' using 'scm_i_pthread_once'.
Use 'frame_arguments_var'. Use 'scm_variable_ref' instead of
'SCM_VARIABLE_REF'.
* libguile/goops.c (delayed_compile_var): New static variable.
(init_delayed_compile_var): New static function.
(make_dispatch_procedure): Remove thread-unsafe lazy initialization.
Call 'init_delayed_compile_var' using 'scm_i_pthread_once'.
Use 'delayed_compile_var'. Use 'scm_variable_ref' instead of
'SCM_VARIABLE_REF'.
* libguile/instructions.c (instructions_by_name): New static variable.
(init_instructions_by_name): New static function.
(scm_lookup_instruction_by_name): Remove thread-unsafe lazy
initialization. Call 'init_instructions_by_name' using
'scm_i_pthread_once'.
* libguile/ports.c (current_warning_port_var)
(current_warning_port_once): New static variables.
(init_current_warning_port_var): New static function.
(scm_current_warning_port): Remove lazy initialization using mutexes.
Call 'init_current_warning_port_var' using 'scm_i_pthread_once'.
Use 'current_warning_port_var'.
(scm_set_current_warning_port): Remove thread-unsafe lazy initialization.
Call 'init_current_warning_port_var' using 'scm_i_pthread_once'.
Use 'current_warning_port_var'.
* libguile/strings.c (null_stringbuf): New static variable.
(init_null_stringbuf): New static function.
(scm_i_make_string): Remove thread-unsafe lazy initialization.
Call 'init_null_stringbuf' using 'scm_i_pthread_once'.
* libguile/strports.c (eval_string_var, k_module): New static variables.
(init_eval_string_var_and_k_module): New static function.
(scm_eval_string_in_module): Remove lazy initialization using mutexes.
Call 'init_eval_string_var_and_k_module' using 'scm_i_pthread_once'.
Use 'eval_string_var'.
* libguile/throw.c (CACHE_VAR): Remove incorrect macro.
(catch_var, throw_var, with_throw_handler_var): New static variables.
(scm_catch, scm_catch_with_pre_unwind_handler): Remove thread-unsafe
lazy initialization. Use 'catch_var'.
(init_with_throw_handler_var): New static function.
(scm_with_throw_handler): Remove thread-unsafe lazy initialization.
Call 'init_with_throw_handler_var' using 'scm_i_pthread_once'.
Use 'with_throw_handler_var'.
(scm_throw): Remove thread-unsafe lazy initialization.
Use 'throw_var'.
(scm_init_throw): Initialize 'catch_var' and 'throw_var'.
Mark H Weaver [Thu, 23 Jan 2014 15:09:29 +0000 (10:09 -0500)]
Improve correctness and consistency of 'eval-when' usage.
* module/ice-9/boot-9.scm:
* module/ice-9/i18n.scm:
* module/ice-9/poll.scm:
* module/ice-9/popen.scm:
* module/ice-9/r6rs-libraries.scm:
* module/oop/goops.scm:
* module/oop/goops/compile.scm:
* module/oop/goops/dispatch.scm:
* module/srfi/srfi-88.scm:
* module/system/foreign.scm:
* module/texinfo/serialize.scm: Change most uses of 'compile' to
'expand', except where we must avoid it during initial bootstrap
before the module system is loaded. Remove redundant uses of
'compile' where 'expand' is also given. Standardize on the
"(expand load eval)" order of conditions.
Mark H Weaver [Thu, 23 Jan 2014 08:49:21 +0000 (03:49 -0500)]
Improve docs for 'eval-when'.
* doc/ref/api-macros.texi (Eval When): Explain in detail what each
condition means, including 'expand' which was previously undocumented.
Change the example to use (expand load eval) and recommend that set of
conditions, instead of (compile load eval) which was previously
recommended and shown in the example.
Ludovic Courtès [Tue, 21 Jan 2014 22:39:30 +0000 (23:39 +0100)]
Buffered custom binary input ports correctly handle partial read requests.
* libguile/r6rs-ports.c (cbip_fill_input): Always initialize 'read_pos'
when BUFFERED.
* test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports")["custom binary
input port buffered partial reads"]: New test.
Mark H Weaver [Tue, 21 Jan 2014 21:21:36 +0000 (16:21 -0500)]
Fix nested block comment example in manual.
Reported by Chris K. Jester-Young <cky944@gmail.com>.
* doc/ref/api-evaluation.texi (Block Comments): Fix example.
Mark H Weaver [Tue, 21 Jan 2014 21:06:40 +0000 (16:06 -0500)]
REPL Server: Don't establish a SIGINT handler.
* module/system/repl/server.scm (call-with-sigint): Remove.
(accept-new-client): Don't wrap 'call-with-sigint' around call to
'accept'.
Mark H Weaver [Tue, 21 Jan 2014 20:50:58 +0000 (15:50 -0500)]
Write out HTTP Basic auth headers correctly.
Fixes <http://bugs.gnu.org/14370>.
Reported by Atom X Zane <atomx@deadlyhead.com>.
* module/web/http.scm (write-credentials): Handle the Basic auth scheme
correctly.
* test-suite/tests/web-http.test (pass-if-round-trip): Use
'pass-if-equal' for better error reporting.
("request headers"): Add tests.
* THANKS: Add "Atom X Zane" to bug fix section.
Mark H Weaver [Tue, 21 Jan 2014 08:57:04 +0000 (03:57 -0500)]
Merge branch 'stable-2.0'
Conflicts:
libguile/read.c
test-suite/tests/web-response.test
Andy Wingo [Sat, 18 Jan 2014 20:08:52 +0000 (21:08 +0100)]
Add support for content-disposition
* module/web/http.scm ("Content-Disposition"): Add a parser and
serializer. Defined in RFC2616 section 19.5.1.
* test-suite/tests/web-http.test ("entity headers"): New test case.
Mark H Weaver [Mon, 20 Jan 2014 22:15:53 +0000 (17:15 -0500)]
Fix (port-conversion-strategy #f).
Reported by Doug Evans <xdje42@gmail.com>.
* libguile/ports.c (scm_port_conversion_strategy): Don't validate
that 'port' is an open port until after the (port == #f) case
has been handled.
Ludovic Courtès [Thu, 16 Jan 2014 22:43:31 +0000 (23:43 +0100)]
Custom binary input ports support 'setvbuf'.
* libguile/r6rs-ports.c (CBIP_BUFFER_SIZE): Adjust comment. Set to 8KiB.
(SCM_SET_CBIP_BYTEVECTOR): New macro.
(cbip_setvbuf): New function.
(make_cbip): Set PORT's 'setvbuf' internal field.
(cbip_fill_input): Check whether PORT is buffered. When unbuffered,
check whether BV can hold C_REQUESTED bytes, and allocate a new
bytevector if not; copy the data back from BV to c_port->read_pos.
Remove 'again' label, and don't loop there.
* test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports")["custom binary
input port unbuffered & 'port-position'", "custom binary input port
unbuffered & 'read!' calls", "custom binary input port, unbuffered
then buffered", "custom binary input port, buffered then unbuffered"]:
New tests.
* doc/ref/api-io.texi (R6RS Binary Input): Document the buffering of
custom binary input ports, and link to 'setvbuf'.
Ludovic Courtès [Thu, 16 Jan 2014 22:52:01 +0000 (23:52 +0100)]
Prepare 'setvbuf' to support for non-file ports.
* libguile/ports-internal.h (struct scm_port_internal): Add
setvbuf' field. Change 'pending_eof' to a 1-bit unsigned char.
* libguile/ports.c (scm_new_port_table_entry): Clear 'pti->setvbuf'.
* libguile/fports.c (scm_setvbuf): Accept any open port, and error out
when PORT's setvbuf' field is NULL. Remove explicit 'scm_gc_free' calls.
(scm_i_fdes_to_port): Set PORT's 'setvbuf' field.
* test-suite/tests/ports.test ("setvbuf")["closed port", "string port"]:
New tests.
* doc/ref/posix.texi (Ports and File Descriptors): Suggest that
'setvbuf' works for different port types.
Andy Wingo [Sat, 18 Jan 2014 20:08:52 +0000 (21:08 +0100)]
Add support for content-disposition
* module/web/http.scm ("Content-Disposition"): Add a parser and
serializer. Defined in RFC2616 section 19.5.1.
* test-suite/tests/web-http.test ("entity headers"): New test case.
Arne Babenhauserheide [Fri, 17 Jan 2014 15:25:16 +0000 (16:25 +0100)]
doc: embedding example more readable.
* doc/ref/guile.texi (A Sample Guile Main Program): Easier to read
example code and building split into 2 subsections.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Ludovic Courtès [Fri, 17 Jan 2014 17:20:09 +0000 (18:20 +0100)]
Thank Sree Harsha.
Ludovic Courtès [Fri, 17 Jan 2014 17:18:41 +0000 (18:18 +0100)]
Arrange so that 'file-encoding' does not truncate the encoding name.
Fixes <http://bugs.gnu.org/16463>.
Reported by Sree Harsha Totakura <sreeharsha@totakura.in>.
* libguile/read.c (ENCODING_NAME_MAX_SIZE): New macro.
(SCM_ENCODING_SEARCH_SIZE): Change to 500 + ENCODING_NAME_MAX_SIZE.
(scm_i_scan_for_encoding): Return NULL if there's less than
ENCODING_NAME_MAX_SIZE bytes once "coding: *" has been read.
* test-suite/tests/coding.test ("line
comment")["http://bugs.gnu.org/16463"]: New test.
Andy Wingo [Thu, 16 Jan 2014 11:05:47 +0000 (12:05 +0100)]
Finish documenting the new compiler
* doc/ref/compiler.texi (An Introduction to CPS): Reword.
(Compiling CPS): New sub-sub-section.
(Bytecode): New sub-section.
Andy Wingo [Sun, 12 Jan 2014 22:02:34 +0000 (23:02 +0100)]
Fix CPS doc typos
* doc/ref/compiler.texi (CPS in Guile): Fix a couple typos.
Ludovic Courtès [Wed, 15 Jan 2014 22:41:23 +0000 (23:41 +0100)]
web: Don't throw if a response is longer than its Content-Length says.
* module/web/response.scm (make-delimited-input-port): Read at most LEN
bytes from PORT, instead of trying to read more and returning an error
if more is available. Try again when 'get-bytevector-n!' return zero.
* test-suite/tests/web-response.test (example-1): Add garbage after the
body itself.
Ludovic Courtès [Wed, 15 Jan 2014 22:07:25 +0000 (23:07 +0100)]
Custom binary input ports sanity-check the return value of 'read!'.
* libguile/r6rs-ports.c (cbip_fill_input): Throw an exception when
C_OCTETS is greater than what was requested.
* test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports")["custom binary
input port 'read!' returns too much"]: New test.
Mark H Weaver [Wed, 15 Jan 2014 08:08:32 +0000 (03:08 -0500)]
Document that we support srfi-46 and add it to %cond-expand-features.
* module/ice-9/boot-9.scm (%cond-expand-features): Add srfi-46.
* doc/ref/srfi-modules.texi (SRFI-0): Add srfi-46 to the list of core
features.
(SRFI-46): New node.
* doc/ref/api-macros.texi (Syntax Rules): Mention that the custom
ellipsis identifier support is specified by SRFI-46.
* test-suite/tests/syntax.test ("syntax-rules"): Add ellipsis hygiene
test from SRFI-46.
Mark H Weaver [Wed, 15 Jan 2014 07:37:46 +0000 (02:37 -0500)]
Document that we support srfi-87 and add it to %cond-expand-features.
* module/ice-9/boot-9.scm (%cond-expand-features): Add srfi-87.
* doc/ref/srfi-modules.texi (SRFI-0): Add srfi-87 to the list of core
features.
(SRFI-87): New node.
Mark H Weaver [Wed, 15 Jan 2014 04:53:08 +0000 (23:53 -0500)]
Merge branch 'stable-2.0'
Mark H Weaver [Wed, 15 Jan 2014 04:29:50 +0000 (23:29 -0500)]
print: In R7RS |...| symbols, print most graphic characters unescaped.
* libguile/print.c (print_r7rs_extended_symbol): Print any unicode
graphic character other than '|' or '\' unescaped. Escape any spacing
character other than ASCII space.
Mark H Weaver [Wed, 15 Jan 2014 03:23:39 +0000 (22:23 -0500)]
Merge branch 'stable-2.0'
Conflicts:
libguile/print.c
libguile/read.c
test-suite/tests/print.test
Mark H Weaver [Tue, 14 Jan 2014 22:38:30 +0000 (17:38 -0500)]
print: Support R7RS |...| symbol notation.
* libguile/print.c (scm_print_opts): Add 'r7rs-symbols' print option.
(symbol_has_extended_read_syntax): If the 'r7rs-symbols' option is
enabled, then disallow '|' and '\' from bare symbols.
(print_extended_symbol): Use 'scm_lfwrite' and 'scm_putc' instead of
'display_string' and 'display_character' when printing ASCII literals.
(print_r7rs_extended_symbol): New static function.
(scm_i_print_symbol_name): If the 'r7rs-symbols' option is enabled,
use 'print_r7rs_extended_symbol' instead of 'print_extended_symbol'.
* libguile/private-options.h (SCM_PRINT_R7RS_SYMBOLS_P): New macro.
(SCM_N_PRINT_OPTIONS): Increment.
* doc/ref/api-evaluation.texi (Scheme Write): Mention 'r7rs-symbols'
print option.
* test-suite/tests/print.test ("write"): Add tests.
Mark H Weaver [Sun, 12 Jan 2014 12:55:22 +0000 (07:55 -0500)]
read: Support R7RS |...| symbol notation.
* libguile/private-options.h (SCM_R7RS_SYMBOLS_P): New macro.
(SCM_N_READ_OPTIONS): Increment.
* libguile/read.c (scm_read_opts): Add entry for 'r7rs-symbols'.
(t_read_opts): Add field for 'r7rs_symbols_p'.
(scm_read_string_like_syntax): New function based on earlier
'scm_read_string' that handles either string literals or R7RS quoted
symbols (delimited by vertical bars), depending on the value of 'chr'.
(scm_read_string): Reimplement based on 'scm_read_string_like_syntax'.
(scm_read_r7rs_symbol): New static function.
* doc/ref/api-data.texi (Symbol Read Syntax): Briefly describe the R7RS
symbol syntax, mention the 'r7rs-symbols' read option, and give some
examples.
* doc/ref/api-evaluation.texi (Scheme Read): Mention the 'r7rs-symbols'
read option.
* test-suite/tests/reader.test ("reading"): Add test.
Mark H Weaver [Tue, 14 Jan 2014 18:26:30 +0000 (13:26 -0500)]
Document that we support srfi-62 and add it to %cond-expand-features.
* module/ice-9/boot-9.scm (%cond-expand-features): Add srfi-62.
* doc/ref/srfi-modules.texi (SRFI-0): Add srfi-62 to the list of core
features.
(SRFI-62): New node.
Mark H Weaver [Tue, 14 Jan 2014 08:18:34 +0000 (03:18 -0500)]
Merge branch 'stable-2.0'
Conflicts:
libguile/chars.c
libguile/read.c
test-suite/tests/reader.test
Mark H Weaver [Tue, 14 Jan 2014 08:13:58 +0000 (03:13 -0500)]
read: use 'c_tolower' instead of 'tolower' in 'try_read_ci_chars'.
* libguile/read.c: Include <c-ctype.h>.
(try_read_ci_chars): Use 'c_tolower' instead of 'tolower'.
Mark H Weaver [Sun, 12 Jan 2014 09:36:57 +0000 (04:36 -0500)]
Recognize 'escape' character name, per R7RS.
* libguile/chars.c (scm_r7rs_charnames, scm_r7rs_charnums):
New static constants.
(SCM_N_R7RS_CHARNAMES): New macro.
(scm_i_charname, scm_i_charname_to_char): Adapt to new R7RS
char names.
* doc/ref/api-data.texi (Characters): Document #\escape.
* test-suite/tests/reader.test ("reading"): Add test.
Mark H Weaver [Sun, 12 Jan 2014 09:36:29 +0000 (04:36 -0500)]
read: Accept "\|" in string literals.
* libguile/read.c (scm_read_string): Accept "\|" in string literals.
* doc/ref/api-data.texi (String Syntax): Add "\|" to the list of
supported backslash escapes.
* test-suite/tests/reader.test ("reading"): Add test.
Mark H Weaver [Sun, 12 Jan 2014 09:36:02 +0000 (04:36 -0500)]
read: Support R7RS '#true' and '#false' syntax for booleans.
* libguile/read.c (try_read_ci_chars): New static function.
(scm_read_boolean, scm_read_array): Use 'try_read_ci_chars'.
* doc/ref/api-data.texi (Booleans): Update docs.
* test-suite/tests/reader.test ("reading"): Add tests.
Mark H Weaver [Tue, 14 Jan 2014 07:19:52 +0000 (02:19 -0500)]
Add srfi-16 and srfi-30 to %cond-expand-features.
* module/ice-9/boot-9.scm (%cond-expand-features): Add srfi-16 and
srfi-30.
* doc/ref/srfi-modules.texi (SRFI-0): Add srfi-16 and srfi-30 to the
list of core features.
* module/srfi/srfi-16.scm: Remove call to 'cond-expand-provide'.
Mark H Weaver [Tue, 14 Jan 2014 06:16:42 +0000 (01:16 -0500)]
Merge branch 'stable-2.0'
Conflicts:
libguile/hash.c
module/ice-9/psyntax-pp.scm
module/ice-9/psyntax.scm
test-suite/tests/r6rs-ports.test
Ludovic Courtès [Mon, 13 Jan 2014 22:15:28 +0000 (23:15 +0100)]
'port-position' works on CBIPs that do not support 'set-port-position!'.
* libguile/r6rs-ports.c (cbp_seek)[WHENCE == SEEK_CUR]: Break out of the
switch statement when OFFSET is zero.
Pass 'scm_wrong_type_arg_msg' a phrase suitable for use after
"expecting".
* test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports")["custom binary
input port supports `port-position', not `set-port-position!'"]: New
test.
Andy Wingo [Sun, 12 Jan 2014 14:31:35 +0000 (15:31 +0100)]
Finish CPS documentation
* doc/ref/compiler.texi (Continuation-Passing Style): Flesh out the
documentation.
Mark H Weaver [Sun, 12 Jan 2014 12:47:00 +0000 (07:47 -0500)]
Fix 'exact-integer?' comment in numbers.test.
* test-suite/tests/numbers.test: Fix 'exact-integer?' comment.
Mark H Weaver [Sun, 12 Jan 2014 12:11:44 +0000 (07:11 -0500)]
Fix hashing of empty vectors.
Fixes a bug introduced in
cc1cd04f8111c306cf48b93e131d5c1765c808a3
"Fix hashing of vectors to run in bounded time."
* libguile/hash.c (scm_hasher): Avoid division by zero.
* test-suite/tests/hash.test ("hash"): Add tests.