Main Page   Modules   Compound List   File List   Compound Members   File Members  

bit_array.h File Reference

#include <stdio.h>
#include <gandalf/common/misc_defs.h>
#include <gandalf/common/allocate.h>
#include <gandalf/common/memory_stack.h>

Go to the source code of this file.

Compounds

struct  Gan_BitArray
 1-dimensional array of bits More...


Defines

#define GAN_BITWORD_SIZE   64
#define GAN_BITWORD_FULL   (gan_ui64) GAN_UI64_MAX
#define GAN_MSB_SET   (gan_ui64) 0x8000000000000000
#define GAN_LSB_SET   (gan_ui64) 1

Typedefs

typedef gan_ui64 Gan_BitWord
 64-bit word

typedef Gan_BitArray Gan_BitArray
 1-dimensional array of bits


Enumerations

enum  Gan_Alignment { GAN_WORD_ALIGNMENT, GAN_BYTE_ALIGNMENT, GAN_BIT_ALIGNMENT }
 Alignment options when computing bounds of a bit array. More...


Functions

Gan_BitArraygan_bit_array_form_data (Gan_BitArray *ba, Gan_BitWord *data, unsigned data_words, unsigned int no_bits)
 Form new bit array using pre-allocated data array.

Gan_BitArraygan_bit_array_ms_form (Gan_MemoryStack *ms, Gan_BitArray *ba, unsigned int no_bits)
 Form new bit array using stack memory style memory allocation.

Gan_Bool gan_bit_array_set_size (Gan_BitArray *ba, unsigned int no_bits)
 Reset size of existing bit array.

void gan_bit_array_free (Gan_BitArray *ba)
 Free bit array.

void gan_bit_array_free_va (Gan_BitArray *ba,...)
 Free NULL terminated list of bit arrays.

Gan_Bool gan_bit_array_invert_i (Gan_BitArray *ba)
 Invert all the bits in a bit array.

Gan_BitArraygan_bit_array_invert_s (Gan_BitArray *ba)
 Invert all the bits in a bit array.

Gan_Bool gan_bit_array_and_i (Gan_BitArray *ba_dst, Gan_BitArray *ba)
 Perform binary AND operation between two bit arrays.

Gan_Bool gan_bit_array_nand_i (Gan_BitArray *ba_dst, Gan_BitArray *ba)
 Perform binary NAND (not and) operation between bit arrays.

Gan_Bool gan_bit_array_or_i (Gan_BitArray *ba_dst, Gan_BitArray *ba)
Gan_Bool gan_bit_array_eor_i (Gan_BitArray *ba_dst, Gan_BitArray *ba)
Gan_Bool gan_bit_array_andnot_i (Gan_BitArray *ba_dst, Gan_BitArray *ba)
 Perform binary AND-NOT operation between bit arrays.

Gan_BitArraygan_bit_array_and_s (Gan_BitArray *ba1, Gan_BitArray *ba2)
Gan_BitArraygan_bit_array_nand_s (Gan_BitArray *ba1, Gan_BitArray *ba2)
Gan_BitArraygan_bit_array_or_s (Gan_BitArray *ba1, Gan_BitArray *ba2)
Gan_BitArraygan_bit_array_eor_s (Gan_BitArray *ba1, Gan_BitArray *ba2)
Gan_BitArraygan_bit_array_andnot_s (Gan_BitArray *ba1, Gan_BitArray *ba2)
Gan_Bool gan_bit_array_insert (Gan_BitArray *source, unsigned int offset_s, Gan_BitArray *dest, unsigned int offset_d, unsigned int no_bits)
 Insert part of one bit array in another.

Gan_Bool gan_bit_array_fill (Gan_BitArray *ba, Gan_Bool val)
 Set all bits in a bit array.

Gan_Bool gan_bit_array_copy_q (Gan_BitArray *ba_source, Gan_BitArray *ba_dest)
 Copy one bit array to another.

Gan_BitArraygan_bit_array_copy_s (Gan_BitArray *ba_source)
 Return a copy of a bit array.

Gan_Bool gan_bit_array_expand_q (Gan_BitArray *ba, Gan_BitArray *ref_ba, Gan_BitArray *exp_ba)
 Expand bit array by padding it with zeros in a reference bit array.

Gan_BitArraygan_bit_array_expand_s (Gan_BitArray *ba, Gan_BitArray *ref_ba)
 Expand bit array by padding it with zeros in a reference bit array.

Gan_Bool gan_bit_array_fill_part (Gan_BitArray *ba, unsigned int offset, unsigned int no_bits, Gan_Bool val)
 Fill part of a bit array.

Gan_Bool gan_bit_array_invert_part (Gan_BitArray *ba, unsigned int offset, unsigned int no_bits)
 Invert part of a bit array.

void gan_bit_array_fprint (FILE *fp, Gan_BitArray *ba, int indent)
 Print bit array in ASCII to file.

