Fix MinGW compilation, bug184.

This commit is contained in:
Wilson Snyder 2009-11-13 11:08:30 -05:00
parent 92819f5082
commit 3fc55bba8e
4 changed files with 29 additions and 4 deletions

View File

@ -18,6 +18,8 @@ indicates the contributor was also the author of the fix; Thanks!
*** Add VARHIDDEN warning when signal name hides module name.
**** Fix MinGW compilation, bug184. [by Shankar Giri]
**** Support optional cell parenthesis, bug179. [by Byron Bradley]
**** Support for loop i++, ++i, i--, --i, bug175. [by Byron Bradley]

View File

@ -43,11 +43,11 @@ The resulting executable will perform the actual simulation.
This version of verilator has been built and tested on:
SuSE AMD64 i686-linux-2.6.5
SuSE 11.1 AMD64 i686-linux-2.6.27, GCC 4.3.2
Other users report success with Redhat Linux, Windows under Cygwin, Macs,
HPUX and Solaris. It should run with minor porting on any Linixish
platform.
Other users report success with Redhat Linux, Windows under Cygwin, Windows
under MinGW, Macs, HPUX and Solaris. It should run with minor porting on
any Linix-ish platform.
=head1 INSTALLATION

View File

@ -146,7 +146,9 @@ inline void V3FileDependImp::writeTimes(const string& filename, const string& cm
string cmdline = stripQuotes(cmdlineIn);
*ofp<<"C \""<<cmdline<<"\""<<endl;
#if !defined (__MINGW32__)
sync(); // Push files so sizes look correct
#endif
for (set<DependFile>::iterator iter=m_filenameList.begin();
iter!=m_filenameList.end(); ++iter) {
// Read stats of files we create after we're done making them (execpt for this file, of course)
@ -238,7 +240,11 @@ void V3File::createMakeDir() {
static bool created = false;
if (!created) {
created = true;
#if !defined (__MINGW32__)
mkdir(v3Global.opt.makeDir().c_str(), 0777);
#else
mkdir(v3Global.opt.makeDir().c_str());
#endif
}
}

View File

@ -23,7 +23,9 @@
#include "verilatedos.h"
#include <sys/types.h>
#include <sys/stat.h>
#if !defined(__MINGW32__)
#include <sys/utsname.h>
#endif
#include <cctype>
#include <dirent.h>
#include <unistd.h>
@ -318,7 +320,16 @@ void V3Options::setenvStr(const string& envvar, const string& value, const strin
} else {
UINFO(1,"export "<<envvar<<"="<<value<<endl);
}
//setenv() replaced by putenv() in MinGW environment. Prototype is different
//putenv() requires NAME=VALUE format
#if !defined (__MINGW32__)
setenv(envvar.c_str(),value.c_str(),true);
#else
int len = value.size() + envvar.size() + 5;
char *str = new char[len];
sprintf(str,"%s=%s", envvar.c_str(), value.c_str());
putenv(str);
#endif
}
string V3Options::getenvSYSTEMC() {
@ -344,12 +355,18 @@ string V3Options::getenvSYSTEMC_ARCH() {
setenvStr("SYSTEMC_ARCH", var, "Hardcoded at build time");
}
if (var == "") {
#if defined (__MINGW32__)
// Hardcoded with MINGW current version. Would like a better way.
string sysname = "MINGW32_NT-5.0";
var = "mingw32";
#else
struct utsname uts;
uname(&uts);
string sysname = downcase(uts.sysname); // aka 'uname -s'
if (wildmatch(sysname.c_str(), "*solaris*")) { var = "gccsparcOS5"; }
else if (wildmatch(sysname.c_str(), "*cygwin*")) { var ="cygwin"; }
else { var = "linux"; }
#endif
setenvStr("SYSTEMC_ARCH", var,"From sysname '"+sysname+"'");
}
return var;