Make unused attribute compatible to all compilers.

This commit is contained in:
Lukas Steiner
2020-09-23 16:05:54 +02:00
parent 45b944a811
commit cbc455e643
15 changed files with 37 additions and 28 deletions

View File

@@ -55,6 +55,7 @@ endif()
add_subdirectory(src/common/third_party/DRAMPower)
# Add nlohmann:
set(JSON_BuildTests OFF)
add_subdirectory(src/common/third_party/nlohmann)
# Add SystemC:

View File

@@ -37,6 +37,14 @@
#ifndef DEBUGMANAGER_H
#define DEBUGMANAGER_H
#if __has_cpp_attribute(maybe_unused)
#define NDEBUG_UNUSED(var_decl) [[maybe_unused]] var_decl
#elif (__GNUC__ || __clang__)
#define NDEBUG_UNUSED(var_decl) var_decl __attribute__((unused))
#else
#define NDEBUG_UNUSED(var_decl) var_decl
#endif
#ifdef NDEBUG
#define PRINTDEBUGMESSAGE(sender, message) {}
#else

View File

@@ -112,14 +112,14 @@ struct TemperatureSimConfig
void showTemperatureSimConfig()
{
int i __attribute__((unused)) = 0;
for (auto e __attribute__((unused)) : powerInitialValues)
NDEBUG_UNUSED(int i) = 0;
for (NDEBUG_UNUSED(auto e) : powerInitialValues)
{
PRINTDEBUGMESSAGE("TemperatureSimConfig", "powerInitialValues["
+ std::to_string(i++) + "]: " + std::to_string(e));
}
i = 0;
for (auto e __attribute__((unused)) : powerThresholds)
for (NDEBUG_UNUSED(auto e) : powerThresholds)
{
PRINTDEBUGMESSAGE("TemperatureSimConfig", "powerThreshold["
+ std::to_string(i++) + "]: " + std::to_string(e));

View File

@@ -115,6 +115,6 @@ struct CommandTuple
};
};
using readyCommands_t = std::vector<CommandTuple::Type>;
using ReadyCommands = std::vector<CommandTuple::Type>;
#endif // COMMAND_H

View File

