aboutsummaryrefslogtreecommitdiffstats
path: root/common/nextpnr.h
diff options
context:
space:
mode:
authorClifford Wolf <cliffordvienna@gmail.com>2018-07-25 11:07:51 +0000
committerClifford Wolf <cliffordvienna@gmail.com>2018-07-25 11:07:51 +0000
commitf3dab003e7b9a417a490f341f7e4dd28d7417caf (patch)
tree0755eff0f628d039bbc47548bed959f6352c5556 /common/nextpnr.h
parent9bcdf2000901a49d96b3ccd16fcb154ff7abc7b3 (diff)
parent1e71621f6517faca01f1351ec60dd51288e14ec8 (diff)
downloadnextpnr-f3dab003e7b9a417a490f341f7e4dd28d7417caf.tar.gz
nextpnr-f3dab003e7b9a417a490f341f7e4dd28d7417caf.tar.bz2
nextpnr-f3dab003e7b9a417a490f341f7e4dd28d7417caf.zip
Merge branch 'bba' into 'master'
bbasm See merge request SymbioticEDA/nextpnr!18
Diffstat (limited to 'common/nextpnr.h')
-rw-r--r--common/nextpnr.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/common/nextpnr.h b/common/nextpnr.h
index 4a1aaac1..f391469c 100644
--- a/common/nextpnr.h
+++ b/common/nextpnr.h
@@ -23,10 +23,10 @@
#include <condition_variable>
#include <memory>
#include <mutex>
-#include <pthread.h>
#include <stdexcept>
#include <stdint.h>
#include <string>
+#include <thread>
#include <unordered_map>
#include <unordered_set>
#include <vector>
@@ -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__))
@@ -354,7 +354,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
@@ -387,12 +387,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();
}