diff options
author | Nicholas Corgan <nick.corgan@ettus.com> | 2014-07-07 15:31:33 -0700 |
---|---|---|
committer | Nicholas Corgan <nick.corgan@ettus.com> | 2014-07-07 15:31:33 -0700 |
commit | 3b6ca994ca2219d3834814d3175ef6aec04b33fb (patch) | |
tree | f3b58aee799276f40317f518eb548b1fd16b0be5 /gnuradio-runtime/lib | |
parent | 597b93798a804cde1783d6d2ab53b348d57c44cd (diff) |
Windows compatibility fixes
* Fixed usage of Windows thread-naming API, changed minimum Windows version
* Fixed MSVC usage of isnan, round
Diffstat (limited to 'gnuradio-runtime/lib')
-rw-r--r-- | gnuradio-runtime/lib/block.cc | 2 | ||||
-rw-r--r-- | gnuradio-runtime/lib/math/qa_fast_atan2f.cc | 12 | ||||
-rw-r--r-- | gnuradio-runtime/lib/thread/thread.cc | 26 | ||||
-rw-r--r-- | gnuradio-runtime/lib/tpb_thread_body.cc | 5 |
4 files changed, 31 insertions, 14 deletions
diff --git a/gnuradio-runtime/lib/block.cc b/gnuradio-runtime/lib/block.cc index 9e4fcf5cca..108c852db4 100644 --- a/gnuradio-runtime/lib/block.cc +++ b/gnuradio-runtime/lib/block.cc @@ -30,7 +30,6 @@ #include <gnuradio/buffer.h> #include <gnuradio/prefs.h> #include <gnuradio/config.h> -#include <gnuradio/rpcregisterhelpers.h> #include <stdexcept> #include <iostream> @@ -796,6 +795,7 @@ namespace gr { { d_pc_rpc_set = true; #if defined(GR_CTRLPORT) && defined(GR_PERFORMANCE_COUNTERS) +#include <gnuradio/rpcregisterhelpers.h> d_rpc_vars.push_back( rpcbasic_sptr(new rpcbasic_register_trigger<block>( alias(), "reset_perf_counters", &block::reset_perf_counters, diff --git a/gnuradio-runtime/lib/math/qa_fast_atan2f.cc b/gnuradio-runtime/lib/math/qa_fast_atan2f.cc index 2ec4ecb182..b704756798 100644 --- a/gnuradio-runtime/lib/math/qa_fast_atan2f.cc +++ b/gnuradio-runtime/lib/math/qa_fast_atan2f.cc @@ -30,6 +30,12 @@ #include <cmath> #include <limits> +#ifdef _MSC_VER +#define isnan _isnan +#else +using std::isnan; +#endif + void qa_fast_atan2f::t1() { @@ -92,7 +98,7 @@ qa_fast_atan2f::t2() x = inf; y = inf; gr_atan2f = gr::fast_atan2f(x, y); - CPPUNIT_ASSERT(std::isnan(gr_atan2f)); + CPPUNIT_ASSERT(isnan(gr_atan2f)); /* Test x as NAN */ @@ -123,11 +129,11 @@ qa_fast_atan2f::t2() x = inf; y = nan; gr_atan2f = gr::fast_atan2f(x, y); - CPPUNIT_ASSERT(std::isnan(gr_atan2f)); + CPPUNIT_ASSERT(isnan(gr_atan2f)); x = nan; y = inf; gr_atan2f = gr::fast_atan2f(x, y); - CPPUNIT_ASSERT(std::isnan(gr_atan2f)); + CPPUNIT_ASSERT(isnan(gr_atan2f)); } diff --git a/gnuradio-runtime/lib/thread/thread.cc b/gnuradio-runtime/lib/thread/thread.cc index e393ae5438..483dfed493 100644 --- a/gnuradio-runtime/lib/thread/thread.cc +++ b/gnuradio-runtime/lib/thread/thread.cc @@ -120,21 +120,14 @@ namespace gr { DWORD dwFlags; // Reserved for future use, must be zero } THREADNAME_INFO; #pragma pack(pop) - void - set_thread_name(gr_thread_t thread, std::string name) + static void + _set_thread_name(gr_thread_t thread, const char* name, DWORD dwThreadId) { const DWORD SET_THREAD_NAME_EXCEPTION = 0x406D1388; - DWORD dwThreadId = GetThreadId(thread); - if (dwThreadId == 0) - return; - - if (name.empty()) - name = boost::str(boost::format("thread %lu") % dwThreadId); - THREADNAME_INFO info; info.dwType = 0x1000; - info.szName = name.c_str(); + info.szName = name; info.dwThreadID = dwThreadId; info.dwFlags = 0; @@ -147,6 +140,19 @@ namespace gr { } } + void + set_thread_name(gr_thread_t thread, std::string name) + { + DWORD dwThreadId = GetThreadId(thread); + if (dwThreadId == 0) + return; + + if (name.empty()) + name = boost::str(boost::format("thread %lu") % dwThreadId); + + _set_thread_name(thread, name.c_str(), dwThreadId); + } + } /* namespace thread */ } /* namespace gr */ diff --git a/gnuradio-runtime/lib/tpb_thread_body.cc b/gnuradio-runtime/lib/tpb_thread_body.cc index d2f0fce833..d80ab860fa 100644 --- a/gnuradio-runtime/lib/tpb_thread_body.cc +++ b/gnuradio-runtime/lib/tpb_thread_body.cc @@ -37,7 +37,12 @@ namespace gr { { //std::cerr << "tpb_thread_body: " << block << std::endl; +#ifdef _MSC_VER + #include <Windows.h> + thread::set_thread_name(GetCurrentThread(), boost::str(boost::format("%s%d") % block->name() % block->unique_id())); +#else thread::set_thread_name(pthread_self(), boost::str(boost::format("%s%d") % block->name() % block->unique_id())); +#endif block_detail *d = block->detail().get(); block_executor::state s; |