summaryrefslogtreecommitdiff
path: root/libguile/bytevectors.h
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2009-11-15 19:34:38 +0100
committerLudovic Courtès <ludo@gnu.org>2009-11-16 09:23:45 +0100
commit3fe87cf7aff396d7bd993aa009f48eb8afd6c1cd (patch)
treea27750be21b5bc418e564b4a665a804bf46c3729 /libguile/bytevectors.h
parentc4daa519107798d06ae96d2f69dc211fc57cc8a3 (diff)
downloadguile-3fe87cf7aff396d7bd993aa009f48eb8afd6c1cd.tar.gz
Re-add an indirection in bytevectors.
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.
Diffstat (limited to 'libguile/bytevectors.h')
-rw-r--r--libguile/bytevectors.h15
1 files changed, 8 insertions, 7 deletions
diff --git a/libguile/bytevectors.h b/libguile/bytevectors.h
index 525b02078..59db89e86 100644
--- a/libguile/bytevectors.h
+++ b/libguile/bytevectors.h
@@ -26,15 +26,14 @@
/* R6RS bytevectors. */
-/* The size in words of the bytevector header (type tag, flags, and
- length). */
-#define SCM_BYTEVECTOR_HEADER_SIZE 2U
+/* The size in words of the bytevector header (type tag and flags, length,
+ and pointer to the underlying buffer). */
+#define SCM_BYTEVECTOR_HEADER_SIZE 3U
#define SCM_BYTEVECTOR_LENGTH(_bv) \
((size_t) SCM_CELL_WORD_1 (_bv))
-#define SCM_BYTEVECTOR_CONTENTS(_bv) \
- ((signed char *) SCM_CELL_OBJECT_LOC ((_bv), \
- SCM_BYTEVECTOR_HEADER_SIZE))
+#define SCM_BYTEVECTOR_CONTENTS(_bv) \
+ ((signed char *) SCM_CELL_WORD_2 (_bv))
SCM_API SCM scm_endianness_big;
@@ -124,7 +123,9 @@ SCM_API SCM scm_utf32_to_string (SCM, SCM);
scm_tc7_bytevector | ((scm_t_bits)(_f) << 7UL))
#define SCM_BYTEVECTOR_ELEMENT_TYPE(_bv) \
- (SCM_BYTEVECTOR_FLAGS (_bv))
+ (SCM_BYTEVECTOR_FLAGS (_bv) & 0xffUL)
+#define SCM_BYTEVECTOR_CONTIGUOUS_P(_bv) \
+ (SCM_BYTEVECTOR_FLAGS (_bv) >> 8UL)
/* Hint that is passed to `scm_gc_malloc ()' and friends. */
#define SCM_GC_BYTEVECTOR "bytevector"