Fix mkdir on MSYS2, msg2614.

This commit is contained in:
Wilson Snyder 2018-08-27 18:07:52 -04:00
parent 15abb4d590
commit c93d28050e
5 changed files with 21 additions and 7 deletions

View File

@ -7,8 +7,6 @@
// Include common routines
#include <verilated.h>
#include <sys/stat.h> // mkdir
// Include model header, generated from Verilating "top.v"
#include "Vtop.h"
@ -51,7 +49,7 @@ int main(int argc, char** argv, char** env) {
VL_PRINTF("Enabling waves into logs/vlt_dump.vcd...\n");
tfp = new VerilatedVcdC;
top->trace(tfp, 99); // Trace 99 levels of hierarchy
mkdir("logs", 0777);
Verilated::mkdir("logs");
tfp->open("logs/vlt_dump.vcd"); // Open the dump file
}
#endif
@ -112,7 +110,7 @@ int main(int argc, char** argv, char** env) {
// Coverage analysis (since test passed)
#if VM_COVERAGE
mkdir("logs", 0777);
Verilated::mkdir("logs");
VerilatedCov::write("logs/coverage.dat");
#endif

View File

@ -96,7 +96,7 @@ int sc_main(int argc, char* argv[]) {
cout << "Enabling waves into logs/vlt_dump.vcd...\n";
tfp = new VerilatedVcdSc;
top->trace(tfp, 99);
mkdir("logs", 0777);
Verilated::mkdir("logs");
tfp->open("logs/vlt_dump.vcd");
}
#endif
@ -134,7 +134,7 @@ int sc_main(int argc, char* argv[]) {
// Coverage analysis (since test passed)
#if VM_COVERAGE
mkdir("logs", 0777);
Verilated::mkdir("logs");
VerilatedCov::write("logs/coverage.dat");
#endif

View File

@ -26,6 +26,11 @@
#define _VERILATED_CPP_
#include "verilated_imp.h"
#include <cctype>
#include <sys/stat.h> // mkdir
#if defined(WIN32) || defined(__MINGW32__)
# include <direct.h> // mkdir
#endif
#define VL_VALUE_STRING_MAX_WIDTH 8192 ///< Max static char array for VL_VALUE_STRING
@ -1741,6 +1746,14 @@ void Verilated::overWidthError(const char* signame) VL_MT_SAFE {
VL_FATAL_MT("unknown",0,"", msg.c_str());
}
void Verilated::mkdir(const char* dirname) VL_MT_UNSAFE {
#if defined(_WIN32) || defined(__MINGW32__)
::mkdir(dirname);
#else
::mkdir(dirname, 0777);
#endif
}
void Verilated::quiesce() VL_MT_SAFE {
#ifdef VL_THREADED
// Wait until all threads under this evaluation are quiet

View File

@ -445,6 +445,9 @@ public:
static const char* productName() VL_PURE { return VERILATOR_PRODUCT; }
static const char* productVersion() VL_PURE { return VERILATOR_VERSION; }
/// Convenience OS utilities
static void mkdir(const char* dirname) VL_MT_UNSAFE;
/// When multithreaded, quiesce the model to prepare for trace/saves/coverage
/// This may only be called when no locks are held.
static void quiesce() VL_MT_SAFE;

View File

@ -196,7 +196,7 @@ public:
#if defined(__linux)
return sched_getcpu();
#elif defined(__APPLE__)
uint32_t info[4];
vluint32_t info[4];
__cpuid_count(1, 0, info[0], info[1], info[2], info[3]);
/* info[1] is EBX, bits 24-31 are APIC ID */
if ((info[3] & (1 << 9)) == 0) {