Skip to content

Commit

Permalink
Replace C header includes with C++ includes, rerun clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
bengineerd committed Oct 16, 2024
1 parent d64c015 commit 0ef1351
Show file tree
Hide file tree
Showing 51 changed files with 144 additions and 259 deletions.
21 changes: 10 additions & 11 deletions include/rogue/hardware/drivers/DmaDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,18 @@ struct DmaRegisterData {

// Conditional inclusion for non-kernel environments
#ifndef DMA_IN_KERNEL
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/fcntl.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/signal.h>
#include <sys/socket.h>
#include <unistd.h>

#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <cstring>

/**
* dmaWrite - Writes data to a DMA channel.
* @fd: File descriptor for the DMA device.
Expand All @@ -167,7 +168,7 @@ static inline ssize_t dmaWrite(int32_t fd, const void* buf, size_t size, uint32_
w.flags = flags;
w.size = size;
w.is32 = (sizeof(void*) == 4);
w.data = (uint64_t)buf;//NOLINT
w.data = (uint64_t)buf; // NOLINT

return (write(fd, &w, sizeof(struct DmaWriteData)));
}
Expand Down Expand Up @@ -237,7 +238,7 @@ static inline ssize_t dmaWriteVector(int32_t fd,
w.flags = (x == 0) ? begFlags : ((x == (iovlen - 1)) ? endFlags : midFlags);
w.size = iov[x].iov_len;
w.is32 = (sizeof(void*) == 4);
w.data = (uint64_t)iov[x].iov_base;//NOLINT
w.data = (uint64_t)iov[x].iov_base; // NOLINT

do {
res = write(fd, &w, sizeof(struct DmaWriteData));
Expand Down Expand Up @@ -288,7 +289,7 @@ static inline ssize_t dmaWriteIndexVector(int32_t fd,
w.flags = (x == 0) ? begFlags : ((x == (iovlen - 1)) ? endFlags : midFlags);
w.size = iov[x].iov_len;
w.is32 = (sizeof(void*) == 4);
w.index = (uint32_t)(((uint64_t)iov[x].iov_base) & 0xFFFFFFFF);//NOLINT
w.index = (uint32_t)(((uint64_t)iov[x].iov_base) & 0xFFFFFFFF); // NOLINT

do {
res = write(fd, &w, sizeof(struct DmaWriteData));
Expand Down Expand Up @@ -324,7 +325,7 @@ static inline ssize_t dmaRead(int32_t fd, void* buf, size_t maxSize, uint32_t* f
memset(&r, 0, sizeof(struct DmaReadData));
r.size = maxSize;
r.is32 = (sizeof(void*) == 4);
r.data = (uint64_t)buf;//NOLINT
r.data = (uint64_t)buf; // NOLINT

ret = read(fd, &r, sizeof(struct DmaReadData));

Expand Down Expand Up @@ -645,9 +646,7 @@ static inline ssize_t dmaGetBuffCount(int32_t fd) {
*/
static inline std::string dmaGetGitVersion(int32_t fd) {
char gitv[32] = {0}; // Initialize with zeros to ensure null-termination
if (ioctl(fd, DMA_Get_GITV, gitv) < 0) {
return "";
}
if (ioctl(fd, DMA_Get_GITV, gitv) < 0) { return ""; }
gitv[32 - 1] = '\0'; // Ensure null-termination
return std::string(gitv);
}
Expand Down
4 changes: 1 addition & 3 deletions include/rogue/interfaces/memory/Block.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ template <class T>
inline boost::python::list std_vector_to_py_list(std::vector<T> vector) {
typename std::vector<T>::iterator iter;
boost::python::list list;
for (iter = vector.begin(); iter != vector.end(); ++iter) {
list.append(*iter);
}
for (iter = vector.begin(); iter != vector.end(); ++iter) { list.append(*iter); }
return list;
}

Expand Down
2 changes: 1 addition & 1 deletion include/rogue/interfaces/stream/Master.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include "rogue/Directives.h"

#include <stdint.h>
#include <stdio.h>

#include <cstdio>
#include <memory>
#include <mutex>
#include <string>
Expand Down
14 changes: 5 additions & 9 deletions include/rogue/protocols/packetizer/CRC.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,11 @@ class CRC {
#endif

#ifdef CRCPP_USE_CPP11
CRC() = delete;
CRC(const CRC& other) = delete;
CRC() = delete;
CRC(const CRC& other) = delete;
CRC& operator=(const CRC& other) = delete;
CRC(CRC&& other) = delete;
CRC& operator=(CRC&& other) = delete;
CRC& operator=(CRC&& other) = delete;
#endif

private:
Expand Down Expand Up @@ -553,9 +553,7 @@ inline CRCType CRC::Finalize(CRCType remainder, CRCType finalXOR, bool reflectOu
static crcpp_constexpr CRCType BIT_MASK =
(CRCType(1) << (CRCWidth - CRCType(1))) | ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1));

if (reflectOutput) {
remainder = Reflect(remainder, CRCWidth);
}
if (reflectOutput) { remainder = Reflect(remainder, CRCWidth); }

return (remainder ^ finalXOR) & BIT_MASK;
}
Expand Down Expand Up @@ -585,9 +583,7 @@ inline CRCType CRC::UndoFinalize(CRCType crc, CRCType finalXOR, bool reflectOutp

crc = (crc & BIT_MASK) ^ finalXOR;

if (reflectOutput) {
crc = Reflect(crc, CRCWidth);
}
if (reflectOutput) { crc = Reflect(crc, CRCWidth); }

return crc;
}
Expand Down
7 changes: 3 additions & 4 deletions include/rogue/protocols/xilinx/JtagDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@

