#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
+#include <stdint.h>
#include <stdio.h>
+#ifndef _YOSYS_
+# error It looks like you are trying to build Yosys without the config defines set. \
+ When building Yosys with a custom make system, make sure you set all the \
+ defines the Yosys Makefile would set for your build configuration.
+#endif
+
+#ifdef YOSYS_ENABLE_TCL
+# include <tcl.h>
+#endif
+
+#ifdef _WIN32
+# undef NOMINMAX
+# define NOMINMAX 1
+# undef YY_NO_UNISTD_H
+# define YY_NO_UNISTD_H 1
+
+# include <windows.h>
+# include <io.h>
+# include <direct.h>
+
+# define strtok_r strtok_s
+# define strdup _strdup
+# define snprintf _snprintf
+# define getcwd _getcwd
+# define mkdir _mkdir
+# define popen _popen
+# define pclose _pclose
+# define PATH_MAX MAX_PATH
+
+# ifndef __MINGW32__
+# define isatty _isatty
+# define fileno _fileno
+# endif
+#endif
+
#define PRIVATE_NAMESPACE_BEGIN namespace {
#define PRIVATE_NAMESPACE_END }
#define YOSYS_NAMESPACE_BEGIN namespace Yosys {
#define USING_YOSYS_NAMESPACE using namespace Yosys;
#if __cplusplus >= 201103L
-# define OVERRIDE override
-# define FINAL final
+# define YS_OVERRIDE override
+# define YS_FINAL final
+#else
+# define YS_OVERRIDE
+# define YS_FINAL
+#endif
+
+#if defined(__GNUC__) || defined(__clang__)
+# define YS_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
+# define YS_NORETURN
+#elif defined(_MSC_VER)
+# define YS_ATTRIBUTE(...)
+# define YS_NORETURN __declspec(noreturn)
#else
-# define OVERRIDE
-# define FINAL
+# define YS_ATTRIBUTE(...)
+# define YS_NORETURN
#endif
YOSYS_NAMESPACE_BEGIN
struct Cell;
}
-std::string stringf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
+std::string stringf(const char *fmt, ...) YS_ATTRIBUTE(format(printf, 1, 2));
std::string vstringf(const char *fmt, va_list ap);
+int readsome(std::istream &f, char *s, int n);
std::string next_token(std::string &text, const char *sep);
bool patmatch(const char *pattern, const char *string);
-int readsome(std::istream &f, char *s, int n);
+int run_command(const std::string &command, std::function<void(const std::string&)> process_line = std::function<void(const std::string&)>());
+std::string make_temp_file(std::string template_str = "/tmp/yosys_XXXXXX");
+std::string make_temp_dir(std::string template_str = "/tmp/yosys_XXXXXX");
+bool check_file_exists(std::string filename, bool is_exec = false);
+void remove_directory(std::string dirname);
template<typename T> int GetSize(const T &obj) { return obj.size(); }
int GetSize(RTLIL::Wire *wire);
void yosys_shutdown();
#ifdef YOSYS_ENABLE_TCL
-#include <tcl.h>
Tcl_Interp *yosys_get_tcl_interp();
#endif