2015-02-27 01:40:45 +00:00
|
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
// DESCRIPTION: Verilator: Os-specific function wrapper
|
|
|
|
|
//
|
|
|
|
|
// Code available from: http://www.veripool.org/verilator
|
|
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
//
|
2019-01-04 00:17:22 +00:00
|
|
|
|
// Copyright 2003-2019 by Wilson Snyder. This program is free software; you can
|
2015-02-27 01:40:45 +00:00
|
|
|
|
// redistribute it and/or modify it under the terms of either the GNU
|
|
|
|
|
// Lesser General Public License Version 3 or the Perl Artistic License
|
|
|
|
|
// Version 2.0.
|
|
|
|
|
//
|
|
|
|
|
// Verilator is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
|
|
|
|
|
#ifndef _V3OS_H_
|
|
|
|
|
#define _V3OS_H_ 1
|
2018-10-14 17:43:24 +00:00
|
|
|
|
|
2015-02-27 01:40:45 +00:00
|
|
|
|
#include "config_build.h"
|
|
|
|
|
#include "verilatedos.h"
|
2018-10-14 17:43:24 +00:00
|
|
|
|
|
2019-10-03 01:38:06 +00:00
|
|
|
|
// Limited V3 headers here - this is a base class for Vlc etc
|
2015-02-27 01:40:45 +00:00
|
|
|
|
#include "V3Error.h"
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
// V3Os: OS static class
|
|
|
|
|
|
|
|
|
|
class V3Os {
|
|
|
|
|
public:
|
|
|
|
|
// METHODS (environment)
|
|
|
|
|
static string getenvStr(const string& envvar, const string& defaultValue);
|
|
|
|
|
static void setenvStr(const string& envvar, const string& value, const string& why);
|
|
|
|
|
|
|
|
|
|
// METHODS (generic filename utilities)
|
2018-08-25 13:52:45 +00:00
|
|
|
|
static string filenameFromDirBase(const string& dir, const string& basename);
|
|
|
|
|
static string filenameNonDir(const string& filename); ///< Return non-directory part of filename
|
|
|
|
|
static string filenameNonExt(const string& filename); ///< Return non-extensioned (no .) part of filename
|
|
|
|
|
static string filenameNonDirExt(const string& filename) { ///< Return basename of filename
|
2018-03-10 21:32:04 +00:00
|
|
|
|
return filenameNonExt(filenameNonDir(filename)); }
|
2018-08-25 13:52:45 +00:00
|
|
|
|
static string filenameDir(const string& filename); ///< Return directory part of filename
|
|
|
|
|
static string filenameSubstitute(const string& filename); ///< Return filename with env vars removed
|
2018-10-14 22:39:33 +00:00
|
|
|
|
static string filenameRealPath(const string& filename); ///< Return realpath of filename
|
2018-08-25 13:52:45 +00:00
|
|
|
|
static bool filenameIsRel(const string& filename); ///< True if relative
|
2015-02-27 01:40:45 +00:00
|
|
|
|
|
2018-11-27 00:09:08 +00:00
|
|
|
|
// METHODS (file utilities)
|
|
|
|
|
static string getline(std::istream& is, char delim='\n');
|
|
|
|
|
|
2015-02-27 01:40:45 +00:00
|
|
|
|
// METHODS (directory utilities)
|
|
|
|
|
static void createDir(const string& dirname);
|
|
|
|
|
static void unlinkRegexp(const string& dir, const string& regexp);
|
2017-09-18 02:52:57 +00:00
|
|
|
|
|
2018-09-20 22:09:19 +00:00
|
|
|
|
// METHODS (random)
|
|
|
|
|
static vluint64_t rand64(vluint64_t* statep);
|
|
|
|
|
|
2017-09-18 02:52:57 +00:00
|
|
|
|
// METHODS (performance)
|
|
|
|
|
static uint64_t timeUsecs(); ///< Return wall time since epoch in microseconds, or 0 if not implemented
|
2019-05-19 20:13:13 +00:00
|
|
|
|
static uint64_t memUsageBytes(); ///< Return memory usage in bytes, or 0 if not implemented
|
2015-02-27 01:40:45 +00:00
|
|
|
|
};
|
|
|
|
|
|
2019-05-19 20:13:13 +00:00
|
|
|
|
#endif // Guard
|