mirror of https://github.com/YosysHQ/yosys.git
gzip: back to pointers
This commit is contained in:
parent
fa8642be02
commit
b85dda9cb9
|
@ -100,17 +100,17 @@ gzip_istream::ibuf::~ibuf() {
|
|||
|
||||
// Takes a successfully opened ifstream. If it's gzipped, returns an istream. Otherwise,
|
||||
// returns the original ifstream, rewound to the start.
|
||||
std::istream& uncompressed(const std::string filename, std::ios_base::openmode mode) {
|
||||
std::ifstream& f = *new std::ifstream();
|
||||
f.open(filename, mode);
|
||||
if (f.fail())
|
||||
std::istream* uncompressed(const std::string filename, std::ios_base::openmode mode) {
|
||||
std::ifstream* f = new std::ifstream();
|
||||
f->open(filename, mode);
|
||||
if (f->fail())
|
||||
return f;
|
||||
// Check for gzip magic
|
||||
unsigned char magic[3];
|
||||
int n = 0;
|
||||
while (n < 3)
|
||||
{
|
||||
int c = f.get();
|
||||
int c = f->get();
|
||||
if (c != EOF) {
|
||||
magic[n] = (unsigned char) c;
|
||||
}
|
||||
|
@ -122,16 +122,16 @@ std::istream& uncompressed(const std::string filename, std::ios_base::openmode m
|
|||
if (magic[2] != 8)
|
||||
log_cmd_error("gzip file `%s' uses unsupported compression type %02x\n",
|
||||
filename.c_str(), unsigned(magic[2]));
|
||||
gzip_istream& s = *new gzip_istream();
|
||||
delete &f;
|
||||
s.open(filename.c_str());
|
||||
gzip_istream* s = new gzip_istream();
|
||||
delete f;
|
||||
s->open(filename.c_str());
|
||||
return s;
|
||||
#else
|
||||
log_cmd_error("File `%s' is a gzip file, but Yosys is compiled without zlib.\n", filename.c_str());
|
||||
#endif // YOSYS_ENABLE_ZLIB
|
||||
} else {
|
||||
f.clear();
|
||||
f.seekg(0, std::ios::beg);
|
||||
f->clear();
|
||||
f->seekg(0, std::ios::beg);
|
||||
return f;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ private:
|
|||
|
||||
#endif // YOSYS_ENABLE_ZLIB
|
||||
|
||||
std::istream& uncompressed(const std::string filename, std::ios_base::openmode mode = std::ios_base::in);
|
||||
std::istream* uncompressed(const std::string filename, std::ios_base::openmode mode = std::ios_base::in);
|
||||
|
||||
YOSYS_NAMESPACE_END
|
||||
|
||||
|
|
|
@ -470,7 +470,7 @@ void Frontend::extra_args(std::istream *&f, std::string &filename, std::vector<s
|
|||
next_args.insert(next_args.end(), filenames.begin()+1, filenames.end());
|
||||
}
|
||||
yosys_input_files.insert(filename);
|
||||
f = &uncompressed(filename, bin_input ? std::ifstream::binary : std::ifstream::in);
|
||||
f = uncompressed(filename, bin_input ? std::ifstream::binary : std::ifstream::in);
|
||||
}
|
||||
if (f == NULL)
|
||||
log_cmd_error("Can't open input file `%s' for reading: %s\n", filename.c_str(), strerror(errno));
|
||||
|
|
|
@ -309,12 +309,12 @@ struct ClockgatePass : public Pass {
|
|||
if (!liberty_files.empty()) {
|
||||
LibertyMergedCells merged;
|
||||
for (auto path : liberty_files) {
|
||||
std::istream& f = uncompressed(path);
|
||||
if (f.fail())
|
||||
std::istream* f = uncompressed(path);
|
||||
if (f->fail())
|
||||
log_cmd_error("Can't open liberty file `%s': %s\n", path.c_str(), strerror(errno));
|
||||
LibertyParser p(f);
|
||||
LibertyParser p(*f);
|
||||
merged.merge(p);
|
||||
delete &f;
|
||||
delete f;
|
||||
}
|
||||
std::tie(pos_icg_desc, neg_icg_desc) =
|
||||
find_icgs(merged.cells, dont_use_cells);
|
||||
|
|
|
@ -631,12 +631,12 @@ struct DfflibmapPass : public Pass {
|
|||
|
||||
LibertyMergedCells merged;
|
||||
for (auto path : liberty_files) {
|
||||
std::istream& f = uncompressed(path);
|
||||
if (f.fail())
|
||||
std::istream* f = uncompressed(path);
|
||||
if (f->fail())
|
||||
log_cmd_error("Can't open liberty file `%s': %s\n", path.c_str(), strerror(errno));
|
||||
LibertyParser p(f);
|
||||
LibertyParser p(*f);
|
||||
merged.merge(p);
|
||||
delete &f;
|
||||
delete f;
|
||||
}
|
||||
|
||||
find_cell(merged.cells, ID($_DFF_N_), false, false, false, false, false, false, dont_use_cells);
|
||||
|
|
Loading…
Reference in New Issue