BitMap: Change the size param to the number of entries (bits)
This commit is contained in:
parent
eee0bb070c
commit
d4da8cab4e
|
@ -17,13 +17,13 @@ namespace xe {
|
|||
|
||||
BitMap::BitMap() = default;
|
||||
|
||||
BitMap::BitMap(size_t size) { Resize(size); }
|
||||
BitMap::BitMap(size_t size_bits) { Resize(size_bits); }
|
||||
|
||||
BitMap::BitMap(uint32_t* data, size_t size) {
|
||||
assert_true(size % 4 == 0);
|
||||
BitMap::BitMap(uint32_t* data, size_t size_bits) {
|
||||
assert_true(size_bits % 32 == 0);
|
||||
|
||||
data_.resize(size / 4);
|
||||
std::memcpy(data_.data(), data, size);
|
||||
data_.resize(size_bits / 32);
|
||||
std::memcpy(data_.data(), data, size_bits / 32);
|
||||
}
|
||||
|
||||
size_t BitMap::Acquire() {
|
||||
|
@ -74,10 +74,10 @@ void BitMap::Release(size_t index) {
|
|||
} while (!atomic_cas(entry, new_entry, &data_[slot]));
|
||||
}
|
||||
|
||||
void BitMap::Resize(size_t new_size) {
|
||||
void BitMap::Resize(size_t new_size_bits) {
|
||||
auto old_size = data_.size();
|
||||
assert_true(new_size % 4 == 0);
|
||||
data_.resize(new_size / 4);
|
||||
assert_true(new_size_bits % 32 == 0);
|
||||
data_.resize(new_size_bits / 32);
|
||||
|
||||
// Initialize new entries.
|
||||
if (data_.size() > old_size) {
|
||||
|
|
|
@ -20,13 +20,13 @@ class BitMap {
|
|||
public:
|
||||
BitMap();
|
||||
|
||||
// Size is the number of 8-bit entries, must be a multiple of 4.
|
||||
BitMap(size_t size);
|
||||
// Size is the number of entries, must be a multiple of 32.
|
||||
BitMap(size_t size_bits);
|
||||
|
||||
// Data does not have to be aligned to a 4-byte boundary, but it is
|
||||
// preferable.
|
||||
// Size is the number of 8-bit entries, must be a multiple of 4.
|
||||
BitMap(uint32_t* data, size_t size);
|
||||
// Size is the number of entries, must be a multiple of 32.
|
||||
BitMap(uint32_t* data, size_t size_bits);
|
||||
|
||||
// (threadsafe) Acquires an entry and returns its index. Returns -1 if there
|
||||
// are no more free entries.
|
||||
|
@ -35,9 +35,8 @@ class BitMap {
|
|||
// (threadsafe) Releases an entry by an index.
|
||||
void Release(size_t index);
|
||||
|
||||
// Resize the bitmap. Size is the number of 8-bit entries, must be a multiple
|
||||
// of 4.
|
||||
void Resize(size_t new_size);
|
||||
// Resize the bitmap. Size is the number of entries, must be a multiple of 32.
|
||||
void Resize(size_t new_size_bits);
|
||||
|
||||
// Sets all entries to free.
|
||||
void Reset();
|
||||
|
|
|
@ -80,7 +80,7 @@ KernelState::KernelState(Emulator* emulator)
|
|||
pib->unk_54 = pib->unk_58 = 0;
|
||||
|
||||
// Hardcoded maximum of 2048 TLS slots.
|
||||
tls_bitmap_.Resize(64 * 4);
|
||||
tls_bitmap_.Resize(2048);
|
||||
|
||||
xam::AppManager::RegisterApps(this, app_manager_.get());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue