summaryrefslogtreecommitdiff
path: root/libguile/bytevectors.c
AgeCommit message (Collapse)AuthorFilesLines
2013-08-16In bytevector->uint-list et al, check that SIZE divides the bv length.Mark H Weaver1-1/+5
Fixes <http://bugs.gnu.org/15100>. Reported by Göran Weinholt <goran@weinholt.se>. * libguile/bytevectors.c (INTEGERS_TO_LIST): Enforce the R6RS requirement that SIZE divides the bytevector length. * test-suite/tests/bytevectors.test: Add test. Remove tests that assumes that this "divides" check is not enforced.
2013-08-16Merge remote-tracking branch 'origin/stable-2.0'Mark H Weaver1-5/+3
2013-08-16Improved error checking in bytevector->uint-list and bytevector->sint-list.Mark H Weaver1-5/+3
Partially fixes <http://bugs.gnu.org/15100>. Reported by Göran Weinholt <goran@weinholt.se>. * libguile/bytevectors.c (INTEGERS_TO_LIST): Make sure SIZE isn't 0. Allow SIZE to be greater than the bytevector length, for consistency with allowing extra bytes at the end when the bytevector length is non-zero. Use scm_from_size_t instead of scm_from_uint. * test-suite/tests/bytevectors.test: Add tests. Remove a test that checks for an exception when SIZE is greater than the bytevector length.
2013-01-15string->utf8 implementation uses scm_from_utf8_stringnAndy Wingo1-2/+1
* libguile/bytevectors.c (UTF_TO_STRING): Use scm_from_utf8_stringn.
2013-01-15fix bug where scm_from_utf8_stringn would not detect bad utf-8Andy Wingo1-3/+2
* libguile/strings.c (scm_from_utf8_stringn): * libguile/symbols.c (utf8_string_equals_wide_string): The "bad UTF8" return from u8_mbtouc is a 0xfffd character, not a negative byte length. Fixes a bug in which invalid UTF-8 would not be caught. * libguile/bytevectors.c (scm_utf8_to_string): Use scm_from_utf8_stringn directly. Just a little cleanup. * test-suite/tests/iconv.test ("narrow non-ascii string"): Add test for parsing bad utf-8 with substitution.
2012-04-26Merge commit 'd10f7b572c0ca1ccef87f9c46069daa30946e0cf'Andy Wingo1-51/+20
Conflicts: libguile/smob.c libguile/smob.h test-suite/tests/tree-il.test
2012-04-22bytevectors: Fix IEEE-754 endianness conversion.Ludovic Courtès1-51/+20
Fixes <http://bugs.gnu.org/11310>. Reported by Klaus Stehle <klaus.stehle@uni-tuebingen.de>. * libguile/ieee-754.h: Remove. * libguile/Makefile.am (noinst_HEADERS): Remove `ieee-754.h'. * libguile/bytevectors.c (scm_ieee754_float, scm_ieee754_double): New unions. (float_to_foreign_endianness, float_from_foreign_endianness, double_to_foreign_endianness, double_from_foreign_endianness): Rewrite in terms of the new unions. * test-suite/tests/bytevectors.test ("2.8 Operations on IEEE-754 Representations")["single, little endian", "single, big endian", "double, little endian", "double, big endian"]: New tests.
2012-02-23Revert "wrap iconv_open / iconv_close with a lock to help in thread/fork issues"Andy Wingo1-6/+0
This reverts commit 8dfb7bbfd908ca883d0fdd0d868e13e6b20803ae.
2012-02-17wrap iconv_open / iconv_close with a lock to help in thread/fork issuesAndy Wingo1-0/+6
* libguile/bytevectors.c (STRING_TO_UTF, scm_string_to_utf8) (UTF_TO_STRING): * libguile/ports.c (open_iconv_descriptors, close_iconv_descriptors): * libguile/strings.c (scm_from_stringn, scm_to_stringn): Wrap operations that acquire and destroy iconv contexts with a mutex. While iconv is threadsafe, internally it uses a lock, and we need to make sure when we fork() that no one has that lock -- so we surround it with another one. Gross.
2012-02-11Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-26/+30
Conflicts: libguile/read.c test-suite/tests/tree-il.test
2012-02-10more efficient scm_string_to_utf8, scm_string_to_utf32Andy Wingo1-26/+30
* libguile/bytevectors.c (scm_string_to_utf8): More efficient implementation. (scm_string_to_utf32): Likewise.
2012-01-31Revert "add SCM_HEAP_OBJECT_BASE"Andy Wingo1-1/+1
This reverts commit 47ed8656db8800f3ad20a40eb2c4e9ef3dc891e3. Conflicts: libguile/foreign.c
2011-12-01Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-3/+3
Conflicts: configure.ac libguile/fluids.c libguile/gc.c libguile/gc.h libguile/objcodes.c libguile/procprop.c libguile/vm.c module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm
2011-11-20Allow overlapping regions to be passed to `bytevector-copy!'.Ludovic Courtès1-3/+3
Reported by Dmitry Chestnykh <dmitry@codingrobots.com>. Fixes <http://debbugs.gnu.org/10070>. * libguile/bytevectors.c (scm_bytevector_copy_x): Use `memmove', not `memcpy'. * test-suite/tests/bytevectors.test ("2.2 General Operations")["bytevector-copy! overlapping"]: New test. * doc/ref/api-data.texi (Bytevector Manipulation): Mention possible overlapping.
2011-11-08locking for putc, putsAndy Wingo1-4/+4
* libguile/ports.c (scm_putc, scm_puts): * libguile/ports.h (scm_putc_unlocked, scm_puts_unlocked): Separate into _unlocked and locked variants. Change all callers to use the _unlocked versions.
2011-10-24add SCM_HEAP_OBJECT_BASEAndy Wingo1-1/+1
* libguile/tags.h (SCM_HEAP_OBJECT_BASE): New macro. Given a SCM, returns a pointer to the start of its memory area on the heap. * libguile/bytevectors.c: * libguile/fluids.c: * libguile/foreign.c: * libguile/gc.h: * libguile/guardians.c: * libguile/numbers.h: * libguile/ports.c: * libguile/smob.c: * libguile/struct.c: * libguile/weak-set.c: * libguile/weak-table.c: * libguile/weak-vector.c: Use it.
2011-10-24add SCM_{PACK,UNPACK}_POINTERAndy Wingo1-2/+2
* libguile/tags.h (SCM_UNPACK_POINTER, SCM_PACK_POINTER): New macros. The old SCM2PTR and PTR2SCM were defined in such a way that round-tripping through a pointer could lose precision, even in the case in which you weren't interested in actually dereferencing the pointer, it was simply that you needed to plumb a SCM through APIs that take pointers. These new macros are more like SCM_PACK and SCM_UNPACK, but for pointer types. The bit representation of the pointer should be the same as the scm_t_bits representation. * libguile/gc.h (PTR2SCM, SCM2PTR): Remove support for (old) UNICOS pointers. We are going to try tagging the SCM object itself in the future, and I don't think that keeping this support is worth its cost. It probably doesn't work anyway. * libguile/backtrace.c: * libguile/bytevectors.c: * libguile/continuations.c: * libguile/fluids.c: * libguile/foreign.c: * libguile/gc.h: * libguile/guardians.c: * libguile/hashtab.c: * libguile/load.c: * libguile/numbers.c: * libguile/ports.c: * libguile/smob.c: * libguile/strings.c: * libguile/symbols.c: * libguile/vm.c: * libguile/weak-set.c: * libguile/weak-table.c: * libguile/weak-vector.c: Update many sites to use the new macros.
2011-08-31Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-2/+2
Conflicts: libguile/bytevectors.c libguile/bytevectors.h libguile/objcodes.c libguile/r6rs-ports.c libguile/strings.c libguile/vm.c
2011-08-18fix a couple of leaksAndy Wingo1-1/+1
* libguile/bytevectors.h: * libguile/bytevectors.c (scm_c_take_gc_bytevector): Rename this internal function, from scm_c_take_bytevector. This indicates that unlike the other scm_take_* functions, this one takes GC-managed memory. * libguile/objcodes.c (scm_objcode_to_bytecode): * libguile/vm.c (really_make_boot_program): Use scm_gc_malloc_pointerless, not scm_malloc. Thanks to Stefan Israelsson Tampe! * libguile/r6rs-ports.c: * libguile/strings.c: Adapt to renames.
2011-07-29minor style fix in bytevectors.cAndy Wingo1-1/+1
* libguile/bytevectors.c (SCM_BYTEVECTOR_HEADER_BYTES): Use sizeof scm_t_bits, not sizeof SCM. It's the same, but it seems like the right thing.
2011-07-25Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-24/+66
Conflicts: GUILE-VERSION test-suite/tests/srfi-4.test
2011-07-01Add type and range checks to the complex generalized vector accessors.Ludovic Courtès1-46/+64
* libguile/bytevectors.c (COMPLEX_ACCESSOR_PROLOGUE, COMPLEX_NATIVE_REF, COMPLEX_NATIVE_SET): New macros. (bytevector_ref_c32, bytevector_ref_c64): Defined in terms of `COMPLEX_NATIVE_REF'. (bytevector_set_c32, bytevector_set_c64): Defined in terms of `COMPLEX_NATIVE_SET'. (bytevector_ref_fns): Make `static'. * test-suite/tests/srfi-4.test ("c32 vectors")["generalized-vector-ref", "generalized-vector-set!", "generalized-vector-ref, out-of-range", "generalized-vector-set!, out-of-range"]: New tests. ("c64 vectors")["generalized-vector-ref", "generalized-vector-set!", "generalized-vector-ref, out-of-range", "generalized-vector-set!, out-of-range"]: New tests.
2011-07-01Fix unaligned accesses for bytevectors of complex numbers.Ludovic Courtès1-10/+34
* libguile/bytevectors.c (bytevector_ref_c32, bytevector_ref_c64, bytevector_set_c32, bytevector_set_c64): Use `memcpy' to avoid unaligned accesses. This fixes SIGBUS on SPARC and possibly other alignment-sensitive platforms.
2011-05-15remove SCM_I_SIZE limits definesAndy Wingo1-1/+1
* libguile/__scm.h: Remove defines for SCM_I_SIZE_MAX, SCM_I_SSIZE_MIN, and SCM_I_SSIZE_MAX, as there is no longer a scm_t_size / scm_size_t type. * libguile/bytevectors.c (make_bytevector): Replace a use of SCM_I_SIZE_MAX with ((size_t) -1).
2011-05-13merge strictness branch from 2.0Andy Wingo1-4/+4
2011-05-13scm_is_eq for SCM vals, not == or !=Andy Wingo1-4/+4
* libguile/bytevectors.c (scm_make_bytevector, STRING_TO_UTF) (UTF_TO_STRING): * libguile/continuations.c (scm_i_check_continuation): * libguile/expand.h (SCM_EXPANDED_P): * libguile/fluids.c (scm_i_make_with_fluids): * libguile/generalized-vectors.c (scm_make_generalized_vector): * libguile/goops.c (SCM_GOOPS_UNBOUNDP, slot_definition_using_name): (scm_c_extend_primitive_generic, more_specificp, scm_make) * libguile/i18n.c (SCM_VALIDATE_OPTIONAL_LOCALE_COPY): (scm_locale_string_to_integer) * libguile/modules.c (resolve_duplicate_binding): (scm_module_reverse_lookup) * libguile/posix.c (scm_to_resource): * libguile/r6rs-ports.c (scm_put_bytevector): * libguile/socket.c (scm_connect, scm_bind, scm_sendto * libguile/stacks.c (find_prompt): * libguile/variable.c (scm_variable_ref, scm_variable_bound_p): * libguile/vm-engine.h (ASSERT_BOUND_VARIABLE, ASSERT_BOUND) * libguile/vm-i-system.c (VARIABLE_BOUNDP, local_bound) (long_local_bound, fluid_ref): Use scm_is_eq to compare, not == / !=.
2011-05-07bytevectors have internal parent fieldAndy Wingo1-6/+23
* libguile/bytevectors.h (SCM_BYTEVECTOR_HEADER_SIZE): Bump, giving bytevectors another word: a parent pointer. Will allow for sub-bytevectors and efficient mmap bindings. * libguile/bytevectors.c (make_bytevector): (make_bytevector_from_buffer): Init parent to #f. (scm_c_take_bytevector, scm_c_take_typed_bytevector): Another argument, the parent, which gets set in the bytevector. * libguile/foreign.c (scm_pointer_to_bytevector): Use the parent field instead of registering a weak reference from bytevector to foreign pointer. * libguile/objcodes.c (scm_objcode_to_bytecode): Use the parent field to avoid copying the objcode. * libguile/srfi-4.c (DEFINE_SRFI_4_C_FUNCS): * libguile/strings.c (scm_from_stringn): * libguile/vm.c (really_make_boot_program): * libguile/r6rs-ports.c (scm_get_bytevector_some) (scm_get_bytevector_all, bytevector_output_port_procedure): Set the parent to #f.
2011-03-08Fix bytevectors VALIDATE_REAL to test for reals, not rationalsMark H Weaver1-1/+1
Reported and fixed by Daniel Llorens <dll@bluewin.ch>. * libguile/bytevectors.c (VALIDATE_REAL): Test for reals, not rationals. * test-suite/tests/srfi-4.test (f32 vectors, f64 vectors): Add tests.
2011-03-08Fix bytevectors VALIDATE_REAL to test for reals, not rationalsMark H Weaver1-1/+1
Reported and fixed by Daniel Llorens <dll@bluewin.ch>. * libguile/bytevectors.c (VALIDATE_REAL): Test for reals, not rationals. * test-suite/tests/srfi-4.test (f32 vectors, f64 vectors): Add tests.
2011-01-07use scm_from_latin1_symboln for string literals and load-symbolAndy Wingo1-3/+3
* libguile/bytevectors.c: * libguile/eval.c: * libguile/goops.c: * libguile/i18n.c: * libguile/load.c: * libguile/memoize.c: * libguile/modules.c: * libguile/ports.c: * libguile/print.c: * libguile/procs.c: * libguile/programs.c: * libguile/read.c: * libguile/script.c: * libguile/srfi-14.c: * libguile/stacks.c: * libguile/strings.c: * libguile/throw.c: * libguile/vm.c: Use scm_from_latin1_symboln to make symbols from string literals, because they aren't in the user's locale -- they are in ASCII, and we can optimize this case. * libguile/vm-i-loader.c: Also use scm_from_latin1_symboln when loading narrow symbols.
2010-12-04make-string et al nulls memory if not given an initializerAndy Wingo1-0/+2
* libguile/gc-malloc.c: Add a note that the gc-malloc does not clear the memory block, so users need to make sure it is initialized. * libguile/bitvectors.c (scm_c_make_bitvector): * libguile/bytevectors.c (scm_make_bytevector): * libguile/strings.c (scm_c_make_string): If no initializer is given, initialize the bytes to 0. Prevents information leakage if an app uses make-string et al without initializers. * libguile/foreign.c (make_cif): Initialize this too, to prevent leakage in the struct holes. Paranoia...
2010-11-19fix a number of assuptions that a long could hold an inumAndy Wingo1-4/+4
* libguile/bytevectors.c: * libguile/goops.c: * libguile/instructions.c: * libguile/numbers.c: * libguile/random.c: * libguile/read.c: * libguile/vm-i-scheme.c: Fix a number of assumptions that a long could hold an inum. This is not the case on platforms whose void* is larger than their long. * libguile/numbers.c (scm_i_inum2big): New helper, only implemented for sizeof(void*) == sizeof(long); produces a compile error on other platforms. Basically gmp doesn't have a nice interface for converting between mpz values and intmax_t.
2010-06-01rename (rnrs bytevector) to (rnrs bytevectors)Andy Wingo1-1/+1
* module/rnrs/bytevectors.scm: Rename to (rnrs bytevectors), from (rnrs bytevector), to match the name from the R6RS. * benchmark-suite/benchmarks/bytevectors.bm: * doc/ref/api-data.texi: * doc/ref/api-foreign.texi: * libguile/bytevectors.c: * module/6/rnrs.scm: * module/language/assembly.scm: * module/language/assembly/compile-bytecode.scm: * module/language/assembly/decompile-bytecode.scm: * module/language/glil/compile-assembly.scm: * module/language/tree-il/primitives.scm: * module/srfi/srfi-4.scm: * module/srfi/srfi-4/gnu.scm: * module/system/foreign.scm: * test-suite/standalone/test-ffi: * test-suite/tests/asm-to-bytecode.test: * test-suite/tests/bytevectors.test: * test-suite/tests/foreign.test: * test-suite/tests/r6rs-ports.test: Update all referrers.
2010-04-01more fixes to equal? for arraysAndy Wingo1-1/+2
* 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-03-16rename libguile to libguile-@EFFECTIVE_VERSION@, currently libguile-2.0Andy Wingo1-1/+2
* libguile/Makefile.am (lib_LTLIBRARIES): Instead of just "libguile.la", make "libguile-@EFFECTIVE_VERSION@.la". This allows multiple versions of Guile to be installed at once. See http://www106.pair.com/rhp/parallel.html for a rationale. (libguile_@GUILE_EFFECTIVE_VERSION@_la_CFLAGS): (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (libguile_@GUILE_EFFECTIVE_VERSION@_la_DEPENDENCIES): (libguile_@GUILE_EFFECTIVE_VERSION@_la_LIBADD): (libguile_@GUILE_EFFECTIVE_VERSION@_la_LDFLAGS): Fixup automake vars to include the effective version. (guile_LDADD): Fix up the spelling of libguile. * libguile/bytevectors.c (scm_bootstrap_bytevectors): * libguile/foreign.c (scm_register_foreign): * libguile/i18n.c (scm_bootstrap_i18n): * libguile/instructions.c (scm_bootstrap_instructions): * libguile/objcodes.c (scm_bootstrap_objcodes): * libguile/programs.c (scm_bootstrap_programs): * libguile/vm.c (scm_bootstrap_vm): Register extensions using e.g. "libguile-2.0" as the libname -- i.e., including the effective version in the libname. * module/ice-9/i18n.scm: * module/rnrs/bytevector.scm: * module/rnrs/io/ports.scm: * module/system/foreign.scm: * module/system/vm/instruction.scm: * module/system/vm/objcode.scm: * module/system/vm/program.scm: * module/system/vm/vm.scm: When doing a load-extension for something in Guile, use the effective version also. * meta/guile-2.0-uninstalled.pc.in (Libs): * meta/guile-2.0.pc.in (Libs): Use -lguile-@EFFECTIVE_VERSION@. This change should mean that code built against Guile should not be affected by the libguile rename. * guile-readline/Makefile.am (libguilereadline_v_@LIBGUILEREADLINE_MAJOR@_la_LIBADD): * srfi/Makefile.am (libguile_srfi_srfi_1_v_@LIBGUILE_SRFI_SRFI_1_MAJOR@_la_LIBADD): (libguile_srfi_srfi_4_v_@LIBGUILE_SRFI_SRFI_4_MAJOR@_la_LIBADD): (libguile_srfi_srfi_13_14_v_@LIBGUILE_SRFI_SRFI_13_14_MAJOR@_la_LIBADD): (libguile_srfi_srfi_60_v_@LIBGUILE_SRFI_SRFI_60_MAJOR@_la_LIBADD): * test-suite/standalone/Makefile.am (test_num2integral_LDADD): (test_round_LDADD): (libtest_asmobs_la_LIBADD): (libtest_ffi_la_LIBADD): (test_list_LDADD): (test_unwind_LDADD): (test_conversion_LDADD): (test_loose_ends_LDADD): (test_scm_c_read_LDADD): (test_scm_take_locale_symbol_LDADD): (test_scm_take_u8vector_LDADD): (libtest_extensions_la_LIBADD): (test_with_guile_module_LDADD): (test_scm_with_guile_LDADD): Fix up the spelling of libguile.la.
2010-01-07reimplement srfi-4 vectors on top of bytevectorsAndy Wingo1-11/+10
* libguile/srfi-4.h: * libguile/srfi-4.c (scm_make_srfi_4_vector): New function, exported by (srfi srfi-4 gnu). * libguile/srfi-4.i.c: Removed. * module/srfi/srfi-4.scm: * module/srfi/srfi-4/gnu.scm: Reimplement srfi-4 vectors on top of bytevectors. The implementation is mostly in Scheme now. * test-suite/tests/unif.test: Update to use (srfi srfi-4 gnu). * libguile/bytevectors.c (bytevector_ref_c32, bytevector_ref_c64) (bytevector_set_c32, bytevector_set_c64): Fix some embarrassing bugs. Still need to do an upper bounds check. * libguile/deprecated.h: Remove deprecated array functions: scm_i_arrayp, scm_i_array_ndim, scm_i_array_mem, scm_i_array_v, scm_i_array_base, scm_i_array_dims, and the deprecated macros: SCM_ARRAYP, SCM_ARRAY_NDIM, SCM_ARRAY_CONTP, SCM_ARRAY_MEM, SCM_ARRAY_V, SCM_ARRAY_BASE, SCM_ARRAY_DIMS. * libguile/deprecated.c (scm_uniform_vector_read_x) (scm_uniform_vector_write, scm_uniform_array_read_x) (scm_uniform_array_write): Newly deprecated functions. * libguile/generalized-arrays.c (scm_array_type): Remove the bytevector hack. * libguile/objcodes.c (scm_bytecode_to_objcode, scm_objcode_to_bytecode): Rework to operate on bytevectors, as scm_make_u8vector now causes a module lookup, which can't be done e.g. when loading the VM boot program for psyntax-pp.go on a fresh bootstrap. * libguile/objcodes.h (SCM_F_OBJCODE_IS_BYTEVECTOR): (SCM_OBJCODE_IS_BYTEVECTOR): s/U8VECTOR/BYTEVECTOR/. * module/ice-9/boot-9.scm (the-scm-module): A terrible hack to pull in (srfi srfi-4), as the bindings are primarily there now. We'll worry about this later.
2010-01-07Revert "Remove unused internal bytevector functions."Andy Wingo1-0/+14
This reverts commit c4daa519107798d06ae96d2f69dc211fc57cc8a3.
2009-12-05more boot cleanupAndy Wingo1-2/+1
* libguile/bytevectors.c (scm_bootstrap_bytevectors): Remove a call to scm_gc_protect_object. * libguile/gc.h: * libguile/gc.c (scm_init_gc_protect_object): Rename from scm_init_storage, and just return void. Make the GC boot procs have internal linkage. * libguile/init.c: Adapt to the name change.
2009-12-05remove a bunch of needless scm_permanent_object callsAndy Wingo1-2/+2
* libguile/array-handle.c: * libguile/bytevectors.c: * libguile/deprecated.c: * libguile/eval.c: * libguile/feature.c: * libguile/filesys.c: * libguile/gc.c: * libguile/gdbint.c: * libguile/goops.c: * libguile/instructions.c: * libguile/load.c: * libguile/modules.c: * libguile/numbers.c: * libguile/options.c: * libguile/ports.c: * libguile/scmsigs.c: * libguile/srcprop.c: * libguile/srfi-4.c: * libguile/stacks.c: * libguile/threads.c: * libguile/vm.c: Remove calls to scm_permanent_object, as they are no longer needed with the BDW GC.
2009-11-16Re-add an indirection in bytevectors.Ludovic Courtès1-23/+47
The intent is to allow for mmap(3) bindings and to actually reuse user-provided buffers in `scm_c_take_bytevector ()'. * libguile/bytevectors.h (SCM_BYTEVECTOR_HEADER_SIZE): Increment. (SCM_BYTEVECTOR_CONTENTS): Take the pointer from the second word. (SCM_BYTEVECTOR_CONTIGUOUS_P): New macro. (SCM_BYTEVECTOR_ELEMENT_TYPE): Adjust to live alongside the CONTIGUOUS flag. * libguile/bytevectors.c (SCM_BYTEVECTOR_SET_CONTENTS, SCM_BYTEVECTOR_SET_CONTIGUOUS_P): New macros. (SCM_BYTEVECTOR_SET_ELEMENT_TYPE): Adjust. (SCM_BYTEVECTOR_TYPED_LENGTH): Properly parenthesize. (make_bytevector): Adjust to new bytevector header. (make_bytevector_from_buffer): Reuse CONTENTS. (scm_c_shrink_bytevector): Differentiate between contiguous and non-contiguous bytevectors.
2009-11-16Remove unused internal bytevector functions.Ludovic Courtès1-14/+0
* libguile/bytevectors.c (scm_i_make_typed_bytevector, scm_c_take_typed_bytevector): Remove. * libguile/bytevectors.h: Adjust accordingly.
2009-10-28Modify bytevectors/string conversions to allow wide stringsMichael Gran1-97/+68
The bytevector to string conversion functions were accomplished by converting via locale strings. This did not allow conversions of wide strings in an 8-bit locale. This is avoided by using knowledge of the storage format of the string. * libguile/bytevectors.c (STRING_TO_UTF, scm_string_to_utf8): modify string to bytevector conversion to use internal string information (UTF_TO_STRING, scm_utf8_to_string): modify bytevector to string conversion
2009-10-16bitvector tweaksAndy Wingo1-1/+4
* libguile/arrays.c (scm_from_contiguous_typed_array): * libguile/bytevectors.c (scm_uniform_array_to_bytevector): Error if the uniform element size is more than 8 bits, but not divisible by 8 -- because our math could overflow in that case. * module/ice-9/deprecated.scm (#\y): Indeed, #* is the valid bitvector syntax :)
2009-10-15Fix segfault for `(uniform-array->bytevector (bitvector))'.Ludovic Courtès1-3/+2
* libguile/bytevectors.c (scm_uniform_array_to_bytevector): Fix BYTE_LEN computation for bitvectors. * test-suite/tests/bytevectors.test ("uniform-array->bytevector"): New test prefix.
2009-09-18fix bitvectors after the array handle refactoringAndy Wingo1-7/+14
* libguile/uniform.h (scm_array_handle_uniform_element_bit_size): New public accessor. * libguile/uniform.c (scm_array_handle_uniform_element_size): Better errors in non-byte-aligned arrays. (scm_uniform_vector_element_type, scm_uniform_vector_element_size) (scm_c_uniform_vector_ref, scm_c_uniform_vector_set_x): (scm_uniform_vector_to_list): Don't require byte-aligned access. * libguile/bytevectors.c (scm_uniform_array_to_bytevector): * libguile/arrays.c (scm_from_contiguous_typed_array): Fix for uniform arrays whose element size is not a multiple of the byte size.
2009-08-31Remove the distinction between inline/outline storage for bytevectors.Ludovic Courtès1-88/+58
* libguile/bytevectors.c (SCM_BYTEVECTOR_INLINE_THRESHOLD, SCM_BYTEVECTOR_INLINEABLE_SIZE_P, SCM_BYTEVECTOR_SET_CONTENTS, SCM_BYTEVECTOR_SET_INLINE): Remove. (SCM_BYTEVECTOR_HEADER_BYTES): New macro. (SCM_BYTEVECTOR_SET_ELEMENT_TYPE): Adjust to new flag layout. (make_bytevector): Remove content inlining machinery; use `scm_gc_malloc_pointerless ()' in all cases; special-case zero-sized vu8 buffers. (make_bytevector_from_buffer): Simplified. (scm_c_shrink_bytevector): New, formerly `scm_i_shrink_bytevector ()'. Remove buffer inlining machinery. (scm_bootstrap_bytevectors): Use `make_bytevector ()' for SCM_NULL_BYTEVECTOR. * libguile/bytevectors.h (SCM_BYTEVECTOR_HEADER_SIZE): New macro. (SCM_BYTEVECTOR_CONTENTS): Adjust to new layout. (SCM_SET_BYTEVECTOR_FLAGS): Properly cast F. (SCM_F_BYTEVECTOR_INLINE, SCM_BYTEVECTOR_INLINE_P): Remove. (SCM_BYTEVECTOR_ELEMENT_TYPE): Adjust. (scm_c_shrink_bytevector): Remove macro, make a C function declaration.
2009-08-30Use a TC7 tag instead of a SMOB for bytevectors.Ludovic Courtès1-32/+29
* libguile/bytevectors.c (scm_tc16_bytevector): Remove. (SCM_BYTEVECTOR_SET_LENGTH, SCM_BYTEVECTOR_SET_CONTENTS, SCM_BYTEVECTOR_SET_INLINE, SCM_BYTEVECTOR_SET_ELEMENT_TYPE, make_bytevector_from_buffer, scm_is_bytevector, scm_bootstrap_bytevectors): Adjust to the SMOB->tc7 change. (scm_i_print_bytevector): New, formerly `print_bytevector ()'. (bytevector_equal_p): Remove. * libguile/bytevectors.h (SCM_BYTEVECTOR_LENGTH, SCM_BYTEVECTOR_CONTENTS, SCM_BYTEVECTOR_P): Adjust to SMOB->tc7 change. (SCM_BYTEVECTOR_FLAGS, SCM_SET_BYTEVECTOR_FLAGS): New macros. (scm_tc16_bytevector): Remove declaration. (scm_i_print_bytevector): New declaration. * libguile/eq.c (scm_equal_p): Handle `scm_tc7_bytevector'. * libguile/evalext.c (scm_self_evaluating_p): Likewise. * libguile/print.c (iprin1): Likewise. * libguile/tags.h (scm_tc7_bytevector): New. (scm_tc7_unused_8): Remove. * libguile/validate.h (SCM_VALIDATE_BYTEVECTOR): Adjust. * test-suite/tests/bytevectors.test ("Datum Syntax")["self-evaluating?"]: New test.
2009-08-28Merge branch 'master' into boehm-demers-weiser-gcLudovic Courtès1-67/+255
Conflicts: libguile/Makefile.am libguile/bytevectors.c libguile/gc-card.c libguile/gc-mark.c libguile/programs.c libguile/srcprop.c libguile/srfi-14.c libguile/symbols.c libguile/threads.c libguile/unif.c libguile/vm.c
2009-08-18Use `scm_gc_malloc_pointerless ()' for bytevectors.Ludovic Courtès1-1/+2
* libguile/bytevectors.c (make_bytevector): Use `scm_gc_malloc_pointerless ()' for the buffer itself. * libguile/r6rs-ports.c (scm_get_bytevector_some, scm_get_bytevector_all, bop_buffer_grow): Likewise.
2009-08-18Remove unneeded SMOB mark/free procedures.Ludovic Courtès1-20/+0
* libguile/bytevectors.c (free_bytevector): Remove. (scm_bootstrap_bytevectors): Update accordingly. * libguile/r6rs-ports.c (bip_mark, cbp_mark, bop_free, bop_proc_mark): Remove. (initialize_bytevector_input_ports, initialize_custom_binary_input_ports, initialize_bytevector_output_ports, initialize_custom_binary_output_ports): Update accordingly.