From 25142dad0464bed59dc03672931aab637f82d376 Mon Sep 17 00:00:00 2001
From: Paul Cercueil <paul.cercueil@analog.com>
Date: Mon, 14 Sep 2015 14:53:35 +0200
Subject: cmake: Windows-specific fixes for compatibility

* Properly wrap the prefix variables in quotation marks. This allows
  to set an empty prefix.

* Fix library names when compiling for Windows. This now also works
  when using mingw-w64.

* Fix boost module name when compiling with mingw-w64

* Fix build under mingw-w64

* Fix config.h header to avoid macro redefinition

* Remove duplicated Boost::thread entry in dependencies list
---
 gnuradio-runtime/lib/realtime_impl.cc | 70 +++++++++++++++++------------------
 1 file changed, 35 insertions(+), 35 deletions(-)

(limited to 'gnuradio-runtime/lib/realtime_impl.cc')

diff --git a/gnuradio-runtime/lib/realtime_impl.cc b/gnuradio-runtime/lib/realtime_impl.cc
index 54db9d8d70..83afd9568d 100644
--- a/gnuradio-runtime/lib/realtime_impl.cc
+++ b/gnuradio-runtime/lib/realtime_impl.cc
@@ -65,7 +65,41 @@ namespace gr {
 #endif
 
 
-#if defined(HAVE_PTHREAD_SETSCHEDPARAM)
+#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
+
+#include <windows.h>
+
+namespace gr {
+  namespace impl {
+
+    rt_status_t enable_realtime_scheduling(rt_sched_param p)
+    {
+      //set the priority class on the process
+      int pri_class = (true)? REALTIME_PRIORITY_CLASS : NORMAL_PRIORITY_CLASS;
+      if(SetPriorityClass(GetCurrentProcess(), pri_class) == 0)
+        return RT_OTHER_ERROR;
+
+      //scale the priority value to the constants
+      int priorities[] = {
+        THREAD_PRIORITY_IDLE, THREAD_PRIORITY_LOWEST, THREAD_PRIORITY_BELOW_NORMAL, THREAD_PRIORITY_NORMAL,
+        THREAD_PRIORITY_ABOVE_NORMAL, THREAD_PRIORITY_HIGHEST, THREAD_PRIORITY_TIME_CRITICAL
+      };
+      const double priority = double(p.priority)/(rt_priority_max() - rt_priority_min());
+      size_t pri_index = size_t((priority+1.0)*6/2.0); // -1 -> 0, +1 -> 6
+      pri_index %= sizeof(priorities)/sizeof(*priorities); //range check
+
+      //set the thread priority on the thread
+      if(SetThreadPriority(GetCurrentThread(), priorities[pri_index]) == 0)
+        return RT_OTHER_ERROR;
+
+      //printf("SetPriorityClass + SetThreadPriority\n");
+      return RT_OK;
+    }
+
+  } // namespace impl
+} // namespace gr
+
+#elif defined(HAVE_PTHREAD_SETSCHEDPARAM)
 
 namespace gr {
   namespace impl {
@@ -141,40 +175,6 @@ namespace gr {
   } // namespace impl
 } // namespace gr
 
-#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
-
-#include <windows.h>
-
-namespace gr {
-  namespace impl {
-
-    rt_status_t enable_realtime_scheduling(rt_sched_param p)
-    {
-      //set the priority class on the process
-      int pri_class = (true)? REALTIME_PRIORITY_CLASS : NORMAL_PRIORITY_CLASS;
-      if(SetPriorityClass(GetCurrentProcess(), pri_class) == 0)
-        return RT_OTHER_ERROR;
-
-      //scale the priority value to the constants
-      int priorities[] = {
-        THREAD_PRIORITY_IDLE, THREAD_PRIORITY_LOWEST, THREAD_PRIORITY_BELOW_NORMAL, THREAD_PRIORITY_NORMAL,
-        THREAD_PRIORITY_ABOVE_NORMAL, THREAD_PRIORITY_HIGHEST, THREAD_PRIORITY_TIME_CRITICAL
-      };
-      const double priority = double(p.priority)/(rt_priority_max() - rt_priority_min());
-      size_t pri_index = size_t((priority+1.0)*6/2.0); // -1 -> 0, +1 -> 6
-      pri_index %= sizeof(priorities)/sizeof(*priorities); //range check
-
-      //set the thread priority on the thread
-      if(SetThreadPriority(GetCurrentThread(), priorities[pri_index]) == 0)
-        return RT_OTHER_ERROR;
-
-      //printf("SetPriorityClass + SetThreadPriority\n");
-      return RT_OK;
-    }
-
-  } // namespace impl
-} // namespace gr
-
 #else
 
 namespace gr {
-- 
cgit v1.2.3