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

32 commits

Author SHA1 Message Date
Ludovic Courtès
438974d08d 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.
2009-06-22 01:09:39 +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
Neil Jerram
b5cb4464ca Make multi-byte reads on unbuffered ports more efficient.
Idea and original patch were by Ludovic Courts, this is Neil Jerram's
reworking of it.

	* libguile/srfi-4.c (scm_uniform_vector_read_x): Use scm_c_read,
	instead of equivalent code here.

	* libguile/ports.c (scm_fill_input): Add assertion that read
	buffer is empty when called.
	(port_and_swap_buffer, swap_buffer): New, for...
	(scm_c_read): Use caller's buffer for reading, to avoid making N
	1-byte low-level read calls, in the case where the port is
	unbuffered (or has a very small buffer).
2008-09-15 18:52:51 +01:00
Ludovic Courtès
dbb605f575 Include <config.h> in all C files; use #ifdef HAVE_CONFIG_H' rather than #if'. 2008-09-13 15:35:27 +02:00
Marius Vollmer
b0c0a310db Replace SCM_C_INLINE with SCM_C_INLINE_KEYWORD. Thanks to Mark Gran! 2006-05-27 21:32:22 +00:00
Kevin Ryde
2b829bbb3d merge from 1.8 branch 2006-04-17 00:05:42 +00:00
Marius Vollmer
ab7acbb74e (take_uvec): Make BASE pointer non-const.
(scm_take_u8vector, etc): Likewise.  Thanks to Ludovic Courtès!
2005-12-06 21:42:19 +00:00
Marius Vollmer
92205699d0 The FSF has a new address. 2005-05-23 19:57:22 +00:00
Marius Vollmer
69d2000d93 Docstring updates. 2005-03-04 17:55:49 +00:00
Marius Vollmer
9de87eea47 See ChangeLog from 2005-03-02. 2005-03-02 20:42:01 +00:00
Marius Vollmer
00c17d4526 (scm_take_u64vector,
scm_array_handle_u64_elements,
scm_array_handle_u64_writable_elements, scm_u64vector_elements,
scm_u64vector_writable_elements): Do not define when scm_t_uint64
is not available.
(scm_take_s64vector, scm_array_handle_s64_elements,
scm_array_handle_s64_writable_elements, scm_s64vector_elements,
scm_s64vector_writable_elements): Likewise for scm_t_int64.
(uvec_sizes, uvec_print, uvec_equalp): Use SCM bignums when
scm_t_int64/scm_t_uint64 are not available.
(uvec_mark): New, to mark the bignums.
(alloc_uvec): Initialize bignums.
(uvec_fast_ref): Return bignums directly.
(scm_uint64_min, scm_uint64_max, scm_int64_min, scm_int64_max,
assert_exact_integer): New.
(uvec_fast_set): Use them to validate the bignums.
(scm_init_srfi_4): Set mark function of smob when needed.
Initialize scm_uint64_min, scm_uint64_max, scm_int64_min,
scm_int64_max.
2005-01-14 18:19:13 +00:00
Marius Vollmer
04b87de561 (SCM_ARRAYP, SCM_I_ARRAYP): Renamed former to latter internal
version.  Changed all uses.
(scm_tc16_array, scm_i_tc16_array,
scm_tc16_enclosed_array, scm_i_tc16_enclosed_array,
SCM_ARRAY_FLAG_CONTIGUOUS, SCM_I_ARRAY_FLAG_CONTIGUOUS,
SCM_ENCLOSE_ARRAYP, SCM_I_ENCLOSE_ARRAYP,
SCM_ARRAY_NDIM, SCM_I_ARRAY_NDIM,
SCM_ARRAY_CONTP, SCM_I_ARRAY_CONTP,
SCM_ARRAY_MEM, SCM_I_ARRAY_MEM,
SCM_ARRAY_V, SCM_I_ARRAY_V,
SCM_ARRAY_BASE, SCM_I_ARRAY_BASE,
SCM_ARRAY_DIMS, SCM_I_ARRAY_DIMS,
scm_t_array, scm_i_t_array): Likewise.
(SCM_SET_ARRAY_CONTIGUOUS_FLAG, SCM_CLR_ARRAY_CONTIGUOUS_FLAG):
Moved from unif.h to unif.c.
(scm_c_array_rank): New.
(scm_array_rank): Reimplement using it.
2005-01-11 16:55:38 +00:00
Marius Vollmer
4e8ad32394 (coerce_to_uvec, scm_c_uniform_vector_ref,
scm_c_uniform_vector_set_x): Use generic scm_array_handle_ref/set
instead of uvec_fast_ref/set since scm_array_handle_ref should be
faster now.
2005-01-09 22:37:50 +00:00
Marius Vollmer
4ea4bc4c40 * srfi-4.h, srfi-4.c, srfi-4.i.c (scm_i_uniform_vector_ref_proc,
scm_i_uniform_vector_set_proc): New.
(u8ref, u8set, s8ref, s8set, etc): New.
(uvec_reffers, uvec_setters): New.
(uvec_to_list): Use generic scm_array_handle_ref instead of
uvec_fast_ref since scm_array_handle_ref should be faster now.
More changes like this are upcoming.
2005-01-09 22:06:56 +00:00
Marius Vollmer
7c2ef9a87b (scm_uniform_element_size): Deprecated implementation
as well.
2005-01-09 17:43:14 +00:00
Marius Vollmer
5e320e5926 (uvec_type): New.
(uvec_to_list, uvec_ref, uvec_set_x, scm_c_uniform_vector_ref,
scm_c_uniform_vector_x): Use it to get concrete type.
2005-01-09 15:45:21 +00:00
Marius Vollmer
6e433d8b8f Include deprecation.h. 2005-01-07 15:44:45 +00:00
Marius Vollmer
4330ee2502 (SCM_IS_UVEC): New, use it instead of
SCM_SMOB_PREDICATE in this file.
(is_uvec): Also recognize one-dimensional uniform numeric arrays
of the right type.
(scm_is_uniform_vector): Likewise.
(uvec_fast_ref): Made BASE param const.
(uvec_writable_elements, uvec_elements): New.
(uvec_to_list, uvec_ref, uvec_set_x, uvec_length,
scm_c_uniform_vector_length, scm_c_uniform_vector_ref,
scm_c_uniform_set_x): Use them to also deal with one-dimensional
arrays.
(scm_uniform_vector_ref, scm_uniform_vector_set_x): Deprecate old
argument convention.
(scm_uniform_vector_to_list): Let uvec_to_list do all the
checking.
(scm_uniform_vector_length): Use uvec_length.
2005-01-07 00:28:33 +00:00
Marius Vollmer
fea99690f2 (scm_c_uniform_vector_element_size,
scm_c_uniform_vector_size): Removed.
(scm_array_handle_uniform_element_size): New.
2005-01-06 18:44:08 +00:00
Marius Vollmer
6e708ef2b1 * weaks.c: Use new vector elements API or simple vector
API, as appropriate.

