1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

refactor: whitespaces for references

This commit is contained in:
Steffen Vogel 2020-06-14 21:53:18 +02:00
parent 138dabb899
commit c80be0544b
15 changed files with 70 additions and 70 deletions

View file

@ -131,19 +131,19 @@ public:
return CPU_EQUAL_S(sz, setp, rhs.setp);
}
CpuSet& operator&=(const CpuSet &rhs)
CpuSet & operator&=(const CpuSet &rhs)
{
CPU_AND_S(sz, setp, setp, rhs.setp);
return *this;
}
CpuSet& operator|=(const CpuSet &rhs)
CpuSet & operator|=(const CpuSet &rhs)
{
CPU_OR_S(sz, setp, setp, rhs.setp);
return *this;
}
CpuSet& operator^=(const CpuSet &rhs)
CpuSet & operator^=(const CpuSet &rhs)
{
CPU_XOR_S(sz, setp, setp, rhs.setp);
return *this;

View file

@ -49,7 +49,7 @@ public:
using EdgeIdentifier = Edge::Identifier;
using Path = std::list<EdgeIdentifier>;
DirectedGraph(const std::string& name = "DirectedGraph") :
DirectedGraph(const std::string &name = "DirectedGraph") :
lastVertexId(0), lastEdgeId(0)
{
logger = logging.get(name);
@ -68,9 +68,9 @@ public:
template<class UnaryPredicate>
VertexIdentifier findVertex(UnaryPredicate p)
{
for (auto& v : vertices) {
auto& vertexId = v.first;
auto& vertex = v.second;
for (auto &v : vertices) {
auto &vertexId = v.first;
auto &vertex = v.second;
if (p(vertex)) {
return vertexId;
@ -156,8 +156,8 @@ public:
// delete every edge that start or ends at this vertex
auto it = edges.begin();
while (it != edges.end()) {
auto& edgeId = it->first;
auto& edge = it->second;
auto &edgeId = it->first;
auto &edge = it->second;
bool removeEdge = false;
@ -197,7 +197,7 @@ public:
bool getPath(VertexIdentifier fromVertexId,
VertexIdentifier toVertexId,
Path& path,
Path &path,
check_path_fn pathCheckFunc = checkPath)
{
if (fromVertexId == toVertexId) {
@ -206,12 +206,12 @@ public:
} else {
auto fromVertex = getVertex(fromVertexId);
for (auto& edgeId : fromVertex->edges) {
for (auto &edgeId : fromVertex->edges) {
auto edgeOfFromVertex = getEdge(edgeId);
// loop detection
bool loop = false;
for (auto& edgeIdInPath : path) {
for (auto &edgeIdInPath : path) {
auto edgeInPath = getEdge(edgeIdInPath);
if (edgeInPath->from == edgeOfFromVertex->to) {
loop = true;
@ -242,15 +242,15 @@ public:
return false;
}
void dump(const std::string& fileName = "") const
void dump(const std::string &fileName = "") const
{
logger->info("Vertices:");
for (auto& v : vertices) {
auto& vertex = v.second;
for (auto &v : vertices) {
auto &vertex = v.second;
// format connected vertices into a list
std::stringstream ssEdges;
for (auto& edge : vertex->edges) {
for (auto &edge : vertex->edges) {
ssEdges << getEdge(edge)->to << " ";
}
@ -263,8 +263,8 @@ public:
}
logger->info("Edges:");
for (auto& e : edges) {
auto& edge = e.second;
for (auto &e : edges) {
auto &edge = e.second;
logger->info(" {}: {} -> {}", *edge, edge->from, edge->to);
if (s.is_open()) {

View file

@ -34,11 +34,11 @@ public:
using Identifier = std::size_t;
friend std::ostream&
operator<< (std::ostream& stream, const Edge& edge)
operator<< (std::ostream &stream, const Edge &edge)
{ return stream << edge.id; }
bool
operator==(const Edge& other)
operator==(const Edge &other)
{ return this->id == other.id; }
Vertex::Identifier getVertexTo() const

View file

@ -38,11 +38,11 @@ public:
{ return id; }
friend std::ostream&
operator<< (std::ostream& stream, const Vertex& vertex)
operator<< (std::ostream &stream, const Vertex &vertex)
{ return stream << vertex.id; }
bool
operator==(const Vertex& other)
operator==(const Vertex &other)
{ return this->id == other.id; }
private:

View file

@ -38,7 +38,7 @@ class OpalSink : public spdlog::sinks::base_sink<Mutex>
{
protected:
void sink_it_(const spdlog::details::log_msg& msg) override
void sink_it_(const spdlog::details::log_msg &msg) override
{
#ifdef ENABLE_OPAL_ASYNC
fmt::memory_buffer formatted;

View file

@ -83,19 +83,19 @@ public:
{}
// just act as an accessor, do not take ownership of MemoryBlock
MemoryAccessor(const MemoryBlock& mem) :
MemoryAccessor(const MemoryBlock &mem) :
translation(MemoryManager::get().getTranslationFromProcess(mem.getAddrSpaceId()))
{}
MemoryAccessor(const MemoryTranslation& translation) :
MemoryAccessor(const MemoryTranslation &translation) :
translation(translation)
{}
T& operator*() const {
T & operator*() const {
return *reinterpret_cast<T*>(translation.getLocalAddr(0));
}
T& operator[](size_t idx) const {
T & operator[](size_t idx) const {
const size_t offset = sizeof(T) * idx;
return *reinterpret_cast<T*>(translation.getLocalAddr(offset));
}
@ -189,19 +189,19 @@ public:
}
protected:
void insertMemoryBlock(const MemoryBlock& mem)
void insertMemoryBlock(const MemoryBlock &mem)
{
auto& mm = MemoryManager::get();
auto & mm = MemoryManager::get();
mm.createMapping(mem.getOffset(), 0, mem.getSize(),
derivedAlloc->getName(),
memoryAddrSpaceId,
mem.getAddrSpaceId());
}
void removeMemoryBlock(const MemoryBlock& mem)
void removeMemoryBlock(const MemoryBlock &mem)
{
// this will also remove any mapping to and from the memory block
auto& mm = MemoryManager::get();
auto & mm = MemoryManager::get();
mm.removeAddressSpace(mem.getAddrSpaceId());
}

View file

@ -64,7 +64,7 @@ public:
{ return size; }
friend std::ostream&
operator<< (std::ostream& stream, const MemoryTranslation& translation)
operator<< (std::ostream &stream, const MemoryTranslation &translation)
{
return stream << std::hex
<< "(src=0x" << translation.src
@ -74,7 +74,7 @@ public:
}
/// Merge two MemoryTranslations together
MemoryTranslation& operator+=(const MemoryTranslation& other);
MemoryTranslation &operator+=(const MemoryTranslation &other);
private:
uintptr_t src; ///< Base address of local address space
@ -100,14 +100,14 @@ private:
{
logger = logging.get("memory:manager");
pathCheckFunc = [&](const MemoryGraph::Path& path) {
pathCheckFunc = [&](const MemoryGraph::Path &path) {
return this->pathCheck(path);
};
}
// ... and no copying or assigning
MemoryManager(const MemoryManager&) = delete;
MemoryManager& operator=(const MemoryManager&) = delete;
MemoryManager &operator=(const MemoryManager&) = delete;
/**
* @brief Custom edge in memory graph representing a memory mapping
@ -134,7 +134,7 @@ private:
size_t size; ///< Size of the mapping
friend std::ostream&
operator<< (std::ostream& stream, const Mapping& mapping)
operator<< (std::ostream &stream, const Mapping &mapping)
{
return stream << static_cast<const Edge&>(mapping) << " = "
<< mapping.name
@ -159,7 +159,7 @@ private:
std::string name; ///< Human-readable name
friend std::ostream&
operator<< (std::ostream& stream, const AddressSpace& addrSpace)
operator<< (std::ostream &stream, const AddressSpace &addrSpace)
{
return stream << static_cast<const Vertex&>(addrSpace) << " = "
<< addrSpace.name;
@ -191,7 +191,7 @@ public:
{ return getOrCreateAddressSpace("pcie"); }
AddressSpaceId
getProcessAddressSpaceMemoryBlock(const std::string& memoryBlock)
getProcessAddressSpaceMemoryBlock(const std::string &memoryBlock)
{ return getOrCreateAddressSpace(getSlaveAddrSpaceName("process", memoryBlock)); }
@ -205,7 +205,7 @@ public:
/// Create a default mapping
MappingId
createMapping(uintptr_t src, uintptr_t dest, size_t size,
const std::string& name,
const std::string &name,
AddressSpaceId fromAddrSpace,
AddressSpaceId toAddrSpace);
@ -220,7 +220,7 @@ public:
AddressSpaceId
findAddressSpace(const std::string& name);
findAddressSpace(const std::string &name);
std::list<AddressSpaceId>
findPath(AddressSpaceId fromAddrSpaceId, AddressSpaceId toAddrSpaceId);
@ -233,21 +233,21 @@ public:
{ return getTranslation(getProcessAddressSpace(), foreignAddrSpaceId); }
static std::string
getSlaveAddrSpaceName(const std::string& ipInstance, const std::string& memoryBlock)
getSlaveAddrSpaceName(const std::string &ipInstance, const std::string &memoryBlock)
{ return ipInstance + "/" + memoryBlock; }
static std::string
getMasterAddrSpaceName(const std::string& ipInstance, const std::string& busInterface)
getMasterAddrSpaceName(const std::string &ipInstance, const std::string &busInterface)
{ return ipInstance + ":" + busInterface; }
private:
/// Convert a Mapping to MemoryTranslation for calculations
static MemoryTranslation
getTranslationFromMapping(const Mapping& mapping)
getTranslationFromMapping(const Mapping &mapping)
{ return MemoryTranslation(mapping.src, mapping.dest, mapping.size); }
bool
pathCheck(const MemoryGraph::Path& path);
pathCheck(const MemoryGraph::Path &path);
/// Directed graph that stores address spaces and memory mappings
MemoryGraph memoryGraph;

View file

@ -99,7 +99,7 @@ protected:
} /* namespace villas */
template<typename T>
std::istream& operator>>(villas::utils::Popen& po, T& value)
std::istream &operator>>(villas::utils::Popen &po, T &value)
{
return *(po.input.stream) >> value;
}

View file

@ -131,7 +131,7 @@ tokenize(std::string s, std::string delimiter);
template<typename T>
void
assertExcept(bool condition, const T& exception)
assertExcept(bool condition, const T &exception)
{
if (not condition)
throw exception;

View file

@ -33,7 +33,7 @@ class Version {
protected:
int components[3];
static int cmp(const Version& lhs, const Version& rhs);
static int cmp(const Version &lhs, const Version &rhs);
public:
/** Parse a dotted version string. */
@ -41,12 +41,12 @@ public:
Version(int maj, int min = 0, int pat = 0);
inline bool operator==(const Version& rhs) { return cmp(*this, rhs) == 0; }
inline bool operator!=(const Version& rhs) { return cmp(*this, rhs) != 0; }
inline bool operator< (const Version& rhs) { return cmp(*this, rhs) < 0; }
inline bool operator> (const Version& rhs) { return cmp(*this, rhs) > 0; }
inline bool operator<=(const Version& rhs) { return cmp(*this, rhs) <= 0; }
inline bool operator>=(const Version& rhs) { return cmp(*this, rhs) >= 0; }
inline bool operator==(const Version &rhs) { return cmp(*this, rhs) == 0; }
inline bool operator!=(const Version &rhs) { return cmp(*this, rhs) != 0; }
inline bool operator< (const Version &rhs) { return cmp(*this, rhs) < 0; }
inline bool operator> (const Version &rhs) { return cmp(*this, rhs) > 0; }
inline bool operator<=(const Version &rhs) { return cmp(*this, rhs) <= 0; }
inline bool operator>=(const Version &rhs) { return cmp(*this, rhs) >= 0; }
};
} /* namespace villas */

View file

@ -73,7 +73,7 @@ std::string encode(const std::vector<byte>& input)
return encoded;
}
std::vector<byte> decode(const std::string& input)
std::vector<byte> decode(const std::string &input)
{
if (input.length() % 4)
throw std::runtime_error("Invalid base64 length!");

View file

@ -51,7 +51,7 @@ HostRam::HostRamAllocator::allocateBlock(size_t size)
throw std::bad_alloc();
}
auto& mm = MemoryManager::get();
auto &mm = MemoryManager::get();
/* Assemble name for this block */
std::stringstream name;
@ -141,7 +141,7 @@ LinearAllocator::allocateBlock(size_t size)
}
auto& mm = MemoryManager::get();
auto &mm = MemoryManager::get();
/* Assemble name for this block */
std::stringstream blockName;
@ -191,7 +191,7 @@ HostDmaRam::HostDmaRamAllocator::HostDmaRamAllocator(int num) :
LinearAllocator(MemoryManager::get().getOrCreateAddressSpace(getUdmaBufName(num)), getUdmaBufBufSize(num)),
num(num)
{
auto& mm = MemoryManager::get();
auto &mm = MemoryManager::get();
logger = logging.get(getName());
if (getSize() == 0) {
@ -226,7 +226,7 @@ HostDmaRam::HostDmaRamAllocator::HostDmaRamAllocator(int num) :
HostDmaRam::HostDmaRamAllocator::~HostDmaRamAllocator()
{
auto& mm = MemoryManager::get();
auto &mm = MemoryManager::get();
void* baseVirt;
try {
@ -293,7 +293,7 @@ HostDmaRam::getUdmaBufPhysAddr(int num)
HostDmaRam::HostDmaRamAllocator&HostDmaRam::getAllocator(int num)
{
auto& allocator = allocators[num];
auto &allocator = allocators[num];
if (not allocator) {
allocator = std::make_unique<HostDmaRamAllocator>(num);
}

View file

@ -64,7 +64,7 @@ MemoryManager::getOrCreateAddressSpace(std::string name)
MemoryManager::MappingId
MemoryManager::createMapping(uintptr_t src, uintptr_t dest, size_t size,
const std::string& name,
const std::string &name,
MemoryManager::AddressSpaceId fromAddrSpace,
MemoryManager::AddressSpaceId toAddrSpace)
{
@ -87,7 +87,7 @@ MemoryManager::addMapping(std::shared_ptr<Mapping> mapping,
}
MemoryManager::AddressSpaceId
MemoryManager::findAddressSpace(const std::string& name)
MemoryManager::findAddressSpace(const std::string &name)
{
return memoryGraph.findVertex(
[&](const std::shared_ptr<AddressSpace>& v) {
@ -114,7 +114,7 @@ MemoryManager::findPath(MemoryManager::AddressSpaceId fromAddrSpaceId,
throw std::out_of_range("no translation found");
}
for (auto& mappingId : pathGraph) {
for (auto &mappingId : pathGraph) {
auto mapping = memoryGraph.getEdge(mappingId);
path.push_back(mapping->getVertexTo());
}
@ -142,7 +142,7 @@ MemoryManager::getTranslation(MemoryManager::AddressSpaceId fromAddrSpaceId,
MemoryTranslation translation(0, 0, SIZE_MAX);
/* Iterate through path and merge all mappings into a single translation */
for (auto& mappingId : path) {
for (auto &mappingId : path) {
auto mapping = memoryGraph.getEdge(mappingId);
translation += getTranslationFromMapping(*mapping);
}
@ -151,7 +151,7 @@ MemoryManager::getTranslation(MemoryManager::AddressSpaceId fromAddrSpaceId,
}
bool
MemoryManager::pathCheck(const MemoryGraph::Path& path)
MemoryManager::pathCheck(const MemoryGraph::Path &path)
{
/* Start with an identity mapping */
MemoryTranslation translation(0, 0, SIZE_MAX);
@ -159,7 +159,7 @@ MemoryManager::pathCheck(const MemoryGraph::Path& path)
/* Try to add all mappings together to a common translation. If this fails
* there is a non-overlapping window.
*/
for (auto& mappingId : path) {
for (auto &mappingId : path) {
auto mapping = memoryGraph.getEdge(mappingId);
try {
translation += getTranslationFromMapping(*mapping);
@ -188,7 +188,7 @@ MemoryTranslation::getForeignAddr(uintptr_t addrInLocalAddrSpace) const
}
MemoryTranslation&
MemoryTranslation::operator+=(const MemoryTranslation& other)
MemoryTranslation::operator+=(const MemoryTranslation &other)
{
Logger logger = logging.get("MemoryTranslation");

View file

@ -56,7 +56,7 @@ Version::Version(int maj, int min, int pat) :
}
int Version::cmp(const Version& lhs, const Version& rhs)
int Version::cmp(const Version &lhs, const Version &rhs)
{
int d;

View file

@ -100,7 +100,7 @@ Test(graph, path, .description = "Find path")
cr_assert(g.getPath(v1id, v3id, path1));
logger->info(" Path from {} to {} via:", v1id, v3id);
for(auto& edge : path1) {
for(auto &edge : path1) {
logger->info(" -> edge {}", edge);
}
@ -121,7 +121,7 @@ Test(graph, path, .description = "Find path")
cr_assert(g.getPath(v4id, v6id, path4));
logger->info(" Path from {} to {} via:", v4id, v6id);
for(auto& edge : path4) {
for(auto &edge : path4) {
logger->info(" -> edge {}", edge);
}
}
@ -129,7 +129,7 @@ Test(graph, path, .description = "Find path")
Test(graph, memory_manager, .description = "Global Memory Manager")
{
Logger logger = logging.get("test:graph:mm");
auto& mm = villas::MemoryManager::get();
auto &mm = villas::MemoryManager::get();
logger->info("Create address spaces");
auto dmaRegs = mm.getOrCreateAddressSpace("DMA Registers");