The Pedigree Project
0.1
|
#include <ExtensibleBitmap.h>
Public Member Functions | |
ExtensibleBitmap () | |
ExtensibleBitmap (const ExtensibleBitmap &other) | |
~ExtensibleBitmap () | |
ExtensibleBitmap & | operator= (const ExtensibleBitmap &other) |
void | set (size_t n) |
void | clear (size_t n) |
bool | test (size_t n) const |
size_t | getFirstSet () const |
size_t | getFirstClear () |
size_t | getLastSet () const |
size_t | getLastClear () const |
Private Attributes | |
uintptr_t | m_StaticMap |
uint8_t * | m_pDynamicMap |
size_t | m_DynamicMapSize |
size_t | m_nMaxBit |
size_t | m_nFirstSetBit |
size_t | m_nFirstClearBit |
size_t | m_nLastSetBit |
size_t | m_nLastClearBit |
Defines an "extensible bitmap" - a bitmap that can extend to accommodate any value.
It does not currently deal well with a sparse domain - one bit set at 0x1 and another at 0x100000 will generate a bitmap with 0x100000/0x8 bytes usage.
Definition at line 32 of file ExtensibleBitmap.h.
ExtensibleBitmap::ExtensibleBitmap | ( | ) |
Creates a new, empty bitmap.
Definition at line 23 of file ExtensibleBitmap.cc.
ExtensibleBitmap::ExtensibleBitmap | ( | const ExtensibleBitmap & | other | ) |
Creates a new bitmap identical to that given.
Definition at line 30 of file ExtensibleBitmap.cc.
References m_DynamicMapSize, and m_pDynamicMap.
ExtensibleBitmap::~ExtensibleBitmap | ( | ) |
void ExtensibleBitmap::clear | ( | size_t | n | ) |
Clears the bit in the bitmap indexed by n.
Definition at line 130 of file ExtensibleBitmap.cc.
References m_nFirstSetBit, m_nMaxBit, m_pDynamicMap, m_StaticMap, and test().
Referenced by UsbHub::deviceConnected(), UsbHub::deviceDisconnected(), PosixSubsystem::freeFd(), PosixSubsystem::freeMultipleFds(), and Thread::inhibitEvent().
|
inline |
Returns the index of the first clear bit.
Definition at line 60 of file ExtensibleBitmap.h.
Referenced by UsbHub::deviceConnected().
|
inline |
Returns the index of the first set bit.
Definition at line 55 of file ExtensibleBitmap.h.
|
inline |
Returns the index of the last clear bit.
Definition at line 74 of file ExtensibleBitmap.h.
|
inline |
Returns the index of the last set bit.
Definition at line 69 of file ExtensibleBitmap.h.
ExtensibleBitmap & ExtensibleBitmap::operator= | ( | const ExtensibleBitmap & | other | ) |
Makes this bitmap mirror the one given.
Definition at line 41 of file ExtensibleBitmap.cc.
References m_DynamicMapSize, m_nFirstSetBit, m_nMaxBit, m_pDynamicMap, and m_StaticMap.
void ExtensibleBitmap::set | ( | size_t | n | ) |
Sets the bit in the bitmap indexed by n.
Definition at line 72 of file ExtensibleBitmap.cc.
References m_DynamicMapSize, m_nFirstSetBit, m_nMaxBit, m_pDynamicMap, m_StaticMap, and test().
Referenced by PosixSubsystem::allocateFd(), PosixSubsystem::copyDescriptors(), UsbHub::deviceConnected(), PosixSubsystem::getFd(), and Thread::inhibitEvent().
bool ExtensibleBitmap::test | ( | size_t | n | ) | const |
Returns the bit in the bitmap indexed by n.
Definition at line 187 of file ExtensibleBitmap.cc.
References m_nMaxBit, m_pDynamicMap, and m_StaticMap.
Referenced by clear(), PosixSubsystem::getFd(), and set().
|
private |
Amount of memory the dynamic map occupies.
Definition at line 88 of file ExtensibleBitmap.h.
Referenced by ExtensibleBitmap(), operator=(), and set().
|
private |
First/last bit set/clear indexes.
Definition at line 94 of file ExtensibleBitmap.h.
Referenced by clear(), operator=(), and set().
|
private |
Largest stored bit in the dynamic map.
Definition at line 91 of file ExtensibleBitmap.h.
Referenced by clear(), operator=(), set(), and test().
|
private |
The dynamic map, to accommodate bit numbers > {31,63}
Definition at line 85 of file ExtensibleBitmap.h.
Referenced by clear(), ExtensibleBitmap(), operator=(), set(), test(), and ~ExtensibleBitmap().
|
private |
Performance hint - one statically allocated word. Means we can index data from 0..{31,63} without dynamically allocating anything.
Definition at line 82 of file ExtensibleBitmap.h.
Referenced by clear(), operator=(), set(), and test().