aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-10-15 01:20:14 +0200
committerClifford Wolf <clifford@clifford.at>2014-10-15 01:20:14 +0200
commit8cea352a6aafa80d397d8a6a7d195c1378dcb324 (patch)
treecc670a0dadca8f6df7a1d24e1f00fa649d40f29a /kernel
parent2873a8444ee5dbd0a3d034fb4a7a877c680be45d (diff)
parent1fc6208ec05af672c7c6b7973b0eba1295bca5f4 (diff)
downloadyosys-8cea352a6aafa80d397d8a6a7d195c1378dcb324.tar.gz
yosys-8cea352a6aafa80d397d8a6a7d195c1378dcb324.tar.bz2
yosys-8cea352a6aafa80d397d8a6a7d195c1378dcb324.zip
Merge branch 'win32'
Diffstat (limited to 'kernel')
-rw-r--r--kernel/log.cc25
-rw-r--r--kernel/log.h12
-rw-r--r--kernel/rtlil.h6
-rw-r--r--kernel/yosys.cc16
-rw-r--r--kernel/yosys.h11
5 files changed, 44 insertions, 26 deletions
diff --git a/kernel/log.cc b/kernel/log.cc
index 87a75410d..2cae6a636 100644
--- a/kernel/log.cc
+++ b/kernel/log.cc
@@ -21,7 +21,10 @@
#include "libs/sha1/sha1.h"
#include "backends/ilang/ilang_backend.h"
-#include <sys/time.h>
+#ifndef _WIN32
+# include <sys/time.h>
+#endif
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -48,6 +51,26 @@ static struct timeval initial_tv = { 0, 0 };
static bool next_print_log = false;
static int log_newline_count = 0;
+#ifdef _WIN32
+// this will get time information and return it in timeval, simulating gettimeofday()
+int gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+ LARGE_INTEGER counter;
+ LARGE_INTEGER freq;
+
+ QueryPerformanceFrequency(&freq);
+ QueryPerformanceCounter(&counter);
+
+ counter.QuadPart *= 1000000;
+ counter.QuadPart /= freq.QuadPart;
+
+ tv->tv_sec = counter.QuadPart / 1000000;
+ tv->tv_usec = counter.QuadPart % 1000000;
+
+ return 0;
+}
+#endif
+
void logv(const char *format, va_list ap)
{
while (format[0] == '\n' && format[1] != 0) {
diff --git a/kernel/log.h b/kernel/log.h
index b4182b5f3..904ba4759 100644
--- a/kernel/log.h
+++ b/kernel/log.h
@@ -23,9 +23,9 @@
#define LOG_H
#include <time.h>
-#include <sys/time.h>
#ifndef _WIN32
+# include <sys/time.h>
# include <sys/resource.h>
#endif
@@ -51,12 +51,12 @@ extern int log_verbose_level;
void logv(const char *format, va_list ap);
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));
+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));
void log_spacer();
void log_push();
diff --git a/kernel/rtlil.h b/kernel/rtlil.h
index 8df0bfe19..5629c8652 100644
--- a/kernel/rtlil.h
+++ b/kernel/rtlil.h
@@ -920,23 +920,25 @@ struct RTLIL::SigBit
}
};
-struct RTLIL::SigSpecIterator
+struct RTLIL::SigSpecIterator : public std::iterator<std::input_iterator_tag, RTLIL::SigSpec>
{
RTLIL::SigSpec *sig_p;
int index;
inline RTLIL::SigBit &operator*() const;
inline bool operator!=(const RTLIL::SigSpecIterator &other) const { return index != other.index; }
+ inline bool operator==(const RTLIL::SigSpecIterator &other) const { return index == other.index; }
inline void operator++() { index++; }
};
-struct RTLIL::SigSpecConstIterator
+struct RTLIL::SigSpecConstIterator : public std::iterator<std::input_iterator_tag, RTLIL::SigSpec>
{
const RTLIL::SigSpec *sig_p;
int index;
inline const RTLIL::SigBit &operator*() const;
inline bool operator!=(const RTLIL::SigSpecConstIterator &other) const { return index != other.index; }
+ inline bool operator==(const RTLIL::SigSpecIterator &other) const { return index == other.index; }
inline void operator++() { index++; }
};
diff --git a/kernel/yosys.cc b/kernel/yosys.cc
index e50bfcbe6..ba3049c53 100644
--- a/kernel/yosys.cc
+++ b/kernel/yosys.cc
@@ -172,22 +172,6 @@ bool patmatch(const char *pattern, const char *string)
return false;
}
-int readsome(std::istream &f, char *s, int n)
-{
- int rc = f.readsome(s, n);
-
- // win32 sometimes returns 0 on a non-empty stream..
- if (rc == 0) {
- int c = f.get();
- if (c != EOF) {
- *s = c;
- rc = 1;
- }
- }
-
- return rc;
-}
-
int run_command(const std::string &command, std::function<void(const std::string&)> process_line)
{
if (!process_line)
diff --git a/kernel/yosys.h b/kernel/yosys.h
index 5a37dd3c5..239146d77 100644
--- a/kernel/yosys.h
+++ b/kernel/yosys.h
@@ -58,6 +58,12 @@
#include <string.h>
#include <stdio.h>
+#ifndef _YOSYS_
+# error It looks like you are trying to build Yosys with 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
@@ -77,6 +83,10 @@
# define FINAL
#endif
+#if !defined(__GNUC__) && !defined(__clang__)
+# define __attribute__(...)
+#endif
+
YOSYS_NAMESPACE_BEGIN
namespace RTLIL {
@@ -90,7 +100,6 @@ 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);
-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");