GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LDT / dev > test_bt / linux-gcc


Interface   Data Structures   File List   Data Fields   Globals  

BIT.h File Reference

Utility routines to manipulate 16 and 32 bit words. More...


Defines

#define BW_(x)
 Replaces each 4-bit sequence in arg by the number of bits in sequence.
#define BS_(x)
 Replaces each 4-bit sequence in arg by the number of bits in sequence.

Functions

static __inline unsigned int BIT__countW (unsigned int w)
 Computes the number of bits set (1) in 32-bit argument.
static __inline unsigned int BIT__countS (unsigned short int s)
 Computes the number of bits set (1) in 16-bit argument.
static __inline unsigned int BIT__countB (unsigned char c)
 Computes the number of bits set (1) in 8-bit argument.


Detailed Description

Utility routines to manipulate 16 and 32 bit words.

Author:
JJRussell - russell@slac.stanford.edu

   CVS $Id: BIT.h,v 1.2 2009/04/29 23:01:53 russell Exp $

Define Documentation

#define BS_ (  ) 

Value:

((x) - (((x)>>1)&0x7777)                        \
                               - (((x)>>2)&0x3333)                        \
                               - (((x)>>3)&0x1111))
Replaces each 4-bit sequence in arg by the number of bits in sequence.

See also:
BIT_countS
Replaces each 4-bit sequence in 16-bit argument by the number of bits in that sequence (which will, of course, fit in 4 bits).

Warning:
This is not a public macro, it used only to implement BIT32_count

Referenced by BIT__countS().

#define BW_ (  ) 

Value:

((x) - (((x)>>1)&0x77777777)                    \
                               - (((x)>>2)&0x33333333)                    \
                               - (((x)>>3)&0x11111111))
Replaces each 4-bit sequence in arg by the number of bits in sequence.

See also:
BIT_countW
Replaces each 4-bit sequence in 32-bit argument by the number of bits in that sequence (which will, of course, fit in 4 bits).

Warning:
This is not a public macro, it used only to implement BIT32_count

Referenced by BIT__countW().


Function Documentation

static __inline unsigned int BIT__countB ( unsigned char  c  )  [static]

Computes the number of bits set (1) in 8-bit argument.

Returns:
The number of set bits
Parameters:
c The character to count the bits in
The algorithm is to do this in two 4-bit chunks, where the nibbles are used to access an array of 16 x 2 bit values. 2* nibble-1 is used as an index the array. The array itself holds the count, except the value 0xf must be special cased, since the number of bits is 4, a value that is unable to fit into 2 bits.

static __inline unsigned int BIT__countS ( unsigned short int  s  )  [static]

Computes the number of bits set (1) in 16-bit argument.

See also:
BS_
Credit to Chris Smith (original algorithm) Jane Huffman (original writer) Brad Merril & Jerry Leichter (ported from 36-bit words to 32-bit words)

References BS_.

static __inline unsigned int BIT__countW ( unsigned int  w  )  [static]

Computes the number of bits set (1) in 32-bit argument.

See also:
BW_
Credit to Chris Smith (original algorithm) Jane Huffman (original writer) Brad Merril & Jerry Leichter (ported from 36-bit words to 32-bit words)

References BW_.


Generated on Thu Mar 31 11:41:26 2011 by  doxygen 1.5.8