summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-10-17 14:01:47 +0200
committerClifford Wolf <clifford@clifford.at>2014-10-17 14:01:47 +0200
commit468ae923748a01b2763bafa3cf5fba883fe06479 (patch)
treef80cf488e9a2f07592c2444b853d0c53edce7a20 /kernel
parent973d37673377c3ddba8020e718e4cd6174379175 (diff)
Various win32 / vs build fixes
Diffstat (limited to 'kernel')
-rw-r--r--kernel/log.h4
-rw-r--r--kernel/rtlil.cc2
-rw-r--r--kernel/yosys.cc8
-rw-r--r--kernel/yosys.h17
4 files changed, 16 insertions, 15 deletions
diff --git a/kernel/log.h b/kernel/log.h
index 10250cb9..81d01ace 100644
--- a/kernel/log.h
+++ b/kernel/log.h
@@ -55,8 +55,8 @@ void logv_header(const char *format, va_list ap);
void logv_error(const char *format, va_list ap) __attribute__((noreturn));
void log(const char *format, ...) __attribute__((format(printf, 1, 2)));
void log_header(const char *format, ...) __attribute__((format(printf, 1, 2)));
-void log_error(const char *format, ...) __attribute__((format(printf, 1, 2))) __attribute__((noreturn));
-void log_cmd_error(const char *format, ...) __attribute__((format(printf, 1, 2))) __attribute__((noreturn));
+_NORETURN_ void log_error(const char *format, ...) __attribute__((format(printf, 1, 2))) __attribute__((noreturn));
+_NORETURN_ void log_cmd_error(const char *format, ...) __attribute__((format(printf, 1, 2))) __attribute__((noreturn));
void log_spacer();
void log_push();
diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc
index 5a94008d..36443c5a 100644
--- a/kernel/rtlil.cc
+++ b/kernel/rtlil.cc
@@ -2204,7 +2204,7 @@ void RTLIL::SigSpec::unpack() const
that->hash_ = 0;
}
-#define DJB2(_hash, _value) do { (_hash) = (((_hash) << 5) + (_hash)) + (_value); } while (0)
+#define DJB2(_hash, _value) (_hash) = (((_hash) << 5) + (_hash)) + (_value)
void RTLIL::SigSpec::hash() const
{
diff --git a/kernel/yosys.cc b/kernel/yosys.cc
index ed90a6f3..26665e5b 100644
--- a/kernel/yosys.cc
+++ b/kernel/yosys.cc
@@ -269,12 +269,12 @@ std::string make_temp_dir(std::string template_str)
#ifdef _WIN32
bool check_file_exists(std::string filename, bool)
{
- return _access(filename.c_str(), 0);
+ return _access(filename.c_str(), 0) == 0;
}
#else
bool check_file_exists(std::string filename, bool is_exec)
{
- return access(filename.c_str(), is_exec ? X_OK : F_OK);
+ return access(filename.c_str(), is_exec ? X_OK : F_OK) == 0;
}
#endif
@@ -497,10 +497,10 @@ std::string proc_share_dirname()
{
std::string proc_self_path = proc_self_dirname();
std::string proc_share_path = proc_self_path + "share/";
- if (check_file_exists(proc_share_path, true) == 0)
+ if (check_file_exists(proc_share_path, true))
return proc_share_path;
proc_share_path = proc_self_path + "../share/yosys/";
- if (check_file_exists(proc_share_path, true) == 0)
+ if (check_file_exists(proc_share_path, true))
return proc_share_path;
log_error("proc_share_dirname: unable to determine share/ directory!\n");
}
diff --git a/kernel/yosys.h b/kernel/yosys.h
index 562cec12..a0a42be9 100644
--- a/kernel/yosys.h
+++ b/kernel/yosys.h
@@ -56,6 +56,7 @@
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
+#include <stdint.h>
#include <stdio.h>
#ifndef _YOSYS_
@@ -68,17 +69,18 @@
# include <tcl.h>
#endif
-// a few platform specific things
#ifdef _WIN32
-# ifndef NOMINMAX
-# define NOMINMAX 1
-# endif
+# undef NOMINMAX
+# define NOMINMAX 1
+# undef YY_NO_UNISTD_H
+# define YY_NO_UNISTD_H 1
+# undef _CRT_SECURE_NO_WARNINGS
+# define _CRT_SECURE_NO_WARNINGS 1
+
# include <windows.h>
-# include <stdint.h> // takes care of a number of typedefs
# include <io.h>
# include <direct.h>
-// these are always a bit dangerous :-)
# define strtok_r strtok_s
# define strdup _strdup
# define snprintf _snprintf
@@ -89,7 +91,6 @@
# define PATH_MAX MAX_PATH
#endif
-
#define PRIVATE_NAMESPACE_BEGIN namespace {
#define PRIVATE_NAMESPACE_END }
#define YOSYS_NAMESPACE_BEGIN namespace Yosys {
@@ -128,7 +129,7 @@ bool patmatch(const char *pattern, const char *string);
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(std::string filename, bool is_exec = false);
+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(); }