unsigned GAN_NO_BITWORDS (unsigned no_bits)
 Macro: Number of bit-words given number of bits.

Gan_BitArraygan_bit_array_form (Gan_BitArray *ba, unsigned int no_bits)
 Macro: Form bit array.

Gan_BitArraygan_bit_array_alloc (unsigned int no_bits)
 Macro: Allocate new bit array.

Gan_BitArraygan_bit_array_ms_malloc (unsigned int no_bits)
 Macro: Allocate new bit array using stack-style memory allocation.

Gan_Bool gan_bit_array_print (Gan_BitArray *bit_array, int indent)
 Macro: Print bit array in ASCII to standard output.

Gan_Bool gan_bit_array_set_bit (Gan_BitArray *bit_array, int pos)
 Macro: Set bit in bit list to 1 (true).

Gan_Bool gan_bit_array_get_bit (Gan_BitArray *bit_array, int pos)
 Macro: get bit of bit array.

Gan_Bool gan_bit_array_clear_bit (Gan_BitArray *bit_array, int pos)
 Macro: clear bit in bit list to 0 (false).

Gan_Bool gan_bit_array_twiddle_bit (Gan_BitArray *bit_array, int pos, Gan_Bool val)
 Macro: set/clear bit depending on Boolean argument.

Gan_Bool gan_bit_array_invert_bit (Gan_BitArray *bit_array, int pos)
 Macro: Invert bit.


Detailed Description

Module: Binary array module

Part of: Gandalf Library

Revision: Last edited: Author:

Copyright: (c) 2000 Imagineer Software Limited


Function Documentation

Gan_Bool gan_bit_array_and_i Gan_BitArray   ba_dst,
Gan_BitArray   ba
 

Perform binary AND operation between two bit arrays.

Returns:
GAN_TRUE on success, GAN_FALSE on failure.
Perform binary AND operation between bit arrays ba and ba_dst, writing the result into ba_dst.

Gan_BitArray* gan_bit_array_and_s Gan_BitArray   ba1,
Gan_BitArray   ba2
 

Perform binary AND operation between bit arrays.

Returns:
The result as a new bit array.
Perform binary AND operation between bit arrays ba1 and ba2, returning the result as a new bit array.

Gan_Bool gan_bit_array_andnot_i Gan_BitArray   ba_dst,
Gan_BitArray   ba
 

Perform binary AND-NOT operation between bit arrays.

Returns:
GAN_TRUE on success, GAN_FALSE on failure.
Perform binary AND-NOT operation between bit arrays ba and ba_dst, writing the result into ba_dst.

Gan_BitArray* gan_bit_array_andnot_s Gan_BitArray   ba1,
Gan_BitArray   ba2
 

Perform binary AND-NOT operation between bit arrays.

Returns:
The result as a new bit array.
Perform binary AND-NOT operation between bit arrays ba1 and ba2, returning the result as a new bit array.

Gan_Bool gan_bit_array_copy_q Gan_BitArray   ba_source,
Gan_BitArray   ba_dest
 

Copy one bit array to another.

Returns:
GAN_TRUE on success, GAN_FALSE on failure.
Copy bit array ba_source to ba_dest.

Gan_BitArray* gan_bit_array_copy_s Gan_BitArray   ba_source
 

Return a copy of a bit array.

Returns:
A new copy of the bit array ba_source.
Return a copy of bit array ba_source.

Gan_Bool gan_bit_array_eor_i Gan_BitArray   ba_dst,
Gan_BitArray   ba
 

Perform binary EOR (exclusive or) operation between bit arrays.

Returns:
GAN_TRUE on success, GAN_FALSE on failure.
Perform binary EOR (exclusive or) operation between bit arrays ba and ba_dst, writing the result into ba_dst.

Gan_BitArray* gan_bit_array_eor_s Gan_BitArray   ba1,
Gan_BitArray   ba2
 

Perform binary EOR (exclusive or) operation between bit arrays.

Returns:
The result as a new bit array.
Perform binary EOR (exclusive or) operation between bit arrays ba1 and ba2, returning the result as a new bit array.

Gan_Bool gan_bit_array_expand_q Gan_BitArray   ba,
Gan_BitArray   ref_ba,
Gan_BitArray   exp_ba
 

Expand bit array by padding it with zeros in a reference bit array.

Parameters:
ba Input bit array
ref_ba Reference bit array specifying padded bits
exp_ba Expanded bit array or NULL.
Returns:
GAN_TRUE on success, GAN_FALSE on failure.
Expand bit array ba by padding it with zeros in a reference bit array ref_ba.

Gan_BitArray* gan_bit_array_expand_s Gan_BitArray   ba,
Gan_BitArray   ref_ba
 

Expand bit array by padding it with zeros in a reference bit array.

Parameters:
ba Input bit array
ref_ba Reference bit array specifying padded bits
Returns:
Expanded bit array as a new bit array, or NULL on failure.
Expand bit array ba by padding it with zeros in a reference bit array ref_ba.

