* libguile/sort.c (sort!, sort, restricted-vector-sort!, sorted?):
Support arrays of rank 1, whatever the type.
* libguile/quicksort.i.c: Fix accessors to handle typed arrays.
* test-suite/tests/sort.test: Test also with typed arrays.
* libguile/array-map.c (scm_array_for_each_cell): Bail out early if any
of the sizes is zero. Pack ais at the end of the fake stack.
* test-suite/tests/array-map.test: Add regression test.
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.
* libguile/vectors.c (scm_vector): Use SCM_I_VECTOR_WELTS on new vector
instead of generic scm_vector_elements; cf. scm_vector_copy().
(scm_vector_elements): Forward to scm_vector_writable_elements().
(scm_vector_writable_elements): Remove special error message for weak
vector arg.
* libguile/generalized-vectors.c (SCM_VALIDATE_VECTOR_WITH_HANDLE):
Remove unused macro.
* libguile/array-handle.c (scm_array_handle_elements): Forward to
scm_array_handle_writable_elements().
* 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.
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): like rafe, when there's more than one argument.
(AREF, ASET): remove.
* libguile/arrays.c (scm_c_array_rank): moved from
libguile/generalized-arrays.c. Don't use array handles, but follow the
same type check sequence as the other array functions
(shared-array-root, etc).
(scm_array_rank): moved from libguile/generalized-arrays.h.
* libguile/arrays.h: move prototypes here.
SCM_I_ARRAY_FLAG_CONTIGUOUS (arrays.h) was set by all array-creating
functions (make-typed-array, transpose-array, make-shared-array) but it
was only used by array-contents, which needed to traverse the dimensions
anyway.
* libguile/arrays.c (scm_make_typed_array,
scm_from_contiguous_typed_array): don't set the contiguous flag.
(scm_transpose_array, scm_make_shared_array): don't call
scm_i_ra_set_contp.
(scm_array_contents): inline scm_i_ra_set_contp() here. Adopt uniform
type check order. Remove redundant comments.
(scm_i_ra_set_contp): remove.
* libguile/arrays.h: note.
* test-suite/tests/arrays.test: test array-contents with rank 0 array.
This function is undocumented, unused within Guile, and can be trivially
replaced by make-array + array-copy without requiring contiguity.
* libguile/arrays.h (scm_from_contiguous_array): remove declaration.
* libguile/arrays.c (scm_from_contiguous_array): remove.
* libguile/arrays.c (scm_shared_array_root): adopt uniform check order.
(scm_shared_array_offset, scm_shared_array_increments): use the array
fields directly just as scm_shared_array_root does.
* test-suite/tests/arrays.test: tests for shared-array-offset,
shared-array-increments.
Based on a patch by Andy Stormont <astormont@racktopsystems.com>.
* configure.ac: Check for strtod_l.
* libguile/i18n.c (scm_locale_string_to_integer): Fix style.
(scm_locale_string_to_inexact): Check for strtod_l.
* libguile/programs.c (try_parse_arity): New helper, to parse bytecode
to determine the minimum arity of a function in a cheaper way than
grovelling through the debug info. Should speed up all thunk? checks
and similar.
(scm_i_program_arity): Simplify.
* libguile/gsubr.h:
* libguile/gsubr.c (scm_i_primitive_arity):
* libguile/foreign.h:
* libguile/foreign.c (scm_i_foreign_arity):
* libguile/ports.c (scm_init_ports): Use the locale as the default
charset. After the switch to default GUILE_INSTALL_LOCALE=1, this
harmonizes the default port encoding with the installed locale.
* libguile/conv-integer.i.c (SCM_FROM_TYPE_PROTO):
* libguile/conv-uinteger.i.c (SCM_FROM_TYPE_PROTO): Fix a big in which
scm_from_int64 and scm_from_uint64 on a 32-bit platform leaked memory
if they needed to allocate a bignum. Fixes#20079.
* libguile/smob.c (clear_smobnum): New helper.
(finalize_smob): Re-set the smobnum to the "finalized smob" type
before finalizing. Fixes#19883.
(scm_smob_prehistory): Pre-register a "finalized smob" type, which has
no mark procedure.
* test-suite/standalone/test-smob-mark-race.c: New file.
* test-suite/standalone/Makefile.am: Arrange to build and run the new
test.
* libguile/filesys.c (scm_i_relativize_path): Canonicalize the file
names elements that we will be using as prefixes. Fixes the case
where a load path contains a relative file name: #19540.
* test-suite/tests/ports.test ("%file-port-name-canonicalization"): Add
tests that elements of the load path are canonicalized.
* libguile/i18n.c (str_upcase, str_downcase, str_upcase_l)
(str_downcase_l): Remove unused inline functions. Based on a patch by
Pedro Aguilar <paguilar@paguilar.org>. Fixes#19172.
* libguile/ports.c (scm_setvbuf): Fix bad use of SCM as a test value.
Actually all ports have read buffers, so we can remove the condition
entirely. Thanks Hydra for building in this way :)
* doc/ref/vm.texi (Top-Level Environment Instructions): Update
documentation.
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump, sadly.
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
* libguile/vm-engine.c (define!): Change to store variable in dst slot.
* module/language/tree-il/compile-cps.scm (convert):
* module/language/cps/compile-bytecode.scm (compile-function): Adapt to
define! change.
* module/language/cps/effects-analysis.scm (current-module): Fix define!
effects. Incidentally here was the bug: in Guile 2.2 you can't have
effects on different object kinds in one instruction, without
reverting to &unknown-memory-kinds.
* test-suite/tests/compiler.test ("regression tests"): Add a test.
* libguile/bytevectors.c (bytevector_large_set): Fix computation of
value size in words.
* test-suite/tests/bytevectors.test: Add test.
Thanks to Ben Rocer <fleabyte@mail.com> for the bug report and fix.
* libguile/load.c (load_thunk_from_path, try_load_thunk_from_file): New
functions.
(search_path): Simplify.
(scm_primitive_load_path, scm_init_eval_in_scheme): Use the new
functions to load compiled files.
* module/ice-9/boot-9.scm (load-in-vicinity): Skip invalid .go files.
Inspired by a patch from Jan Nieuwenhuizen <janneke@gnu.org>.
* libguile/vm-engine.c (SP_REF_SLOT, SP_SET_SLOT): New defines.
(push, pop, mov, long-mov): Move full slots. Fixes 32-bit with
unboxed 64-bit stack values; before when shuffling these values
around, we were only shuffling the lower 32 bits on 32-bit platforms.
* libguile/vm-engine.c (VM_VALIDATE): Refactor some type-related
assertions to use a common macro.
(vector-length, vector-set!/immediate): Fix the proc mentioned in the
error message.
* doc/ref/posix.texi (Network Sockets and Communication):
* libguile/socket.c (scm_accept): Return #f if the socket is nonblocking
and no connection is ready.
* libguile/ports.c (scm_port_encode_char): New function.
* module/ice-9/ports.scm (port-encode-char): Export port-encode-char to
the internals module.
* module/ice-9/sports.scm (put-char): New function.
(port-bindings): Add put-char and put-string.
* libguile/ports.h (scm_put_char):
* libguile/ports.c (scm_put_char): New function.
(scm_put_string): Add docstrings, and expose to the internal ports
module.
* module/ice-9/ports.scm (put-char, put-string): Expose these bindings
only through the internals module.
* libguile/socket.c (scm_init_socket): Define TCP_NODELAY and TCP_CORK
if they are available.
* doc/ref/posix.texi (Network Sockets and Communication): Add
documentation.
* NEWS: Add entry.
* libguile/ports.c (scm_port_clear_stream_start_for_bom_write): Instead
of returning the BOM, take an optional buffer in which to write the
BOM. Return number of bytes written.
(port_clear_stream_start_for_bom_write): Remove.
(scm_i_write): Adapt scm_port_clear_stream_start_for_bom_write call.
(try_encode_char_to_iconv_buf, encode_latin1_chars_to_latin1_buf):
(encode_latin1_chars_to_utf8_buf, encode_latin1_chars_to_iconv_buf):
(encode_latin1_chars, encode_utf32_chars_to_latin1_buf):
(encode_utf32_chars_to_utf8_buf, encode_utf32_chars_to_iconv_buf):
(encode_utf32_chars, port_encode_chars): New helpers.
(scm_port_encode_chars): New procedure.
(scm_c_put_latin1_chars, scm_c_put_utf32_chars): Rework to use new
encoding helpers.
(scm_lfwrite): Use scm_c_put_latin1_chars.
* libguile/print.c (iprin1): Use scm_c_put_string for strings.
* test-suite/test-suite/lib.scm (exception:encoding-error): Add an
additional expected error string for `encoding-error'.