From 5e58a329e6826fe6262077c1276ecf375b014f92 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 25 Jul 2018 09:32:13 +0200 Subject: Make thread check portable --- common/nextpnr.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/nextpnr.h b/common/nextpnr.h index 3ba4f3b3..e89512f2 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -23,10 +23,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include @@ -344,7 +344,7 @@ struct BaseCtx { // Lock to perform mutating actions on the Context. std::mutex mutex; - pthread_t mutex_owner; + std::thread::id mutex_owner; // Lock to be taken by UI when wanting to access context - the yield() // method will lock/unlock it when its' released the main mutex to make @@ -377,12 +377,12 @@ struct BaseCtx void lock(void) { mutex.lock(); - mutex_owner = pthread_self(); + mutex_owner = std::this_thread::get_id(); } void unlock(void) { - NPNR_ASSERT(pthread_equal(pthread_self(), mutex_owner) != 0); + NPNR_ASSERT(std::this_thread::get_id() != mutex_owner); mutex.unlock(); } -- cgit v1.2.3 From e3ce2f544d8a5ea3e23f6c7b43232bf2dfcee19c Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 25 Jul 2018 11:58:23 +0200 Subject: noreturn have to be void, so there is no UB --- common/nextpnr.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/nextpnr.h b/common/nextpnr.h index e89512f2..2eb46bd3 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -79,19 +79,19 @@ class assertion_failure : public std::runtime_error }; NPNR_NORETURN -inline bool assert_fail_impl(const char *message, const char *expr_str, const char *filename, int line) +inline void assert_fail_impl(const char *message, const char *expr_str, const char *filename, int line) { throw assertion_failure(message, expr_str, filename, line); } NPNR_NORETURN -inline bool assert_fail_impl_str(std::string message, const char *expr_str, const char *filename, int line) +inline void assert_fail_impl_str(std::string message, const char *expr_str, const char *filename, int line) { throw assertion_failure(message, expr_str, filename, line); } -#define NPNR_ASSERT(cond) ((void)((cond) || (assert_fail_impl(#cond, #cond, __FILE__, __LINE__)))) -#define NPNR_ASSERT_MSG(cond, msg) ((void)((cond) || (assert_fail_impl(msg, #cond, __FILE__, __LINE__)))) +#define NPNR_ASSERT(cond) (!(cond) ? assert_fail_impl(#cond, #cond, __FILE__, __LINE__) : (void)true) +#define NPNR_ASSERT_MSG(cond, msg) (!(cond) ? assert_fail_impl(msg, #cond, __FILE__, __LINE__) : (void)true) #define NPNR_ASSERT_FALSE(msg) (assert_fail_impl(msg, "false", __FILE__, __LINE__)) #define NPNR_ASSERT_FALSE_STR(msg) (assert_fail_impl_str(msg, "false", __FILE__, __LINE__)) -- cgit v1.2.3 From aad0d3eb3587b0c09ea89731e5387cd70338b375 Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski Date: Wed, 25 Jul 2018 11:32:21 +0100 Subject: ice40: support PLL40_*_PAD, fix pass-through LUT for LOCK --- common/placer1.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/placer1.cc b/common/placer1.cc index f713fb88..4659da11 100644 --- a/common/placer1.cc +++ b/common/placer1.cc @@ -94,7 +94,13 @@ class SAPlacer BelType bel_type = ctx->getBelType(bel); if (bel_type != ctx->belTypeFromId(cell->type)) { log_error("Bel \'%s\' of type \'%s\' does not match cell " - "\'%s\' of type \'%s\'", + "\'%s\' of type \'%s\'\n", + loc_name.c_str(), ctx->belTypeToId(bel_type).c_str(ctx), cell->name.c_str(ctx), + cell->type.c_str(ctx)); + } + if (!ctx->isValidBelForCell(cell, bel)) { + log_error("Bel \'%s\' of type \'%s\' is not valid for cell " + "\'%s\' of type \'%s\'\n", loc_name.c_str(), ctx->belTypeToId(bel_type).c_str(ctx), cell->name.c_str(ctx), cell->type.c_str(ctx)); } -- cgit v1.2.3 From ddfb1f1ff366e57282ea144e24b1d86fcbdc31be Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Wed, 25 Jul 2018 13:35:53 +0200 Subject: Fix BaseCtx::unlock() Signed-off-by: Clifford Wolf --- common/nextpnr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/nextpnr.h b/common/nextpnr.h index f391469c..f7f1cebc 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -392,7 +392,7 @@ struct BaseCtx void unlock(void) { - NPNR_ASSERT(std::this_thread::get_id() != mutex_owner); + NPNR_ASSERT(std::this_thread::get_id() == mutex_owner); mutex.unlock(); } -- cgit v1.2.3 From 7a8e8999d21205044e707a2765dc444531d69cef Mon Sep 17 00:00:00 2001 From: David Shah Date: Wed, 25 Jul 2018 19:45:38 +0200 Subject: clangformat Signed-off-by: David Shah --- common/nextpnr.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/nextpnr.h b/common/nextpnr.h index f7f1cebc..1cce21c0 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -276,11 +276,11 @@ struct CellInfo : ArchCellInfo // placement constraints CellInfo *constr_parent; - std::vector constr_children; + std::vector constr_children; const int UNCONSTR = INT_MIN; - int constr_x = UNCONSTR; // this.x - parent.x - int constr_y = UNCONSTR; // this.y - parent.y - int constr_z = UNCONSTR; // this.z - parent.z + int constr_x = UNCONSTR; // this.x - parent.x + int constr_y = UNCONSTR; // this.y - parent.y + int constr_z = UNCONSTR; // this.z - parent.z bool constr_abs_z = false; // parent.z := 0 // parent.[xyz] := 0 when (constr_parent == nullptr) }; -- cgit v1.2.3