eg_bit.h File Reference

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <limits.h>
#include "eg_config.h"
#include "eg_macros.h"
#include "eg_mempool.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.

Word lengths and related macros

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

Defines

#define EGBIT_COUNT(x, c)   ((x) & EGBIT_MASK(c)) + (((x) >> (EGBIT_TWO(c))) & EGBIT_MASK(c))
#define EGBIT_MASK(c)   (((unsigned int)(-1)) / (EGBIT_TWO(EGBIT_TWO(c)) + 1u))
#define EGBIT_TWO(c)   (0x1u << (c))
#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.

Typedefs

typedef int32_t bit_int_t
typedef bit_int_t EGbitset_t

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)
void EGfreeBitSet (void *bitfield, const size_t size, EGmemPool_t *mem)
EGbitset_tEGnewBitSet (EGmemPool_t *mem, size_t *n)


Define Documentation

#define __EGBIT_MASK__   31U
 

Definition at line 62 of file eg_bit.h.

#define __EGBIT_SHIFT__   5U
 

Definition at line 61 of file eg_bit.h.

#define __EGBIT_WORD_SIZE__   32U
 

Definition at line 60 of file eg_bit.h.

#define EGBIT_COUNT x,
 )     ((x) & EGBIT_MASK(c)) + (((x) >> (EGBIT_TWO(c))) & EGBIT_MASK(c))
 

#define EGBIT_MASK  )     (((unsigned int)(-1)) / (EGBIT_TWO(EGBIT_TWO(c)) + 1u))
 

#define EGBIT_TWO  )     (0x1u << (c))
 

#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 68 of file eg_bit.h.


Typedef Documentation

typedef int32_t bit_int_t
 

Definition at line 80 of file eg_bit.h.

typedef bit_int_t EGbitset_t
 

Definition at line 81 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
[inline]
 

Definition at line 149 of file eg_bit.h.

int EGbitCopy bit_int_t *const   a,
const bit_int_t *const   b,
const unsigned int  from,
const unsigned int  to
[inline]
 

Definition at line 295 of file eg_bit.h.

EGbitset_t EGbitCount bit_int_t bitset,
const unsigned int  from,
const unsigned int  to
[inline]
 

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

Definition at line 552 of file eg_bit.h.

Here is the call graph for this function:

EGbitset_t EGbitElemBitCount EGbitset_t  n  )  [inline]
 

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 532 of file eg_bit.h.

int EGbitIsEqual const bit_int_t a,
const bit_int_t b,
const unsigned int  from,
const unsigned int  to
[inline]
 

Definition at line 338 of file eg_bit.h.

int EGbitIsLeq const bit_int_t a,
const bit_int_t b,
const unsigned int  from,
const unsigned int  to
[inline]
 

Definition at line 312 of file eg_bit.h.

int EGbitLeftShift bit_int_t dst,
const bit_int_t src,
const unsigned int  shift,
const unsigned int  from,
const unsigned int  to
[inline]
 

Definition at line 200 of file eg_bit.h.

unsigned int EGbitNext const bit_int_t dst,
const unsigned int  pos,
const unsigned int  size
[inline]
 

Definition at line 420 of file eg_bit.h.

int EGbitOr bit_int_t dst,
const bit_int_t src,
const unsigned int  from,
const unsigned int  to
[inline]
 

Definition at line 127 of file eg_bit.h.

int EGbitPlus bit_int_t dst,
const bit_int_t src,
const unsigned int  from,
const unsigned int  to
[inline]
 

Definition at line 261 of file eg_bit.h.

unsigned int EGbitPrev const EGbitset_t dst,
const unsigned int  pos
[inline]
 

Definition at line 473 of file eg_bit.h.

int EGbitReset bit_int_t dst,
const unsigned int  from,
const unsigned int  to
[inline]
 

Definition at line 384 of file eg_bit.h.

int EGbitRightShift bit_int_t dst,
const bit_int_t src,
const unsigned int  shift,
const unsigned int  from,
const unsigned int  to
[inline]
 

Definition at line 171 of file eg_bit.h.

int EGbitSanity void   ) 
 

Definition at line 414 of file eg_bit.c.

Here is the call graph for this function:

int EGbitSet bit_int_t *const   dst,
const unsigned int  pos
[inline]
 

Definition at line 245 of file eg_bit.h.

int EGbitTest bit_int_t const *const   dst,
const unsigned int  pos
[inline]
 

Definition at line 406 of file eg_bit.h.

int EGbitUnset bit_int_t dst,
const unsigned int  pos
[inline]
 

Definition at line 229 of file eg_bit.h.

int EGbitXor bit_int_t dst,
const bit_int_t src,
const unsigned int  from,
const unsigned int  to
[inline]
 

Definition at line 362 of file eg_bit.h.

void EGfreeBitSet void *  bitfield,
const size_t  size,
EGmemPool_t mem
[inline]
 

Definition at line 92 of file eg_bit.h.

EGbitset_t* EGnewBitSet EGmemPool_t mem,
size_t *  n
[inline]
 

Definition at line 104 of file eg_bit.h.


Generated on Mon Jan 30 08:49:16 2006 for EGlib by  doxygen 1.4.5