diff --git a/include/sta/Machine.hh b/include/sta/Machine.hh index a12cd5d4..5b826432 100644 --- a/include/sta/Machine.hh +++ b/include/sta/Machine.hh @@ -50,12 +50,12 @@ #define va_copy(d,s) ((d)=(s)) #define strcasecmp _stricmp #define strncasecmp strncmp - #define strtof(nptr,endptr) static_cast(strtod(nptr,endptr)) #define strtoull _strtoui64 // Flex doesn't check for unistd.h. #define YY_NO_UNISTD_H namespace sta { int vsnprint(char *str, size_t size, const char *fmt, va_list args); + int vasprintf(char **str, const char *fmt, va_list args); } #else #define vsnprint vsnprintf @@ -89,4 +89,3 @@ size_t memoryUsage(); } // namespace sta - diff --git a/include/sta/Report.hh b/include/sta/Report.hh index ac30fcab..10b8d0c3 100644 --- a/include/sta/Report.hh +++ b/include/sta/Report.hh @@ -20,6 +20,7 @@ #include #include #include +#include "Machine.hh" // __attribute__ #include "DisallowCopyAssign.hh" struct Tcl_Interp; diff --git a/include/sta/StringUtil.hh b/include/sta/StringUtil.hh index 361a551c..7b3f0f32 100644 --- a/include/sta/StringUtil.hh +++ b/include/sta/StringUtil.hh @@ -19,6 +19,7 @@ #include #include #include +#include "Machine.hh" // __attribute__ #include "Vector.hh" namespace sta { diff --git a/util/MachineWin32.cc b/util/MachineWin32.cc index 59234381..a3019606 100644 --- a/util/MachineWin32.cc +++ b/util/MachineWin32.cc @@ -1,18 +1,10 @@ -// OpenSTA, Static Timing Analyzer +// Parallax Static Timing Analyzer // Copyright (c) 2021, Parallax Software, Inc. +// All rights reserved. // -// 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 . +// No part of this document may be copied, transmitted or +// disclosed in any form or fashion without the express +// written consent of Parallax Software, Inc. #include "Machine.hh" @@ -44,6 +36,25 @@ vsnprint(char *str, size_t size, const char *fmt, va_list args) return length; } +int +vasprintf(char **str, const char *fmt, va_list args) +{ + size_t size = 1024; + for (;;) { + size *= 2; + char *buffer = new char[size]; + // Copy args before using them because consumption is destructive. + va_list args_copy2; + va_copy(args_copy2, args); + int length = vsnprintf(buffer, size, fmt, args_copy2); + if (length >= 0) { + *str = buffer; + return length; + } + delete[] buffer; + } +} + int processorCount() {