win32 compatibility

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2021-07-21 18:41:46 -07:00
parent d3a199b584
commit 85bdbe638f
4 changed files with 27 additions and 15 deletions

View File

@ -50,12 +50,12 @@
#define va_copy(d,s) ((d)=(s))
#define strcasecmp _stricmp
#define strncasecmp strncmp
#define strtof(nptr,endptr) static_cast<float>(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

View File

@ -20,6 +20,7 @@
#include <stdarg.h>
#include <string>
#include <mutex>
#include "Machine.hh" // __attribute__
#include "DisallowCopyAssign.hh"
struct Tcl_Interp;

View File

@ -19,6 +19,7 @@
#include <stdarg.h>
#include <string.h>
#include <string>
#include "Machine.hh" // __attribute__
#include "Vector.hh"
namespace sta {

View File

@ -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 <https://www.gnu.org/licenses/>.
// 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()
{