Gan_Bool gan_bit_array_fill Gan_BitArray   ba,
Gan_Bool    val
 

Set all bits in a bit array.

Returns:
GAN_TRUE on success, GAN_FALSE on failure.
Set all bits in bit array ba to the given boolean value val.

Gan_Bool gan_bit_array_fill_part Gan_BitArray   ba,
unsigned int    offset,
unsigned int    no_bits,
Gan_Bool    val
 

Fill part of a bit array.

Returns:
GAN_TRUE on success, GAN_FALSE on failure.
Fill part of a bit array, specified by the start point offset and the given number of bits no_bits. The part is filled with the given boolean value val.

Gan_BitArray* gan_bit_array_form_data Gan_BitArray   ba,
Gan_BitWord   data,
unsigned    data_words,
unsigned int    no_bits
 

Form new bit array using pre-allocated data array.

Parameters:
ba Existing bit array or NULL
data Block of memory to use for bit array
data_words Number of words in data array
no_bits Number of bits in bit array
Returns:
Formed bit array, or NULL on error.
Form new bit array of size no_bits using pre-allocated data array data. If data is not NULL, the number of data_words must be enough to store no_bits bits.

void gan_bit_array_fprint FILE *    fp,
Gan_BitArray   ba,
int    indent
 

Print bit array in ASCII to file.

void gan_bit_array_free Gan_BitArray   ba
 

Free bit array.

void gan_bit_array_free_va Gan_BitArray   ba,
...   
 

Free NULL terminated list of bit arrays.

Returns:
No value.
Free list of bit arrays starting with ba and terminated with NULL.

Gan_Bool gan_bit_array_insert Gan_BitArray   src,
unsigned int    offset_src,
Gan_BitArray   dst,
unsigned int    offset_dst,
unsigned int    no_bits
 

Insert part of one bit array in another.

Parameters:
src Source bit array
offset_src Offset of start of insertion region in src
dst Destination bit array
offset_dst Offset of start of insertion region in dst
no_bits Number of bits to insert
Returns:
GAN_TRUE on success, GAN_FALSE on failure.
Insert part of bit array src in bit array dst

Gan_Bool gan_bit_array_invert_i Gan_BitArray   ba
 

Invert all the bits in a bit array.

Returns:
GAN_TRUE on success, GAN_FALSE on failure.
Invert all the bits in a bit array ba.

Gan_Bool gan_bit_array_invert_part Gan_BitArray   ba,
unsigned int    offset,
unsigned int    no_bits
 

Invert part of a bit array.

Returns:
GAN_TRUE on success, GAN_FALSE on failure.
Invert part of a bit array, specified by the start point offset and the given number of bits no_bits.

Gan_BitArray* gan_bit_array_invert_s Gan_BitArray   ba
 

Invert all the bits in a bit array.

Returns:
A new inverted bit array.
Invert all the bits in a bit array ba, returning the result as anew bit array.

Gan_BitArray* gan_bit_array_ms_form Gan_MemoryStack   ms,
Gan_BitArray   ba,
unsigned int    no_bits
 

Form new bit array using stack memory style memory allocation.

Parameters:
ms Pointer to memory stack structure
ba Existing bit array or NULL
no_bits Number of bits in bit array
Returns:
Formed bit array, or NULL on error.
Form new bit array of size no_bits using stack-style memory allocation.

Gan_Bool gan_bit_array_nand_i Gan_BitArray   ba_dst,
Gan_BitArray   ba
 

Perform binary NAND (not and) operation between bit arrays.

Returns:
GAN_TRUE on success, GAN_FALSE on failure.
Perform binary NAND (not and) operation between bit arrays ba and ba_dst, writing the result into ba_dst.

Gan_BitArray* gan_bit_array_nand_s Gan_BitArray   ba1,
Gan_BitArray   ba2
 

Perform binary NAND (not and) operation between bit arrays.

Returns:
The result as a new bit array.
Perform binary NAND (not and) operation between bit arrays ba1 and ba2, returning the result as a new bit array.

Gan_Bool gan_bit_array_or_i Gan_BitArray   ba_dst,
Gan_BitArray   ba
 

Perform binary OR operation between bit arrays.

Returns:
GAN_TRUE on success, GAN_FALSE on failure.
Perform binary OR operation between bit arrays ba and ba_dst, writing the result into ba_dst.

Gan_BitArray* gan_bit_array_or_s Gan_BitArray   ba1,
Gan_BitArray   ba2
 

Perform binary OR operation between bit arrays.

Returns:
The result as a new bit array.
Perform binary OR operation between bit arrays ba1 and ba2, returning the result as a new bit array.

Gan_Bool gan_bit_array_set_size Gan_BitArray   ba,
unsigned int    no_bits
 

Reset size of existing bit array.

Returns:
GAN_TRUE on success, GAN_FALSE on failure.
Reset size of existing bit array ba to no_bits.


Generated on Mon Oct 13 16:14:40 2003 by doxygen1.3-rc1