* srfi-4.h, srfi-4.c, srfi-4.i.c (scm_array_handle_uniform_elements,
scm_array_handle_uniform_writable_elements,
scm_uniform_vector_elements, scm_uniform_vector_writable_elements):
(scm_<foo>vector_elements, scm_<foo>vector_writable_elements): Use
scm_t_array_handle, deliver length and increment.
(scm_array_handle_<foo>_elements,
scm_array_handle_<foo>_writable_elements): New.

* unif.h, unif.c (scm_t_array_handle, scm_array_get_handle,
scm_array_handle_rank, scm_array_handle_dims, scm_array_handle_ref
scm_array_handle_set, scm_array_handle_elements
scm_array_handle_writable_elements, scm_vector_get_handle): New.
(scm_make_uve, scm_array_prototype, scm_list_to_uniform_array,
scm_dimensions_to_uniform_array): Deprecated for real.  (scm_array_p,
scm_i_array_p): Use latter for SCM_DEFINE since snarfing wont allow a
mismatch between C and Scheme arglists.  (scm_make_shared_array,
scm_enclose_array): Correctly use scm_c_generalized_vector_length
instead of scm_uniform_vector_length.

* weaks.h, weaks.c: Use new internal weak vector API from
vectors.h.

* Makefile.am (libguile_la_SOURCES, DOT_X_FILES, DOT_DOC_FILES,
EXTRA_libguile_la_SOURCES): Changed ramap.c and unif.c from being
'extra' to being regular sources.
(noinst_HEADERS): Added quicksort.i.c.
* quicksort.i.c: New file.

