mirror of
https://github.com/verilator/verilator.git
synced 2025-01-19 12:54:02 +00:00
Internals: Fix destructor calling virtual. No functional change intended.
This commit is contained in:
parent
821dd070bf
commit
a83ed6b06f
@ -172,18 +172,18 @@ void VerilatedRestore::open(const char* filenamep) VL_MT_UNSAFE_ONE {
|
|||||||
header();
|
header();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedSave::close() VL_MT_UNSAFE_ONE {
|
void VerilatedSave::closeImp() VL_MT_UNSAFE_ONE {
|
||||||
if (!isOpen()) return;
|
if (!isOpen()) return;
|
||||||
trailer();
|
trailer();
|
||||||
flush();
|
flushImp();
|
||||||
m_isOpen = false;
|
m_isOpen = false;
|
||||||
::close(m_fd); // May get error, just ignore it
|
::close(m_fd); // May get error, just ignore it
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerilatedRestore::close() VL_MT_UNSAFE_ONE {
|
void VerilatedRestore::closeImp() VL_MT_UNSAFE_ONE {
|
||||||
if (!isOpen()) return;
|
if (!isOpen()) return;
|
||||||
trailer();
|
trailer();
|
||||||
flush();
|
flushImp();
|
||||||
m_isOpen = false;
|
m_isOpen = false;
|
||||||
::close(m_fd); // May get error, just ignore it
|
::close(m_fd); // May get error, just ignore it
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ void VerilatedRestore::close() VL_MT_UNSAFE_ONE {
|
|||||||
//=============================================================================
|
//=============================================================================
|
||||||
// Buffer management
|
// Buffer management
|
||||||
|
|
||||||
void VerilatedSave::flush() VL_MT_UNSAFE_ONE {
|
void VerilatedSave::flushImp() VL_MT_UNSAFE_ONE {
|
||||||
m_assertOne.check();
|
m_assertOne.check();
|
||||||
if (VL_UNLIKELY(!isOpen())) return;
|
if (VL_UNLIKELY(!isOpen())) return;
|
||||||
const uint8_t* wp = m_bufp;
|
const uint8_t* wp = m_bufp;
|
||||||
|
@ -62,9 +62,9 @@ public:
|
|||||||
m_bufp = new uint8_t[bufferSize()];
|
m_bufp = new uint8_t[bufferSize()];
|
||||||
m_cp = m_bufp;
|
m_cp = m_bufp;
|
||||||
}
|
}
|
||||||
/// Flish, close, and destruct
|
/// Flush, close, and destruct
|
||||||
virtual ~VerilatedSerialize() {
|
virtual ~VerilatedSerialize() {
|
||||||
close();
|
// Child classes will need to typically call closeImp() in destructors
|
||||||
if (m_bufp) VL_DO_CLEAR(delete[] m_bufp, m_bufp = nullptr);
|
if (m_bufp) VL_DO_CLEAR(delete[] m_bufp, m_bufp = nullptr);
|
||||||
}
|
}
|
||||||
// METHODS
|
// METHODS
|
||||||
@ -137,7 +137,7 @@ public:
|
|||||||
}
|
}
|
||||||
/// Destruct
|
/// Destruct
|
||||||
virtual ~VerilatedDeserialize() {
|
virtual ~VerilatedDeserialize() {
|
||||||
close();
|
// Child classes will need to typically call closeImp() in destructors
|
||||||
if (m_bufp) VL_DO_CLEAR(delete[] m_bufp, m_bufp = nullptr);
|
if (m_bufp) VL_DO_CLEAR(delete[] m_bufp, m_bufp = nullptr);
|
||||||
}
|
}
|
||||||
// METHODS
|
// METHODS
|
||||||
@ -190,21 +190,24 @@ class VerilatedSave final : public VerilatedSerialize {
|
|||||||
private:
|
private:
|
||||||
int m_fd = -1; // File descriptor we're writing to
|
int m_fd = -1; // File descriptor we're writing to
|
||||||
|
|
||||||
|
void closeImp() VL_MT_UNSAFE_ONE;
|
||||||
|
void flushImp() VL_MT_UNSAFE_ONE;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
/// Construct new object
|
/// Construct new object
|
||||||
VerilatedSave() = default;
|
VerilatedSave() = default;
|
||||||
/// Flush, close and destruct
|
/// Flush, close and destruct
|
||||||
~VerilatedSave() override { close(); }
|
~VerilatedSave() override { closeImp(); }
|
||||||
// METHODS
|
// METHODS
|
||||||
/// Open the file; call isOpen() to see if errors
|
/// Open the file; call isOpen() to see if errors
|
||||||
void open(const char* filenamep) VL_MT_UNSAFE_ONE;
|
void open(const char* filenamep) VL_MT_UNSAFE_ONE;
|
||||||
/// Open the file; call isOpen() to see if errors
|
/// Open the file; call isOpen() to see if errors
|
||||||
void open(const std::string& filename) VL_MT_UNSAFE_ONE { open(filename.c_str()); }
|
void open(const std::string& filename) VL_MT_UNSAFE_ONE { open(filename.c_str()); }
|
||||||
/// Flush and close the file
|
/// Flush and close the file
|
||||||
void close() override VL_MT_UNSAFE_ONE;
|
void close() override VL_MT_UNSAFE_ONE { closeImp(); }
|
||||||
/// Flush data to file
|
/// Flush data to file
|
||||||
void flush() override VL_MT_UNSAFE_ONE;
|
void flush() override VL_MT_UNSAFE_ONE { flushImp(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
@ -217,12 +220,15 @@ class VerilatedRestore final : public VerilatedDeserialize {
|
|||||||
private:
|
private:
|
||||||
int m_fd = -1; // File descriptor we're writing to
|
int m_fd = -1; // File descriptor we're writing to
|
||||||
|
|
||||||
|
void closeImp() VL_MT_UNSAFE_ONE;
|
||||||
|
void flushImp() VL_MT_UNSAFE_ONE {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
/// Construct new object
|
/// Construct new object
|
||||||
VerilatedRestore() = default;
|
VerilatedRestore() = default;
|
||||||
/// Flush, close and destruct
|
/// Flush, close and destruct
|
||||||
~VerilatedRestore() override { close(); }
|
~VerilatedRestore() override { closeImp(); }
|
||||||
|
|
||||||
// METHODS
|
// METHODS
|
||||||
/// Open the file; call isOpen() to see if errors
|
/// Open the file; call isOpen() to see if errors
|
||||||
@ -230,8 +236,8 @@ public:
|
|||||||
/// Open the file; call isOpen() to see if errors
|
/// Open the file; call isOpen() to see if errors
|
||||||
void open(const std::string& filename) VL_MT_UNSAFE_ONE { open(filename.c_str()); }
|
void open(const std::string& filename) VL_MT_UNSAFE_ONE { open(filename.c_str()); }
|
||||||
/// Close the file
|
/// Close the file
|
||||||
void close() override VL_MT_UNSAFE_ONE;
|
void close() override VL_MT_UNSAFE_ONE { closeImp(); }
|
||||||
void flush() override VL_MT_UNSAFE_ONE {}
|
void flush() override VL_MT_UNSAFE_ONE { flushImp(); }
|
||||||
void fill() override VL_MT_UNSAFE_ONE;
|
void fill() override VL_MT_UNSAFE_ONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user