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