forked from github/verilator
Fix MSVC++ compiler error, bug927.
This commit is contained in:
parent
4c29a13a6e
commit
491539ff32
2
Changes
2
Changes
@ -23,6 +23,8 @@ indicates the contributor was also the author of the fix; Thanks!
|
||||
|
||||
**** Fix width extension on mis-width ports, bug918. [Patrick Maupin]
|
||||
|
||||
**** Fix MSVC++ compiler error, bug927. [Hans Tichelaar]
|
||||
|
||||
|
||||
* Verilator 3.872 2015-04-05
|
||||
|
||||
|
@ -421,7 +421,7 @@ public:
|
||||
do { \
|
||||
va_list args; \
|
||||
va_start(args, message); \
|
||||
vsnprintf(m_buff, sizeof(m_buff), message.c_str(), args); \
|
||||
VL_VSNPRINTF(m_buff, sizeof(m_buff), message.c_str(), args); \
|
||||
va_end(args); \
|
||||
} while (0)
|
||||
|
||||
|
@ -207,6 +207,22 @@ typedef unsigned long long vluint64_t; ///< 64-bit unsigned type
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# define VL_VSNPRINTF vl_vsnprintf
|
||||
inline int vl_vsnprintf(char* str, size_t size, const char* format, va_list ap) {
|
||||
int count = -1;
|
||||
if (size != 0) {
|
||||
count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
|
||||
}
|
||||
if (count == -1) {
|
||||
count = _vscprintf(format, ap);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
#else
|
||||
# define VL_VSNPRINTF vsnprintf
|
||||
#endif
|
||||
|
||||
//=========================================================================
|
||||
// File system functions
|
||||
|
||||
|
@ -117,7 +117,7 @@ void yyerrorf(const char* format, ...) {
|
||||
|
||||
va_list ap;
|
||||
va_start(ap,format);
|
||||
vsnprintf(msg,maxlen,format,ap);
|
||||
VL_VSNPRINTF(msg,maxlen,format,ap);
|
||||
msg[maxlen-1] = '\0';
|
||||
va_end(ap);
|
||||
|
||||
|
@ -18,6 +18,7 @@ if (!-r "$root/.git") {
|
||||
uint();
|
||||
printfll();
|
||||
cstr();
|
||||
vsnprintf();
|
||||
}
|
||||
|
||||
ok(1);
|
||||
@ -86,4 +87,22 @@ sub cstr {
|
||||
}
|
||||
}
|
||||
|
||||
sub vsnprintf {
|
||||
my $files = "src/*.c* src/*.h include/*.c* include/*.h test_c/*.c* test_regress/t/*.c* test_regress/t/*.h";
|
||||
my $cmd = "cd $root && grep -n -P 'vsnprintf' $files | sort";
|
||||
print "C $cmd\n";
|
||||
my $grep = `$cmd`;
|
||||
my %names;
|
||||
foreach my $line (split /\n/, $grep) {
|
||||
if ($line =~ /\b(vsnprintf)\b/) {
|
||||
next if $line =~ /# *define\s*VL_VSNPRINTF/;
|
||||
print "$line\n";
|
||||
$names{$1} = 1;
|
||||
}
|
||||
}
|
||||
if (keys %names) {
|
||||
$Self->error("Files with vsnprintf, use VL_VSNPRINTF: ",join(' ',sort keys %names));
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user