Defines | Functions

eg_bit.h File Reference

#include "eg_config.h"
#include "eg_macros.h"
#include "eg_mem.h"
Include dependency graph for eg_bit.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define __EGBIT_DEBUG_LEVEL__   10
#define bit_int_t   uint32_t
#define EGbitset_t   bit_int_t
#define EGbitsetSize(__Bsize)   (((__Bsize)>>__EGBIT_SHIFT__)+(((__Bsize)&__EGBIT_MASK__)?1:0))
 Macro to compute the right size of a bitset given the desired number of bits in the bitset.
Word lengths and related macros

#define __EGBIT_WORD_SIZE__   32U
#define __EGBIT_SHIFT__   5U
#define __EGBIT_MASK__   31U

Functions

int EGbitAnd (bit_int_t *dst, const bit_int_t *src, const unsigned int from, const unsigned int to)
int EGbitCopy (bit_int_t *const a, const bit_int_t *const b, const unsigned int from, const unsigned int to)
EGbitset_t EGbitCount (bit_int_t *bitset, const unsigned int from, const unsigned int to)
 Count the number of on-bits in a bit-map.
EGbitset_t EGbitElemBitCount (EGbitset_t n)
 Count number of on bits on 32-bit integers.
int EGbitIsEqual (const bit_int_t *a, const bit_int_t *b, const unsigned int from, const unsigned int to)
int EGbitIsLeq (const bit_int_t *a, const bit_int_t *b, const unsigned int from, const unsigned int to)
int EGbitLeftShift (bit_int_t *dst, const bit_int_t *src, const unsigned int shift, const unsigned int from, const unsigned int to)
unsigned int EGbitNext (const bit_int_t *dst, const unsigned int pos, const unsigned int size)
int EGbitOr (bit_int_t *dst, const bit_int_t *src, const unsigned int from, const unsigned int to)
int EGbitPlus (bit_int_t *dst, const bit_int_t *src, const unsigned int from, const unsigned int to)
unsigned int EGbitPrev (const EGbitset_t *dst, const unsigned int pos)
int EGbitReset (bit_int_t *dst, const unsigned int from, const unsigned int to)
int EGbitRightShift (bit_int_t *dst, const bit_int_t *src, const unsigned int shift, const unsigned int from, const unsigned int to)
int EGbitSanity (void)
int EGbitSet (bit_int_t *const dst, const unsigned int pos)
int EGbitTest (bit_int_t const *const dst, const unsigned int pos)
int EGbitUnset (bit_int_t *dst, const unsigned int pos)
int EGbitXor (bit_int_t *dst, const bit_int_t *src, const unsigned int from, const unsigned int to)

Define Documentation

#define __EGBIT_DEBUG_LEVEL__   10

Definition at line 60 of file eg_bit.h.

Referenced by EGbitSet(), EGbitTest(), and EGbitUnset().

#define __EGBIT_MASK__   31U

Definition at line 68 of file eg_bit.h.

Referenced by EGbitNext(), EGbitPrev(), EGbitSanity(), EGbitSet(), EGbitTest(), and EGbitUnset().

#define __EGBIT_SHIFT__   5U

Definition at line 67 of file eg_bit.h.

Referenced by EGbitCopy(), EGbitSanity(), EGbitSet(), EGbitTest(), and EGbitUnset().

#define __EGBIT_WORD_SIZE__   32U

Definition at line 66 of file eg_bit.h.

Referenced by EGbitLeftShift(), EGbitPlus(), EGbitRightShift(), and EGbitSanity().

#define bit_int_t   uint32_t

Definition at line 87 of file eg_bit.h.

#define EGbitset_t   bit_int_t
#define EGbitsetSize (   __Bsize  )     (((__Bsize)>>__EGBIT_SHIFT__)+(((__Bsize)&__EGBIT_MASK__)?1:0))

Macro to compute the right size of a bitset given the desired number of bits in the bitset.

Definition at line 74 of file eg_bit.h.


Function Documentation

int EGbitAnd ( bit_int_t *  dst,
const bit_int_t *  src,
const unsigned int  from,
const unsigned int  to 
)
int EGbitCopy ( bit_int_t *const   a,
const bit_int_t *const   b,
const unsigned int  from,
const unsigned int  to 
)
EGbitset_t EGbitCount ( bit_int_t *  bitset,
const unsigned int  from,
const unsigned int  to 
)

Count the number of on-bits in a bit-map.

EGbitset_t EGbitElemBitCount ( EGbitset_t  n  ) 

Count number of on bits on 32-bit integers.

Returns:
Number of on bits in the given 32-bit integer
Description:
Parallel Count carries out bit counting in a parallel fashion. Consider n after the first line has finished executing. Imagine splitting n into pairs of bits. Each pair contains the number of ones in those two bit positions in the original n. After the second line has finished executing, each nibble contains the number of ones in those four bits positions in the original n. Continuing this for five iterations, the 64 bits contain the number of ones among these sixty-four bit positions in the original n. That is what we wanted to compute.

Definition at line 550 of file eg_bit.c.

References EGBIT_COUNT.

Referenced by EGbitCount().

int EGbitIsEqual ( const bit_int_t *  a,
const bit_int_t *  b,
const unsigned int  from,
const unsigned int  to 
)
int EGbitIsLeq ( const bit_int_t *  a,
const bit_int_t *  b,
const unsigned int  from,
const unsigned int  to 
)
int EGbitLeftShift ( bit_int_t *  dst,
const bit_int_t *  src,
const unsigned int  shift,
const unsigned int  from,
const unsigned int  to 
)
unsigned int EGbitNext ( const bit_int_t *  dst,
const unsigned int  pos,
const unsigned int  size 
)
int EGbitOr ( bit_int_t *  dst,
const bit_int_t *  src,
const unsigned int  from,
const unsigned int  to 
)
int EGbitPlus ( bit_int_t *  dst,
const bit_int_t *  src,
const unsigned int  from,
const unsigned int  to 
)
unsigned int EGbitPrev ( const EGbitset_t *  dst,
const unsigned int  pos 
)

Definition at line 279 of file eg_bit.c.

References __EGBIT_MASK__, EGbitset_t, and EXIT.

int EGbitReset ( bit_int_t *  dst,
const unsigned int  from,
const unsigned int  to 
)
int EGbitRightShift ( bit_int_t *  dst,
const bit_int_t *  src,
const unsigned int  shift,
const unsigned int  from,
const unsigned int  to 
)
int EGbitSanity ( void   ) 

Definition at line 376 of file eg_bit.c.

References __EGBIT_MASK__, __EGBIT_SHIFT__, __EGBIT_WORD_SIZE__, EGbitAnd(), EGbitNext(), EGbitOr(), EGbitReset(), EGbitSet(), EGbitset_t, and EGbitXor().

Here is the call graph for this function:

int EGbitSet ( bit_int_t *const   dst,
const unsigned int  pos 
)
int EGbitTest ( bit_int_t const *const   dst,
const unsigned int  pos 
)
int EGbitUnset ( bit_int_t *  dst,
const unsigned int  pos 
)
int EGbitXor ( bit_int_t *  dst,
const bit_int_t *  src,
const unsigned int  from,
const unsigned int  to 
)