From: Ralph Ronnquist Date: Mon, 27 Jun 2022 00:24:40 +0000 (+1000) Subject: restore to the 8-bit level index variant X-Git-Tag: 0.1~7 X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=5a02e98f44e95db2660e1468c5765d924af68534;p=rrq%2Frrqmisc.git restore to the 8-bit level index variant --- diff --git a/vector/Makefile b/vector/Makefile index f8b05a7..edd309f 100644 --- a/vector/Makefile +++ b/vector/Makefile @@ -2,7 +2,7 @@ LIBRARY = libvector.a LIBOBJS = vector.o hashvector.o # This is overridable on command line -VECTOR_LEVEL_BITS = 4 +VECTOR_LEVEL_BITS = 8 default: $(LIBRARY) diff --git a/vector/vector.c b/vector/vector.c index feaed9f..c4482a7 100644 --- a/vector/vector.c +++ b/vector/vector.c @@ -32,6 +32,19 @@ static int VECTOR_INDEX_PART_INC(vector_index *index,int part) { } return ++VECTOR_PART_BYTE(index,part).msb; } +#elif VECTOR_LEVEL_BITS == 8 + +#define VECTOR_LEVEL_MASK ( VECTOR_SLOTS - 1 ) + +typedef union { + vector_index as_whole; + unsigned char as_byte[8]; +} vector_indexing; + +#define VECTOR_INDEX_PART(i,p) (((vector_indexing*)(i))->as_byte[p]) + +#define VECTOR_INDEX_PART_INC(i,p) (++VECTOR_INDEX_PART(i,p)) + #endif /** diff --git a/vector/vector.h b/vector/vector.h index d84c08c..ccd57f3 100644 --- a/vector/vector.h +++ b/vector/vector.h @@ -6,11 +6,13 @@ * of index pages. The indexing is done using "unsigned long" indexes. */ +#ifndef VECTOR_LEVEL_BITS /*! * Macro: VECTOR_LEVEL_BITS * This defines the number of bits in the indexing bit field. */ -#define VECTOR_LEVEL_BITS 4 +#define VECTOR_LEVEL_BITS 8 +#endif /*! * Type: vector_index