Skip to content

Commit c8aa667

Browse files
authored
Merge pull request #707 from os-fpga/blif_checker_correct_pin_dirs
blif_checker: correct pin directions
2 parents eeadae4 + f4d046f commit c8aa667

File tree

7 files changed

+342
-45
lines changed

7 files changed

+342
-45
lines changed

stars/src/file_readers/pinc_Fio.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ bool MMapReader::read() noexcept {
392392
buf_ = nullptr;
393393
fd_ = -1;
394394
mm_len_ = 0;
395+
pad_ = false;
395396

396397
struct stat sb;
397398
if (::stat(fnm_.c_str(), &sb)) {
@@ -446,6 +447,7 @@ bool MMapReader::read() noexcept {
446447
if (tr) lout() << "MMapReader::read() failed: " << fnm_ << endl;
447448
return false;
448449
}
450+
pad_ = true;
449451
return true;
450452
}
451453

@@ -462,8 +464,12 @@ bool MMapReader::read() noexcept {
462464
}
463465

464466
buf_ = (char*)addr;
465-
buf_[fsz_ + 1] = 0;
466-
buf_[fsz_] = 0;
467+
468+
if (fsz_ % 4096) {
469+
buf_[fsz_] = 0;
470+
pad_ = true;
471+
}
472+
467473
assert(isMapped());
468474

469475
return true;
@@ -805,6 +811,11 @@ bool MMapReader::makeLines(bool cutComments, bool cutNL) noexcept {
805811
if (!sz_ || !fsz_) return false;
806812
if (!buf_) return false;
807813

814+
if (!pad_ and fsz_ > 4) {
815+
lastByte_ = buf_[fsz_ - 1];
816+
buf_[fsz_ - 1] = 0;
817+
}
818+
808819
if (cutNL) {
809820
num_lines_ = 0;
810821
// count lines
@@ -986,11 +997,14 @@ char* MMapReader::skipLine(char* curL) noexcept {
986997
}
987998

988999
bool MMapReader::advanceLine(char*& curL) noexcept {
989-
if (!curL) return false;
990-
1000+
if (!curL)
1001+
return false;
9911002
char* p = skipLine(curL);
992-
if (!p) return false;
1003+
if (!p)
1004+
return false;
9931005
assert(p > buf_);
1006+
if (p >= buf_ + fsz_)
1007+
return false;
9941008
curL = p;
9951009
return true;
9961010
}

stars/src/file_readers/pinc_Fio.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,13 @@ inline size_t hf_std(CStr z) noexcept
209209
class MMapReader : public Fio
210210
{
211211
public:
212-
static constexpr size_t MIN_SIZE_for_MMAP = 2048; // half-page
212+
static constexpr size_t MIN_SIZE_for_MMAP = 4098; // > 1 page
213213

214214
char* buf_ = nullptr;
215-
int fd_ = -1;
216215
size_t mm_len_ = 0;
216+
int fd_ = -1;
217+
int16_t lastByte_ = -1;
218+
bool pad_ = false;
217219

218220
public:
219221
MMapReader() noexcept = default;

0 commit comments

Comments
 (0)