Andy Wingo [Sun, 19 Jul 2009 13:11:53 +0000 (15:11 +0200)]
bytevectors have "element type" field, e.g. for generalized-vector-ref
Bytevectors have a very close relationship to other forms of uniform
vectors. Often you want to view a u64vector as a series of bytes, for
writing over a socket; or to process an incoming stream using the
convenient and less error-prone s16vector-ref API rather than
bytevector-s16-native-ref.
The essential needs of the representation of a bytevector and an
s64vector are the same, so we take advantage of that and extend the
bytevector implementation to have a "native type" field, which defaults
to VU8.
This commit doesn't actually expose any user-noticeable changes,
however.
* libguile/bytevectors.h (SCM_BYTEVECTOR_ELEMENT_TYPE): New internal
defines.
(scm_i_make_typed_bytevector, scm_c_take_typed_bytevector): New
internal functions.
* libguile/bytevectors.c (SCM_BYTEVECTOR_SET_ELEMENT_TYPE):
(SCM_BYTEVECTOR_TYPE_SIZE):
(SCM_BYTEVECTOR_TYPED_LENGTH): New internal macros.
(make_bytevector, make_bytevector_from_buffer): Take an extra
argument, the element type. The length argument is interpreted as
being the number of elements, which corresponds to the number of bytes
in the default VU8 case. Doing it this way eliminates a class of bugs
-- e.g. a u32vector of length 3 bytes doesn't make sense. We do have
to check for another class of bugs: overflow. The length stored on the
bytevector itself is still the byte length, though.
(scm_i_make_typed_bytevector):
(scm_c_take_typed_bytevector): New internal functions.
(scm_i_shrink_bytevector): Make sure the new size is valid for the
bytevector's type.
(scm_i_bytevector_generalized_set_x): Remove this function, the
array-handle infrastructure takes care of this for us.
(print_bytevector): Print the bytevector according to its type.
(scm_make_bytevector, scm_bytevector_copy)
(scm_uniform_array_to_bytevector)
(scm_u8_list_to_bytevector, scm_bytevector_to_uint_list): Adapt to
make_bytevector extra arg.
(bv_handle_ref, bv_handle_set_x): Adapt to ref and set based on the
type of the bytevector, e.g. f64 or u8.
(bytevector_get_handle): Set the typed length of the vector, not the
byte length.
Conflicts:
libguile/bytevectors.c
Andy Wingo [Sat, 18 Jul 2009 11:46:29 +0000 (13:46 +0200)]
bytevector inlinedness indicated by flag, not length
* libguile/bytevectors.h (SCM_BYTEVECTOR_INLINE_P): Change to check a
flag instead of checking the length of the bytevector.
* libguile/bytevectors.c (make_bytevector_from_buffer): Handle the len
<= inline threshold case as well. Set the inline flag as appropriate.
(make_bytevector): Updat the inline flag as appropriate.
(scm_c_take_bytevector): Just dispatch to make_bytevector_from_buffer.
(scm_i_shrink_bytevector): Update the inline flag as appropriate.
Update the length when shrinking an already-inlined vector.
(STRING_TO_UTF): Fix some indentation.
Andy Wingo [Sat, 18 Jul 2009 11:26:18 +0000 (13:26 +0200)]
any->u8vector and family now implemented in Scheme
* module/Makefile.am:
* module/srfi/srfi-4/gnu.scm: New module, for extensions to srfi-4.
Currently defines the any->FOOvector family.
* libguile/srfi-4.c:
* libguile/srfi-4.i.c: Dispatch scm_any_to_FOOvector calls to the
scheme-implemented functions in (srfi srfi-4 gnu).
Andy Wingo [Sat, 18 Jul 2009 10:58:37 +0000 (12:58 +0200)]
make-typed-array builds backing vector via make-generalized-vector
* libguile/arrays.c: Rework to use scm_make_generalized_vector instead
of our own type table.
* libguile/bitvectors.c: Fix some includes.
Andy Wingo [Sat, 18 Jul 2009 10:43:54 +0000 (12:43 +0200)]
add registry of vector constructors, make-generalized-vector
* libguile/generalized-vectors.h:
* libguile/generalized-vectors.c: Add a registry of vector constructors.
(scm_make_generalized_vector): New public function, constructs a
vector of a given type.
* libguile/bitvectors.c:
* libguile/bytevectors.c:
* libguile/srfi-4.c:
* libguile/strings.c:
* libguile/vectors.c: Register vector constructors.
* libguile/extensions.c (scm_init_extensions): No need to NULL the list
of registered extensions here, the static init does it for us. Allows
scm_c_register_extension to be called before scm_init_extensions.
* libguile/init.c (scm_i_init_guile): Move array initialization earlier,
so e.g. scm_init_strings has access to a valid list of array element
types when registering its vector constructor.
Andy Wingo [Sat, 18 Jul 2009 10:18:15 +0000 (12:18 +0200)]
uniform vector functions to their own file
* libguile/uniform.c:
* libguile/uniform.h:
* libguile/srfi-4.c:
* libguile/srfi-4.h:
* libguile/Makefile.am: Move uniform vector funcs out of srfi-4 to their
own file.
* libguile.h:
* libguile/arrays.c:
* libguile/bytevectors.c: Update includers.
Andy Wingo [Fri, 17 Jul 2009 17:05:32 +0000 (19:05 +0200)]
generic vector ops to own file
* libguile/Makefile.am:
* libguile/vectors.c:
* libguile/vectors.h:
* libguile/generalized-vectors.c:
* libguile/generalized-vectors.h: Move generic vector ops off into their
own file too. The implementation is now based on the generic
array-handle infrastructure.
* libguile.h:
* libguile/array-map.c:
* libguile/bitvectors.c:
* libguile/random.c:
* libguile/srfi-4.c: Update includers.
Andy Wingo [Fri, 17 Jul 2009 16:54:06 +0000 (18:54 +0200)]
move generic array foo out to its own file
* libguile/arrays.h:
* libguile/arrays.c:
* libguile/generalized-arrays.h:
* libguile/generalized-arrays.c: Move some generic functionality out of
arrays.c to a new file.
* libguile/array-map.c:
* libguile/deprecated.c:
* libguile/init.c: Update includers.
Andy Wingo [Fri, 17 Jul 2009 10:45:24 +0000 (12:45 +0200)]
remove enclosed arrays
* libguile/arrays.h:
* libguile/array-map.c:
* libguile/arrays.c:
* libguile/deprecated.c: Remove "enclosed arrays". The only user-facing
procedures that this affects are scm_enclose_array / enclose-array. If
enclosed arrays are added back, it should be through the generic array
interface; but really, it sounds like something that would be better
implemented in Scheme.
Andy Wingo [Sun, 19 Jul 2009 13:04:40 +0000 (15:04 +0200)]
add generic array implementation facility
* libguile/array-handle.c (scm_i_register_array_implementation):
(scm_i_array_implementation_for_obj): Add generic array facility,
which will (in a few commits) detangle the array code.
(scm_array_get_handle): Use the generic array facility. Note that
scm_t_array_handle no longer has ref and set function pointers;
instead it has a pointer to the array implementation. It is unlikely
that code out there used these functions, however, as the supported
way was through scm_array_handle_ref/set_x.
(scm_array_handle_pos): Move this function here from arrays.c.
(scm_array_handle_element_type): New function, returns a Scheme value
representing the type of element stored in this array.
* libguile/array-handle.h (scm_t_array_element_type): New enum, for
generically determining the type of an array.
(scm_array_handle_rank):
(scm_array_handle_dims): These are now just #defines.
* libguile/arrays.c:
* libguile/bitvectors.c:
* libguile/bytevectors.c:
* libguile/srfi-4.c:
* libguile/strings.c:
* libguile/vectors.c: Register array implementations for all of these.
* libguile/inline.h: Update for array_handle_ref/set change.
* libguile/deprecated.h: Need to include arrays.h now.
Andy Wingo [Thu, 16 Jul 2009 23:08:35 +0000 (01:08 +0200)]
rename unif.[ch] to arrays.[ch]
* libguile/Makefile.am:
* libguile/unif.c:
* libguile/unif.h:
* libguile/arrays.c:
* libguile/arrays.h: Rename unif.[ch] to arrays.[ch].
* libguile.h:
* libguile/array-handle.c:
* libguile/array-map.c:
* libguile/bitvectors.c:
* libguile/bytevectors.c:
* libguile/eq.c:
* libguile/gc-card.c:
* libguile/gc-malloc.c:
* libguile/gc-mark.c:
* libguile/gc.c:
* libguile/init.c:
* libguile/inline.h:
* libguile/print.c:
* libguile/random.c:
* libguile/read.c:
* libguile/socket.c:
* libguile/sort.c:
* libguile/srfi-4.c:
* libguile/srfi-4.h:
* libguile/strports.c:
* libguile/vectors.c:
* libguile/vectors.h: Update includers.
Andy Wingo [Thu, 16 Jul 2009 22:58:32 +0000 (00:58 +0200)]
bitvector exodus from unif.[ch]
* libguile/Makefile.am:
* libguile/unif.c:
* libguile/unif.h:
* libguile/bitvectors.c:
* libguile/bitvectors.h: Move bitvector functionality out of unif.[ch].
* libguile/array-handle.c:
* libguile/array-map.c:
* libguile/init.c:
* libguile/read.c:
* libguile/srfi-4.c:
* libguile/vectors.c: Oh, what a tangled web we weave...
Andy Wingo [Thu, 16 Jul 2009 22:47:31 +0000 (00:47 +0200)]
parts of unif.[ch] to array-handle.[ch]
* libguile/array-handle.c:
* libguile/array-handle.h: Move some parts of unif.c and unif.h to these
new files.
* libguile/unif.c:
* libguile/unif.h: Update includers. Since unif.h depends on the array
handle type, we include array-handle.h, which also means that there
will be no difference for our callers.
* libguile/init.c: Call scm_init_array_handle, though it does nothing as
of yet.
* libguile/Makefile.am: Adapt for new files.
Andy Wingo [Thu, 16 Jul 2009 22:25:49 +0000 (00:25 +0200)]
rename ramap.[ch] to array-map.[ch]
* libguile/array-map.c:
* libguile/array-map.h: Rename from ramap.c and ramap.h.
* libguile.h:
* libguile/Makefile.am:
* libguile/eq.c:
* libguile/init.c:
* libguile/sort.c:
* libguile/unif.c:
* libguile/vectors.c: All referrers changed.
Andy Wingo [Thu, 16 Jul 2009 22:16:43 +0000 (00:16 +0200)]
rename scm_i_make_ra to scm_i_make_array
* libguile/unif.c (scm_i_make_array): Rename from scm_i_make_ra. All
callers changed.
Andy Wingo [Thu, 16 Jul 2009 20:15:04 +0000 (22:15 +0200)]
clean up libguile/Makefile.am
* libguile/Makefile.am: Clean up some of the file lists, should make
future diffs easier to parse.
Andy Wingo [Thu, 16 Jul 2009 20:02:25 +0000 (22:02 +0200)]
remove convert.{c,i.c,h}
* libguile/convert.c:
* libguile/convert.h:
* libguile/convert.i.c: Remove these functions, which were undocumented,
not in the libguile/ header, and thus unlikely to have been used.
Andy Wingo [Thu, 16 Jul 2009 19:51:47 +0000 (21:51 +0200)]
remove deprecated functions from unif.c
* libguile/unif.h:
* libguile/unif.c: Remove deprecated functions.
* module/ice-9/deprecated.scm: Remove array-related deprecated
functions.
* NEWS: Update.
Ludovic Courtès [Wed, 15 Jul 2009 21:57:18 +0000 (23:57 +0200)]
Bump version number for 1.9.1.
* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.
Ludovic Courtès [Wed, 15 Jul 2009 21:56:27 +0000 (23:56 +0200)]
Make the non-integrated VM test-suite less verbose.
* testsuite/run-vm-tests.scm (run-vm-tests): Don't display the number of
tests passed since it's always 1 or 0.
Ludovic Courtès [Wed, 15 Jul 2009 21:53:22 +0000 (23:53 +0200)]
Add FIXMEs about misaligned objcode-metas.
* libguile/objcodes.c (scm_c_make_objcode_slice): Add comment about
misaligned `objcode-meta'.
* module/language/assembly/compile-bytecode.scm (write-bytecode):
Likewise.
Ludovic Courtès [Wed, 15 Jul 2009 21:51:42 +0000 (23:51 +0200)]
Fix unaligned access in the VM code.
* libguile/vm.c (struct t_32bit_aligned): New.
(really_make_boot_program)[bytes]: Use it. This fixes possibly
unaligned accesses, which cause a "bus error" on some platforms (e.g.,
sparc-*).
Ludovic Courtès [Wed, 15 Jul 2009 21:12:43 +0000 (23:12 +0200)]
Const-qualify buffers passed to `scm_c_make_objcode_slice ()'.
* libguile/objcodes.c (scm_c_make_objcode_slice): Add `const' qualifier
for PTR and DATA.
* libguile/objcodes.h: Update accordingly.
Ludovic Courtès [Wed, 15 Jul 2009 20:46:54 +0000 (22:46 +0200)]
Switch remaining GPLv2+ Guile-VM headers to LGPLv3+.
* module/system/base/compile.scm, module/system/base/syntax.scm,
module/system/repl/common.scm, module/system/repl/describe.scm,
module/system/vm/instruction.scm, module/system/vm/objcode.scm,
module/system/vm/profile.scm, module/system/vm/program.scm,
module/system/vm/trace.scm: Switch header from GPLv2+ to LGPLv3+.
Ludovic Courtès [Tue, 14 Jul 2009 23:17:32 +0000 (01:17 +0200)]
Fix typo in the compile-type verification of `OBJCODE_COOKIE'.
* libguile/objcodes.c: Fix `sizeof (OBJCODE_COOKIE)' assertion: the
trailing 0 must not be taken into account, and multiple of 8 means the
3 LSBs are clear.
Ludovic Courtès [Tue, 14 Jul 2009 23:03:35 +0000 (01:03 +0200)]
Make sure at compile-time that `OBJCODE_COOKIE' has the right size.
* libguile/objcodes.c: Use `verify' to assert that the size of
`OBJCODE_COOKIE' is a multiple of 8.
Ludovic Courtès [Tue, 14 Jul 2009 22:58:01 +0000 (00:58 +0200)]
Explicitly use Gnulib's `verify' module.
* m4/gnulib-cache.m4: Add `verify'.
Ludovic Courtès [Tue, 14 Jul 2009 22:55:33 +0000 (00:55 +0200)]
Augment `OBJCODE_COOKIE' to detect wrong endianness or word size.
* libguile/objcodes.c (OBJCODE_ENDIANNESS, _OBJCODE_STRINGIFY,
OBJCODE_STRINGIFY, OBJCODE_WORD_SIZE): New macros.
(OBJCODE_COOKIE): Use them. The intent is that `.go' files compiled
for a different endianness or word size are detected.
Ludovic Courtès [Tue, 14 Jul 2009 22:32:05 +0000 (00:32 +0200)]
Remove the `long_long' and `ulong_long' types.
* libguile/gen-scmconfig.c (main): Don't emit typedefs for `long_long'
and `ulong_long'. This was already deprecated in 1.8 and known to
cause conflicts with other libraries such as HDF5, as reported by Mark
Patterson <mpatterson@physics.queensu.ca>
(http://lists.gnu.org/archive/html/bug-guile/2009-02/msg00003.html).
Andy Wingo [Tue, 14 Jul 2009 20:55:35 +0000 (22:55 +0200)]
update NEWS
* NEWS: Update.
Andy Wingo [Thu, 2 Jul 2009 15:46:23 +0000 (17:46 +0200)]
NEWS has info on 1.9.N to 1.9.N+1 in addition to 1.8 to 2.0
* NEWS: Update to have an incremental section in addition to a
comprehensive 1.8->2.0 section.
Andy Wingo [Thu, 2 Jul 2009 15:46:23 +0000 (17:46 +0200)]
fix race in which some instruction name symbols could go unmarked
* libguile/instructions.c: In loops, replace scm_op_last with
SCM_VM_NUM_INSTRUCTIONS.
(fetch_instruction_table): Protect the instruction symbols from
collection. Before they were only marked by the name->opcode hash
table, leading to races in which they could be collected.
(scm_lookup_instruction_by_name): Protect the hash table earlier, as
it's not actually a stack variable, since it's static.
Andy Wingo [Thu, 2 Jul 2009 15:43:07 +0000 (17:43 +0200)]
fix bounds checks for the last element of bv-*-{ref,set}
* libguile/vm-i-scheme.c (BV_FIXABLE_INT_REF, BV_INT_REF):
(BV_FLOAT_REF, BV_FIXABLE_INT_SET, BV_INT_SET, BV_FLOAT_SET): Fix the
bounds check for the last element.
Ludovic Courtès [Tue, 14 Jul 2009 15:12:04 +0000 (17:12 +0200)]
Remove potential "uninitialized variable" GCC warnings.
* libguile/vm-i-scheme.c (vector_ref, vector_set, BV_FIXABLE_INT_REF,
BV_INT_REF, BV_FLOAT_REF, BV_FIXABLE_INT_SET, BV_INT_SET,
BV_FLOAT_SET): Explicitly initialize all locals, to make some versions
of GCC happier. Patch by Dale P. Smith <dsmich@roadrunner.com>.
Ludovic Courtès [Tue, 14 Jul 2009 14:07:13 +0000 (16:07 +0200)]
Fix tests that assumed little endian.
* test-suite/tests/asm-to-bytecode.test (u32->u8-list): New procedure.
("compiler")[(load-program 3 2 1 0 () 3 #f (make-int8 3) (return)),
(load-program 3 2 1 0 () 3 (load-program 3 2 1 0 ...))]: Make these
tests work on hosts whose endianness is not little endian.
Ludovic Courtès [Sun, 5 Jul 2009 21:57:37 +0000 (23:57 +0200)]
Use Gnulib's `vsnprintf' module.
* m4/gnulib-cache.m4: Use `vsnprintf', needed by `deprecation.c'.
Ludovic Courtès [Sun, 5 Jul 2009 20:19:30 +0000 (22:19 +0200)]
Update `NEWS'.
* NEWS: Update.
Ludovic Courtès [Sun, 5 Jul 2009 19:13:51 +0000 (21:13 +0200)]
Enclose `bit-operations.test' in its own module.
* test-suite/tests/bit-operations.test: Use the `define-module' clause.
Ludovic Courtès [Sun, 5 Jul 2009 19:10:35 +0000 (21:10 +0200)]
Fix the `BUILD_PTHREAD_SUPPORT' Automake conditional when not using pthread.
* configure.in: Set $build_pthread_support to "no" when thread support
isn't built. This fixes the `BUILD_PTHREAD_SUPPORT' Automake
conditional.
Andy Wingo [Thu, 2 Jul 2009 19:55:28 +0000 (21:55 +0200)]
fix error message for bad objcode cookie
* libguile/objcodes.c: Whoop-dee :)
Neil Jerram [Wed, 1 Jul 2009 00:39:24 +0000 (01:39 +0100)]
Read complex numbers where both parts are inexact decimals
Thanks to Bill Schottstaedt for reporting this problem!
* libguile/numbers.c (mem2ureal): Don't be misled by *p_exactness
being INEXACT on entry (as is possible when reading a complex
number): use local exactness variable x which starts as EXACT.
Call mem2decimal_from_point () with &x instead of p_exactness.
* test-suite/tests/numbers.test ("string->number"): Add complex number
tests suggested by Bill.
Neil Jerram [Tue, 30 Jun 2009 22:56:40 +0000 (23:56 +0100)]
Correction to doc on Accessing Arrays from C
Thanks to Ludovic for the new wording!
* doc/ref/api-compound.texi (Accessing Arrays from C): Correct text to
reflect the current implementation of scm_array_get_handle and
scm_array_handle_release - which don't actuall do any dynwind stuff.
Ludovic Courtès [Sun, 28 Jun 2009 21:33:17 +0000 (23:33 +0200)]
Remove seek/truncate shortcuts to file ports.
Suggested by Neil.
* libguile/fports.c (fport_seek_or_seek64): Rename to `fport_seek ()'.
(fport_seek, scm_i_fport_seek, scm_i_fport_truncate): Remove.
* libguile/fports.h (scm_i_fport_seek, scm_i_fport_truncate): Remove
declarations.
* libguile/ports.c (scm_seek): Remove shortcut that would call out to
`scm_i_fport_seek ()'.
(scm_truncate_file): Likewise.
Andy Wingo [Fri, 26 Jun 2009 10:41:34 +0000 (12:41 +0200)]
bytevector ops now compile down to low-level VM ops
* libguile/instructions.c (scm_instruction_list): Fix a longstanding bug
in this humble function.
* libguile/vm-i-scheme.c (BV_FIXABLE_INT_SET, BV_INT_SET, BV_FLOAT_SET):
Fix some bugs in these macros -- now the bytevector ops work.
* module/language/tree-il/compile-glil.scm (*primcall-ops*): Compile
bytevector calls to VM ops.
* module/language/tree-il/primitives.scm
(*interesting-primitive-names*): Resolve bytevector calls to primitive
calls.
Andy Wingo [Fri, 26 Jun 2009 09:12:37 +0000 (11:12 +0200)]
run bytevectors tests under the compiler and evaluator
* test-suite/tests/bytevectors.test: Run a number of tests under the
compiler/vm and the evaluator.
Andy Wingo [Thu, 25 Jun 2009 22:15:37 +0000 (00:15 +0200)]
vector-ref and vector-set! now have opcodes
* module/language/tree-il/primitives.scm
(*interesting-primitive-names*): Resolve vector-ref and vector-set!.
* module/language/tree-il/compile-glil.scm (*primcall-ops*): And compile
vector-ref and vector-set! to their opcodes.
* libguile/vm-i-scheme.c (vector-ref, vector-set): New opcodes, placed
before the bytevector ops. The renumbering shouldn't affect anyone,
given that the bytevector ops were not yet used. Fix a few bugs in the
bytevector ops.
Andy Wingo [Wed, 24 Jun 2009 21:49:11 +0000 (23:49 +0200)]
add bytevector ops to the vm
* libguile/instructions.h (SCM_VM_NUM_INSTRUCTIONS): Enlarge to 255. Not
sure what performance effects this will have.
* libguile/vm-engine.c: Add new error case, vm_error_not_a_bytevector.
* libguile/vm-engine.h: Don't assign specific registers for i386. Having
added the new VM vector ops, GCC 4.4 is erroring for me now.
* libguile/vm-i-scheme.c: Add bytevector-specific ops to the VM.
We don't actually use them yet, though.
Andy Wingo [Wed, 24 Jun 2009 21:46:42 +0000 (23:46 +0200)]
bytevectors provide scm_i_native_endianness to the vm
* libguile/bytevectors.h (scm_i_native_endianness): Allow the VM to use
scm_i_native_endianness, but still keep it marked as internal.
* libguile/bytevectors.c: Adjust to use scm_i_native_endianness instead
of native_endianness. Define it at bootstrap time.
Andy Wingo [Wed, 24 Jun 2009 21:44:03 +0000 (23:44 +0200)]
minor doc tweaks
* doc/ref/api-compound.texi: Generalized vector doc fixups.
* doc/ref/api-data.texi: Minor fixes to bytevector docs.
Neil Jerram [Thu, 25 Jun 2009 22:24:57 +0000 (23:24 +0100)]
Revert "* FAQ: New file."
This reverts commit
d53f85dd859fa69af8a0b67482774d2a88aaf407.
It was a confusing mistake to create an FAQ file in the Guile
repository/distribution, because there was already an FAQ page on the
Guile web site. The information that was in the FAQ file is now in
the FAQ web page.
Ludovic Courtès [Thu, 25 Jun 2009 21:32:44 +0000 (23:32 +0200)]
Add `scm_t_off' type so that `scm_t_port' has a fixed layout.
* libguile/gen-scmconfig.c (main): Produce a definition for
`scm_t_off'.
* libguile/ports.h (scm_t_port)[read_buf_size, saved_read_buf_size,
write_buf_size, seek, truncate]: Use `scm_t_off' instead of `off_t' so
that the layout and size of the structure does not depend on the
application's `_FILE_OFFSET_BITS' value. Reported by Bill
Schottstaedt, see
http://lists.gnu.org/archive/html/bug-guile/2009-06/msg00018.html.
(scm_set_port_seek, scm_set_port_truncate): Update.
* libguile/ports.c (scm_set_port_seek, scm_set_port_truncate): Use
`scm_t_off' and `off_t_or_off64_t'.
* libguile/fports.c (fport_seek, fport_truncate): Use `scm_t_off'
instead of `off_t'.
* libguile/r6rs-ports.c (bip_seek, cbp_seek, bop_seek): Use `scm_t_off'
instead of `off_t'.
* libguile/rw.c (scm_write_string_partial): Likewise.
* libguile/strports.c (st_resize_port, st_seek, st_truncate): Likewise.
* doc/ref/api-io.texi (Port Implementation): Update prototype of
`scm_set_port_seek ()' and `scm_set_port_truncate ()'.
* NEWS: Update.
Ludovic Courtès [Thu, 25 Jun 2009 20:45:12 +0000 (22:45 +0200)]
Fix `load-objcode' FD/mapping leak occurring upon failure.
* libguile/objcodes.c (make_objcode_by_mmap): Close FD and unmap ADDR
upon failure.
Andy Wingo [Wed, 24 Jun 2009 13:14:00 +0000 (15:14 +0200)]
allow primcall ops to push 0 values
* libguile/objcodes.c (OBJCODE_COOKIE): Bump the objcode cookie. We'll
be doing this on incompatible changes until 2.0.
* libguile/vm-i-scheme.c (set_car, set_cdr, slot_set): These
instructions don't have natural return values -- so declare them that
way, that they push 0 values.
* module/language/tree-il/compile-glil.scm (flatten): When compiling
primitive calls, check `(instruction-pushes op)' to see how many
values that instruction will push, and do something appropriate,
instead of just assuming that all primcall ops push 1 value.
Andy Wingo [Wed, 24 Jun 2009 11:42:59 +0000 (13:42 +0200)]
remove lambda wrap hack of brainfuck tree-il compiler
* module/language/brainfuck/compile-tree-il.scm (compile-tree-il):
Remove the hack where we wrapped the compiled code in a `lambda',
because not only should the tree-il compiler optimize that away, it
was really papering around other inefficiencies, and obtuse to boot.
Neil Jerram [Thu, 18 Jun 2009 19:35:45 +0000 (20:35 +0100)]
Remove AC_SYS_RESTARTABLE_SYSCALLS and related code
As the Autoconf documentation says, "These days portable programs
[...] should not rely on `HAVE_RESTARTABLE_SYSCALLS', since nowadays
whether a system call is restartable is a dynamic issue, not a
configuration-time issue."
In other words, if we ever rely on HAVE_RESTARTABLE_SYSCALLS, we are
at the mercy of any code that Guile happens to be linked with, because
that code could install a signal handler without the SA_RESTART flag,
and then a Guile system call could unexpectedly return EINTR.
The readline part of this goes back to this problem report:
http://sources.redhat.com/ml/guile/2000-05/msg00177.html; and is an
excellent example of the above paragraph. It was noted during the
discussion that undefining HAVE_RESTARTABLE_SYSCALLS would fix the
problem, but that solution wasn't adopted - I guess because Guile was
still using cooperative threads then (not pthreads) and so there was a
significant concern (whether founded or not) that not using
restartable syscalls (where available) could lead to a loss of
performance.
Now Guile's default mode of operation is with pthreads, where we
already don't assume that HAVE_RESTARTABLE_SYSCALLS is reliable, so
there is no possible further performance loss. And in any case we
really have no choice, if we want correct operation.
Thanks to Sylvain Beucler for reporting this and suggesting the fix.
* configure.in (AC_SYS_RESTARTABLE_SYSCALLS): Removed.
* doc/ref/posix.texi (Signals): Remove statement that Guile always
sets SA_RESTART flag.
* guile-readline/configure.in (GUILE_SIGWINCH_SA_RESTART_CLEARED):
Remove this setting, together with its test code.
(HAVE_RL_PRE_INPUT_HOOK): Remove this setting and its code, as no
longer needed.
* guile-readline/readline.c (sigwinch_enable_restart): Removed.
(scm_init_readline): Remove setting of rl_pre_input_hook.
* libguile/_scm.h (SCM_SYSCALL): Remove the definition that relies on
HAVE_RESTARTABLE_SYSCALLS.
* libguile/scmsigs.c (scm_sigaction_for_thread): Don't always set the
SA_RESTART flag if available. Update docstring accordingly.
(scm_init_scmsigs): Remove code that sets SA_RESTART flag for all
signals.
* THANKS: Add Sylvain.
Andy Wingo [Mon, 22 Jun 2009 20:57:48 +0000 (22:57 +0200)]
flush whitespace from the repl input buffer *before* evaluation
* module/system/repl/repl.scm (start-repl): Given that the input port of
the repl is line-buffered, it's likely we have #\newline in the input
that is strictly extraneous, an in-band indicator to the repl that it
should begin reading now. So flush out that newline, so that you can
(read-char) at the repl, and it actually does wait for you to type in
a char instead of just returning #\newline.
While it's not an overriding concern, this does fix some brainfuck
programs that want to input from the user.
Andy Wingo [Mon, 22 Jun 2009 20:44:34 +0000 (22:44 +0200)]
more docs to brainfuck->tree-il compiler
* module/language/brainfuck/compile-tree-il.scm (compile-tree-il): Wrap
the result in a ((lambda () ...)), so we can use toplevel-ref. Add
lots more comments.
Andy Wingo [Mon, 22 Jun 2009 18:45:01 +0000 (20:45 +0200)]
meta-commands read off their own arguments
* module/system/repl/command.scm: Update copyright.
(meta-command): Rework so that it's the various meta-commands that do
the reading for their arguments. This way you can compile forms that
span more than one line, and forms that need to be read with another
language's reader.
(define-meta-command): New helper macro. Update commands to use it.
(help): Allow ,help on commands too.
* module/system/repl/repl.scm: Update copyright.
(start-repl): Adjust to give meta-command what it wants.
Ludovic Courtès [Sun, 21 Jun 2009 22:56:00 +0000 (00:56 +0200)]
Always create the bytevector SMOB type.
* libguile/bytevectors.c (scm_tc16_bytevector, print_bytevector,
bytevector_equal_p, free_bytevector): Don't use the snarfing macros.
(scm_bootstrap_bytevectors): New.
(scm_init_bytevectors): No longer initialize SCM_NULL_BYTEVECTOR,
which is done by `scm_bootstrap_bytevectors ()'.
* libguile/bytevectors.h (scm_bootstrap_bytevectors): New declaration.
(scm_init_bytevectors): Made internal. This can be done because we
explicitly register it with `scm_c_register_extension ()' in
`scm_bootstrap_bytevectors ()'.
* libguile/init.c (scm_i_init_guile): Call `scm_bootstrap_bytevectors ()'.
This is so that expressions like "(generalized-vector-length #vu8())"
work even when `(rnrs bytevector)' hasn't been loaded.
Ludovic Courtès [Sun, 21 Jun 2009 22:51:08 +0000 (00:51 +0200)]
Make bytevectors accessible using the generalized-vector API.
As a side effect, this allows compilation of literal bytevectors
("#vu8(...)"), which gets done by the generic array handling
of the GLIL->assembly compiler.
* doc/ref/api-compound.texi (Generalized Vectors): Mention bytevectors.
(Arrays, Array Syntax): Likewise.
* doc/ref/api-data.texi (Bytevectors as Generalized Vectors): New node.
* libguile/bytevectors.c (scm_i_bytevector_generalized_set_x): New.
* libguile/bytevectors.h (scm_i_bytevector_generalized_set_x): New
declaration.
* libguile/srfi-4.c (scm_i_generalized_vector_type,
scm_array_handle_uniform_element_size,
scm_array_handle_uniform_writable_elements): Add support for
bytevectors.
* libguile/unif.c (type_creator_table): Add `vu8'.
(bytevector_ref, bytevector_set): New functions.
(memoize_ref, memoize_set): Add support for bytevectors.
* libguile/vectors.c (scm_is_generalized_vector,
scm_c_generalized_vector_length, scm_c_generalized_vector_ref,
scm_c_generalized_vector_set_x): Add support for bytevectors.
* test-suite/tests/bytevectors.test ("Generalized Vectors"): New test
set.
Ludovic Courtès [Sun, 21 Jun 2009 21:16:57 +0000 (23:16 +0200)]
bytevectors: Add a C-friendly API.
* doc/ref/api-data.texi (Bytevector Manipulation): Add
`scm_is_bytevector ()', `scm_c_bytevector_length ()',
`scm_c_bytevector_length ()', and `scm_c_bytevector_set_x ()'.
* libguile/bytevectors.c (scm_is_bytevector, scm_c_bytevector_length,
scm_c_bytevector_ref, scm_c_bytevector_set_x): New functions.
(scm_bytevector_p): Use `scm_is_bytevector ()'.
(scm_bytevector_length): Use `scm_c_bytevector_length ()'.
* libguile/bytevectors.h (scm_is_bytevector, scm_c_bytevector_length,
scm_c_bytevector_ref, scm_c_bytevector_set_x): New declarations.
Ludovic Courtès [Sun, 21 Jun 2009 14:55:58 +0000 (16:55 +0200)]
bytevectors: Use `size_t' rather than `unsigned' for sizes.
* doc/ref/api-data.texi (Bytevector Manipulation): Update.
* libguile/bytevectors.c (INTEGER_ACCESSOR_PROLOGUE,
make_bytevector_from_buffer, scm_c_make_bytevector,
scm_c_take_bytevector, scm_i_shrink_bytevector): Use `size_t' for
bytevector lengths.
Ludovic Courtès [Sun, 21 Jun 2009 21:32:19 +0000 (23:32 +0200)]
Fix documentation of `make-bytevector'.
* doc/ref/api-data.texi (Bytevector Manipulation): Fix documentation of
the FILL argument of `make-bytevector'.
Andy Wingo [Sun, 21 Jun 2009 12:53:33 +0000 (14:53 +0200)]
add brainfuck->tree-il compiler
* module/Makefile.am (BRAINFUCK_LANG_SOURCES): Compile at the end. Add
compile-tree-il.scm.
* module/language/brainfuck/compile-tree-il.scm: New compiler, compiles
to tree-il instead of scheme. I thought it would be more illustrative,
though there are some uncommented bits.
* module/language/brainfuck/parse.scm: Modify not to put a header on the
scheme representation. After all, we don't put <scheme> before scheme
code, do we? :)
* module/language/brainfuck/spec.scm: Add tree-il compiler.
* module/language/tree-il.scm: Understand (set! (lexical foo) ...).
* module/system/base/language.scm: Update license. Actually, updates
licenses on all these.
Andy Wingo [Sun, 21 Jun 2009 11:36:39 +0000 (13:36 +0200)]
formatting changes to (language brainfuck compile-scheme)
* module/language/brainfuck/compile-scheme.scm: Standalone comments
should have more than one semicolon, and update copyright to LGPLv3+.
Andy Wingo [Sun, 21 Jun 2009 11:10:56 +0000 (13:10 +0200)]
link to brainfuck wikipedia page
* doc/ref/compiler.texi: Point to more info on Brainfuck. Patch by
Daniel Kraft.
Daniel Kraft [Sat, 23 May 2009 07:58:54 +0000 (09:58 +0200)]
added documenting comments to the brainfuck compiler and mention it in the VM documentation.
* doc/ref/compiler.texi: Mention the new brainfuck compiler as an example.
* module/language/brainfuck/compile-scheme.scm: Add a lot of documentation comments.
* module/language/brainfuck/parse.scm: Ditto.
* module/language/brainfuck/spec.scm: Ditto.
Daniel Kraft [Sat, 23 May 2009 07:58:54 +0000 (09:58 +0200)]
basic brainfuck -> scheme example compiler.
* module/Makefile.am: Install the brainfuck compiler modules.
* module/language/brainfuck/spec.scm: New file.
* module/language/brainfuck/parse.scm: New file.
* module/language/brainfuck/compile-scheme.scm: New file.
Andy Wingo [Sun, 21 Jun 2009 10:57:55 +0000 (12:57 +0200)]
remove obsolete guile-vm.texi
* doc/guile-vm.texi: Remove, has been folded into the Guile manual for a
while now.
* doc/Makefile.am: Remove guile-vm.texi.
Andy Wingo [Sun, 21 Jun 2009 10:51:16 +0000 (12:51 +0200)]
update .gitignore
* .gitignore: Update.
Neil Jerram [Sun, 21 Jun 2009 12:31:20 +0000 (13:31 +0100)]
Deterministic test for the r6rs-ports.test segmentation fault
* test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports"): Add (gc), to
test the (ex-)bug in cbp_mark () when marking a closed port.
Andy Wingo [Sun, 21 Jun 2009 10:41:46 +0000 (12:41 +0200)]
Fix crash when marking closed custom bytevector port
* libguile/r6rs-ports.c (cbp_mark): A closed port will have had its
stream destroyed, so don't dereference the stream in that case. Patch by
Mike Gran.
Andy Wingo [Sat, 20 Jun 2009 12:26:54 +0000 (14:26 +0200)]
put autocompiled files into ~/.cache or $XDG_CACHE_HOME
* module/system/base/compile.scm (compiled-file-name): Remove unneeded
path separator.
* libguile/load.c (scm_init_load_path): Change so the default cache path
is ~/.cache/guile/ccache/1.9, and respect $XDG_CACHE_HOME.
Andy Wingo [Sat, 20 Jun 2009 10:41:11 +0000 (12:41 +0200)]
fix source information lossage for (define (foo) ...) lambda sugar
* module/ice-9/psyntax.scm (source-wrap): Use decorate-source, for
clarity.
(syntax-type): When turning the RHS of (define (foo) ...) into a
lambda, decorate the resulting lambda expression with source
information, as the RHS later goes to chi-expr, which receives no
source information. Perhaps that is a bug. In any case, fixes some
source location lossage, reported by Jao.
* module/ice-9/psyntax-pp.scm: Regenerated.
Andy Wingo [Sat, 20 Jun 2009 09:41:50 +0000 (11:41 +0200)]
better error in make_objcode_by_mmap
* libguile/objcodes.c (make_objcode_by_mmap): Better error when the
object header is incorrect.
Andy Wingo [Sat, 20 Jun 2009 08:47:37 +0000 (10:47 +0200)]
source information for the interpreter
* module/ice-9/psyntax.scm: Try to propagate source information when
generating output for the interpreter.
* module/ice-9/psyntax-pp.scm: Regenerate.
Ludovic Courtès [Fri, 19 Jun 2009 20:46:07 +0000 (22:46 +0200)]
Make `cond-expand' compilable.
* module/ice-9/boot-9.scm (cond-expand): Changed into a `define-macro'
macro.
Ludovic Courtès [Fri, 19 Jun 2009 20:01:56 +0000 (22:01 +0200)]
Fix copyright year and authorship of `guile-tools'.
Ludovic Courtès [Fri, 19 Jun 2009 19:55:53 +0000 (21:55 +0200)]
Slightly improve `NEWS'.
Ludovic Courtès [Fri, 19 Jun 2009 19:54:51 +0000 (21:54 +0200)]
Fix "guile-tools disassemble".
* module/scripts/disassemble.scm (disassemble): Accept a variable number
of arguments. Invoke the right `disassemble' procedure.
Andy Wingo [Fri, 19 Jun 2009 12:27:56 +0000 (14:27 +0200)]
don't autocompile at installcheck
* examples/Makefile.am: Don't autocompile our tests at installcheck
time.
Andy Wingo [Fri, 19 Jun 2009 12:26:47 +0000 (14:26 +0200)]
new function: canonicalize-path. use when autocompiling
* libguile/filesys.h:
* libguile/filesys.c (scm_canonicalize_path): New function,
canonicalize-path.
* module/system/base/compile.scm (compiled-file-name): Canonicalize the
filename so that compiling e.g. ../foo.scm doesn't compile to
~/.guile-ccache/1.9/../foo.scm.
Andy Wingo [Fri, 19 Jun 2009 11:01:11 +0000 (13:01 +0200)]
gnulib-tool --import canonicalize-lgpl
Andy Wingo [Fri, 19 Jun 2009 10:32:01 +0000 (12:32 +0200)]
generate changelogs at dist time
* Makefile.am: Add rule to make a ChangeLog at dist-time. The rule comes
from coreutils.
* build-aux/gitlog-to-changelog: New helper script, from gnulib.
Andy Wingo [Fri, 19 Jun 2009 09:20:34 +0000 (11:20 +0200)]
rename SCM_SNAME to SCM_SUBR_NAME
* libguile/procs.h: Rename SCM_SNAME to SCM_SUBR_NAME.
* libguile/debug.c:
* libguile/eval.c:
* libguile/eval.i.c:
* libguile/goops.c:
* libguile/gsubr.c:
* libguile/print.c:
* libguile/procs.c: Update callers.
Andy Wingo [Fri, 19 Jun 2009 09:19:34 +0000 (11:19 +0200)]
another draft of NEWS
* NEWS: Another draft.
Ludovic Courtès [Fri, 19 Jun 2009 00:35:57 +0000 (02:35 +0200)]
Fix decompilation of the `load-array' instruction.
This allows, e.g., ",c #u8(1 2 3)" at the REPL to actually work instead
of failing to decode `load-array'.
* module/language/assembly/decompile-bytecode.scm (decode-bytecode):
Account for the `load-array' instruction, which is followed by a
bytevector instead of a string. We should find a more elegant way to
do that.
Ludovic Courtès [Fri, 19 Jun 2009 00:14:22 +0000 (02:14 +0200)]
Fix the REPL's `,compile' command.
* module/system/repl/command.scm (compile): Use `guile:disassemble'
instead of the former `disassemble-objcode'.
Ludovic Courtès [Thu, 18 Jun 2009 22:47:11 +0000 (00:47 +0200)]
Implement R6RS bytevector read syntax.
* libguile/read.c (scm_read_bytevector): New function.
(scm_read_sharp): Add `v' case for bytevectors.
* test-suite/lib.scm (exception:read-error): New variable.
* test-suite/tests/bytevectors.test ("Datum Syntax"): New test set.
Ludovic Courtès [Thu, 18 Jun 2009 22:10:21 +0000 (00:10 +0200)]
Fix `equal?' on bytevectors.
* libguile/bytevectors.c (bytevector_equal_p): New function.
* test-suite/tests/bytevectors.test ("2.3 Operations on Bytes and
Octets")["equal?"]: New test.
Ludovic Courtès [Thu, 28 May 2009 21:57:31 +0000 (23:57 +0200)]
Import documentation for the R6RS bytevector and port APIs.
* doc/ref/api-compound.texi (Uniform Numeric Vectors): Add xref to the
bytevector API.
* doc/ref/api-data.texi (Bytevectors): New node.
* doc/ref/api-io.texi (R6RS I/O Ports): New node.
Andy Wingo [Thu, 18 Jun 2009 21:02:51 +0000 (23:02 +0200)]
update NEWS, THANKS
* NEWS: Update, but only partially. I wanted to push out this
incomplete, not yet organized draft for review, if anyone had
comments. I'll pick it up tomorrow morning.
* THANKS: Add Juhani, whose last name changed?
Neil Jerram [Wed, 17 Jun 2009 21:35:30 +0000 (22:35 +0100)]
Change guile-readline license to GPLv3+
Neil Jerram [Wed, 17 Jun 2009 21:30:26 +0000 (22:30 +0100)]
Complete changing license to LGPLv3+
(Still guile-readline to do, but that will all be GPLv3+.)
Neil Jerram [Wed, 17 Jun 2009 20:34:38 +0000 (21:34 +0100)]
Reinstate lines removed by mistake from chars.test
Neil Jerram [Tue, 16 Jun 2009 23:22:09 +0000 (00:22 +0100)]
Change Guile license to LGPLv3+
(Not quite finished, the following will be done tomorrow.
module/srfi/*.scm
module/rnrs/*.scm
module/scripts/*.scm
testsuite/*.scm
guile-readline/*
)
Neil Jerram [Sun, 14 Jun 2009 17:41:50 +0000 (18:41 +0100)]
Update README on using libraries in non-standard locations
* README: Update instructions on using libraries in non-standard
locations. Also change expected next stable release number from
1.10.0 to 2.0.0.
Neil Jerram [Sun, 14 Jun 2009 17:07:01 +0000 (18:07 +0100)]
Add Tex and texinfo output and auxiliary suffixes to .gitignore
Neil Jerram [Sun, 14 Jun 2009 16:58:15 +0000 (17:58 +0100)]
Provide easier configure options for GMP and readline
This patch uses the AC_LIB_LINKFLAGS macro, provided by Gnulib's
havelib module, to provide --with-gmp-prefix and
--with-readline-prefix configure options. Many thanks to Bruno Haible
for suggesting and explaining this to me.
* configure.in (top level): Add AC_LIB_LINKFLAGS(gmp).
* guile-readline/configure.in (AC_CONFIG_AUX_DIR): Change to
../build-aux, to share the main build-aux directory and so avoid
having to distribute multiple copies of config.rpath.
(top level): Add AC_LIB_LINKFLAGS(readline).
* lib/Makefile.am, m4/gnulib-cache.m4: Regenerated by gnulib-tool for
new import of the `havelib' module.
Neil Jerram [Sat, 13 Jun 2009 09:45:45 +0000 (10:45 +0100)]
Fix for make distcheck
* examples/Makefile.am (AM_CFLAGS, AM_LIBS): Set PATH so that
guile-config can find guile.