1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-03 08:10:31 +02:00
guile/libguile/bitvectors.h
Andy Wingo 30ad63113a Add bitvectors-internal.h
* libguile/bitvectors-internal.h: New file.
* libguile/Makefile.am (noinst_HEADERS): Add new file.
* libguile/bitvectors.c: Adapt to add scm_ prefix to the is_bytevector,
bytevector_bits, etc helpers.
* libguile/bitvectors.h (scm_is_bitvector): Define inline.  Remove
internal defines from the header.
* libguile/eq.c:
* libguile/init.c:
* libguile/print.c:
* libguile/array-handle.c: Adapt.
2025-06-30 15:26:14 +02:00

75 lines
2.6 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef SCM_BITVECTORS_H
#define SCM_BITVECTORS_H
/* Copyright 1995-1997,1999-2001,2004,2006,2008-2009,2014,2018,2020,2025
Free Software Foundation, Inc.
This file is part of Guile.
Guile 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.
Guile 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 Guile. If not, see
<https://www.gnu.org/licenses/>. */
#include "libguile/array-handle.h"
/* Bitvectors. Exciting stuff, maybe!
*/
/** Bit vectors */
SCM_API SCM scm_list_to_bitvector (SCM list);
SCM_API SCM scm_bitvector_to_list (SCM vec);
SCM_API SCM scm_bitvector_copy (SCM vec, SCM start, SCM end);
SCM_API SCM scm_bitvector_position (SCM v, SCM item, SCM start);
static inline int
scm_is_bitvector (SCM obj)
{
return SCM_HAS_TYP7 ((obj), scm_tc7_bitvector);
}
SCM_API SCM scm_c_make_bitvector (size_t len, SCM fill);
SCM_API size_t scm_c_bitvector_length (SCM vec);
SCM_API size_t scm_c_bitvector_count (SCM v);
SCM_API int scm_c_bitvector_bit_is_set (SCM vec, size_t idx);
SCM_API int scm_c_bitvector_bit_is_clear (SCM vec, size_t idx);
SCM_API void scm_c_bitvector_set_bit_x (SCM vec, size_t idx);
SCM_API void scm_c_bitvector_clear_bit_x (SCM vec, size_t idx);
SCM_API void scm_c_bitvector_set_bits_x (SCM v, SCM bits);
SCM_API void scm_c_bitvector_clear_bits_x (SCM v, SCM bits);
SCM_API void scm_c_bitvector_set_all_bits_x (SCM vec);
SCM_API void scm_c_bitvector_clear_all_bits_x (SCM vec);
SCM_API void scm_c_bitvector_flip_all_bits_x (SCM vec);
SCM_API size_t scm_c_bitvector_count_bits (SCM v, SCM bits);
SCM_API const scm_t_bits *scm_array_handle_bit_elements (scm_t_array_handle *h);
SCM_API scm_t_bits *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_bits *scm_bitvector_elements (SCM vec,
scm_t_array_handle *h,
size_t *offp,
size_t *lenp,
ssize_t *incp);
SCM_API scm_t_bits *scm_bitvector_writable_elements (SCM vec,
scm_t_array_handle *h,
size_t *offp,
size_t *lenp,
ssize_t *incp);
#endif /* SCM_BITVECTORS_H */