Support multi channel descriptor I/O (#2190)

clang-format and Changes update. No functional change.
This commit is contained in:
Wilson Snyder 2020-05-14 18:14:50 -04:00
parent 1a0da2e4ec
commit c1a9fe07e9
3 changed files with 8 additions and 11 deletions

View File

@ -5,6 +5,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
* Verilator 4.035 devel
**** Support multi channel descriptor I/O (#2190) [Stephen Henry]
**** Support $countbits. (#2287) [Yossi Nivin]
**** Support $isunbounded and parameter $. (#2104)

View File

@ -1222,15 +1222,11 @@ IData VL_FOPEN_MCD_N(const std::string& filename) VL_MT_SAFE {
return VerilatedImp::fdNewMcd(filename.c_str());
}
void VL_FFLUSH_I(IData fdi) VL_MT_SAFE {
VerilatedImp::fdFlush(fdi);
}
void VL_FFLUSH_I(IData fdi) VL_MT_SAFE { VerilatedImp::fdFlush(fdi); }
IData VL_FSEEK_I(IData fdi, IData offset, IData origin) VL_MT_SAFE {
return VerilatedImp::fdSeek(fdi, offset, origin);
}
IData VL_FTELL_I(IData fdi) VL_MT_SAFE {
return VerilatedImp::fdTell(fdi);
}
IData VL_FTELL_I(IData fdi) VL_MT_SAFE { return VerilatedImp::fdTell(fdi); }
void VL_FCLOSE_I(IData fdi) VL_MT_SAFE {
// While threadsafe, each thread can only access different file handles
VerilatedImp::fdClose(fdi);

View File

@ -457,7 +457,7 @@ public: // But only for verilated*.cpp
IData idx = s_s.m_fdFreeMct.back();
s_s.m_fdFreeMct.pop_back();
s_s.m_fdps[idx] = fopen(filenamep, "w");
if(VL_UNLIKELY(!s_s.m_fdps[idx])) return 0;
if (VL_UNLIKELY(!s_s.m_fdps[idx])) return 0;
return (1 << idx);
}
static IData fdNew(const char* filenamep, const char* modep) VL_MT_SAFE {
@ -489,14 +489,14 @@ public: // But only for verilated*.cpp
FILE* fp;
VerilatedLockGuard lock(s_s.m_fdMutex);
const int n = fdToFp(fdi, &fp);
if(VL_UNLIKELY(!fp || (n != 1))) return 0;
if (VL_UNLIKELY(!fp || (n != 1))) return 0;
return static_cast<IData>(fseek(fp, static_cast<long>(offset), static_cast<int>(origin)));
}
static IData fdTell(IData fdi) VL_MT_SAFE {
FILE* fp;
VerilatedLockGuard lock(s_s.m_fdMutex);
const int n = fdToFp(fdi, &fp);
if(VL_UNLIKELY(!fp || (n != 1))) return 0;
if (VL_UNLIKELY(!fp || (n != 1))) return 0;
return static_cast<IData>(ftell(fp));
}
static void fdClose(IData fdi) VL_MT_SAFE {
@ -531,8 +531,7 @@ public: // But only for verilated*.cpp
case 1: fp[out++] = stdout; break;
case 2: fp[out++] = stderr; break;
default:
if (VL_LIKELY(idx < s_s.m_fdps.size()))
fp[out++] = s_s.m_fdps[idx];
if (VL_LIKELY(idx < s_s.m_fdps.size())) fp[out++] = s_s.m_fdps[idx];
break;
}
} else {