Veil
|
Functions for manipulating Bitmaps, BitmapHashes and BitmapArrays. More...
Go to the source code of this file.
Functions | |
void | vl_ClearBitmap (Bitmap *bitmap) |
Clear all bits in a Bitmap. More... | |
void | vl_NewBitmap (Bitmap **p_bitmap, bool shared, int32 min, int32 max) |
Return a newly initialised (empty) Bitmap. More... | |
void | vl_BitmapSetbit (Bitmap *bitmap, int32 bit) |
Set a bit within a Bitmap. More... | |
void | vl_BitmapClearbit (Bitmap *bitmap, int32 bit) |
Clear a bit within a Bitmap. More... | |
bool | vl_BitmapTestbit (Bitmap *bitmap, int32 bit) |
Test a bit within a Bitmap. More... | |
void | vl_BitmapUnion (Bitmap *target, Bitmap *source) |
Create the union of two bitmaps, updating the first with the result. More... | |
void | vl_BitmapIntersect (Bitmap *target, Bitmap *source) |
Create the intersection of two bitmaps, updating the first with the result. More... | |
int32 | vl_BitmapNextBit (Bitmap *bitmap, int32 bit, bool *found) |
Return the next set bit in the Bitmap. More... | |
Bitmap * | vl_BitmapFromArray (BitmapArray *bmarray, int32 elem) |
Return a specified Bitmap from a BitmapArray. More... | |
void | vl_ClearBitmapArray (BitmapArray *bmarray) |
Clear all bitmaps in the given BitmapArray. More... | |
void | vl_NewBitmapArray (BitmapArray **p_bmarray, bool shared, int32 arrayzero, int32 arraymax, int32 bitzero, int32 bitmax) |
Return a newly initialised (empty) BitmapArray. More... | |
static HTAB * | new_hash (char *name) |
Create a new hash table. More... | |
VarEntry * | vl_NextHashEntry (HTAB *hash, VarEntry *prev) |
Utility function for scanning the hash table of a BitmapHash. More... | |
void | vl_NewBitmapHash (BitmapHash **p_bmhash, char *name, int32 bitzero, int32 bitmax) |
Return a newly initialised (empty) BitmapHash. More... | |
Bitmap * | vl_BitmapFromHash (BitmapHash *bmhash, char *hashelem) |
Return a specified Bitmap from a BitmapHash. More... | |
Bitmap * | vl_AddBitmapToHash (BitmapHash *bmhash, char *hashelem) |
Create a newly allocated empty Bitmap to a BitmapHash. More... | |
bool | vl_BitmapHashHasKey (BitmapHash *bmhash, char *hashelem) |
Determine whether the supplied key exists in the BitmapHash. More... | |
Variables | |
static uint32 | bitmasks [] |
Array of bit positions for int32, indexed by bitno. More... | |
Functions for manipulating Bitmaps, BitmapHashes and BitmapArrays.
Definition in file veil_bitmap.c.
void vl_ClearBitmap | ( | Bitmap * | bitmap | ) |
Clear all bits in a Bitmap.
bitmap | The Bitmap in which all bits are to be cleared |
Definition at line 73 of file veil_bitmap.c.
References ARRAYELEMS, Bitmap::bitmax, Bitmap::bitset, and Bitmap::bitzero.
Referenced by veil_clear_bitmap(), veil_intersect_from_bitmap_hash(), vl_ClearBitmapArray(), and vl_NewBitmap().
void vl_NewBitmap | ( | Bitmap ** | p_bitmap, |
bool | shared, | ||
int32 | min, | ||
int32 | max | ||
) |
Return a newly initialised (empty) Bitmap.
The bitmap may already exist in which case it will be re-used if possible. The bitmap may be created in either session or shared memory depending on the value of shared.
p_bitmap | Pointer to an existing bitmap if one exists |
shared | Whether to create the bitmap in shared memory |
min | The smallest bit to be stored in the bitmap |
max | The largest bit to be stored in the bitmap |
Definition at line 95 of file veil_bitmap.c.
References ARRAYELEMS, Bitmap::bitmax, Bitmap::bitzero, DBG_SET_CANARY, DBG_SET_ELEMS, DBG_SET_TRAILER, Bitmap::type, vl_ClearBitmap(), vl_free(), vl_malloc(), and vl_shmalloc().
Referenced by veil_init_bitmap(), and vl_NewBitmapArray().
void vl_BitmapSetbit | ( | Bitmap * | bitmap, |
int32 | bit | ||
) |
Set a bit within a Bitmap.
If the bit is outside of the acceptable range, raise an error.
bitmap | The Bitmap within which the bit is to be set. |
bit | The bit to be set. |
Definition at line 151 of file veil_bitmap.c.
References bitmasks, Bitmap::bitmax, Bitmap::bitset, BITSET_BIT, BITSET_ELEM, BITZERO, Bitmap::bitzero, DBG_CHECK_INDEX, DBG_TEST_CANARY, and DBG_TEST_TRAILER.
Referenced by veil_bitmap_array_setbit(), veil_bitmap_hash_setbit(), and veil_bitmap_setbit().
void vl_BitmapClearbit | ( | Bitmap * | bitmap, |
int32 | bit | ||
) |
Clear a bit within a Bitmap.
If the bit is outside of the acceptable range, raise an error.
bitmap | The Bitmap within which the bit is to be cleared. |
bit | The bit to be cleared. |
Definition at line 181 of file veil_bitmap.c.
References bitmasks, Bitmap::bitmax, Bitmap::bitset, BITSET_BIT, BITSET_ELEM, BITZERO, and Bitmap::bitzero.
Referenced by veil_bitmap_array_clearbit(), veil_bitmap_clearbit(), and veil_bitmap_hash_clearbit().
bool vl_BitmapTestbit | ( | Bitmap * | bitmap, |
int32 | bit | ||
) |
Test a bit within a Bitmap.
If the bit is outside of the acceptable range return false.
bitmap | The Bitmap within which the bit is to be set. |
bit | The bit to be tested. |
Definition at line 210 of file veil_bitmap.c.
References bitmasks, Bitmap::bitmax, Bitmap::bitset, BITSET_BIT, BITSET_ELEM, BITZERO, and Bitmap::bitzero.
Referenced by veil_bitmap_array_testbit(), veil_bitmap_hash_testbit(), veil_bitmap_testbit(), and vl_BitmapNextBit().
Create the union of two bitmaps, updating the first with the result.
target | The Bitmap into which the result will be placed. |
source | The Bitmap to be unioned into target. |
Definition at line 232 of file veil_bitmap.c.
References ARRAYELEMS, Bitmap::bitmax, Bitmap::bitset, and Bitmap::bitzero.
Referenced by veil_bitmap_union(), veil_union_from_bitmap_array(), veil_union_from_bitmap_hash(), and veil_union_into_bitmap_hash().
Create the intersection of two bitmaps, updating the first with the result.
target | The Bitmap into which the result will be placed. |
source | The Bitmap to be intersected into target. |
Definition at line 262 of file veil_bitmap.c.
References ARRAYELEMS, Bitmap::bitmax, Bitmap::bitset, and Bitmap::bitzero.
Referenced by veil_bitmap_intersect(), veil_intersect_from_bitmap_array(), and veil_intersect_from_bitmap_hash().
int32 vl_BitmapNextBit | ( | Bitmap * | bitmap, |
int32 | bit, | ||
bool * | found | ||
) |
Return the next set bit in the Bitmap.
bitmap | The Bitmap being scanned. |
bit | The starting bit from which to scan the bitmap |
found | Boolean that will be set to true when a set bit has been found. |
Definition at line 295 of file veil_bitmap.c.
References vl_BitmapTestbit().
Referenced by veil_bitmap_array_bits(), veil_bitmap_bits(), and veil_bitmap_hash_bits().
Bitmap* vl_BitmapFromArray | ( | BitmapArray * | bmarray, |
int32 | elem | ||
) |
Return a specified Bitmap from a BitmapArray.
bmarray | The BitmapArray from which the result is to be returned. |
elem | The index of the Bitmap within the array. |
Definition at line 321 of file veil_bitmap.c.
References BitmapArray::arraymax, BitmapArray::arrayzero, BitmapArray::bitmap, DBG_CHECK_INDEX, DBG_TEST_CANARY, and DBG_TEST_TRAILER.
Referenced by veil_bitmap_array_bits(), veil_bitmap_array_clearbit(), veil_bitmap_array_setbit(), veil_bitmap_array_testbit(), veil_bitmap_from_array(), veil_intersect_from_bitmap_array(), and veil_union_from_bitmap_array().
void vl_ClearBitmapArray | ( | BitmapArray * | bmarray | ) |
Clear all bitmaps in the given BitmapArray.
bmarray | The BitmapArray to be cleared |
Definition at line 341 of file veil_bitmap.c.
References BitmapArray::arraymax, BitmapArray::arrayzero, BitmapArray::bitmap, DBG_CHECK_INDEX, DBG_TEST_CANARY, DBG_TEST_TRAILER, and vl_ClearBitmap().
Referenced by veil_clear_bitmap_array(), and vl_NewBitmapArray().
void vl_NewBitmapArray | ( | BitmapArray ** | p_bmarray, |
bool | shared, | ||
int32 | arrayzero, | ||
int32 | arraymax, | ||
int32 | bitzero, | ||
int32 | bitmax | ||
) |
Return a newly initialised (empty) BitmapArray.
It may already exist in which case it will be re-used if possible. It may be created in either session or shared memory depending on the value of shared.
p_bmarray | Pointer to an existing bitmap if one exists. |
shared | Whether to create the bitmap in shared memory |
arrayzero | The lowest array index |
arraymax | The highest array index |
bitzero | The smallest bit to be stored in the bitmap |
bitmax | The largest bit to be stored in the bitmap |
Definition at line 368 of file veil_bitmap.c.
References ARRAYELEMS, BitmapArray::arraymax, BitmapArray::arrayzero, BitmapArray::bitmap, BitmapArray::bitmax, BitmapArray::bitzero, DBG_TEST_CANARY, DBG_TEST_TRAILER, BitmapArray::type, vl_ClearBitmapArray(), vl_free(), vl_malloc(), vl_NewBitmap(), and vl_shmalloc().
Referenced by veil_init_bitmap_array().
|
static |
Create a new hash table.
This is allocated from session memory as BitmapHashes may not be declared as shared variables.
name | The name of the hash to be created. Note that we prefix this with "vl_" to prevent name collisions from other subsystems. |
Definition at line 449 of file veil_bitmap.c.
References HASH_KEYLEN.
Utility function for scanning the hash table of a BitmapHash.
hash | The hash table being scanned |
prev | The entry from which to scan, starting with NULL. |
Definition at line 474 of file veil_bitmap.c.
Referenced by serialise_bitmap_hash(), sizeof_bitmaps_in_hash(), veil_bitmap_hash_entries(), and vl_NewBitmapHash().
void vl_NewBitmapHash | ( | BitmapHash ** | p_bmhash, |
char * | name, | ||
int32 | bitzero, | ||
int32 | bitmax | ||
) |
Return a newly initialised (empty) BitmapHash.
It may already exist in which case it will be re-used if possible. BitmapHash variables may only be created as session (not shared) variables.
p_bmhash | Pointer to an existing bitmap if one exists. |
name | The name to be used for the hash table |
bitzero | The smallest bit to be stored in the bitmap |
bitmax | The largest bit to be stored in the bitmap |
Definition at line 499 of file veil_bitmap.c.
References BitmapHash::hash, VarEntry::obj, Object::type, and vl_NextHashEntry().
Referenced by veil_clear_bitmap_hash(), and veil_init_bitmap_hash().
Bitmap* vl_BitmapFromHash | ( | BitmapHash * | bmhash, |
char * | hashelem | ||
) |
Return a specified Bitmap from a BitmapHash.
Raise an error if the returned object from the hash search is not a bitmap.
bmhash | The BitmapHash from which the result is to be returned. |
hashelem | The key of the Bitmap within the hash. |
Definition at line 548 of file veil_bitmap.c.
References BitmapHash::hash, VarEntry::obj, and Object::type.
Referenced by veil_bitmap_hash_bits(), veil_bitmap_hash_testbit(), veil_intersect_from_bitmap_hash(), and veil_union_from_bitmap_hash().
Bitmap* vl_AddBitmapToHash | ( | BitmapHash * | bmhash, |
char * | hashelem | ||
) |
Create a newly allocated empty Bitmap to a BitmapHash.
bmhash | The BitmapHash to which to add the new Bitmap. |
hashelem | The key for the new entry |
Definition at line 588 of file veil_bitmap.c.
References BitmapHash::hash, VarEntry::obj, and Object::type.
Referenced by veil_bitmap_from_hash(), veil_bitmap_hash_clearbit(), veil_bitmap_hash_setbit(), and veil_union_into_bitmap_hash().
bool vl_BitmapHashHasKey | ( | BitmapHash * | bmhash, |
char * | hashelem | ||
) |
Determine whether the supplied key exists in the BitmapHash.
bmhash | The BitmapHash to be tested |
hashelem | The key to be tested |
Definition at line 629 of file veil_bitmap.c.
References BitmapHash::hash.
Referenced by veil_bitmap_hash_key_exists().
|
static |
Array of bit positions for int32, indexed by bitno.
Definition at line 56 of file veil_bitmap.c.
Referenced by vl_BitmapClearbit(), vl_BitmapSetbit(), and vl_BitmapTestbit().