@@ -373,7 +373,7 @@ unsigned int Controller::transport_dbg(tlm_generic_payload &trans)
void Controller::finishBeginReq()
{
uint64_t id __attribute__((unused)) = DramExtension::getPayloadID(payloadToAcquire);
NDEBUG_UNUSED(uint64_t id) = DramExtension::getPayloadID(payloadToAcquire);
PRINTDEBUGMESSAGE(name(), "Payload " + std::to_string(id) + " entered system.");
if (totalNumberOfPayloads == 0)
@@ -419,7 +419,7 @@ void Controller::startBeginResp()
void Controller::finishEndResp()
{
uint64_t id __attribute__((unused)) = DramExtension::getPayloadID(payloadToRelease);
NDEBUG_UNUSED(uint64_t id) = DramExtension::getPayloadID(payloadToRelease);
PRINTDEBUGMESSAGE(name(), "Payload " + std::to_string(id) + " left system.");
payloadToRelease->release();

View File

@@ -75,7 +75,7 @@ protected:
private:
unsigned totalNumberOfPayloads = 0;
std::vector<unsigned> ranksNumberOfPayloads;
readyCommands_t readyCommands;
ReadyCommands readyCommands;
MemSpec *memSpec;

View File

@@ -72,13 +72,13 @@ void ControllerRecordable::recordPhase(tlm_generic_payload &trans, tlm_phase pha
{
sc_time recTime = delay + sc_time_stamp();
unsigned int thr __attribute__((unused)) = DramExtension::getExtension(trans).getThread().ID();
unsigned int ch __attribute__((unused)) = DramExtension::getExtension(trans).getChannel().ID();
unsigned int bg __attribute__((unused)) = DramExtension::getExtension(trans).getBankGroup().ID();
unsigned int bank __attribute__((unused)) = DramExtension::getExtension(trans).getBank().ID();
unsigned int row __attribute__((unused)) = DramExtension::getExtension(trans).getRow().ID();
unsigned int col __attribute__((unused)) = DramExtension::getExtension(trans).getColumn().ID();
uint64_t id __attribute__((unused)) = DramExtension::getExtension(trans).getPayloadID();
NDEBUG_UNUSED(unsigned thr) = DramExtension::getExtension(trans).getThread().ID();
NDEBUG_UNUSED(unsigned ch) = DramExtension::getExtension(trans).getChannel().ID();
NDEBUG_UNUSED(unsigned bg) = DramExtension::getExtension(trans).getBankGroup().ID();
NDEBUG_UNUSED(unsigned bank) = DramExtension::getExtension(trans).getBank().ID();
NDEBUG_UNUSED(unsigned row) = DramExtension::getExtension(trans).getRow().ID();
NDEBUG_UNUSED(unsigned col) = DramExtension::getExtension(trans).getColumn().ID();
NDEBUG_UNUSED(uint64_t id) = DramExtension::getExtension(trans).getPayloadID();
PRINTDEBUGMESSAGE(name(), "Recording " + getPhaseName(phase) + " thread " +
std::to_string(thr) + " channel " + std::to_string(ch) + " bank group " + std::to_string(

View File

@@ -45,7 +45,7 @@ class CmdMuxIF
{
public:
virtual ~CmdMuxIF() {}
virtual CommandTuple::Type selectCommand(readyCommands_t &) = 0;
virtual CommandTuple::Type selectCommand(ReadyCommands &) = 0;
};
#endif // CMDMUXIF_H

View File

@@ -38,7 +38,7 @@
using namespace tlm;
CommandTuple::Type CmdMuxOldest::selectCommand(readyCommands_t &readyCommands)
CommandTuple::Type CmdMuxOldest::selectCommand(ReadyCommands &readyCommands)
{
readyCommands.erase(std::remove_if(readyCommands.begin(), readyCommands.end(),
[](CommandTuple::Type element) {

View File

@@ -40,7 +40,7 @@
class CmdMuxOldest : public CmdMuxIF
{
public:
CommandTuple::Type selectCommand(readyCommands_t &);
CommandTuple::Type selectCommand(ReadyCommands &);
};
#endif // CMDMUXOLDEST_H

View File

@@ -39,7 +39,7 @@
using namespace tlm;
CommandTuple::Type
CmdMuxStrict::selectCommand(readyCommands_t &readyCommands)
CmdMuxStrict::selectCommand(ReadyCommands &readyCommands)
{
readyCommands.erase(std::remove_if(readyCommands.begin(), readyCommands.end(),
[](CommandTuple::Type element) {

View File

@@ -40,7 +40,7 @@
class CmdMuxStrict : public CmdMuxIF
{
public:
CommandTuple::Type selectCommand(readyCommands_t &);
CommandTuple::Type selectCommand(ReadyCommands &);
private:
uint64_t nextPayloadID = 0;

View File

@@ -166,7 +166,7 @@ void DRAMSys::logo()
#undef BOLDTXT
}
void DRAMSys::setupDebugManager(const std::string &traceName __attribute__((unused)))
void DRAMSys::setupDebugManager(NDEBUG_UNUSED(const std::string &traceName))
{
#ifndef NDEBUG
auto &dbg = DebugManager::getInstance();

View File

@@ -164,8 +164,8 @@ void TemperatureController::temperatureThread()
updateTemperatures();
double p = adjustThermalSimPeriod();
int i __attribute__((unused)) = 0;
for (auto t __attribute__((unused)) : temperatureValues) {
NDEBUG_UNUSED(int i) = 0;
for (NDEBUG_UNUSED(auto t) : temperatureValues) {
PRINTDEBUGMESSAGE(name(), "Temperature[" + std::to_string(i++)
+ "] is " + std::to_string(t));
}

View File

@@ -88,12 +88,12 @@ void DramRecordable<BaseDram>::recordPhase(tlm_generic_payload &trans, tlm_phase
if (phase == END_PDNA || phase == END_PDNP || phase == END_SREF)
recTime += this->memSpec->getCommandLength(phaseToCommand(phase));
unsigned int thr __attribute__((unused)) = DramExtension::getExtension(trans).getThread().ID();
unsigned int ch __attribute__((unused)) = DramExtension::getExtension(trans).getChannel().ID();
unsigned int bg __attribute__((unused)) = DramExtension::getExtension(trans).getBankGroup().ID();
unsigned int bank __attribute__((unused)) = DramExtension::getExtension(trans).getBank().ID();
unsigned int row __attribute__((unused)) = DramExtension::getExtension(trans).getRow().ID();
unsigned int col __attribute__((unused)) = DramExtension::getExtension(trans).getColumn().ID();
NDEBUG_UNUSED(unsigned thr) = DramExtension::getExtension(trans).getThread().ID();
NDEBUG_UNUSED(unsigned ch) = DramExtension::getExtension(trans).getChannel().ID();
NDEBUG_UNUSED(unsigned bg) = DramExtension::getExtension(trans).getBankGroup().ID();
NDEBUG_UNUSED(unsigned bank) = DramExtension::getExtension(trans).getBank().ID();
NDEBUG_UNUSED(unsigned row) = DramExtension::getExtension(trans).getRow().ID();
NDEBUG_UNUSED(unsigned col) = DramExtension::getExtension(trans).getColumn().ID();
PRINTDEBUGMESSAGE(this->name(), "Recording " + getPhaseName(phase) + " thread " +
std::to_string(thr) + " channel " + std::to_string(ch) + " bank group " + std::to_string(