From 31267a1ae8d670c4b8749fc55b07c01d9285a488 Mon Sep 17 00:00:00 2001 From: William Speirs Date: Thu, 16 Oct 2014 12:06:54 -0400 Subject: [PATCH] Header changes so it will compile on VS --- frontends/verific/verific.cc | 7 +++++-- frontends/vhdl2verilog/vhdl2verilog.cc | 7 +++++-- kernel/driver.cc | 7 +++++-- kernel/yosys.cc | 10 ++++++--- kernel/yosys.h | 29 +++++++++++++++++++++++++- libs/ezsat/ezminisat.cc | 5 ++++- passes/abc/abc.cc | 7 +++++-- passes/cmds/cover.cc | 13 ++++++++++-- passes/cmds/show.cc | 5 ++++- passes/hierarchy/hierarchy.cc | 6 +++++- 10 files changed, 79 insertions(+), 17 deletions(-) diff --git a/frontends/verific/verific.cc b/frontends/verific/verific.cc index 5e1894cfd..44dfba0a8 100644 --- a/frontends/verific/verific.cc +++ b/frontends/verific/verific.cc @@ -20,11 +20,14 @@ #include "kernel/yosys.h" #include "kernel/sigtools.h" #include "kernel/log.h" -#include #include #include #include -#include + +#ifndef _WIN32 +# include +# include +#endif USING_YOSYS_NAMESPACE diff --git a/frontends/vhdl2verilog/vhdl2verilog.cc b/frontends/vhdl2verilog/vhdl2verilog.cc index 39b4f1496..82ff7b502 100644 --- a/frontends/vhdl2verilog/vhdl2verilog.cc +++ b/frontends/vhdl2verilog/vhdl2verilog.cc @@ -20,14 +20,17 @@ #include "kernel/register.h" #include "kernel/sigtools.h" #include "kernel/log.h" -#include #include #include #include -#include #include #include +#ifndef _WIN32 +# include +# include +#endif + YOSYS_NAMESPACE_BEGIN struct Vhdl2verilogPass : public Pass { diff --git a/kernel/driver.cc b/kernel/driver.cc index 8117a61c5..7f2cdb325 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -27,11 +27,14 @@ #include #include -#include -#include #include #include +#ifndef _WIN32 +# include +#endif + + USING_YOSYS_NAMESPACE int main(int argc, char **argv) diff --git a/kernel/yosys.cc b/kernel/yosys.cc index 1ce7b5207..9c1cb58f3 100644 --- a/kernel/yosys.cc +++ b/kernel/yosys.cc @@ -33,17 +33,21 @@ #elif defined(__APPLE__) # include #else +# include +# include # include # include #endif -#include #include -#include #include YOSYS_NAMESPACE_BEGIN +#ifdef _WIN32 +const char *yosys_version_str = "Windows"; +#endif + int autoidx = 1; RTLIL::Design *yosys_design = NULL; @@ -325,10 +329,10 @@ void yosys_shutdown() #ifdef YOSYS_ENABLE_PLUGINS for (auto &it : loaded_plugins) dlclose(it.second); -#endif loaded_plugins.clear(); loaded_plugin_aliases.clear(); +#endif } RTLIL::IdString new_id(std::string file, int line, std::string func) diff --git a/kernel/yosys.h b/kernel/yosys.h index 239146d77..e4465edf7 100644 --- a/kernel/yosys.h +++ b/kernel/yosys.h @@ -68,6 +68,30 @@ # include #endif +// a few platform specific things +#ifdef _WIN32 +# define NOMINMAX +# include +# include // takes care of a number of typedefs +# include +# include + +// these are always a bit dangerous :-) +# define strtok_r strtok_s +# define strdup _strdup +# define snprintf _snprintf +# define access _access +# define getcwd _getcwd +# define mkdir _mkdir +# define popen _popen +# define pclose _pclose + +# define PATH_MAX MAX_PATH +# define F_OK 00 +# define X_OK 00 // note this is NOT correct as there is no execute flag in Windows +#endif + + #define PRIVATE_NAMESPACE_BEGIN namespace { #define PRIVATE_NAMESPACE_END } #define YOSYS_NAMESPACE_BEGIN namespace Yosys { @@ -85,6 +109,9 @@ #if !defined(__GNUC__) && !defined(__clang__) # define __attribute__(...) +# define _NORETURN_ __declspec(noreturn) +#else +# define _NORETURN_ #endif YOSYS_NAMESPACE_BEGIN @@ -96,7 +123,7 @@ namespace RTLIL { struct Cell; } -std::string stringf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); +std::string stringf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); std::string vstringf(const char *fmt, va_list ap); std::string next_token(std::string &text, const char *sep); bool patmatch(const char *pattern, const char *string); diff --git a/libs/ezsat/ezminisat.cc b/libs/ezsat/ezminisat.cc index b996d4a3d..dee82a8df 100644 --- a/libs/ezsat/ezminisat.cc +++ b/libs/ezsat/ezminisat.cc @@ -27,7 +27,10 @@ #include #include #include -#include + +#ifndef _WIN32 +# include +#endif #include "../minisat/Solver.h" #include "../minisat/SimpSolver.h" diff --git a/passes/abc/abc.cc b/passes/abc/abc.cc index 891804393..79aa067d7 100644 --- a/passes/abc/abc.cc +++ b/passes/abc/abc.cc @@ -43,15 +43,18 @@ #include "kernel/sigtools.h" #include "kernel/cost.h" #include "kernel/log.h" -#include #include #include #include -#include #include #include #include +#ifndef _WIN32 +# include +# include +#endif + #include "blifparse.h" USING_YOSYS_NAMESPACE diff --git a/passes/cmds/cover.cc b/passes/cmds/cover.cc index 857d5aa47..b8baaf3d8 100644 --- a/passes/cmds/cover.cc +++ b/passes/cmds/cover.cc @@ -17,9 +17,18 @@ * */ -#include -#include #include "kernel/yosys.h" +#include + +#ifndef _WIN32 +# include +#else +# include +#endif + +#include "kernel/register.h" +#include "kernel/rtlil.h" +#include "kernel/log.h" USING_YOSYS_NAMESPACE PRIVATE_NAMESPACE_BEGIN diff --git a/passes/cmds/show.cc b/passes/cmds/show.cc index c6335cb30..1413742df 100644 --- a/passes/cmds/show.cc +++ b/passes/cmds/show.cc @@ -21,7 +21,10 @@ #include "kernel/celltypes.h" #include "kernel/log.h" #include -#include + +#ifndef _WIN32 +# include +#endif #ifdef YOSYS_ENABLE_READLINE # include diff --git a/passes/hierarchy/hierarchy.cc b/passes/hierarchy/hierarchy.cc index 4b414d3cb..2a7e96346 100644 --- a/passes/hierarchy/hierarchy.cc +++ b/passes/hierarchy/hierarchy.cc @@ -21,7 +21,11 @@ #include #include #include -#include + +#ifndef _WIN32 +# include +#endif + USING_YOSYS_NAMESPACE PRIVATE_NAMESPACE_BEGIN -- 2.30.2