Fix MinGW compilation printing %lls, bug214
This commit is contained in:
parent
a41aefe77d
commit
8dca56521b
2
Changes
2
Changes
|
|
@ -70,7 +70,7 @@ indicates the contributor was also the author of the fix; Thanks!
|
|||
|
||||
**** Fix MSVC++ 2008 compile issues, bug209. [Amir Gonnen]
|
||||
|
||||
**** Fix MinGW compilation, bug184. [by Shankar Giri]
|
||||
**** Fix MinGW compilation, bug184, bug214. [by Shankar Giri, Amir Gonnen]
|
||||
|
||||
**** Fix Cygwin 1.7.x compiler error with uint32_t, bug204. [Ivan Djordjevic]
|
||||
|
||||
|
|
|
|||
|
|
@ -344,14 +344,14 @@ void _vl_vsformat(string& output, const char* formatp, va_list ap) {
|
|||
}
|
||||
break;
|
||||
case 'd': { // Signed decimal
|
||||
int digits=sprintf(tmp,"%lld",(vlsint64_t)(VL_EXTENDS_QQ(lbits,lbits,ld)));
|
||||
int digits=sprintf(tmp,"%" VL_PRI64 "d",(vlsint64_t)(VL_EXTENDS_QQ(lbits,lbits,ld)));
|
||||
int needmore = width-digits;
|
||||
if (needmore>0) output.append(needmore,' '); // Pre-pad spaces
|
||||
output += tmp;
|
||||
break;
|
||||
}
|
||||
case 'u': { // Unsigned decimal
|
||||
int digits=sprintf(tmp,"%llu",ld);
|
||||
int digits=sprintf(tmp,"%" VL_PRI64 "u",ld);
|
||||
int needmore = width-digits;
|
||||
if (needmore>0) output.append(needmore,' '); // Pre-pad spaces
|
||||
output += tmp;
|
||||
|
|
@ -360,9 +360,9 @@ void _vl_vsformat(string& output, const char* formatp, va_list ap) {
|
|||
case 't': { // Time
|
||||
int digits;
|
||||
if (VL_TIME_MULTIPLIER==1) {
|
||||
digits=sprintf(tmp,"%llu",ld);
|
||||
digits=sprintf(tmp,"%" VL_PRI64 "u",ld);
|
||||
} else if (VL_TIME_MULTIPLIER==1000) {
|
||||
digits=sprintf(tmp,"%llu.%03llu",
|
||||
digits=sprintf(tmp,"%" VL_PRI64 "u.%03" VL_PRI64 "u",
|
||||
(QData)(ld/VL_TIME_MULTIPLIER),
|
||||
(QData)(ld%VL_TIME_MULTIPLIER));
|
||||
} else {
|
||||
|
|
@ -553,7 +553,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
|
|||
_vl_vsss_read(fp,floc,fromp, tmp, "0123456789+-xXzZ?_");
|
||||
if (!tmp[0]) goto done;
|
||||
vlsint64_t ld;
|
||||
sscanf(tmp,"%lld",&ld);
|
||||
sscanf(tmp,"%" VL_PRI64 "d",&ld);
|
||||
VL_SET_WQ(owp,ld);
|
||||
break;
|
||||
}
|
||||
|
|
@ -563,7 +563,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
|
|||
_vl_vsss_read(fp,floc,fromp, tmp, "0123456789+-xXzZ?_");
|
||||
if (!tmp[0]) goto done;
|
||||
QData ld;
|
||||
sscanf(tmp,"%llu",&ld);
|
||||
sscanf(tmp,"%" VL_PRI64 "u",&ld);
|
||||
VL_SET_WQ(owp,ld);
|
||||
break;
|
||||
}
|
||||
|
|
@ -887,7 +887,7 @@ IData VL_VALUEPLUSARGS_IW(int rbits, const char* prefixp, char fmt, WDataOutP rw
|
|||
break;
|
||||
case 'd':
|
||||
vlsint64_t ld;
|
||||
sscanf(dp,"%lld",&ld);
|
||||
sscanf(dp,"%" VL_PRI64 "d",&ld);
|
||||
VL_SET_WQ(rwp,ld);
|
||||
break;
|
||||
case 'b':
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ void VerilatedVcd::printStr (const char* str) {
|
|||
|
||||
void VerilatedVcd::printQuad (vluint64_t n) {
|
||||
char buf [100];
|
||||
sprintf(buf,"%llu",(long long unsigned)n);
|
||||
sprintf(buf,"%" VL_PRI64 "u",(long long unsigned)n);
|
||||
printStr(buf);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,6 +136,16 @@ typedef long long vlsint64_t; ///< 64-bit signed type
|
|||
typedef unsigned long long vluint64_t; ///< 64-bit unsigned type
|
||||
#endif
|
||||
|
||||
//=========================================================================
|
||||
// Printing printf/scanf formats
|
||||
// Alas cinttypes isn't that standard yet
|
||||
|
||||
#ifdef _WIN32
|
||||
# define VL_PRI64 "I64"
|
||||
#else // Linux or compliant Unix flavors
|
||||
# define VL_PRI64 "ll"
|
||||
#endif
|
||||
|
||||
//=========================================================================
|
||||
// Integer size macros
|
||||
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ sub prep {
|
|||
$wholefile =~ s/\bSpScBvExposer/VlScBvExposer/g;
|
||||
#
|
||||
$wholefile =~ s/\b(uint[0-9]+_t)/vl$1/g;
|
||||
$wholefile =~ s/%ll/%" VL_PRI64 "/g;
|
||||
#
|
||||
$wholefile =~ s/\bSP_SC_BV/VL_SC_BV/g;
|
||||
$wholefile =~ s/\bSP_UNLIKELY/VL_UNLIKELY/g;
|
||||
|
|
|
|||
|
|
@ -531,17 +531,17 @@ public:
|
|||
}
|
||||
for (int word=VL_WORDS_I(nodep->num().minWidth())-1; word>0; word--) {
|
||||
// Only 32 bits - llx + long long here just to appease CPP format warning
|
||||
ofp()->printf(",0x%08llx", (long long)(nodep->num().dataWord(word)));
|
||||
ofp()->printf(",0x%08" VL_PRI64 "x", (long long)(nodep->num().dataWord(word)));
|
||||
}
|
||||
ofp()->printf(",0x%08llx)", (long long)(nodep->num().dataWord(0)));
|
||||
ofp()->printf(",0x%08" VL_PRI64 "x)", (long long)(nodep->num().dataWord(0)));
|
||||
} else if (nodep->isQuad()) {
|
||||
vluint64_t num = nodep->toUQuad();
|
||||
if (num<10) ofp()->printf("VL_ULL(%lld)", (long long)num);
|
||||
else ofp()->printf("VL_ULL(0x%llx)", (long long)num);
|
||||
if (num<10) ofp()->printf("VL_ULL(%" VL_PRI64 "d)", (long long)num);
|
||||
else ofp()->printf("VL_ULL(0x%" VL_PRI64 "x)", (long long)num);
|
||||
} else {
|
||||
uint32_t num = nodep->toUInt();
|
||||
if (num<10) puts(cvtToStr(num));
|
||||
else ofp()->printf("0x%llx", (long long)num);
|
||||
else ofp()->printf("0x%" VL_PRI64 "x", (long long)num);
|
||||
//Unneeded-Causes %lx format warnings:
|
||||
// if (!nodep->num().isSigned() && (num & (1UL<<31))) puts("U");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ inline void V3FileDependImp::writeTimes(const string& filename, const string& cm
|
|||
*ofp<<"# DESCR"<<"IPTION: Verilator output: Timestamp data for --skip-identical. Delete at will."<<endl;
|
||||
*ofp<<"C \""<<cmdline<<"\""<<endl;
|
||||
|
||||
#ifndef __WIN32
|
||||
#ifndef _WIN32
|
||||
sync(); // Push files so sizes look correct
|
||||
#endif
|
||||
for (set<DependFile>::iterator iter=m_filenameList.begin();
|
||||
|
|
@ -258,7 +258,7 @@ void V3File::createMakeDir() {
|
|||
static bool created = false;
|
||||
if (!created) {
|
||||
created = true;
|
||||
#ifndef __WIN32
|
||||
#ifndef _WIN32
|
||||
mkdir(v3Global.opt.makeDir().c_str(), 0777);
|
||||
#else
|
||||
mkdir(v3Global.opt.makeDir().c_str());
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
#include "verilatedos.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#if !defined(__WIN32)
|
||||
#ifndef _WIN32
|
||||
# include <sys/utsname.h>
|
||||
#endif
|
||||
#include <cctype>
|
||||
|
|
@ -330,7 +330,7 @@ void V3Options::setenvStr(const string& envvar, const string& value, const strin
|
|||
} else {
|
||||
UINFO(1,"export "<<envvar<<"="<<value<<endl);
|
||||
}
|
||||
#ifndef __WIN32
|
||||
#ifndef _WIN32
|
||||
setenv(envvar.c_str(),value.c_str(),true);
|
||||
#else
|
||||
//setenv() replaced by putenv() in MinGW environment. Prototype is different
|
||||
|
|
@ -367,7 +367,7 @@ string V3Options::getenvSYSTEMC_ARCH() {
|
|||
// Hardcoded with MINGW current version. Would like a better way.
|
||||
string sysname = "MINGW32_NT-5.0";
|
||||
var = "mingw32";
|
||||
#elsif defined (__WIN32)
|
||||
#elsif defined (_WIN32)
|
||||
string sysname = "WIN32";
|
||||
var = "win32";
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -15,6 +15,13 @@ my $Debug;
|
|||
if (!-r "$root/.git") {
|
||||
$Self->skip("Not in a git repository");
|
||||
} else {
|
||||
uint();
|
||||
printfll();
|
||||
}
|
||||
|
||||
ok(1);
|
||||
|
||||
sub uint {
|
||||
### Must trim output before and after our file list
|
||||
#my $files = "*/*.c* */*.h test_regress/t/*.c* test_regress/t/*.h";
|
||||
# src isn't clean, and probably doesn't need to be (yet?)
|
||||
|
|
@ -31,7 +38,7 @@ if (!-r "$root/.git") {
|
|||
next if $line =~ m!include/svdpi.h!; # Not ours
|
||||
if ($line =~ /^([^:]+)/) {
|
||||
$names{$1} = 1;
|
||||
print $line;
|
||||
print "$line\n";
|
||||
}
|
||||
}
|
||||
if (keys %names) {
|
||||
|
|
@ -39,5 +46,22 @@ if (!-r "$root/.git") {
|
|||
}
|
||||
}
|
||||
|
||||
ok(1);
|
||||
sub printfll {
|
||||
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 && fgrep -n ll $files | sort";
|
||||
print "C $cmd\n";
|
||||
my $grep = `$cmd`;
|
||||
my %names;
|
||||
foreach my $line (split /\n/, $grep) {
|
||||
next if $line !~ /%[^ ]*ll/;
|
||||
if ($line =~ /^([^:]+)/) {
|
||||
$names{$1} = 1;
|
||||
print "$line\n";
|
||||
}
|
||||
}
|
||||
if (keys %names) {
|
||||
$Self->error("Files with %ll instead of VL_PRI64: ",join(' ',sort keys %names));
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -55,7 +55,8 @@ extern "C" {
|
|||
|
||||
#define CHECK_RESULT(got, exp) \
|
||||
if ((got) != (exp)) { \
|
||||
printf("%%Error: %s:%d: GOT = %llx EXP = %llx\n", __FILE__,__LINE__, (long long)(got), (long long)(exp)); \
|
||||
printf("%%Error: %s:%d: GOT = %" VL_PRI64 "x EXP = %" VL_PRI64 "x\n", \
|
||||
__FILE__,__LINE__, (long long)(got), (long long)(exp)); \
|
||||
return __LINE__; \
|
||||
}
|
||||
#define CHECK_RESULT_NNULL(got) \
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ long long get_memory_usage() {
|
|||
long long ps_vsize, ps_rss;
|
||||
int items = fscanf(fp, ("%d (%*[^) ]) %*1s %d %*d %*d %*d %*d %u"
|
||||
" %u %u %u %u %d %d %d %d"
|
||||
" %*d %*d %*u %*u %d %llu %llu "),
|
||||
" %*d %*d %*u %*u %d %" VL_PRI64 "u %" VL_PRI64 "u "),
|
||||
&ps_ign, &ps_ign, &ps_ign,
|
||||
&ps_ign, &ps_ign, &ps_ign, &ps_ign,
|
||||
&ps_ign, &ps_ign, &ps_ign, &ps_ign,
|
||||
|
|
@ -68,7 +68,7 @@ int main (int argc, char *argv[]) {
|
|||
make_and_destroy();
|
||||
}
|
||||
firstUsage = get_memory_usage();
|
||||
printf("Memory size %lld bytes\n", firstUsage);
|
||||
printf("Memory size %" VL_PRI64 "d bytes\n", firstUsage);
|
||||
|
||||
int loops = 100*1000;
|
||||
for (int left=loops; left>0;) {
|
||||
|
|
@ -79,7 +79,7 @@ int main (int argc, char *argv[]) {
|
|||
|
||||
long long leaked = get_memory_usage() - firstUsage;
|
||||
if (leaked > 64*1024) { // Have to allow some slop for this code.
|
||||
printf ("Leaked %lld bytes, or ~ %lld bytes/construt\n", leaked, leaked/loops);
|
||||
printf ("Leaked %" VL_PRI64 "d bytes, or ~ %" VL_PRI64 "d bytes/construt\n", leaked, leaked/loops);
|
||||
vl_fatal(__FILE__,__LINE__,"top", "Leaked memory\n");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ int main (int argc, char *argv[]) {
|
|||
| MaskVal (sim->LowMaskSel_Bot, sim->HighMaskSel_Bot);
|
||||
|
||||
if (sim->LogicImm != expected) {
|
||||
printf ("%%Error: %d.%d,%d.%d -> %016llx/%016llx -> %016llx (expected %016llx)\n",
|
||||
printf ("%%Error: %d.%d,%d.%d -> %016" VL_PRI64 "x/%016" VL_PRI64 "x -> %016" VL_PRI64 "x (expected %016" VL_PRI64 "x)\n",
|
||||
sim->LowMaskSel_Top, sim->HighMaskSel_Top,
|
||||
sim->LowMaskSel_Bot, sim->HighMaskSel_Bot,
|
||||
sim->LowLogicImm, sim->HighLogicImm,
|
||||
|
|
|
|||
Loading…
Reference in New Issue