diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/register.cc | 18 | ||||
-rw-r--r-- | kernel/register.h | 2 |
2 files changed, 14 insertions, 6 deletions
diff --git a/kernel/register.cc b/kernel/register.cc index 1fd1bad1d..3033ee710 100644 --- a/kernel/register.cc +++ b/kernel/register.cc @@ -48,7 +48,7 @@ using zlib to write gzip-compressed data every time the stream is flushed. */ class gzip_ostream : public std::ostream { public: - gzip_ostream() + gzip_ostream() : std::ostream(nullptr) { rdbuf(&outbuf); } @@ -71,7 +71,7 @@ private: str(""); return 0; } - ~gzip_streambuf() + virtual ~gzip_streambuf() { sync(); gzclose(gzf); @@ -498,7 +498,15 @@ void Frontend::extra_args(std::istream *&f, std::string &filename, std::vector<s if (f != NULL) { // Check for gzip magic unsigned char magic[3]; - int n = readsome(*ff, reinterpret_cast<char*>(magic), 3); + int n = 0; + while (n < 3) + { + int c = ff->get(); + if (c != EOF) { + magic[n] = (unsigned char) c; + } + n++; + } if (n == 3 && magic[0] == 0x1f && magic[1] == 0x8b) { #ifdef YOSYS_ENABLE_ZLIB log("Found gzip magic in file `%s', decompressing using zlib.\n", filename.c_str()); @@ -604,7 +612,7 @@ void Backend::execute(std::vector<std::string> args, RTLIL::Design *design) delete f; } -void Backend::extra_args(std::ostream *&f, std::string &filename, std::vector<std::string> args, size_t argidx) +void Backend::extra_args(std::ostream *&f, std::string &filename, std::vector<std::string> args, size_t argidx, bool bin_output) { bool called_with_fp = f != NULL; @@ -639,7 +647,7 @@ void Backend::extra_args(std::ostream *&f, std::string &filename, std::vector<st #endif } else { std::ofstream *ff = new std::ofstream; - ff->open(filename.c_str(), std::ofstream::trunc); + ff->open(filename.c_str(), bin_output ? (std::ofstream::trunc | std::ofstream::binary) : std::ofstream::trunc); yosys_output_files.insert(filename); if (ff->fail()) { delete ff; diff --git a/kernel/register.h b/kernel/register.h index c74029823..be836013f 100644 --- a/kernel/register.h +++ b/kernel/register.h @@ -109,7 +109,7 @@ struct Backend : Pass void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE YS_FINAL; virtual void execute(std::ostream *&f, std::string filename, std::vector<std::string> args, RTLIL::Design *design) = 0; - void extra_args(std::ostream *&f, std::string &filename, std::vector<std::string> args, size_t argidx); + void extra_args(std::ostream *&f, std::string &filename, std::vector<std::string> args, size_t argidx, bool bin_output = false); static void backend_call(RTLIL::Design *design, std::ostream *f, std::string filename, std::string command); static void backend_call(RTLIL::Design *design, std::ostream *f, std::string filename, std::vector<std::string> args); |