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

58 commits

Author SHA1 Message Date
Daniel Llorens
0a5023149d Support non-zero lower bounds in array-slice-for-each
* libguile/array-handle.c (scm_array_handle_writable_elements): Fix
  error message.
* libguile/array-map.c (scm_array_slice_for_each): Support non-zero
  lower bounds. Fix error messages.
* test-suite/tests/array-map.test: Test scm_array_slice_for_each with
  non-zero lower bound argument.
2017-10-27 14:44:23 +02:00
Daniel Llorens
e7410a0a0d Allow scm_XXX_writable_elements on empty vectors, even if immutable
* libguile/array-handle.c (initialize_vector_handle): Set both element
  pointers to NULL if the vector is empty.
* libguile/array-map.c (racp): Ignore immutability if destination is
  empty.
* test-suite/tests/sort.test: Check empty/mutable/immutable vectors with
  sort!.
* test-suite/tests/array-map.test: Check array-copy! with
  empty/immutable destination.
2017-10-27 14:44:23 +02:00
Andy Wingo
7ed54fd36d All literal constants are read-only
* libguile/array-handle.c (initialize_vector_handle): Add mutable_p
  argument.  Unless the vector handle is mutable, null out its
  writable_elements member.
  (scm_array_get_handle): Adapt to determine mutability of the various
  arrays.
  (scm_array_handle_elements, scm_array_handle_writable_elements):
  Reverse the sense: instead of implementing read-only in terms of
  read-write, go the other way around, adding an assertion in the
  read-write case that the array handle is mutable.
