Fix C-style rand(); use our Random class instead.

This commit is contained in:
Stephen Anthony 2024-08-06 21:42:29 -02:30
parent 6614a2228a
commit 4c53cb9010
4 changed files with 18 additions and 9 deletions

View File

@ -47,9 +47,10 @@ void BusTransactionQueue::Transaction::setBusState(bool& bs_drive, uInt8& bs_val
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BusTransactionQueue::BusTransactionQueue(size_t capacity) : myQueueCapacity(capacity)
BusTransactionQueue::BusTransactionQueue(size_t capacity)
: myQueueCapacity{capacity},
myQueue{make_unique<Transaction[]>(myQueueCapacity)}
{
myQueue = make_unique<Transaction[]>(myQueueCapacity);
reset();
}

View File

@ -49,9 +49,11 @@ namespace {
} // namespace
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ElfLinker::ElfLinker(uInt32 textBase, uInt32 dataBase, uInt32 rodataBase, const ElfFile& elf)
: myTextBase(textBase), myDataBase(dataBase), myRodataBase(rodataBase), myElf(elf)
{}
ElfLinker::ElfLinker(uInt32 textBase, uInt32 dataBase, uInt32 rodataBase,
const ElfFile& elf)
: myTextBase{textBase}, myDataBase{dataBase}, myRodataBase{rodataBase}, myElf{elf}
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ElfLinker& ElfLinker::setUndefinedSymbolDefault(uInt32 defaultValue)
@ -162,13 +164,15 @@ ElfLinker::RelocatedSymbol ElfLinker::findRelocatedSymbol(string_view name) cons
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const vector<optional<ElfLinker::RelocatedSection>>& ElfLinker::getRelocatedSections() const
const vector<optional<ElfLinker::RelocatedSection>>&
ElfLinker::getRelocatedSections() const
{
return myRelocatedSections;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const vector<optional<ElfLinker::RelocatedSymbol>>& ElfLinker::getRelocatedSymbols() const
const vector<optional<ElfLinker::RelocatedSymbol>>&
ElfLinker::getRelocatedSymbols() const
{
return myRelocatedSymbols;
}

View File

@ -106,7 +106,8 @@ namespace {
} // namespace
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
VcsLib::VcsLib(BusTransactionQueue& transactionQueue) : myTransactionQueue(transactionQueue)
VcsLib::VcsLib(BusTransactionQueue& transactionQueue)
: myTransactionQueue{transactionQueue}
{
}
@ -366,7 +367,7 @@ CortexM0::err_t VcsLib::fetch16(uInt32 address, uInt16& value, uInt8& op, Cortex
}
case ADDR_RANDINT:
cortex.setRegister(0, rand()); // FIXME: use C++11 random library instead
cortex.setRegister(0, myRand.next());
return returnFromStub(value, op);
case ADDR_VCS_TXS2:

View File

@ -19,6 +19,7 @@
#define VCSLIB_H
#include "bspf.hxx"
#include "Random.hxx"
#include "CortexM0.hxx"
#include "BusTransactionQueue.hxx"
@ -71,6 +72,8 @@ class VcsLib: public CortexM0::BusTransactionDelegate {
uInt16 myCurrentAddress{0};
uInt8 myCurrentValue{0};
Random myRand;
private:
VcsLib(const VcsLib&) = delete;
VcsLib(VcsLib&&) = delete;