verilator/src/V3Os.h

67 lines
2.8 KiB
C
Raw Normal View History

2015-02-27 01:40:45 +00:00
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Os-specific function wrapper
//
2019-11-08 03:33:59 +00:00
// Code available from: https://verilator.org
2015-02-27 01:40:45 +00:00
//
//*************************************************************************
//
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.
//
//*************************************************************************
2015-02-27 01:40:45 +00:00
#ifndef _V3OS_H_
#define _V3OS_H_ 1
2015-02-27 01:40:45 +00:00
#include "config_build.h"
#include "verilatedos.h"
// 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)
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
return filenameNonExt(filenameNonDir(filename)); }
static string filenameDir(const string& filename); ///< Return directory part of filename
static string filenameSubstitute(const string& filename); ///< Return filename with env vars removed
static string filenameRealPath(const string& filename); ///< Return realpath of filename
static bool filenameIsRel(const string& filename); ///< True if relative
2015-02-27 01:40:45 +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);
2018-09-20 22:09:19 +00:00
// METHODS (random)
static vluint64_t rand64(vluint64_t* statep);
static string trueRandom(size_t size);
2018-09-20 22:09:19 +00:00
// 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
2015-02-27 01:40:45 +00:00
};
#endif // Guard