Generalize the backing type of bitvec

This commit is contained in:
Nils O. Selåsdal
2013-10-28 23:21:26 +01:00
parent 215035190e
commit eceda7be70
3 changed files with 20 additions and 16 deletions
+8 -3
View File
@@ -1,13 +1,18 @@
#ifndef UC_BITEVEC_H_
#define UC_BITEVEC_H_
#include <limits.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Backing type of the bit vector*/
typedef unsigned long uc_bv_integer;
struct UCBitVec {
//storage for the bits
unsigned long *vec;
uc_bv_integer *vec;
//length in bytes of the above vec.
size_t vec_len;
};
@@ -15,11 +20,11 @@ struct UCBitVec {
/**
* Evaluates the length required for a bitvec to store nbit bits.
*/
#define UC_BV_LEN(nbits) ((nbits/(sizeof(unsigned long)*CHAR_BIT)) + (nbits % (sizeof(unsigned long)*CHAR_BIT) == 0 ? 0 : 1))
#define UC_BV_LEN(nbits) ((nbits/(sizeof(uc_bv_integer)*CHAR_BIT)) + (nbits % (sizeof(uc_bv_integer)*CHAR_BIT) == 0 ? 0 : 1))
/**
* Use as :
* unsigned long v[10];
* uc_bv_integer v[10];
* struct UCBitVec v = BITVEC_STATIC_INIT(v);
*/
#define UC_BV_STATIC_INIT(vec_data)\