Machine/port issues
This commit is contained in:
parent
9003fb279d
commit
181a9f2ccf
|
|
@ -20,6 +20,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include "Machine.hh"
|
||||||
#include "StringUtil.hh"
|
#include "StringUtil.hh"
|
||||||
#include "Vector.hh"
|
#include "Vector.hh"
|
||||||
#include "Sta.hh"
|
#include "Sta.hh"
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "Machine.hh"
|
|
||||||
#include "DisallowCopyAssign.hh"
|
#include "DisallowCopyAssign.hh"
|
||||||
#include "Map.hh"
|
#include "Map.hh"
|
||||||
#include "StringUtil.hh"
|
#include "StringUtil.hh"
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,6 @@
|
||||||
#endif // _MSC_VER
|
#endif // _MSC_VER
|
||||||
|
|
||||||
#if defined(_WINDOWS) || defined(_WIN32)
|
#if defined(_WINDOWS) || defined(_WIN32)
|
||||||
// Export class definitions to DLLs.
|
|
||||||
#define DllExport __declspec(dllexport)
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#define va_copy(d,s) ((d)=(s))
|
#define va_copy(d,s) ((d)=(s))
|
||||||
#define strcasecmp _stricmp
|
#define strcasecmp _stricmp
|
||||||
|
|
@ -60,8 +58,6 @@
|
||||||
int vsnprint(char *str, size_t size, const char *fmt, va_list args);
|
int vsnprint(char *str, size_t size, const char *fmt, va_list args);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define DllExport
|
|
||||||
#include <stdint.h> // intptr_t
|
|
||||||
#define vsnprint vsnprintf
|
#define vsnprint vsnprintf
|
||||||
#endif // _WINDOWS
|
#endif // _WINDOWS
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include "Machine.hh"
|
|
||||||
#include "DisallowCopyAssign.hh"
|
#include "DisallowCopyAssign.hh"
|
||||||
|
|
||||||
struct Tcl_Interp;
|
struct Tcl_Interp;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "Machine.hh"
|
|
||||||
#include "DisallowCopyAssign.hh"
|
#include "DisallowCopyAssign.hh"
|
||||||
#include "StringSeq.hh"
|
#include "StringSeq.hh"
|
||||||
#include "LibertyClass.hh"
|
#include "LibertyClass.hh"
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "Machine.hh"
|
|
||||||
#include "Vector.hh"
|
#include "Vector.hh"
|
||||||
|
|
||||||
namespace sta {
|
namespace sta {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Machine.hh"
|
|
||||||
#include "DisallowCopyAssign.hh"
|
#include "DisallowCopyAssign.hh"
|
||||||
#include "Vector.hh"
|
#include "Vector.hh"
|
||||||
#include "Transition.hh"
|
#include "Transition.hh"
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include "Machine.hh"
|
|
||||||
#include "DisallowCopyAssign.hh"
|
#include "DisallowCopyAssign.hh"
|
||||||
#include "Vector.hh"
|
#include "Vector.hh"
|
||||||
#include "Map.hh"
|
#include "Map.hh"
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Machine.hh"
|
|
||||||
#include "Zlib.hh"
|
#include "Zlib.hh"
|
||||||
#include "Map.hh"
|
#include "Map.hh"
|
||||||
#include "StringSeq.hh"
|
#include "StringSeq.hh"
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include "Sta.hh"
|
#include "Sta.hh"
|
||||||
|
|
||||||
|
#include "Machine.hh"
|
||||||
#include "DispatchQueue.hh"
|
#include "DispatchQueue.hh"
|
||||||
#include "ReportTcl.hh"
|
#include "ReportTcl.hh"
|
||||||
#include "Debug.hh"
|
#include "Debug.hh"
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
#include "Machine.hh"
|
||||||
#include "StaConfig.hh" // STA_VERSION
|
#include "StaConfig.hh" // STA_VERSION
|
||||||
#include "Stats.hh"
|
#include "Stats.hh"
|
||||||
#include "Report.hh"
|
#include "Report.hh"
|
||||||
|
|
|
||||||
191
util/Machine.cc
191
util/Machine.cc
|
|
@ -14,189 +14,12 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "Machine.hh"
|
#if defined(WIN32)
|
||||||
|
#include "MachineWin32.cc"
|
||||||
#ifdef WIN32
|
#elif defined(__APPLE__)
|
||||||
|
#include "MachineApple.cc"
|
||||||
#include <stdio.h>
|
#elif defined(__linux__)
|
||||||
#include <windows.h> // GetSystemInfo
|
#include "MachineLinux.cc"
|
||||||
|
|
||||||
#include "StaConfig.hh"
|
|
||||||
|
|
||||||
namespace sta {
|
|
||||||
|
|
||||||
// Windows returns -1 if the string does not fit rather than the
|
|
||||||
// required string length as the standard specifies.
|
|
||||||
int
|
|
||||||
vsnprint(char *str, size_t size, const char *fmt, va_list args)
|
|
||||||
{
|
|
||||||
// Copy args before using them because consumption is destructive.
|
|
||||||
va_list args_copy1;
|
|
||||||
va_copy(args_copy1, args);
|
|
||||||
int length = vsnprintf(str, size, fmt, args);
|
|
||||||
|
|
||||||
while (length < 0) {
|
|
||||||
size *= 2;
|
|
||||||
char *buffer = new char[size];
|
|
||||||
va_list args_copy2;
|
|
||||||
va_copy(args_copy2, args_copy1);
|
|
||||||
length = vsnprintf(buffer, size, fmt, args_copy2);
|
|
||||||
delete [] buffer;
|
|
||||||
}
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
processorCount()
|
|
||||||
{
|
|
||||||
#if HAVE_PTHREAD_H
|
|
||||||
SYSTEM_INFO info;
|
|
||||||
GetSystemInfo(&info);
|
|
||||||
return info.dwNumberOfProcessors;
|
|
||||||
#else
|
#else
|
||||||
return 1;
|
#include "MachineUnknown.cc"
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
initElapsedTime()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
double
|
|
||||||
elapsedRunTime()
|
|
||||||
{
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
double
|
|
||||||
userRunTime()
|
|
||||||
{
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
double
|
|
||||||
systemRunTime()
|
|
||||||
{
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
memoryUsage()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif // WIN32
|
|
||||||
|
|
||||||
// Common to macos and linux
|
|
||||||
#if defined(__APPLE__) || defined(__linux__)
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/resource.h>
|
|
||||||
|
|
||||||
#include "StaConfig.hh"
|
|
||||||
#include "StringUtil.hh"
|
|
||||||
|
|
||||||
namespace sta {
|
|
||||||
|
|
||||||
static struct timeval elapsed_begin_time_;
|
|
||||||
|
|
||||||
int
|
|
||||||
processorCount()
|
|
||||||
{
|
|
||||||
#if HAVE_PTHREAD_H
|
|
||||||
return sysconf(_SC_NPROCESSORS_CONF);
|
|
||||||
#else
|
|
||||||
return 1;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
initElapsedTime()
|
|
||||||
{
|
|
||||||
struct timezone tz;
|
|
||||||
gettimeofday(&elapsed_begin_time_, &tz);
|
|
||||||
}
|
|
||||||
|
|
||||||
double
|
|
||||||
elapsedRunTime()
|
|
||||||
{
|
|
||||||
static struct timeval time;
|
|
||||||
struct timezone tz;
|
|
||||||
gettimeofday(&time, &tz);
|
|
||||||
return time.tv_sec - elapsed_begin_time_.tv_sec
|
|
||||||
+ (time.tv_usec - elapsed_begin_time_.tv_usec) * 1E-6;
|
|
||||||
}
|
|
||||||
|
|
||||||
double
|
|
||||||
userRunTime()
|
|
||||||
{
|
|
||||||
struct rusage rusage;
|
|
||||||
getrusage(RUSAGE_SELF, &rusage);
|
|
||||||
return rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6;
|
|
||||||
}
|
|
||||||
|
|
||||||
double
|
|
||||||
systemRunTime()
|
|
||||||
{
|
|
||||||
struct rusage rusage;
|
|
||||||
getrusage(RUSAGE_SELF, &rusage);
|
|
||||||
return rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __APPLE__ || __linux__
|
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
|
|
||||||
namespace sta {
|
|
||||||
// rusage->ru_maxrss is not set in linux so read it from /proc.
|
|
||||||
size_t
|
|
||||||
memoryUsage()
|
|
||||||
{
|
|
||||||
string proc_filename;
|
|
||||||
stringPrint(proc_filename, "/proc/%d/status", getpid());
|
|
||||||
size_t memory = 0;
|
|
||||||
FILE *status = fopen(proc_filename.c_str(), "r");
|
|
||||||
if (status) {
|
|
||||||
const size_t line_length = 128;
|
|
||||||
char line[line_length];
|
|
||||||
while (fgets(line, line_length, status) != nullptr) {
|
|
||||||
char *field = strtok(line, " \t");
|
|
||||||
if (stringEq(field, "VmRSS:")) {
|
|
||||||
char *size = strtok(nullptr, " \t");
|
|
||||||
if (size) {
|
|
||||||
char *ignore;
|
|
||||||
// VmRSS is in kilobytes.
|
|
||||||
memory = strtol(size, &ignore, 10) * 1000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(status);
|
|
||||||
}
|
|
||||||
return memory;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __linux__
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
|
|
||||||
namespace sta {
|
|
||||||
size_t
|
|
||||||
memoryUsage()
|
|
||||||
{
|
|
||||||
struct rusage rusage;
|
|
||||||
getrusage(RUSAGE_SELF, &rusage);
|
|
||||||
return rusage.ru_maxrss;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __apple__
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,83 @@
|
||||||
|
// OpenSTA, Static Timing Analyzer
|
||||||
|
// Copyright (c) 2020, Parallax Software, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program 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.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "Machine.hh"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
|
||||||
|
#include "StaConfig.hh"
|
||||||
|
#include "StringUtil.hh"
|
||||||
|
|
||||||
|
namespace sta {
|
||||||
|
|
||||||
|
static struct timeval elapsed_begin_time_;
|
||||||
|
|
||||||
|
int
|
||||||
|
processorCount()
|
||||||
|
{
|
||||||
|
#if HAVE_PTHREAD_H
|
||||||
|
return sysconf(_SC_NPROCESSORS_CONF);
|
||||||
|
#else
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
initElapsedTime()
|
||||||
|
{
|
||||||
|
struct timezone tz;
|
||||||
|
gettimeofday(&elapsed_begin_time_, &tz);
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
elapsedRunTime()
|
||||||
|
{
|
||||||
|
static struct timeval time;
|
||||||
|
struct timezone tz;
|
||||||
|
gettimeofday(&time, &tz);
|
||||||
|
return time.tv_sec - elapsed_begin_time_.tv_sec
|
||||||
|
+ (time.tv_usec - elapsed_begin_time_.tv_usec) * 1E-6;
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
userRunTime()
|
||||||
|
{
|
||||||
|
struct rusage rusage;
|
||||||
|
getrusage(RUSAGE_SELF, &rusage);
|
||||||
|
return rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6;
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
systemRunTime()
|
||||||
|
{
|
||||||
|
struct rusage rusage;
|
||||||
|
getrusage(RUSAGE_SELF, &rusage);
|
||||||
|
return rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
memoryUsage()
|
||||||
|
{
|
||||||
|
struct rusage rusage;
|
||||||
|
getrusage(RUSAGE_SELF, &rusage);
|
||||||
|
return rusage.ru_maxrss;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
@ -0,0 +1,103 @@
|
||||||
|
// OpenSTA, Static Timing Analyzer
|
||||||
|
// Copyright (c) 2020, Parallax Software, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program 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.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "Machine.hh"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
|
||||||
|
#include "StaConfig.hh"
|
||||||
|
#include "StringUtil.hh"
|
||||||
|
|
||||||
|
namespace sta {
|
||||||
|
|
||||||
|
static struct timeval elapsed_begin_time_;
|
||||||
|
|
||||||
|
int
|
||||||
|
processorCount()
|
||||||
|
{
|
||||||
|
#if HAVE_PTHREAD_H
|
||||||
|
return sysconf(_SC_NPROCESSORS_CONF);
|
||||||
|
#else
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
initElapsedTime()
|
||||||
|
{
|
||||||
|
struct timezone tz;
|
||||||
|
gettimeofday(&elapsed_begin_time_, &tz);
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
elapsedRunTime()
|
||||||
|
{
|
||||||
|
static struct timeval time;
|
||||||
|
struct timezone tz;
|
||||||
|
gettimeofday(&time, &tz);
|
||||||
|
return time.tv_sec - elapsed_begin_time_.tv_sec
|
||||||
|
+ (time.tv_usec - elapsed_begin_time_.tv_usec) * 1E-6;
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
userRunTime()
|
||||||
|
{
|
||||||
|
struct rusage rusage;
|
||||||
|
getrusage(RUSAGE_SELF, &rusage);
|
||||||
|
return rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6;
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
systemRunTime()
|
||||||
|
{
|
||||||
|
struct rusage rusage;
|
||||||
|
getrusage(RUSAGE_SELF, &rusage);
|
||||||
|
return rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6;
|
||||||
|
}
|
||||||
|
|
||||||
|
// rusage->ru_maxrss is not set in linux so read it from /proc.
|
||||||
|
size_t
|
||||||
|
memoryUsage()
|
||||||
|
{
|
||||||
|
string proc_filename;
|
||||||
|
stringPrint(proc_filename, "/proc/%d/status", getpid());
|
||||||
|
size_t memory = 0;
|
||||||
|
FILE *status = fopen(proc_filename.c_str(), "r");
|
||||||
|
if (status) {
|
||||||
|
const size_t line_length = 128;
|
||||||
|
char line[line_length];
|
||||||
|
while (fgets(line, line_length, status) != nullptr) {
|
||||||
|
char *field = strtok(line, " \t");
|
||||||
|
if (stringEq(field, "VmRSS:")) {
|
||||||
|
char *size = strtok(nullptr, " \t");
|
||||||
|
if (size) {
|
||||||
|
char *ignore;
|
||||||
|
// VmRSS is in kilobytes.
|
||||||
|
memory = strtol(size, &ignore, 10) * 1000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(status);
|
||||||
|
}
|
||||||
|
return memory;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
// OpenSTA, Static Timing Analyzer
|
||||||
|
// Copyright (c) 2020, Parallax Software, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program 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.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "Machine.hh"
|
||||||
|
|
||||||
|
namespace sta {
|
||||||
|
|
||||||
|
int
|
||||||
|
processorCount()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
initElapsedTime()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
elapsedRunTime()
|
||||||
|
{
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
userRunTime()
|
||||||
|
{
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
systemRunTime()
|
||||||
|
{
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
memoryUsage()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
@ -0,0 +1,88 @@
|
||||||
|
// OpenSTA, Static Timing Analyzer
|
||||||
|
// Copyright (c) 2020, Parallax Software, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program 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.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "Machine.hh"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <windows.h> // GetSystemInfo
|
||||||
|
|
||||||
|
#include "StaConfig.hh" // HAVE_PTHREAD_H
|
||||||
|
|
||||||
|
namespace sta {
|
||||||
|
|
||||||
|
// Windows returns -1 if the string does not fit rather than the
|
||||||
|
// required string length as the standard specifies.
|
||||||
|
int
|
||||||
|
vsnprint(char *str, size_t size, const char *fmt, va_list args)
|
||||||
|
{
|
||||||
|
// Copy args before using them because consumption is destructive.
|
||||||
|
va_list args_copy1;
|
||||||
|
va_copy(args_copy1, args);
|
||||||
|
int length = vsnprintf(str, size, fmt, args);
|
||||||
|
|
||||||
|
while (length < 0) {
|
||||||
|
size *= 2;
|
||||||
|
char *buffer = new char[size];
|
||||||
|
va_list args_copy2;
|
||||||
|
va_copy(args_copy2, args_copy1);
|
||||||
|
length = vsnprintf(buffer, size, fmt, args_copy2);
|
||||||
|
delete [] buffer;
|
||||||
|
}
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
processorCount()
|
||||||
|
{
|
||||||
|
#if HAVE_PTHREAD_H
|
||||||
|
SYSTEM_INFO info;
|
||||||
|
GetSystemInfo(&info);
|
||||||
|
return info.dwNumberOfProcessors;
|
||||||
|
#else
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
initElapsedTime()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
elapsedRunTime()
|
||||||
|
{
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
userRunTime()
|
||||||
|
{
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
systemRunTime()
|
||||||
|
{
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
memoryUsage()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
#include <cstdlib> // exit
|
#include <cstdlib> // exit
|
||||||
#include <cstring> // strlen
|
#include <cstring> // strlen
|
||||||
|
|
||||||
|
#include "Machine.hh"
|
||||||
#include "Error.hh"
|
#include "Error.hh"
|
||||||
|
|
||||||
namespace sta {
|
namespace sta {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue