[#73220] fix portability issues with const char*

This commit is contained in:
Mateusz Gancarz 2025-02-28 08:50:51 +01:00
parent 70238bbdc4
commit ca06d3ddc9
2 changed files with 12 additions and 9 deletions

View File

@ -193,7 +193,7 @@ void VerilatedSaif::initializeSaifFileContents() {
printStr("(VERSION \"5.032\")\n"); printStr("(VERSION \"5.032\")\n");
printStr("(DIVIDER / )\n"); printStr("(DIVIDER / )\n");
printStr("(TIMESCALE "); printStr("(TIMESCALE ");
printStr(timeResStr().c_str()); printStr(timeResStr());
printStr(")\n"); printStr(")\n");
} }
@ -245,7 +245,7 @@ void VerilatedSaif::close() VL_MT_SAFE_EXCLUDES(m_mutex) {
void VerilatedSaif::finalizeSaifFileContents() { void VerilatedSaif::finalizeSaifFileContents() {
printStr("(DURATION "); printStr("(DURATION ");
printStr(std::to_string(m_time).c_str()); printStr(std::to_string(m_time));
printStr(")\n"); printStr(")\n");
incrementIndent(); incrementIndent();
@ -258,7 +258,7 @@ void VerilatedSaif::finalizeSaifFileContents() {
void VerilatedSaif::recursivelyPrintScopes(uint32_t scopeIndex) { void VerilatedSaif::recursivelyPrintScopes(uint32_t scopeIndex) {
const ActivityScope& scope = m_scopes.at(scopeIndex); const ActivityScope& scope = m_scopes.at(scopeIndex);
openInstanceScope(scope.getName().c_str()); openInstanceScope(scope.getName());
printScopeActivities(scope); printScopeActivities(scope);
@ -269,7 +269,7 @@ void VerilatedSaif::recursivelyPrintScopes(uint32_t scopeIndex) {
closeInstanceScope(); closeInstanceScope();
} }
void VerilatedSaif::openInstanceScope(const char* instanceName) { void VerilatedSaif::openInstanceScope(const std::string& instanceName) {
printIndent(); printIndent();
printStr("(INSTANCE "); printStr("(INSTANCE ");
printStr(instanceName); printStr(instanceName);
@ -329,17 +329,17 @@ bool VerilatedSaif::printActivityStats(uint32_t activityCode, const char* activi
printStr(activityName); printStr(activityName);
if (activity.getWidth() > 1) { if (activity.getWidth() > 1) {
printStr("\\["); printStr("\\[");
printStr(std::to_string(i).c_str()); printStr(std::to_string(i));
printStr("\\]"); printStr("\\]");
} }
// We only have two-value logic so TZ, TX and TB will always be 0 // We only have two-value logic so TZ, TX and TB will always be 0
printStr(" (T0 "); printStr(" (T0 ");
printStr(std::to_string(m_time - bit.getHighTime()).c_str()); printStr(std::to_string(m_time - bit.getHighTime()));
printStr(") (T1 "); printStr(") (T1 ");
printStr(std::to_string(bit.getHighTime()).c_str()); printStr(std::to_string(bit.getHighTime()));
printStr(") (TZ 0) (TX 0) (TB 0) (TC "); printStr(") (TZ 0) (TX 0) (TB 0) (TC ");
printStr(std::to_string(bit.getToggleCount()).c_str()); printStr(std::to_string(bit.getToggleCount()));
printStr("))\n"); printStr("))\n");
} }
@ -359,6 +359,8 @@ void VerilatedSaif::clearCurrentlyCollectedData() {
void VerilatedSaif::printStr(const char* str) { m_filep->write(str, strlen(str)); } void VerilatedSaif::printStr(const char* str) { m_filep->write(str, strlen(str)); }
void VerilatedSaif::printStr(const std::string& str) { m_filep->write(str.c_str(), str.size()); }
//============================================================================= //=============================================================================
// Definitions // Definitions

View File

@ -170,7 +170,7 @@ private:
void initializeSaifFileContents(); void initializeSaifFileContents();
void finalizeSaifFileContents(); void finalizeSaifFileContents();
void recursivelyPrintScopes(uint32_t scopeIndex); void recursivelyPrintScopes(uint32_t scopeIndex);
void openInstanceScope(const char* instanceName); void openInstanceScope(const std::string& instanceName);
void closeInstanceScope(); void closeInstanceScope();
void printScopeActivities(const ActivityScope& scope); void printScopeActivities(const ActivityScope& scope);
void openNetScope(); void openNetScope();
@ -184,6 +184,7 @@ private:
int m_indent = 0; int m_indent = 0;
void printStr(const char* str); void printStr(const char* str);
void printStr(const std::string& str);
void clearCurrentlyCollectedData(); void clearCurrentlyCollectedData();