* libguile/array-map.c (racp): Assert that the destination is mutable.
* libguile/bitvectors.c (SCM_F_BITVECTOR_IMMUTABLE, IS_BITVECTOR):
  (IS_MUTABLE_BITVECTOR): Add a flag to indicate immutability.
  (scm_i_bitvector_bits): Fix indentation.
  (scm_i_is_mutable_bitvector): New helper.
  (scm_array_handle_bit_elements)
  ((scm_array_handle_bit_writable_elements): Build writable_elements in
  terms of elements.
  (scm_bitvector_elements, scm_bitvector_writable_elements): Likewise.
  (scm_c_bitvector_set_x): Require a mutable bitvector for the
  fast-path.
  (scm_bitvector_to_list, scm_bit_count): Use read-only elements()
  function.
* libguile/bitvectors.h (scm_i_is_mutable_bitvector): New decl.
* libguile/bytevectors.c (INTEGER_ACCESSOR_PROLOGUE):
  (INTEGER_GETTER_PROLOGUE, INTEGER_SETTER_PROLOGUE):
  (INTEGER_REF, INTEGER_NATIVE_REF, INTEGER_SET, INTEGER_NATIVE_SET):
  (GENERIC_INTEGER_ACCESSOR_PROLOGUE):
  (GENERIC_INTEGER_GETTER_PROLOGUE, GENERIC_INTEGER_SETTER_PROLOGUE):
  (LARGE_INTEGER_NATIVE_REF, LARGE_INTEGER_NATIVE_SET):
  (IEEE754_GETTER_PROLOGUE, IEEE754_SETTER_PROLOGUE):
  (IEEE754_REF, IEEE754_NATIVE_REF, IEEE754_SET, IEEE754_NATIVE_SET):
  Setters require a mutable bytevector.
  (SCM_BYTEVECTOR_SET_FLAG): New helper.
  (SCM_BYTEVECTOR_SET_CONTIGUOUS_P, SCM_BYTEVECTOR_SET_ELEMENT_TYPE):
  Remove helpers.
  (SCM_VALIDATE_MUTABLE_BYTEVECTOR): New helper.
  (make_bytevector, make_bytevector_from_buffer): Use
  SCM_SET_BYTEVECTOR_FLAGS.
  (scm_c_bytevector_set_x, scm_bytevector_fill_x)
  (scm_bytevector_copy_x): Require a mutable bytevector.
* libguile/bytevectors.h (SCM_F_BYTEVECTOR_CONTIGUOUS)
  (SCM_F_BYTEVECTOR_IMMUTABLE, SCM_MUTABLE_BYTEVECTOR_P): New
  definitions.
* libguile/bytevectors.h (SCM_BYTEVECTOR_CONTIGUOUS_P): Just access one
  bit.
* libguile/srfi-4.c (DEFINE_SRFI_4_C_FUNCS): Implement
  writable_elements() in terms of elements().
* libguile/strings.c (scm_i_string_is_mutable): New helper.
* libguile/uniform.c (scm_array_handle_uniform_elements):
  (scm_array_handle_uniform_writable_elements): Implement
  writable_elements in terms of elements.
* libguile/vectors.c (SCM_VALIDATE_MUTABLE_VECTOR): New helper.
  (scm_vector_elements, scm_vector_writable_elements): Implement
  writable_elements in terms of elements.
  (scm_c_vector_set_x): Require a mutable vector.
* libguile/vectors.h (SCM_F_VECTOR_IMMUTABLE, SCM_I_IS_MUTABLE_VECTOR):
  New definitions.
* libguile/vm-engine.c (VM_VALIDATE_MUTABLE_BYTEVECTOR):
  (VM_VALIDATE_MUTABLE_VECTOR, vector-set!, vector-set!/immediate)
  (BV_BOUNDED_SET, BV_SET): Require mutable bytevector/vector.
* libguile/vm.c (vm_error_not_a_mutable_bytevector):
  (vm_error_not_a_mutable_vector): New definitions.
* module/system/vm/assembler.scm (link-data): Mark residualized vectors,
  bytevectors, and bitvectors as being read-only.
2017-04-18 21:27:45 +02:00
Daniel Llorens
7e93950552 Final names for new array functions
Globally rename (array-from* -> array-slice), (array-from ->
array-cell-ref), (array-amend! -> array-cell-set!), (array-for-each-cell
-> array-slice-for-each).
2017-01-09 09:02:04 +01:00
Daniel Llorens
7ef9d0ac2b New functions (array-for-each-cell, array-for-each-cell-in-order)
* libguile/array-map.c (scm_i_array_rebase, scm_array_for_each_cell):
  New functions. Export scm_array_for_each_cell() as
  (array-for-each-cell).

  (array-for-each-cell-in-order): Define additional export.

* libguile/array-map.h (scm_i_array_rebase, scm_array_for_each_cell):
  Add prototypes.

* test-suite/tests/array-map.test: Renamed from
  test-suite/tests/ramap.test, fix module name. Add tests for
  (array-for-each-cell).

* test-suite/Makefile.am: Apply rename array-map.test -> ramap.test.
2016-11-23 13:04:49 +01:00
Daniel Llorens
cd7fee8e65 Special case for array-map! with three arguments
Benchmark:

(define type #t)
(define A (make-typed-array 's32 0 10000 1000))
(define B (make-typed-array 's32 0 10000 1000))
(define C (make-typed-array 's32 0 10000 1000))

before:

scheme@(guile-user)> ,time (array-map! C + A B)
;; 0.792653s real time, 0.790970s run time.  0.000000s spent in GC.

after:

scheme@(guile-user)> ,time (array-map! C + A B)
;; 0.598513s real time, 0.597146s run time.  0.000000s spent in GC.

* libguile/array-map.c (ramap): Add special case with 3 arguments.
2016-11-23 11:49:35 +01:00
Daniel Llorens
31e9f8b974 Speed up for multi-arg cases of scm_ramap functions
This patch results in a 20%-40% speedup in the > 1 argument cases of
the following microbenchmarks:

(define A (make-shared-array #0(1) (const '()) #e1e7))
; 1, 2, 3 arguments.
(define a 0) ,time (array-for-each (lambda (b) (set! a (+ a b))) A)
(define a 0) ,time (array-for-each (lambda (b c) (set! a (+ a b c))) A A)
(define a 0) ,time (array-for-each (lambda (b c d) (set! a (+ a b c d))) A A A)

(define A (make-shared-array (make-array 1) (const '()) #e1e7))
(define B (make-shared-array #0(1) (const '()) #e1e7))
; 1, 2, 3 arguments.
,time (array-map! A + B)
,time (array-map! A + B B)
,time (array-map! A + B B B)

* libguile/array-map.c (scm_ramap): Note on cproc arguments.

  (rafill): Assume that dst's lbnd is 0.

  (racp): Assume that src's lbnd is 0.

  (ramap): Assume that ra0's lbnd is 0. When there're more than two
  arguments, compute the array handles before the loop. Allocate the arg
  list once and reuse it in the loop.

  (rafe): Do as in ramap(), when there's more than one argument.

  (AREF, ASET): Remove.
2016-11-23 11:49:35 +01:00
Daniel Llorens
09850ffc27 Remove deprecated array functions
* libguile/array-map.c (scm_array_fill_int, scm_array_fill_int,
    scm_ra_eqp, scm_ra_lessp scm_ra_leqp, scm_ra_grp, scm_ra_greqp,
    scm_ra_sum, scm_ra_difference, scm_ra_product, scm_ra_divide,
    scm_array_identity): Remove deprecated functions.

* libguile/array-map.h: Remove declaration of deprecated functions.

* libguile/generalized-vectors.h, libguile/generalized-vectors.c
  (scm_is_generalized_vector, scm_c_generalized_vector_length,
  scm_c_generalized_vector_ref, scm_c_generalized_vector_set_x): These
  functions were deprecated in 2.0.9. Remove.

* doc/ref/api-compound.texi: Remove uniform-array-read!,
  uniform-array-write from the manual. These procedures where removed in
  fc7bd367ab (2011-05-12).
2016-11-23 11:49:35 +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
Daniel Llorens
65704b982d Pack array dimensions in array object
* libguile/arrays.c (scm_i_make_array): redo object layout.

* libguile/arrays.h (SCM_I_ARRAY_V, SCM_ARRAY_BASE, SCM_I_ARRAY_DIMS):
  to match new layout.

  (SCM_I_ARRAY_SET_V, SCM_ARRAY_SET_BASE): new setters.

  (SCM_I_ARRAY_MEM, scm_i_t_array): unused, remove.

  (scm_i_shap2ra, scm_make_typed_array, scm_from_contiguous_typed_array,
  scm_from_contiguous_array, scm_make_shared_array, scm_transpose_array,
  scm_array_contents): fix uses of SCM_I_ARRAY_V, SCM_ARRAY_BASE as
  lvalues.

* libguile/array-map.c (make1array, scm_ramapc): fix uses of
  SCM_I_ARRAY_V, SCM_ARRAY_BASE as lvalues.
2014-09-30 11:35:08 +02:00
Daniel Llorens
b98e2f47aa Preallocate index list in scm_array_index_map_x
* libguile/array-map.c
  - (scm_array_index_map_x): preallocate the index list instead of
    constructing it on each rank-1 iteration.
  - (ramap, rafe): use SCM_I_ARRAY_V just once.
2014-02-10 21:58:28 +01:00
Daniel Llorens
b7c8836b71 Don't use ASET in scm_array_index_map_x
* libguile/array-map.c: (scm_array_index_map_x): replace ASET by direct
  use of handle->impl.
2014-02-10 21:58:28 +01:00
Daniel Llorens
992904a8ca In scm_ramapc, only check unrolled axes for emptiness
* libguile/array-map.c: (scm_ramapc)
  - Don't check emptiness while preparing ra0, but only after kroll is known,
    and only before kroll. len = 0 will be caught by the unrolled loop.
  - Use ra0 axis length in unroll check depth for rest args, not ra1's.
  - Recover early exit feature when cproc returns 0.
2014-02-10 21:58:28 +01:00
Daniel Llorens
f26eae9a9a Fix corner cases of scm_ramapc
* libguile/array-map.c
  - (scm_ramapc): mismatched axes limit unrollk (kroll). Reorganize
    the function to do all checking as we go.
  - (scm_ra_matchp): unused; remove.
  - (find_unrollk): inlined in scm_ramapc; remove.
  - (klen): inlined in scm_ramapc; remove.
  - (rafill): n is size_t.
  - (racp): n is size_t. Use n and not i0end to bound the loop.
  - (ramap): Use n and not i0end to bound the loop. This is needed for the rank
    0 case to work with the new scm_ramapc, as inc may be set to 0 in that case.
  - (rafe): idem.

* test-suite/tests/ramap.test
  - check that size mismatch prevents unrolling (matching behavior III) with
    both array-copy! and array-map!.
  - check that non-contiguous stride in non-ref args prevents unrolling
    (rank 2, discontinuous) with both array-copy! and array-map!.
  - check rank 0 cases with array-for-each, array-map!.
  - Test the 0-inc, non empty case for both array-map! and array-copy!.
2014-02-10 21:58:01 +01:00
Daniel Llorens
4cde4f63ee Rewrite scm_ramapc()
* libguile/array-map.c
  - (cind): replace by cindk, that operates only on the unrolled index set.
  - (klen): new function.
  - (make1array): take extra inc argument.
  - (scm_ramapc): rewrite to unroll as many axes as possible instead of just all
    or one.
  - (AREF): lbnd is known to be 0: remove.
  - (ASET): v is known to come from SCM_I_ARRAY_V; assume base, inc, lbnd.
  - (racp): use ssize_t instead of long for the indices.
  - (scm_array_index_map_x): build the index list at the last-but-one axis, then
    set the car of the last element, instead of building the list at the last axis.
* test-suite/tests/ramap.test
  - add array-map! test with offset arguments.
2014-02-10 21:26:55 +01:00
Daniel Llorens
2a8688a9d1 Factor out make1array() in scm_ramapc()
* libguile/array-map.c: (scm_ramapc): factor out vector->array conversion
  to aux function make1array.
2014-02-10 21:26:55 +01:00
Andy Wingo
1ac534e904 Reindent scm_ramapc
* libguile/array-map.c (scm_ramapc): Reindent.
2014-02-09 21:11:08 +01:00
Daniel Llorens
2c001086b2 Raw pointer loop in array-copy! for vector/vector case
This special case improves

(define a (make-array 1. 1000000 10))
(define b (make-array *unspecified* 1000000 10))
(define c (transpose-array (make-array *unspecified* 10 1000000) 1 0))
,time (array-copy! a b)
,time (array-copy! a c)

from 0.041598s / 0.072561 to 0.012164s / 0.041886s on a i7-3930K.

* libguile/array-map.c: (racp): if both src and dst are on vectors, use
  the element pointers to do the copy.
2014-02-09 21:04:25 +01:00
Daniel Llorens
19239bbfcb Replace SCM_IMP in array-map.c
* libguile/array-map.c
  - scm_ramapc: check scm_array_contents with scm_is_false.
2014-02-09 12:54:51 +01:00
Andy Wingo
cf64dca65c Remove array impl. registry; instead, hard-code array handle creation
* libguile/array-handle.h (scm_t_vector_ref, scm_t_vector_set): Rename
  from scm_t_array_ref, scm_t_array_set.  These were named
  scm_i_t_array_ref and scm_i_t_array_set in 1.8 and 2.0.  Change to
  take the vector directly, instead of the array handle.  In this way,
  generic array handles are layered on top of specific implementations
  of backing stores.

  Remove scm_t_array_implementation, introduced in 2.0 but never
  documented.  It was a failed attempt to layer the array implementation
  that actually introduced too many layers, as it prevented the "vref"
  and "vset" members of scm_t_array_handle (called "ref" and "set" in
  1.8, not present in 2.0) from specializing on array backing stores.

  (scm_i_register_array_implementation) (scm_i_array_implementation_for_obj):
  Remove these internal interfaces.

  (scm_t_array_handle): Adapt to scm_t_vector_ref / scm_t_vector_set
  change.

  (scm_array_handle_ref, scm_array_handle_set): Adapt to change in
  vref/vset prototype.

* libguile/array-handle.c (scm_array_get_handle): Inline all the
  necessary initializations here for all specific array types.

* libguile/array-map.c (rafill, racp, ramap, rafe, array_index_map_1):

* libguile/arrays.c: Remove array implementation code.

* libguile/bitvectors.h:
* libguile/bitvectors.c: Remove array implementation code.
  (scm_i_bitvector_bits): New internal interface.

* libguile/bytevectors.c: Remove array implementation code.

* libguile/srfi-4.h: Remove declarations for internal procedures that
  don't exist (!).

* libguile/strings.c: Remove array implementation code.

* libguile/vectors.c: Remove array implementation code.
2014-02-09 12:48:21 +01:00
Daniel Llorens
8269f0be18 Fix array map functions with empty arguments
* libguile/array-map.c
  - scm_ra_matchp: look for empty axes and return new case 5 if so. Use
    array handles to remove the SCM_I_ARRAYP / not branch.
  - scm_ramapc: Heed case 5.
* test-suite/tests/ramap.test
  - test empty arguments for array-copy! and array-for-each. Note those
    that failed in 2.0.9.
2014-02-09 12:48:21 +01:00
Daniel Llorens
b0d9b0744a Fix empty array bug in array-index-map!
* libguile/array-map.c: (scm_array_index_map_x): bail out if any one of the
  axes is empty.
* test-suite/tests/ramap.test: add tests for empty array-case of
  array-index-map!. The 'f64 case with not-last emtpy axis is broken in 2.0.9.
2014-02-09 12:48:19 +01:00
Andy Wingo
7070f12b9d vref, vset members of scm_t_array_handle
* libguile/array-handle.h (scm_t_array_ref, scm_t_array_set): Rename
  from scm_i_t_array_ref, scm_i_t_array_set.
  (scm_t_array_handle): Copy vref and vset from impl to handle.
  (scm_array_handle_ref, scm_array_handle_set):

* libguile/array-map.c (racp, ramap, rafe, rafill, array_index_map_1):
* libguile/array-handle.c (scm_array_get_handle): Adapt.
2014-02-08 21:45:38 +01:00
Daniel Llorens
13af75bfe0 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.
2014-02-07 10:36:55 +01:00
Andy Wingo
828ada1326 Fix array-index-map refactor
* libguile/ramap.c (array_index_map_1): Fix to use array handle
  properly.
2014-02-06 21:36:15 +01:00
Andy Wingo
f0521cdabc 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.
2014-02-06 20:44:47 +01:00
Daniel Llorens
16259ae3dc 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.
2014-02-06 11:35:29 +01:00
Daniel Llorens
5e8c9d4ad5 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.
2014-02-06 11:33:08 +01:00
Mark H Weaver
f6f4feb0a2 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	GUILE-VERSION
	libguile/array-map.c
	libguile/fports.h
	libguile/gc.h
	libguile/inline.h
	libguile/ports.c
	libguile/ports.h
	libguile/print.c
	libguile/r6rs-ports.c
	libguile/read.c
	test-suite/tests/00-socket.test
2013-04-14 02:48:33 -04:00
Daniel Llorens
48ffc52cc9 Don't use scm_generalized_vector_get_handle() in array-map.c
* libguile/array-map.c: (rafill, racp, ramap, rafe): use
  scm_array_get_handle() instead of scm_generalized_get_vector_handle().

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2013-04-07 11:51:58 +02:00
Daniel Llorens
d09b201d59 Deprecate scm_array_fill_int()
* libguile/array-map.h, libgule/array-map.c: move scm_array_fill_int
  to the deprecated section.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2013-04-05 22:54:14 +02:00
Daniel Llorens
ab1ca17986 Remove double indirection in array-fill!
* libguile/array-map.c: new function rafill, like scm_array_fill_int,
  but factors GVSET out of the loop. Use it in scm_array_fill_x instead of
  scm_array_fill_int.
* test-suite/tests/arrays.test: add test for array-fill! with stride != 1.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2013-04-05 22:54:14 +02:00
Daniel Llorens
c3e3ef6eb6 Remove double indirection for 1st arg of array-for-each
* libguile/array-map.c: (rafe): factor GVREF out of rank-1 loop for ra0.
2013-04-03 21:46:27 +02:00
Daniel Llorens
51a1763f65 Remove double indirection in array-map! with <2 args
* libguile/array-map.c: (ramap): factor GVSET/GVREF out of rank-1 loop
  for ra0 and the first element of ras.
2013-04-03 21:46:27 +02:00
Daniel Llorens
9a68d7b388 Avoid per-element cons for 1-arg case of array-map!
* libguile/array-map.c: (ramap): special case when ras is a 1-element list.
2013-04-03 21:46:27 +02:00
Daniel Llorens
75a1b26c5d Deprecate dead code in array-map.c
* libguile/array-map.c, libguile/array-map.h: deprecate scm_ra_eqp,
  scm_ra_lessp, scm_ra_leqp, scm_ra_grp, scm_ra_greqp, scm_ra_sum,
  scm_ra_product, scm_ra_difference, scm_ra_divide, scm_array_identity.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2013-04-03 21:46:27 +02:00
Daniel Llorens
72e2b5923a Remove double indirection in element access in array-copy!
* libguile/array-map.c: (racp): factor scm_generalized_vector_ref,
  scm_generalized_vector_set_x out of the rank-1 loop.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2013-04-03 14:21:49 +02:00
Andy Wingo
0858753e82 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	GUILE-VERSION
	libguile/gc-malloc.c
	libguile/ports.c
2012-02-08 11:48:08 +01:00
Bake Timmons
b7e64f8b26 Improve the usage of variable names in C docstrings.
* libguile/alist.c:
* libguile/array-map.c:
* libguile/arrays.c:
* libguile/bitvectors.c:
* libguile/filesys.c:
* libguile/foreign.c:
* libguile/generalized-arrays.c:
* libguile/hashtab.c:
* libguile/ioext.c:
* libguile/load.c:
* libguile/numbers.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/print.c:
* libguile/procprop.c:
* libguile/promises.c:
* libguile/simpos.c:
* libguile/socket.c:
* libguile/srfi-1.c:
* libguile/srfi-13.c:
* libguile/srfi-14.c:
* libguile/stacks.c:
* libguile/stime.c:
* libguile/strings.c:
* libguile/struct.c:
* libguile/symbols.c:
* libguile/threads.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Make the variable names in the C docstrings more
  consistent.  Replace a few instances of @var with @code when appropriate.
2012-02-02 12:22:10 +01:00
Andy Wingo
91ee7515da Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/__scm.h
	libguile/array-map.c
	libguile/procprop.c
	libguile/tags.h
	module/ice-9/deprecated.scm
	module/ice-9/psyntax-pp.scm
	module/ice-9/psyntax.scm
	test-suite/standalone/test-num2integral.c
	test-suite/tests/regexp.test
2012-01-10 00:41:42 +01:00
Andy Wingo
b2637c985c allocate a tc7 to arrays
* libguile/tags.h (scm_tc7_array): Allocate a tag for arrays.
* libguile/arrays.h (SCM_I_ARRAYP): Change to use scm_tc7_array.  The
  previous definition was not externally usable because scm_i_tc16_array
  was internal.
  (scm_i_print_array): Declare, though internally.

* libguile/arrays.c (scm_i_make_array): Use scm_cell with the tc7
  instead of NEWSMOB.
  (scm_i_print_array): Make not static.
  (SCM_ARRAY_IMPLEMENTATION): Adapt.
  (scm_init_arrays): Remove array smob declaration.

* libguile/eq.c (scm_equal_p): Refactor to put the string, pointer, and
  bytevector cases in the switch.  Add a case for arrays.

* libguile/goops.c: Add <array> declarations.

* libguile/print.c (iprin1): Call scm_i_print_array as needed.

* libguile/evalext.c (scm_self_evaluating_p): Add a case for arrays.
2012-01-09 17:50:56 +01:00
Andy Wingo
62fdadb0a5 check for pairs with scm_is_pair, not scm_nimp
* libguile/array-map.c (scm_ra_matchp, scm_ramapc):
* libguile/dynwind.c (scm_swap_bindings):
* libguile/hooks.c (hook_print, scm_c_run_hook, scm_c_run_hookn):
* libguile/objprop.c (scm_object_property, scm_set_object_property_x):
  Use !scm_is_pair as the termination condition, not scm_imp.
2011-10-24 17:22:47 +02:00
Ludovic Courtès
10b9343f04 Change `scm_ramapc' prototype to avoid empty declarators (bug #23681).
* libguile/array-map.h (scm_ramapc): Change `cproc' to `void *' instead
  of using empty declarators.

* libguile/array-map.c (scm_ramapc): Adjust accordingly.
2011-02-13 14:47:33 +01:00
Andy Wingo
a587d6a973 more fixes to equal? for arrays
* libguile/array-map.c (array_compare, scm_array_equal_p): Rewrite as
  something that operates on the generic array handle infrastructure.
  Based on array->list.
  (scm_i_array_equal_p): Change the docs, as array-equal? is now the same
  as equal?, except that it typechecks its args.

* doc/ref/api-compound.texi (Array Procedures): Update array-equal?
  docs.

* libguile/deprecated.h:
* libguile/deprecated.c (scm_raequal): Deprecate.

* libguile/bytevectors.c (scm_bytevector_eq_p): Bugfix: bytevectors are
  bytevector=? only if their element type is the same.

* libguile/eq.c (scm_equal_p): Only dispatch to scm_array_equal_p if
  both args are arrays (generically).

* test-suite/tests/arrays.test ("equal?"): Add some more tests.
2010-04-01 00:25:06 +02:00
Andy Wingo
3ffd1ba96e fix equal? between an array and a non-array
OK let's try again. While the thanks go to Daniel Llorens del Río for
the tip, the blame continues going to me :)

* test-suite/Makefile.am:
* test-suite/tests/arrays.test: Add a test.

* libguile/array-map.c (raeql): Handle a few 0-dimensional cases. If the
  shapes of the arrays don't match, just return #f instead of raising
  an error.
2010-03-31 00:05:01 +02:00
Andy Wingo
f1d19308ad provide missing prototypes
* libguile/array-map.c:
* libguile/chars.c:
* libguile/eq.c:
* libguile/strorder.c: Provide declarations missing after the asubrs/rpsubrs ->
  gsubr conversion.
2010-01-07 23:49:15 +01:00
Andy Wingo
e7efe8e793 decruftify scm_sys_protects
* libguile/root.h
* libguile/root.c (scm_sys_protects): It used to be that for some reason
  we'd define a special array of "protected" values. This was a little
  silly, always, but with the BDW GC it's completely unnecessary. Also
  many of these variables were unused, and none of them were good API.
  So remove this array, and either eliminate, make static, or make
  internal the various values.

* libguile/snarf.h: No need to generate calls to scm_permanent_object.

* guile-readline/readline.c (scm_init_readline): No need to call
  scm_permanent_object.

* libguile/array-map.c (ramap, rafe): Remove the dubious nullvect
  optimizations.

* libguile/async.c (scm_init_async): No need to init scm_asyncs, it is
  no more.

* libguile/eval.c (scm_init_eval): No need to init scm_listofnull, it is
  no more.

* libguile/gc.c: Make scm_protects a static var.
  (scm_storage_prehistory): Change the sanity check to use the address
  of protects.
  (scm_init_gc_protect_object): No need to clear the scm_sys_protects,
  as it is no more.

* libguile/keywords.c: Make the keyword obarray a static var.
* libguile/numbers.c: Make flo0 a static var.
* libguile/objprop.c: Make object_whash a static var.
* libguile/properties.c: Make properties_whash a static var.

* libguile/srcprop.h:
* libguile/srcprop.c: Make scm_source_whash a global with internal
  linkage.

* libguile/strings.h:
* libguile/strings.c: Make scm_nullstr a global with internal linkage.

* libguile/vectors.c (scm_init_vectors): No need to init scm_nullvect,
  it's unused.
2009-12-05 12:38:43 +01:00
Andy Wingo
8a1f4f98e1 remove rpsubrs
* libguile/tags.h: Remove rpsubrs (I chose to interpret the terse name
  as "recursive predicate subrs"). Just use gsubrs with rest arguments,
  or do a fold yourself.

* libguile/array-map.c (scm_i_array_equal_p): Do the comparison in
  order, why not.

* libguile/chars.c:
* libguile/eq.c:
* libguile/numbers.c:
* libguile/strorder.c: Add 0,2,1 gsubr wrappers for rpsubrs like eq?, <,
  etc.

* libguile/goops.c (scm_class_of)
* libguile/procprop.c (scm_i_procedure_arity)
* libguile/procs.c (scm_thunk_p)
* libguile/vm.c (apply_foreign): Remove rpsubr cases.

* test-suite/tests/numbers.test ("=", "<"): Turn a couple xfails into
  passes.
2009-12-04 13:05:00 +01:00
Andy Wingo
31d845b4bc remove asubrs
* libguile/tags.h (scm_tcs_subrs, scm_tc7_asubr): Remove definitions.

* libguile/goops.c (scm_class_of)
* libguile/procprop.c (scm_i_procedure_arity)
* libguile/procs.c (scm_thunk_p)
* libguile/vm.c (apply_foreign): Remove cases for asubrs.

* libguile/array-map.c: Gut all of the optimizations, because there are
  no more asubrs, soon won't be rpsubrs, and all of this should happen
  on the Scheme level, ideally.
2009-12-03 17:05:14 +01:00
Andy Wingo
b04ab0c624 remove scm_tc7_dsubr
* libguile/tags.h: Remove scm_tc7_dsubr. There are no more users of
  this.

* libguile/array-map.c:
* libguile/eval.c:
* libguile/eval.i.c:
* libguile/goops.c:
* libguile/procprop.c:
* libguile/procs.h: Remove all dsubr cases.
2009-12-03 15:33:09 +01:00