#include "rogue/Directives.h"

#include <errno.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include <cerrno>
#include <cstdio>
#include <cstring>
#include <exception>
#include <memory>
#include <stdexcept>
#include <vector>
#include <cstdio>

#include "rogue/GeneralError.h"
#include "rogue/Logging.h"
Expand Down
3 changes: 1 addition & 2 deletions src/package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@

#include "rogue/Directives.h"

#include <cstdio>

#include <boost/python.hpp>
#include <cstdio>

#include "rogue/Version.h"
#include "rogue/module.h"
Expand Down
6 changes: 3 additions & 3 deletions src/rogue/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

#include <inttypes.h>
#include <stdarg.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>

#include <cstdio>
#include <cstring>
#include <memory>
#include <vector>
#include <string>
#include <cstdio>
#include <vector>

#if defined(__linux__)
#include <sys/syscall.h>
Expand Down
2 changes: 1 addition & 1 deletion src/rogue/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#include <inttypes.h>
#include <unistd.h>

#include <cstdio>
#include <sstream>
#include <string>
#include <cstdio>

#include "rogue/GeneralError.h"
#include "rogue/GilRelease.h"
Expand Down
2 changes: 1 addition & 1 deletion src/rogue/hardware/MemMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@

#include <fcntl.h>
#include <inttypes.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include <cstdio>
#include <cstring>
#include <memory>
#include <thread>
Expand Down
4 changes: 2 additions & 2 deletions src/rogue/hardware/axi/AxiMemMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@

#include <fcntl.h>
#include <inttypes.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include <cstdio>
#include <cstring>
#include <memory>
#include <thread>
#include <string>
#include <thread>

#include "rogue/GeneralError.h"
#include "rogue/GilRelease.h"
Expand Down
10 changes: 4 additions & 6 deletions src/rogue/hardware/axi/AxiStreamDma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
#include "rogue/hardware/axi/AxiStreamDma.h"

#include <inttypes.h>
#include <stdlib.h>

#include <memory>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <memory>
#include <string>

