aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/nextpnr.cc2
-rw-r--r--common/nextpnr.h12
2 files changed, 7 insertions, 7 deletions
diff --git a/common/nextpnr.cc b/common/nextpnr.cc
index ee0c13ba..5af83a15 100644
--- a/common/nextpnr.cc
+++ b/common/nextpnr.cc
@@ -21,7 +21,7 @@
NEXTPNR_NAMESPACE_BEGIN
-BaseCtx *IdString::global_ctx = nullptr;
+std::unordered_set<BaseCtx*> IdString::global_ctx;
void IdString::set(const BaseCtx *ctx, const std::string &s)
{
diff --git a/common/nextpnr.h b/common/nextpnr.h
index 36a8dc75..af092475 100644
--- a/common/nextpnr.h
+++ b/common/nextpnr.h
@@ -50,8 +50,6 @@ struct IdString
{
int index = 0;
- static BaseCtx *global_ctx;
-
static void initialize_arch(const BaseCtx *ctx);
static void initialize_add(const BaseCtx *ctx, const char *s, int idx);
@@ -76,10 +74,12 @@ struct IdString
// --- deprecated old API ---
+ static std::unordered_set<BaseCtx*> global_ctx;
+
const std::string &global_str() const __attribute__((deprecated))
{
- assert(global_ctx != nullptr);
- return str(global_ctx);
+ assert(global_ctx.size() == 1);
+ return str(*global_ctx.begin());
}
};
@@ -204,8 +204,7 @@ struct BaseCtx
BaseCtx()
{
- // assert(IdString::global_ctx == nullptr);
- IdString::global_ctx = this;
+ IdString::global_ctx.insert(this);
idstring_str_to_idx = new std::unordered_map<std::string, int>;
idstring_idx_to_str = new std::vector<const std::string *>;
@@ -215,6 +214,7 @@ struct BaseCtx
~BaseCtx()
{
+ IdString::global_ctx.erase(this);
delete idstring_str_to_idx;
delete idstring_idx_to_str;
}