Fix MinGW compile issues, msg2636.

This commit is contained in:
Wilson Snyder 2018-09-20 18:09:19 -04:00
parent d4159811d2
commit a8519a7a53
4 changed files with 20 additions and 3 deletions

View File

@ -6,6 +6,7 @@ The contributors that suggested a given feature are shown in []. Thanks!
*** Fix Mac OSX 10.13.6 / LLVM 9.1 compile issues, bug1348. [Kevin Kiningham]
*** Fix MinGW compile issues, msg2636. [HyungKi Jeong]
* Verilator 4.002 2018-09-16

View File

@ -188,6 +188,19 @@ void V3Os::unlinkRegexp(const string& dir, const string& regexp) {
}
}
//######################################################################
// METHODS (random)
vluint64_t V3Os::rand64(vluint64_t* statep) {
// Xoroshiro128+ algorithm
vluint64_t result = statep[0] + statep[1];
statep[1] ^= statep[0];
statep[0] = (((statep[0] << 55) | (statep[0] >> 9))
^ statep[1] ^ (statep[1] << 14));
statep[1] = (statep[1] << 36) | (statep[1] >> 28);
return result;
}
//######################################################################
// METHODS (performance)

View File

@ -49,6 +49,9 @@ public:
static void createDir(const string& dirname);
static void unlinkRegexp(const string& dir, const string& regexp);
// METHODS (random)
static vluint64_t rand64(vluint64_t* statep);
// METHODS (performance)
static uint64_t timeUsecs(); ///< Return wall time since epoch in microseconds, or 0 if not implemented
static uint64_t memUsageBytes(); ///< Return memory usage in bytes, or 0 if not implemented

View File

@ -347,7 +347,7 @@ private:
}
void go() {
// Generate a pseudo-random graph
uint16_t rngState[3] = { 0xdead, 0xbeef, 0xf000 };
vluint64_t rngState[2] = {VL_ULL(0x12345678), VL_ULL(0x9abcdef0)};
// Create 50 vertices
for (unsigned i = 0; i < 50; ++i) {
m_vx[i] = new V3GraphVertex(&m_graph);
@ -355,8 +355,8 @@ private:
// Create 250 edges at random. Edges must go from
// lower-to-higher index vertices, so we get a DAG.
for (unsigned i = 0; i < 250; ++i) {
unsigned idx1 = nrand48(rngState) % 50;
unsigned idx2 = nrand48(rngState) % 50;
unsigned idx1 = V3Os::rand64(rngState) % 50;
unsigned idx2 = V3Os::rand64(rngState) % 50;
if (idx1 > idx2) {
new V3GraphEdge(&m_graph, m_vx[idx2], m_vx[idx1], 1);
} else if (idx2 > idx1) {