]> git.vpit.fr Git - perl/modules/Scalar-Vec-Util.git/blobdiff - bitvect.h
Properly prepare the scalars before filling or copying into them
[perl/modules/Scalar-Vec-Util.git] / bitvect.h
index b50c1a10407323cd5de02b6cfadeb9f5578045f7..0f096fdb7f61ec000de50f0cd8d6705485f5f116 100644 (file)
--- a/bitvect.h
+++ b/bitvect.h
 # define BV_UNIT unsigned char
 #endif
 
-#define BV_SIZE(I) ((((I) % CHAR_BIT) != 0) + ((I) / CHAR_BIT))
-
 #define BITS(T) (CHAR_BIT * sizeof(T))
 
+#define BV_SIZE(I) (((((I) % BITS(BV_UNIT)) != 0) + ((I) / BITS(BV_UNIT))) * sizeof(BV_UNIT))
+
 /* 0 <= I <  CHAR_BIT * sizeof(T) */
 #define BV_MASK_LOWER(T, I)  (~((~((T) 0)) << (I)))
 /* 0 <  I <= CHAR_BIT * sizeof(T) */