aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/yosys.cc16
-rw-r--r--kernel/yosys.h1
2 files changed, 17 insertions, 0 deletions
diff --git a/kernel/yosys.cc b/kernel/yosys.cc
index 921f2b383..a40ad4372 100644
--- a/kernel/yosys.cc
+++ b/kernel/yosys.cc
@@ -166,6 +166,22 @@ 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 GetSize(RTLIL::Wire *wire)
{
return wire->width;
diff --git a/kernel/yosys.h b/kernel/yosys.h
index 919e3bb98..d38e60ceb 100644
--- a/kernel/yosys.h
+++ b/kernel/yosys.h
@@ -86,6 +86,7 @@ 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);
template<typename T> int GetSize(const T &obj) { return obj.size(); }
int GetSize(RTLIL::Wire *wire);