Generalize the backing type of bitvec
This commit is contained in:
@@ -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)\
|
||||
|
||||
Reference in New Issue
Block a user