Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

odb: protecting LefParser and DefParser namespaces #6475

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/OpenRoad.i
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
%{

#include "odb/db.h"
#include "odb/lefin.h"
#include "odb/defin.h"
#include "odb/defout.h"
#include "sta/Report.hh"
#include "sta/Network.hh"
Expand Down
1 change: 0 additions & 1 deletion src/Tech.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

#include "db_sta/dbSta.hh"
#include "odb/db.h"
#include "odb/lefin.h"
#include "ord/OpenRoad.hh"

namespace ord {
Expand Down
2 changes: 0 additions & 2 deletions src/gui/src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@
#include "mainWindow.h"
#include "odb/db.h"
#include "odb/dbShape.h"
#include "odb/defin.h"
#include "odb/geom.h"
#include "odb/lefin.h"
#include "ord/OpenRoad.hh"
#include "ruler.h"
#include "scriptWidget.h"
Expand Down
4 changes: 4 additions & 0 deletions src/odb/include/odb/defin.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#pragma once

#include <mutex>
#include <vector>

#include "odb.h"
Expand All @@ -52,6 +53,9 @@ class defin
{
definReader* _reader;

// Protects the DefParser namespace that has static variables
static std::mutex _def_mutex;

public:
enum MODE
{
Expand Down
46 changes: 42 additions & 4 deletions src/odb/include/odb/lefin.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#pragma once

#include <list>
#include <mutex>
#include <string>
#include <vector>

Expand Down Expand Up @@ -65,7 +66,6 @@ class lefiObstruction;
class lefiGeometries;
struct lefiGeomPolygon;
} // namespace LefParser

namespace odb {

class dbObject;
Expand All @@ -77,7 +77,7 @@ class dbDatabase;
class dbTechLayer;
class dbSite;

class lefin
class lefinReader
{
dbDatabase* _db;
dbTech* _tech;
Expand Down Expand Up @@ -196,8 +196,10 @@ class lefin
}
void lineNumber(int lineNo);

lefin(dbDatabase* db, utl::Logger* logger, bool ignore_non_routing_layers);
~lefin();
lefinReader(dbDatabase* db,
utl::Logger* logger,
bool ignore_non_routing_layers);
~lefinReader() = default;

// Skip macro-obstructions in the lef file.
void skipObstructions() { _skip_obstructions = true; }
Expand Down Expand Up @@ -241,4 +243,40 @@ class lefin
bool updateTechAndLib(dbLib* lib, const char* lef_file);
};

class lefin
{
public:
lefin(dbDatabase* db, utl::Logger* logger, bool ignore_non_routing_layers);
~lefin();

// convert distance value to db-units
int dbdist(double value);

// Create a technology from the tech-data of this LEF file.
dbTech* createTech(const char* name, const char* lef_file);

// Create a library from the library-data of this LEF file.
dbLib* createLib(dbTech* tech, const char* name, const char* lef_file);

// Create a technology and library from the MACRO's in this LEF file.
dbLib* createTechAndLib(const char* tech_name,
const char* lib_name,
const char* lef_file);

// Add macros to this library
bool updateLib(dbLib* lib, const char* lef_file);

// Update a technology from the tech-data of this LEF file.
bool updateTech(dbTech* tech, const char* lef_file);

// Add macros to this library and the technology of this library
bool updateTechAndLib(dbLib* lib, const char* lef_file);

private:
lefinReader* _reader;

// Protects the LefParser namespace that has static variables
static std::mutex _lef_mutex;
};

} // namespace odb
6 changes: 6 additions & 0 deletions src/odb/src/defin/defin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@

namespace odb {

// Protects the DefParser namespace that has static variables
std::mutex defin::_def_mutex;

defin::defin(dbDatabase* db, utl::Logger* logger, MODE mode)
{
_reader = new definReader(db, logger, mode);
Expand Down Expand Up @@ -103,6 +106,7 @@ dbChip* defin::createChip(std::vector<dbLib*>& libs,
const char* def_file,
dbTech* tech)
{
std::lock_guard<std::mutex> lock(_def_mutex);
return _reader->createChip(libs, def_file, tech);
}

Expand All @@ -111,11 +115,13 @@ dbBlock* defin::createBlock(dbBlock* parent,
const char* def_file,
dbTech* tech)
{
std::lock_guard<std::mutex> lock(_def_mutex);
return _reader->createBlock(parent, libs, def_file, tech);
}

bool defin::replaceWires(dbBlock* block, const char* def_file)
{
std::lock_guard<std::mutex> lock(_def_mutex);
return _reader->replaceWires(block, def_file);
}

Expand Down
Loading
Loading