diff --git a/common/include/villas/cpuset.hpp b/common/include/villas/cpuset.hpp index 5d9daad5b..e8f67c868 100644 --- a/common/include/villas/cpuset.hpp +++ b/common/include/villas/cpuset.hpp @@ -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; diff --git a/common/include/villas/graph/directed.hpp b/common/include/villas/graph/directed.hpp index 89633c889..8667e3185 100644 --- a/common/include/villas/graph/directed.hpp +++ b/common/include/villas/graph/directed.hpp @@ -49,7 +49,7 @@ public: using EdgeIdentifier = Edge::Identifier; using Path = std::list; - 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 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()) { diff --git a/common/include/villas/graph/edge.hpp b/common/include/villas/graph/edge.hpp index 188f4a451..e8f66d812 100644 --- a/common/include/villas/graph/edge.hpp +++ b/common/include/villas/graph/edge.hpp @@ -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 diff --git a/common/include/villas/graph/vertex.hpp b/common/include/villas/graph/vertex.hpp index c38089d83..e79087833 100644 --- a/common/include/villas/graph/vertex.hpp +++ b/common/include/villas/graph/vertex.hpp @@ -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: diff --git a/common/include/villas/log_opal_sink.hpp b/common/include/villas/log_opal_sink.hpp index dab2486f8..da2c7a8e1 100644 --- a/common/include/villas/log_opal_sink.hpp +++ b/common/include/villas/log_opal_sink.hpp @@ -38,7 +38,7 @@ class OpalSink : public spdlog::sinks::base_sink { 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; diff --git a/common/include/villas/memory.hpp b/common/include/villas/memory.hpp index ef4b970c7..389c43483 100644 --- a/common/include/villas/memory.hpp +++ b/common/include/villas/memory.hpp @@ -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(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(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()); } diff --git a/common/include/villas/memory_manager.hpp b/common/include/villas/memory_manager.hpp index 520e1461f..32578c4b1 100644 --- a/common/include/villas/memory_manager.hpp +++ b/common/include/villas/memory_manager.hpp @@ -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(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(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 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; diff --git a/common/include/villas/popen.hpp b/common/include/villas/popen.hpp index 9bb2b4d96..6872b50f4 100644 --- a/common/include/villas/popen.hpp +++ b/common/include/villas/popen.hpp @@ -99,7 +99,7 @@ protected: } /* namespace villas */ template -std::istream& operator>>(villas::utils::Popen& po, T& value) +std::istream &operator>>(villas::utils::Popen &po, T &value) { return *(po.input.stream) >> value; } diff --git a/common/include/villas/utils.hpp b/common/include/villas/utils.hpp index 19240d132..4418e91d6 100644 --- a/common/include/villas/utils.hpp +++ b/common/include/villas/utils.hpp @@ -131,7 +131,7 @@ tokenize(std::string s, std::string delimiter); template void -assertExcept(bool condition, const T& exception) +assertExcept(bool condition, const T &exception) { if (not condition) throw exception; diff --git a/common/include/villas/version.hpp b/common/include/villas/version.hpp index a1d11e169..4e5be2683 100644 --- a/common/include/villas/version.hpp +++ b/common/include/villas/version.hpp @@ -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 */ diff --git a/common/lib/base64.cpp b/common/lib/base64.cpp index b96c3fed4..cd3de79fb 100644 --- a/common/lib/base64.cpp +++ b/common/lib/base64.cpp @@ -73,7 +73,7 @@ std::string encode(const std::vector& input) return encoded; } -std::vector decode(const std::string& input) +std::vector decode(const std::string &input) { if (input.length() % 4) throw std::runtime_error("Invalid base64 length!"); diff --git a/common/lib/memory.cpp b/common/lib/memory.cpp index 93208221c..6e92fd61d 100644 --- a/common/lib/memory.cpp +++ b/common/lib/memory.cpp @@ -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(num); } diff --git a/common/lib/memory_manager.cpp b/common/lib/memory_manager.cpp index 316abe07b..060177938 100644 --- a/common/lib/memory_manager.cpp +++ b/common/lib/memory_manager.cpp @@ -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, } MemoryManager::AddressSpaceId -MemoryManager::findAddressSpace(const std::string& name) +MemoryManager::findAddressSpace(const std::string &name) { return memoryGraph.findVertex( [&](const std::shared_ptr& 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"); diff --git a/common/lib/version.cpp b/common/lib/version.cpp index 2f7157755..bf6ac87c6 100644 --- a/common/lib/version.cpp +++ b/common/lib/version.cpp @@ -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; diff --git a/common/tests/unit/graph.cpp b/common/tests/unit/graph.cpp index 8e7fbea6f..6a560ab7a 100644 --- a/common/tests/unit/graph.cpp +++ b/common/tests/unit/graph.cpp @@ -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");