* vectors.h, vector.c (SCM_VECTORP, SCM_VECTOR_LENGTH, SCM_VELTS,
SCM_WRITABLE_VELTS, SCM_VECTOR_REF, SCM_VECTOR_SET): Deprecated and
reimplemented.  Replaced all uses with scm_vector_elements,
scm_vector_writable_elements, or SCM_SIMPLE_VECTOR_*, as appropriate.
(scm_is_simple_vector, SCM_SIMPLE_VECTOR_LENGTH,
SCM_SIMPLE_VECTOR_REF, SCM_SIMPLE_VECTOR_SET, SCM_SIMPLE_VECTOR_LOC):
New.  (SCM_VECTOR_BASE, SCM_SET_VECTOR_BASE, SCM_VECTOR_MAX_LENGTH,
SCM_MAKE_VECTOR_TAG, SCM_SET_VECTOR_LENGTH, SCM_VELTS_AS_STACKITEMS,
SCM_SETVELTS, SCM_GC_WRITABLE_VELTS): Removed.  (scm_vector_copy):
New.  (scm_vector_elements, scm_vector_writable_elements): Use
scm_t_array_handle, deliver length and increment.  Moved to
unif.h. Changed all uses.  (scm_vector_release_elements,
scm_vector_release_writable_elements,
(scm_frame_vector_release_elements,
scm_frame_vector_release_writable_elements): Removed.
(SCM_I_IS_VECTOR, SCM_I_VECTOR_ELTS, SCM_I_VECTOR_WELTS,
SCM_I_VECTOR_LENGTH, scm_i_vector_free): New internal API.
(SCM_I_WVECTP SCM_I_WVECT_LENGTH SCM_I_WVECT_VELTS
SCM_I_WVECT_GC_WVELTS SCM_I_WVECT_TYPE SCM_I_WVECT_GC_CHAIN
SCM_I_SET_WVECT_GC_CHAIN, scm_i_allocate_weak_vector): New, for weak
vectors.
2005-01-02 20:06:08 +00:00
Marius Vollmer
f301dbf34a * srfi-4.h (scm_i_proc_make_u8vector, scm_i_proc_make_s8vector,
scm_i_proc_make_u16vector, scm_i_proc_make_s16vector,
scm_i_proc_make_u32vector, scm_i_proc_make_s32vector,
scm_i_proc_make_u64vector, scm_i_proc_make_s64vector,
scm_i_proc_make_f32vector, scm_i_proc_make_f64vector,
scm_i_proc_make_c32vector, scm_i_proc_make_c64vector,
uvec_proc_vars): Removed.
(scm_i_generalized_vector_creator): Removed.
(scm_i_generalized_vector_type): New.

* unif.h, unif.c (scm_typed_array_p, scm_make_array,
scm_make_typed_array, scm_array_type, scm_list_to_array,
scm_list_to_typed_array, scm_is_array, scm_is_typed_array): New.
(scm_array_creator): Removed.
(scm_array_p): Deprecated second PROT argument.
(scm_dimensions_to_uniform_array, scm_list_to_uniform_array):
Deprecated, reimplemented in terms of scm_make_typed_array and
scm_list_to_typed_array.
(scm_i_proc_make_vector, scm_i_proc_make_string,
scm_i_proc_make_bitvector): Removed.
(type_creator_table, init_type_creator_table, type_to_creator,
make_typed_vector): New.
(scm_i_convert_old_prototype): Removed.
(prototype_to_type): New.
(scm_make_uve): Deprecated, reimplemented using make_typed_vector.
(scm_array_dimensions): Use scm_list_1 instead of scm_cons for
minor added clarity.
(scm_make_shared_array, scm_ra2contig): Use make_typed_vector
instead of scm_make_uve.
(tag_creator_table, scm_i_tag_to_creator): Removed.
(tag_to_type): New.
(scm_i_read_array): Use scm_list_to_typed_array instead of
scm_list_to_uniform_array.
2004-12-29 18:21:55 +00:00
Marius Vollmer
b590aceb96 (scm_uniform_vector_elements,
scm_u8vector_elements, etc): Made return value "const".
(scm_uniform_vector_writable_elements,
scm_u8vector_writable_elements, etc): New.
(scm_uniform_vector_release, scm_uniform_vector_release_elements):
Renamed former to latter.  Added explicit call to
scm_remember_upto_here_1.
(scm_frame_uniform_vector_release,
scm_frame_uniform_vector_release_elements): Renamed former to latter.
(scm_uniform_vector_release_writable_elements,
scm_frame_uniform_vector_release_writable_elements): New. Takes
crown of longest identifier yet.
Changed all uses as required by the changes above.
2004-12-27 02:10:14 +00:00
Marius Vollmer
69730f92ca Do not include <libguile.h>, include the
needed files directly.  Include config.h, <unistd.h> and <io.h>
when available.
(scm_uniform_vector_read_x, scm_uniform_vector_write): New.
2004-11-10 01:02:32 +00:00
Marius Vollmer
811eb6d0ee (scm_c_uniform_vector_ref, scm_c_uniform_vector_set_x): New.
(scm_i_uniform_vector_creator): Removed.
(scm_i_generalized_vector_creator): New.
(scm_uniform_vector_length, scm_uniform_element_size): Do not
handle generalized vectors, only uniform numeric vectors.
(alloc_uvec): Do length check here...
(make_uvec): ...but not here.
(coerce_to_uvec): Use new generalized vector functions to handle
all kinds of vectors in one go.
2004-11-09 16:13:58 +00:00
Marius Vollmer
b0780bc595 (make_uvec): Use SCM_I_SIZE_MAX instead of SIZE_MAX for added
portability.
2004-11-04 17:07:42 +00:00
Marius Vollmer
28d4aef1f0 (uvec_fast_ref): Avoid a compiler warning by returning
SCM_BOOL_F if no type matches.
2004-11-02 22:46:26 +00:00
Marius Vollmer
d44ff083ea * srfi-4.h, srfi-4.c (scm_frame_uniform_vector_release): New.
* unif.c (scm_bit_set_star_x, scm_bit_count_star_x): Use it to get
more efficient access to the u32vector.
2004-11-02 20:15:32 +00:00
Marius Vollmer
90d4368c88 (coerce_to_uvec, scm_any_to_u8vector, etc): New.
(scm_uniform_element_size, scm_uniform_vector_length): Do no longer
handle old-style uniform vectors.
2004-11-02 19:34:30 +00:00
Marius Vollmer
cbdc837976 (scm_i_read_homogenous_vector,
scm_i_uniform_vector_prototype): Removed.
(scm_i_uniform_vector_creator): New.
(SCM_UVEC_C32, scm_c32vector, scm_make_c32vector, etc,
SCM_UVEC_C64, scm_c64vector, scm_make_c64vector, etc): New.
Updated all tables and generic functions to support them.
(scm_i_proc_make_u8vector, scm_i_proc_make_s8vector, etc): New.
(scm_init_srfi_4): Initialize them.
2004-10-29 14:10:49 +00:00
Marius Vollmer
faa0036593 * srfi-4.c (take_uvec): New.
(alloc_uvec): Use it.
* srfi-4.h, srfi-4.i.c (scm_take_u8vector, etc): New.
2004-10-27 19:25:14 +00:00
Marius Vollmer
e0e496707b * srfi-4.h, srfi-4.i.c (scm_u8vector_elements, etc): New.
* srfi-4.h, srfi-4.c (scm_uniform_vector_p,
scm_uniform_vector_ref, scm_uniform_vector_set_x,
scm_uniform_vector_to_list, scm_is_uniform_vector,
scm_c_uniform_vector_lengths, scm_c_uniform_vector_size,
scm_uniform_vector_elements, scm_uniform_vector_element_size,
scm_uniform_vector_release): New.
(scm_i_uniform_vector_prototype, scm_i_uniform_vector_tag): New.
(scm_uniform_element_size, scm_uniform_vector_length): Moved here
from unif.h, unif.c and extended to handle both the old and new
uniform vectors.

* unif.h, unif.c (scm_uniform_vector_ref, scm_array_ref): Renamed
the former to the latter.
(scm_uniform_vector_length, scm_uniform_element_size): Moved to
srfi-4.h, srfi-4.c.
(scm_make_uve): Call scm_make_s8vector for #\nul prototype.
(scm_array_p, scm_array_rank, scm_array_dimensions,
scm_transpose_array, scm_enclose_array, scm_array_ref, scm_cvref,
scm_array_set_x, scm_array_contents, scm_uniform_array_read_x,
scm_array_to_list, scm_array_prototype): Handle srfi-4 uniform
vectors.  Removed code for scm_tc7_byvect.
(scm_dimensions_to_uniform_array): Fill array with 0 when
prototype is #\nul.
(scm_i_print_array_dimension, scm_i_legacy_tag,
scm_i_print_array): New.
(scm_raprin1): Call scm_i_print_array for arrays.  Removed code
for scm_tc7_byvect.
2004-10-27 18:11:14 +00:00
Marius Vollmer
f857918291 New files, initially from ../srfi/ but heavily modified. 2004-10-26 16:56:02 +00:00