commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 02/05: Windows compatibility fixes


From: git
Subject: [Commit-gnuradio] [gnuradio] 02/05: Windows compatibility fixes
Date: Tue, 8 Jul 2014 21:27:47 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch maint
in repository gnuradio.

commit 3b6ca994ca2219d3834814d3175ef6aec04b33fb
Author: Nicholas Corgan <address@hidden>
Date:   Mon Jul 7 15:31:33 2014 -0700

    Windows compatibility fixes
    
    * Fixed usage of Windows thread-naming API, changed minimum Windows version
    * Fixed MSVC usage of isnan, round
---
 CMakeLists.txt                              |  2 +-
 gnuradio-runtime/lib/block.cc               |  2 +-
 gnuradio-runtime/lib/math/qa_fast_atan2f.cc | 12 +++++++++---
 gnuradio-runtime/lib/thread/thread.cc       | 26 ++++++++++++++++----------
 gnuradio-runtime/lib/tpb_thread_body.cc     |  5 +++++
 gr-filter/lib/pfb_channelizer_ccf_impl.cc   |  4 ++++
 gr-vocoder/lib/codec2/fdmdv.c               |  4 ++++
 7 files changed, 40 insertions(+), 15 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 404ce04..55dabeb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -86,7 +86,7 @@ endif(CMAKE_COMPILER_IS_GNUCXX)
 
 if(MSVC)
     include_directories(${CMAKE_SOURCE_DIR}/cmake/msvc) #missing headers
-    add_definitions(-D_WIN32_WINNT=0x0501) #minimum version required is 
windows xp
+    add_definitions(-D_WIN32_WINNT=0x0502) #Minimum version: "Windows Server 
2003 with SP1, Windows XP with SP2"
     add_definitions(-DNOMINMAX) #disables stupidity and enables std::min and 
std::max
     add_definitions( #stop all kinds of compatibility warnings
         -D_SCL_SECURE_NO_WARNINGS
diff --git a/gnuradio-runtime/lib/block.cc b/gnuradio-runtime/lib/block.cc
index 9e4fcf5..108c852 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 2ec4ecb..b704756 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 e393ae5..483dfed 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 d2f0fce..d80ab86 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;
diff --git a/gr-filter/lib/pfb_channelizer_ccf_impl.cc 
b/gr-filter/lib/pfb_channelizer_ccf_impl.cc
index fe1966b..c439353 100644
--- a/gr-filter/lib/pfb_channelizer_ccf_impl.cc
+++ b/gr-filter/lib/pfb_channelizer_ccf_impl.cc
@@ -28,6 +28,10 @@
 #include <gnuradio/io_signature.h>
 #include <stdio.h>
 
+#ifdef _MSC_VER
+#define round(number) number < 0.0 ? ceil(number - 0.5) : floor(number + 0.5)
+#endif
+
 namespace gr {
   namespace filter {
 
diff --git a/gr-vocoder/lib/codec2/fdmdv.c b/gr-vocoder/lib/codec2/fdmdv.c
index 6af1cf4..8855f76 100644
--- a/gr-vocoder/lib/codec2/fdmdv.c
+++ b/gr-vocoder/lib/codec2/fdmdv.c
@@ -25,6 +25,10 @@
   along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
 
+#ifdef _MSC_VER
+#define round(number) number < 0.0 ? ceil(number - 0.5) : floor(number + 0.5)
+#endif
+
 /*---------------------------------------------------------------------------*\
 
                                INCLUDES



reply via email to

[Prev in Thread] Current Thread [Next in Thread]