mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 10:03:44 +02:00
+4
-26
@@ -61,7 +61,6 @@ VL_DEFINE_DEBUG_FUNCTIONS;
|
||||
# include <chrono>
|
||||
# include <direct.h> // mkdir
|
||||
# include <io.h> // open, read, write, close
|
||||
# include <psapi.h> // GetProcessMemoryInfo
|
||||
# include <thread>
|
||||
// These macros taken from gdbsupport/gdb_wait.h in binutils-gdb
|
||||
# ifndef WIFEXITED
|
||||
@@ -80,6 +79,9 @@ VL_DEFINE_DEBUG_FUNCTIONS;
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
#define VL_ALLOW_VERILATEDOS_C
|
||||
#include "verilatedos_c.h"
|
||||
|
||||
//######################################################################
|
||||
// Environment
|
||||
|
||||
@@ -397,7 +399,7 @@ uint64_t V3Os::timeUsecs() {
|
||||
|
||||
FILETIME ft; // contains number of 0.1us intervals since the beginning of 1601 UTC.
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
uint64_t us
|
||||
const uint64_t us
|
||||
= ((static_cast<uint64_t>(ft.dwHighDateTime) << 32) + ft.dwLowDateTime + 5ULL) / 10ULL;
|
||||
return us - EPOCH_DIFFERENCE_USECS;
|
||||
#else
|
||||
@@ -408,30 +410,6 @@ uint64_t V3Os::timeUsecs() {
|
||||
#endif
|
||||
}
|
||||
|
||||
uint64_t V3Os::memUsageBytes() {
|
||||
#if defined(_WIN32) || defined(__MINGW32__)
|
||||
const HANDLE process = GetCurrentProcess();
|
||||
PROCESS_MEMORY_COUNTERS pmc;
|
||||
if (GetProcessMemoryInfo(process, &pmc, sizeof(pmc))) {
|
||||
// The best we can do using simple Windows APIs is to get the size of the working set.
|
||||
return pmc.WorkingSetSize;
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
// Highly unportable. Sorry
|
||||
const char* const statmFilename = "/proc/self/statm";
|
||||
FILE* const fp = fopen(statmFilename, "r");
|
||||
if (!fp) return 0;
|
||||
uint64_t size, resident, share, text, lib, data, dt; // All in pages
|
||||
const int items = fscanf(
|
||||
fp, "%" SCNu64 " %" SCNu64 " %" SCNu64 " %" SCNu64 " %" SCNu64 " %" SCNu64 " %" SCNu64,
|
||||
&size, &resident, &share, &text, &lib, &data, &dt);
|
||||
fclose(fp);
|
||||
if (VL_UNCOVERABLE(7 != items)) return 0;
|
||||
return (text + data) * getpagesize();
|
||||
#endif
|
||||
}
|
||||
|
||||
void V3Os::u_sleep(int64_t usec) {
|
||||
#if defined(_WIN32) || defined(__MINGW32__)
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(usec));
|
||||
|
||||
Reference in New Issue
Block a user