Skip to content

Commit

Permalink
Rerun clang-format with version 19.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
bengineerd committed Nov 4, 2024
1 parent 0ef1351 commit 6842425
Show file tree
Hide file tree
Showing 24 changed files with 165 additions and 57 deletions.
4 changes: 3 additions & 1 deletion include/rogue/hardware/drivers/DmaDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,9 @@ 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: 3 additions & 1 deletion include/rogue/interfaces/memory/Block.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ 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
14 changes: 9 additions & 5 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,7 +553,9 @@ 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 @@ -583,7 +585,9 @@ 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
4 changes: 3 additions & 1 deletion src/rogue/hardware/axi/AxiStreamDma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ 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
4 changes: 3 additions & 1 deletion src/rogue/interfaces/ZmqClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ 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: 6 additions & 2 deletions src/rogue/interfaces/ZmqServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ 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 @@ -258,7 +260,9 @@ 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
12 changes: 9 additions & 3 deletions src/rogue/interfaces/api/Bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ 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 @@ -110,14 +112,18 @@ 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
48 changes: 36 additions & 12 deletions src/rogue/interfaces/memory/Block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ void rim::Block::intStartTransaction(uint32_t type, bool forceWr, bool check, ri
highByte = size_ - 1;
if (type == rim::Write || type == rim::Post) {
stale_ = false;
for (vit = variables_.begin(); vit != variables_.end(); ++vit) { (*vit)->stale_ = false; }
for (vit = variables_.begin(); vit != variables_.end(); ++vit) {
(*vit)->stale_ = false;
}
}
} else {
if (type == rim::Read || type == rim::Verify) {
Expand Down Expand Up @@ -733,7 +735,9 @@ void rim::Block::getBytes(uint8_t* data, rim::Variable* var, uint32_t index) {
}

// Change byte order
if (var->byteReverse_) { reverseBytes(data, var->valueBytes_); }
if (var->byteReverse_) {
reverseBytes(data, var->valueBytes_);
}
}

//////////////////////////////////////////
Expand Down Expand Up @@ -922,11 +926,15 @@ void rim::Block::setUIntPy(bp::object& value, rim::Variable* var, int32_t index)
if (PyArray_TYPE(arr) == NPY_UINT64) {
uint64_t* src = reinterpret_cast<uint64_t*>(PyArray_DATA(arr));
npy_intp stride = strides[0] / sizeof(uint64_t);
for (x = 0; x < dims[0]; x++) { setUInt(src[x * stride], var, index + x); }
for (x = 0; x < dims[0]; x++) {
setUInt(src[x * stride], var, index + x);
}
} else if (PyArray_TYPE(arr) == NPY_UINT32) {
uint32_t* src = reinterpret_cast<uint32_t*>(PyArray_DATA(arr));
npy_intp stride = strides[0] / sizeof(uint32_t);
for (x = 0; x < dims[0]; x++) { setUInt(src[x * stride], var, index + x); }
for (x = 0; x < dims[0]; x++) {
setUInt(src[x * stride], var, index + x);
}
} else {
throw(rogue::GeneralError::create("Block::setUIntPy",
"Passed nparray is not of type (uint64 or uint32) for %s",
Expand Down Expand Up @@ -1083,11 +1091,15 @@ void rim::Block::setIntPy(bp::object& value, rim::Variable* var, int32_t index)
if (PyArray_TYPE(arr) == NPY_INT64) {
int64_t* src = reinterpret_cast<int64_t*>(PyArray_DATA(arr));
npy_intp stride = strides[0] / sizeof(int64_t);
for (x = 0; x < dims[0]; x++) { setInt(src[x * stride], var, index + x); }
for (x = 0; x < dims[0]; x++) {
setInt(src[x * stride], var, index + x);
}
} else if (PyArray_TYPE(arr) == NPY_INT32) {
int32_t* src = reinterpret_cast<int32_t*>(PyArray_DATA(arr));
npy_intp stride = strides[0] / sizeof(int32_t);
for (x = 0; x < dims[0]; x++) { setInt(src[x * stride], var, index + x); }
for (x = 0; x < dims[0]; x++) {
setInt(src[x * stride], var, index + x);
}
} else {
throw(rogue::GeneralError::create("Block::setIntPy",
"Passed nparray is not of type (int64 or int32) for %s",
Expand Down Expand Up @@ -1250,7 +1262,9 @@ void rim::Block::setBoolPy(bp::object& value, rim::Variable* var, int32_t index)
if (PyArray_TYPE(arr) == NPY_BOOL) {
bool* src = reinterpret_cast<bool*>(PyArray_DATA(arr));
npy_intp stride = strides[0] / sizeof(bool);
for (x = 0; x < dims[0]; x++) { setBool(src[x * stride], var, index + x); }
for (x = 0; x < dims[0]; x++) {
setBool(src[x * stride], var, index + x);
}
} else {
throw(rogue::GeneralError::create("Block::setBoolPy",
"Passed nparray is not of type (bool) for %s",
Expand Down Expand Up @@ -1460,7 +1474,9 @@ void rim::Block::setFloatPy(bp::object& value, rim::Variable* var, int32_t index
if (PyArray_TYPE(arr) == NPY_FLOAT32) {
float* src = reinterpret_cast<float*>(PyArray_DATA(arr));
npy_intp stride = strides[0] / sizeof(float);
for (x = 0; x < dims[0]; x++) { setFloat(src[x * stride], var, index + x); }
for (x = 0; x < dims[0]; x++) {
setFloat(src[x * stride], var, index + x);
}
} else {
throw(rogue::GeneralError::create("Block::setFLoatPy",
"Passed nparray is not of type (float32) for %s",
Expand Down Expand Up @@ -1607,7 +1623,9 @@ void rim::Block::setDoublePy(bp::object& value, rim::Variable* var, int32_t inde
if (PyArray_TYPE(arr) == NPY_FLOAT64) {
double* src = reinterpret_cast<double*>(PyArray_DATA(arr));
npy_intp stride = strides[0] / sizeof(double);
for (x = 0; x < dims[0]; x++) { setDouble(src[x * stride], var, index + x); }
for (x = 0; x < dims[0]; x++) {
setDouble(src[x * stride], var, index + x);
}
} else {
throw(rogue::GeneralError::create("Block::setFLoatPy",
"Passed nparray is not of type (double) for %s",
Expand Down Expand Up @@ -1754,7 +1772,9 @@ void rim::Block::setFixedPy(bp::object& value, rim::Variable* var, int32_t index
if (PyArray_TYPE(arr) == NPY_FLOAT64) {
double* src = reinterpret_cast<double*>(PyArray_DATA(arr));
npy_intp stride = strides[0] / sizeof(double);
for (x = 0; x < dims[0]; x++) { setFixed(src[x * stride], var, index + x); }
for (x = 0; x < dims[0]; x++) {
setFixed(src[x * stride], var, index + x);
}
} else {
throw(rogue::GeneralError::create("Block::setFixedPy",
"Passed nparray is not of type (double) for %s",
Expand Down Expand Up @@ -1855,7 +1875,9 @@ void rim::Block::setFixed(const double& val, rim::Variable* var, int32_t index)
int64_t fPoint = static_cast<int64_t>(round(val * pow(2, var->binPoint_)));
// Check for positive edge case
uint64_t mask = 1 << (var->valueBits_ - 1);
if (val > 0 && ((fPoint & mask) != 0)) { fPoint -= 1; }
if (val > 0 && ((fPoint & mask) != 0)) {
fPoint -= 1;
}
setBytes(reinterpret_cast<uint8_t*>(&fPoint), var, index);
}

Expand All @@ -1866,7 +1888,9 @@ double rim::Block::getFixed(rim::Variable* var, int32_t index) {

getBytes(reinterpret_cast<uint8_t*>(&fPoint), var, index);
// Do two-complement if negative
if ((fPoint & (1 << (var->valueBits_ - 1))) != 0) { fPoint = fPoint - (1 << var->valueBits_); }
if ((fPoint & (1 << (var->valueBits_ - 1))) != 0) {
fPoint = fPoint - (1 << var->valueBits_);
}

// Convert to float
tmp = static_cast<double>(fPoint);
Expand Down
4 changes: 3 additions & 1 deletion src/rogue/interfaces/memory/Hub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ void rim::HubWrap::doTransaction(rim::TransactionPtr transaction) {
try {
pb(transaction);
return;
} catch (...) { PyErr_Print(); }
} catch (...) {
PyErr_Print();
}
}
}
rim::Hub::doTransaction(transaction);
Expand Down
20 changes: 15 additions & 5 deletions src/rogue/interfaces/memory/Slave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ rim::TransactionPtr rim::Slave::getTransaction(uint32_t index) {

// Clean up if we found an expired transaction, overtime this will clean up
// the list, even if it deletes one expired transaction per call
if (exp != tranMap_.end()) { tranMap_.erase(exp); }
if (exp != tranMap_.end()) {
tranMap_.erase(exp);
}
}
return ret;
}
Expand Down Expand Up @@ -188,7 +190,9 @@ uint32_t rim::SlaveWrap::doMinAccess() {
if (boost::python::override pb = this->get_override("_doMinAccess")) {
try {
return (pb());
} catch (...) { PyErr_Print(); }
} catch (...) {
PyErr_Print();
}
}
}
return (rim::Slave::doMinAccess());
Expand All @@ -207,7 +211,9 @@ uint32_t rim::SlaveWrap::doMaxAccess() {
if (boost::python::override pb = this->get_override("_doMaxAccess")) {
try {
return (pb());
} catch (...) { PyErr_Print(); }
} catch (...) {
PyErr_Print();
}
}
}
return (rim::Slave::doMaxAccess());
Expand All @@ -226,7 +232,9 @@ uint64_t rim::SlaveWrap::doAddress() {
if (boost::python::override pb = this->get_override("_doAddress")) {
try {
return (pb());
} catch (...) { PyErr_Print(); }
} catch (...) {
PyErr_Print();
}
}
}
return (rim::Slave::doAddress());
Expand All @@ -246,7 +254,9 @@ void rim::SlaveWrap::doTransaction(rim::TransactionPtr transaction) {
try {
pb(transaction);
return;
} catch (...) { PyErr_Print(); }
} catch (...) {
PyErr_Print();
}
}
}
rim::Slave::doTransaction(transaction);
Expand Down
4 changes: 3 additions & 1 deletion src/rogue/interfaces/memory/Transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ rim::TransactionLockPtr rim::Transaction::lock() {
//! Get expired state
bool rim::Transaction::expired() {
bool done = false;
if (isSubTransaction_) { done = parentTransaction_.expired(); }
if (isSubTransaction_) {
done = parentTransaction_.expired();
}
return done || (iter_ == NULL || done_);
}

Expand Down
12 changes: 9 additions & 3 deletions src/rogue/interfaces/memory/Variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,9 @@ void rim::VariableWrap::queueUpdate() {
try {
pb();
return;
} catch (...) { PyErr_Print(); }
} catch (...) {
PyErr_Print();
}
}
}

Expand Down Expand Up @@ -652,7 +654,9 @@ void rim::Variable::rateTest() {
uint32_t ret;

gettimeofday(&stime, NULL);
for (x = 0; x < count; ++x) { ret = getUInt(); }
for (x = 0; x < count; ++x) {
ret = getUInt();
}
gettimeofday(&etime, NULL);

timersub(&etime, &stime, &dtime);
Expand All @@ -662,7 +666,9 @@ void rim::Variable::rateTest() {
printf("\nVariable c++ get: Read %" PRIu64 " times in %f seconds. Rate = %f\n", count, durr, rate);

gettimeofday(&stime, NULL);
for (x = 0; x < count; ++x) { setUInt(x); }
for (x = 0; x < count; ++x) {
setUInt(x);
}
gettimeofday(&etime, NULL);

timersub(&etime, &stime, &dtime);
Expand Down
Loading

0 comments on commit 6842425

Please sign in to comment.