#include "rogue/GeneralError.h"
Expand Down Expand Up @@ -133,9 +133,7 @@ void rha::AxiStreamDma::closeShared(rha::AxiStreamDmaSharedPtr desc) {
desc->openCount--;

if (desc->openCount == 0) {
if (desc->rawBuff != NULL) {
dmaUnMapDma(desc->fd, desc->rawBuff);
}
if (desc->rawBuff != NULL) { dmaUnMapDma(desc->fd, desc->rawBuff); }

::close(desc->fd);
desc->fd = -1;
Expand Down
6 changes: 2 additions & 4 deletions src/rogue/interfaces/ZmqClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#include <inttypes.h>
#include <zmq.h>

#include <cstdio>
#include <memory>
#include <string>
#include <cstdio>

#include "rogue/GeneralError.h"
#include "rogue/GilRelease.h"
Expand Down Expand Up @@ -289,9 +289,7 @@ void rogue::interfaces::ZmqClientWrap::doUpdate(bp::object data) {
if (bp::override f = this->get_override("_doUpdate")) {
try {
f(data);
} catch (...) {
PyErr_Print();
}
} catch (...) { PyErr_Print(); }
}
rogue::interfaces::ZmqClient::doUpdate(data);
}
Expand Down
8 changes: 2 additions & 6 deletions src/rogue/interfaces/ZmqServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ bp::object rogue::interfaces::ZmqServerWrap::doRequest(bp::object data) {
if (bp::override f = this->get_override("_doRequest")) {
try {
return (f(data));
} catch (...) {
PyErr_Print();
}
} catch (...) { PyErr_Print(); }
}
return (rogue::interfaces::ZmqServer::doRequest(data));
}
Expand All @@ -260,9 +258,7 @@ std::string rogue::interfaces::ZmqServerWrap::doString(std::string data) {
if (bp::override f = this->get_override("_doString")) {
try {
return (f(data));
} catch (...) {
PyErr_Print();
}
} catch (...) { PyErr_Print(); }
}
}
return (rogue::interfaces::ZmqServer::doString(data));
Expand Down
15 changes: 4 additions & 11 deletions src/rogue/interfaces/api/Bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
#include "rogue/interfaces/api/Bsp.h"

#include <boost/make_shared.hpp>

#include <string>
#include <memory>
#include <string>

#include "rogue/GeneralError.h"

Expand Down Expand Up @@ -57,9 +56,7 @@ ria::Bsp::Bsp(std::string modName, std::string rootClass) {
}

ria::Bsp::~Bsp() {
if (this->_isRoot) {
this->_obj.attr("stop")();
}
if (this->_isRoot) { this->_obj.attr("stop")(); }
}

void ria::Bsp::addVarListener(void (*func)(std::string, std::string), void (*done)()) {
Expand Down Expand Up @@ -113,18 +110,14 @@ std::shared_ptr<rogue::interfaces::api::Bsp> ria::Bsp::getNode(std::string name)
std::string ria::Bsp::operator()(std::string arg) {
try {
return (std::string(bp::extract<char*>(this->_obj.attr("callDisp")(arg))));
} catch (...) {
throw(rogue::GeneralError::create("Bsp::()", "Error executing node %s", this->_name.c_str()));
}
} catch (...) { throw(rogue::GeneralError::create("Bsp::()", "Error executing node %s", this->_name.c_str())); }
}

//! Execute command operator without arg
std::string ria::Bsp::operator()() {
try {
return (std::string(bp::extract<char*>(this->_obj.attr("callDisp")())));
} catch (...) {
throw(rogue::GeneralError::create("Bsp::()", "Error executing node %s", this->_name.c_str()));
}
} catch (...) { throw(rogue::GeneralError::create("Bsp::()", "Error executing node %s", this->_name.c_str())); }
}

//! Execute command
Expand Down
Loading

0 comments on commit 0ef1351

Please sign in to comment.