mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 20:00:19 +02:00
* 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.
85 lines
3 KiB
C
85 lines
3 KiB
C
/* classes: h_files */
|
||
|
||
#ifndef SCM_BITVECTORS_H
|
||
#define SCM_BITVECTORS_H
|
||
|
||
/* Copyright (C) 1995,1996,1997,1999,2000,2001, 2004, 2006, 2008, 2009, 2014 Free Software Foundation, Inc.
|
||
*
|
||
* This library is free software; you can redistribute it and/or
|
||
* modify it under the terms of the GNU Lesser General Public License
|
||
* as published by the Free Software Foundation; either version 3 of
|
||
* the License, or (at your option) any later version.
|
||
*
|
||
* This library is distributed in the hope that it will be useful, but
|
||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
* Lesser General Public License for more details.
|
||
*
|
||
* You should have received a copy of the GNU Lesser General Public
|
||
* License along with this library; if not, write to the Free Software
|
||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||
* 02110-1301 USA
|
||
*/
|
||
|
||
|
||
|
||
#include "libguile/__scm.h"
|
||
#include "libguile/array-handle.h"
|
||
|
||
|
||
|
||
/* Bitvectors. Exciting stuff, maybe!
|
||
*/
|
||
|
||
|
||
/** Bit vectors */
|
||
|
||
SCM_API SCM scm_bitvector_p (SCM vec);
|
||
SCM_API SCM scm_bitvector (SCM bits);
|
||
SCM_API SCM scm_make_bitvector (SCM len, SCM fill);
|
||
SCM_API SCM scm_bitvector_length (SCM vec);
|
||
SCM_API SCM scm_bitvector_ref (SCM vec, SCM idx);
|
||
SCM_API SCM scm_bitvector_set_x (SCM vec, SCM idx, SCM val);
|
||
SCM_API SCM scm_list_to_bitvector (SCM list);
|
||
SCM_API SCM scm_bitvector_to_list (SCM vec);
|
||
SCM_API SCM scm_bitvector_fill_x (SCM vec, SCM val);
|
||
|
||
SCM_API SCM scm_bit_count (SCM item, SCM seq);
|
||
SCM_API SCM scm_bit_position (SCM item, SCM v, SCM k);
|
||
SCM_API SCM scm_bit_set_star_x (SCM v, SCM kv, SCM obj);
|
||
SCM_API SCM scm_bit_count_star (SCM v, SCM kv, SCM obj);
|
||
SCM_API SCM scm_bit_invert_x (SCM v);
|
||
SCM_API SCM scm_istr2bve (SCM str);
|
||
|
||
SCM_API int scm_is_bitvector (SCM obj);
|
||
SCM_API SCM scm_c_make_bitvector (size_t len, SCM fill);
|
||
SCM_API size_t scm_c_bitvector_length (SCM vec);
|
||
SCM_API SCM scm_c_bitvector_ref (SCM vec, size_t idx);
|
||
SCM_API void scm_c_bitvector_set_x (SCM vec, size_t idx, SCM val);
|
||
SCM_API const scm_t_uint32 *scm_array_handle_bit_elements (scm_t_array_handle *h);
|
||
SCM_API scm_t_uint32 *scm_array_handle_bit_writable_elements (scm_t_array_handle *h);
|
||
SCM_API size_t scm_array_handle_bit_elements_offset (scm_t_array_handle *h);
|
||
SCM_API const scm_t_uint32 *scm_bitvector_elements (SCM vec,
|
||
scm_t_array_handle *h,
|
||
size_t *offp,
|
||
size_t *lenp,
|
||
ssize_t *incp);
|
||
SCM_API scm_t_uint32 *scm_bitvector_writable_elements (SCM vec,
|
||
scm_t_array_handle *h,
|
||
size_t *offp,
|
||
size_t *lenp,
|
||
ssize_t *incp);
|
||
|
||
SCM_INTERNAL scm_t_uint32 *scm_i_bitvector_bits (SCM vec);
|
||
SCM_INTERNAL int scm_i_is_mutable_bitvector (SCM vec);
|
||
SCM_INTERNAL int scm_i_print_bitvector (SCM vec, SCM port, scm_print_state *pstate);
|
||
SCM_INTERNAL SCM scm_i_bitvector_equal_p (SCM vec1, SCM vec2);
|
||
SCM_INTERNAL void scm_init_bitvectors (void);
|
||
|
||
#endif /* SCM_BITVECTORS_H */
|
||
|
||
/*
|
||
Local Variables:
|
||
c-file-style: "gnu"
|
||
End:
|
||
*/
|