summaryrefslogtreecommitdiff
path: root/gnuradio-runtime
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime')
-rwxr-xr-xgnuradio-runtime/examples/mp-sched/affinity_set.py8
-rwxr-xr-xgnuradio-runtime/examples/mp-sched/plot_flops.py15
-rwxr-xr-xgnuradio-runtime/examples/mp-sched/run_synthetic.py39
-rw-r--r--gnuradio-runtime/include/gnuradio/attributes.h11
-rw-r--r--gnuradio-runtime/include/gnuradio/high_res_timer.h2
-rw-r--r--gnuradio-runtime/include/gnuradio/types.h23
-rw-r--r--gnuradio-runtime/lib/CMakeLists.txt8
-rw-r--r--gnuradio-runtime/lib/flat_flowgraph.cc4
-rw-r--r--gnuradio-runtime/lib/math/random.cc2
-rw-r--r--gnuradio-runtime/lib/realtime_impl.cc70
-rw-r--r--gnuradio-runtime/lib/scheduler.h2
-rw-r--r--gnuradio-runtime/lib/thread/thread.cc10
-rw-r--r--gnuradio-runtime/lib/thread/thread_body_wrapper.cc2
-rw-r--r--gnuradio-runtime/lib/tpb_thread_body.cc4
-rw-r--r--gnuradio-runtime/python/gnuradio/__init__.py3
-rw-r--r--gnuradio-runtime/python/gnuradio/eng_option.py16
16 files changed, 94 insertions, 125 deletions
diff --git a/gnuradio-runtime/examples/mp-sched/affinity_set.py b/gnuradio-runtime/examples/mp-sched/affinity_set.py
index 15d2233b6a..e6637b44bf 100755
--- a/gnuradio-runtime/examples/mp-sched/affinity_set.py
+++ b/gnuradio-runtime/examples/mp-sched/affinity_set.py
@@ -8,9 +8,9 @@ from gnuradio import eng_notation
from gnuradio import gr
from gnuradio import blocks
from gnuradio import filter
-from gnuradio.eng_option import eng_option
+from gnuradio.eng_arg import eng_arg
from gnuradio.filter import firdes
-from optparse import OptionParser
+from argparse import ArgumentParser
import sys
class affinity_set(gr.top_block):
@@ -51,8 +51,8 @@ class affinity_set(gr.top_block):
self.samp_rate = samp_rate
if __name__ == '__main__':
- parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
- (options, args) = parser.parse_args()
+ parser = ArgumentParser()
+ args = parser.parse_args()
tb = affinity_set()
tb.start()
diff --git a/gnuradio-runtime/examples/mp-sched/plot_flops.py b/gnuradio-runtime/examples/mp-sched/plot_flops.py
index d9d810ae2f..c80820b8a3 100755
--- a/gnuradio-runtime/examples/mp-sched/plot_flops.py
+++ b/gnuradio-runtime/examples/mp-sched/plot_flops.py
@@ -28,7 +28,7 @@ import re
import sys
import os
import tempfile
-from optparse import OptionParser
+from argparse import ArgumentParser
def parse_file(input_filename, output):
@@ -84,14 +84,11 @@ def handle_file(input_filename):
def main():
- usage = "usage: %prog [options] file.dat"
- parser = OptionParser(usage=usage)
- (options, args) = parser.parse_args()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
-
- handle_file(args[0])
+ parser = ArgumentParser()
+ parser.add_argument('file', help='Input file', nargs=1)
+ args = parser.parse_args()
+
+ handle_file(args.file[0])
if __name__ == '__main__':
diff --git a/gnuradio-runtime/examples/mp-sched/run_synthetic.py b/gnuradio-runtime/examples/mp-sched/run_synthetic.py
index 4896bca462..802fb9fd34 100755
--- a/gnuradio-runtime/examples/mp-sched/run_synthetic.py
+++ b/gnuradio-runtime/examples/mp-sched/run_synthetic.py
@@ -27,7 +27,7 @@ import re
import sys
import os
import tempfile
-from optparse import OptionParser
+from argparse import ArgumentParser
def write_shell_script(f, data_filename, description, ncores, gflops, max_pipes_and_stages):
@@ -70,31 +70,26 @@ total runtime of about 43 minutes, assuming that your values for -n and -f are r
For x86 machines, assume 3 FLOPS per processor Hz. E.g., 3 GHz machine -> 9 GFLOPS.
plot_flops.py will make pretty graphs from the output data generated by %prog.
"""
- usage = "usage: %prog [options] output.dat"
- parser = OptionParser(usage=usage, description=description)
- parser.add_option("-d", "--description", metavar="DESC",
- help="machine description, e.g., \"Dual quad-core Xeon 3 GHz\"", default=None)
- parser.add_option("-n", "--ncores", type="int", default=1,
- help="number of processor cores [default=%default]")
- parser.add_option("-g", "--gflops", metavar="GFLOPS", type="float", default=3.0,
- help="estimated GFLOPS per core [default=%default]")
- parser.add_option("-m", "--max-pipes-and-stages", metavar="MAX", type="int", default=16,
- help="maximum number of pipes and stages to use [default=%default]")
- (options, args) = parser.parse_args()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
-
- output_filename = args[0]
+ parser = ArgumentParser(description=description)
+ parser.add_argument("-d", "--description", metavar="DESC",
+ help="machine description, e.g., \"Dual quad-core Xeon 3 GHz\"")
+ parser.add_argument("-n", "--ncores", type=int, default=1,
+ help="number of processor cores [default=%(default)s]")
+ parser.add_argument("-g", "--gflops", metavar="GFLOPS", type=float, default=3.0,
+ help="estimated GFLOPS per core [default=%(default)s]")
+ parser.add_argument("-m", "--max-pipes-and-stages", metavar="MAX", type=int, default=16,
+ help="maximum number of pipes and stages to use [default=%(default)s]")
+ parser.add_argument("output_file_name", metavar="FILE", help="output file name")
+ args = parser.parse_args()
shell = os.popen("/bin/sh", "w")
write_shell_script(shell,
- output_filename,
- options.description,
- options.ncores,
- options.gflops,
- options.max_pipes_and_stages)
+ args.output_file_name,
+ args.description,
+ args.ncores,
+ args.gflops,
+ args.max_pipes_and_stages)
if __name__ == '__main__':
main()
diff --git a/gnuradio-runtime/include/gnuradio/attributes.h b/gnuradio-runtime/include/gnuradio/attributes.h
index 3d2e764cd5..0102c110c2 100644
--- a/gnuradio-runtime/include/gnuradio/attributes.h
+++ b/gnuradio-runtime/include/gnuradio/attributes.h
@@ -78,4 +78,15 @@
# pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
#endif
+////////////////////////////////////////////////////////////////////////
+// implement cross-compiler VLA macros
+////////////////////////////////////////////////////////////////////////
+#ifdef C99
+# define __GR_VLA(TYPE, buf, size) TYPE buf[size]
+# define __GR_VLA2D(TYPE, buf, size, size2) TYPE buf[size][size2]
+#else
+# define __GR_VLA(TYPE, buf, size) TYPE * buf = (TYPE *) alloca(sizeof(TYPE) * (size))
+# define __GR_VLA2D(TYPE, buf, size, size2) TYPE ** buf = (TYPE **) alloca(sizeof(TYPE) * (size) * (size2))
+#endif
+
#endif /* INCLUDED_GNURADIO_ATTRIBUTES_H */
diff --git a/gnuradio-runtime/include/gnuradio/high_res_timer.h b/gnuradio-runtime/include/gnuradio/high_res_timer.h
index ce11cd8ebb..5f6a285a11 100644
--- a/gnuradio-runtime/include/gnuradio/high_res_timer.h
+++ b/gnuradio-runtime/include/gnuradio/high_res_timer.h
@@ -107,7 +107,7 @@ namespace gr {
////////////////////////////////////////////////////////////////////////
#ifdef GNURADIO_HRT_USE_QUERY_PERFORMANCE_COUNTER
- #include <Windows.h>
+ #include <windows.h>
inline gr::high_res_timer_type gr::high_res_timer_now(void){
LARGE_INTEGER counts;
diff --git a/gnuradio-runtime/include/gnuradio/types.h b/gnuradio-runtime/include/gnuradio/types.h
index 6cb0f72834..c91538e60e 100644
--- a/gnuradio-runtime/include/gnuradio/types.h
+++ b/gnuradio-runtime/include/gnuradio/types.h
@@ -37,29 +37,6 @@ typedef std::vector<double> gr_vector_double;
typedef std::vector<void *> gr_vector_void_star;
typedef std::vector<const void *> gr_vector_const_void_star;
-/*
- * #include <config.h> must be placed beforehand
- * in the source file including gnuradio/types.h for
- * the following to work correctly
- */
-#ifdef HAVE_STDINT_H
#include <stdint.h>
-typedef int16_t gr_int16;
-typedef int32_t gr_int32;
-typedef int64_t gr_int64;
-typedef uint16_t gr_uint16;
-typedef uint32_t gr_uint32;
-typedef uint64_t gr_uint64;
-#else
-/*
- * Note: these defaults may be wrong on 64-bit systems
- */
-typedef short gr_int16;
-typedef int gr_int32;
-typedef long long gr_int64;
-typedef unsigned short gr_uint16;
-typedef unsigned int gr_uint32;
-typedef unsigned long long gr_uint64;
-#endif /* HAVE_STDINT_H */
#endif /* INCLUDED_GR_TYPES_H */
diff --git a/gnuradio-runtime/lib/CMakeLists.txt b/gnuradio-runtime/lib/CMakeLists.txt
index cc51f97855..3da550d37b 100644
--- a/gnuradio-runtime/lib/CMakeLists.txt
+++ b/gnuradio-runtime/lib/CMakeLists.txt
@@ -31,9 +31,9 @@ message(STATUS "Loading build date ${BUILD_DATE} into constants...")
message(STATUS "Loading version ${VERSION} into constants...")
#double escape for windows backslash path separators
-string(REPLACE "\\" "\\\\" prefix ${prefix})
-string(REPLACE "\\" "\\\\" SYSCONFDIR ${SYSCONFDIR})
-string(REPLACE "\\" "\\\\" GR_PREFSDIR ${GR_PREFSDIR})
+string(REPLACE "\\" "\\\\" prefix "${prefix}")
+string(REPLACE "\\" "\\\\" SYSCONFDIR "${SYSCONFDIR}")
+string(REPLACE "\\" "\\\\" GR_PREFSDIR "${GR_PREFSDIR}")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/constants.cc.in
@@ -149,7 +149,7 @@ CHECK_INCLUDE_FILE_CXX(windows.h HAVE_WINDOWS_H)
IF(HAVE_WINDOWS_H)
ADD_DEFINITIONS(-DHAVE_WINDOWS_H -DUSING_WINSOCK -DWIN32_LEAN_AND_MEAN)
MESSAGE(STATUS "Adding windows libs to gnuradio runtime libs...")
- LIST(APPEND gnuradio_runtime_libs WS2_32.lib WSock32.lib)
+ LIST(APPEND gnuradio_runtime_libs ws2_32 wsock32)
ENDIF(HAVE_WINDOWS_H)
#need to link with librt on ubuntu 11.10 for shm_*
diff --git a/gnuradio-runtime/lib/flat_flowgraph.cc b/gnuradio-runtime/lib/flat_flowgraph.cc
index 03e67eb2c2..434a92fb3d 100644
--- a/gnuradio-runtime/lib/flat_flowgraph.cc
+++ b/gnuradio-runtime/lib/flat_flowgraph.cc
@@ -331,7 +331,7 @@ namespace gr {
const int alignment = volk_get_alignment();
for(int i = 0; i < block->detail()->ninputs(); i++) {
void *r = (void*)block->detail()->input(i)->read_pointer();
- unsigned long int ri = (unsigned long int)r % alignment;
+ uintptr_t ri = (uintptr_t)r % alignment;
//std::cerr << "reader: " << r << " alignment: " << ri << std::endl;
if(ri != 0) {
size_t itemsize = block->detail()->input(i)->get_sizeof_item();
@@ -343,7 +343,7 @@ namespace gr {
for(int i = 0; i < block->detail()->noutputs(); i++) {
void *w = (void*)block->detail()->output(i)->write_pointer();
- unsigned long int wi = (unsigned long int)w % alignment;
+ uintptr_t wi = (uintptr_t)w % alignment;
//std::cerr << "writer: " << w << " alignment: " << wi << std::endl;
if(wi != 0) {
size_t itemsize = block->detail()->output(i)->get_sizeof_item();
diff --git a/gnuradio-runtime/lib/math/random.cc b/gnuradio-runtime/lib/math/random.cc
index 5e16c96ea4..35f63076b2 100644
--- a/gnuradio-runtime/lib/math/random.cc
+++ b/gnuradio-runtime/lib/math/random.cc
@@ -127,7 +127,7 @@ namespace gr {
x = 2.0*ran1()-1.0;
y = 2.0*ran1()-1.0;
s = x*x+y*y;
- }while(not(s<1.0));
+ }while(s >= 1.0f || s == 0.0f);
d_gauss_stored = true;
d_gauss_value = x*sqrt(-2.0*log(s)/s);
return y*sqrt(-2.0*log(s)/s);
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 {
diff --git a/gnuradio-runtime/lib/scheduler.h b/gnuradio-runtime/lib/scheduler.h
index 575862b27d..0924808965 100644
--- a/gnuradio-runtime/lib/scheduler.h
+++ b/gnuradio-runtime/lib/scheduler.h
@@ -45,7 +45,7 @@ namespace gr {
/*!
* \brief Construct a scheduler and begin evaluating the graph.
*
- * The scheduler will continue running until all blocks until they
+ * The scheduler will continue running until all blocks
* report that they are done or the stop method is called.
*/
scheduler(flat_flowgraph_sptr ffg, int max_noutput_items);
diff --git a/gnuradio-runtime/lib/thread/thread.cc b/gnuradio-runtime/lib/thread/thread.cc
index 483dfed493..f2606c71ae 100644
--- a/gnuradio-runtime/lib/thread/thread.cc
+++ b/gnuradio-runtime/lib/thread/thread.cc
@@ -28,7 +28,7 @@
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
-#include <Windows.h>
+#include <windows.h>
namespace gr {
namespace thread {
@@ -111,6 +111,7 @@ namespace gr {
// Not implemented on Windows
return -1;
}
+#ifndef __MINGW32__
#pragma pack(push,8)
typedef struct tagTHREADNAME_INFO
{
@@ -152,6 +153,13 @@ namespace gr {
_set_thread_name(thread, name.c_str(), dwThreadId);
}
+#else
+ void
+ set_thread_name(gr_thread_t thread, std::string name)
+ {
+ /* Not implemented on mingw-w64 */
+ }
+#endif /* !__MINGW32__ */
} /* namespace thread */
} /* namespace gr */
diff --git a/gnuradio-runtime/lib/thread/thread_body_wrapper.cc b/gnuradio-runtime/lib/thread/thread_body_wrapper.cc
index e23b7d15d0..fffa7e4c44 100644
--- a/gnuradio-runtime/lib/thread/thread_body_wrapper.cc
+++ b/gnuradio-runtime/lib/thread/thread_body_wrapper.cc
@@ -34,7 +34,7 @@
namespace gr {
namespace thread {
-#if defined(HAVE_PTHREAD_SIGMASK) && defined(HAVE_SIGNAL_H)
+#if defined(HAVE_PTHREAD_SIGMASK) && defined(HAVE_SIGNAL_H) && !defined(__MINGW32__)
void mask_signals()
{
diff --git a/gnuradio-runtime/lib/tpb_thread_body.cc b/gnuradio-runtime/lib/tpb_thread_body.cc
index e0aacb4153..e3f57eef53 100644
--- a/gnuradio-runtime/lib/tpb_thread_body.cc
+++ b/gnuradio-runtime/lib/tpb_thread_body.cc
@@ -37,8 +37,8 @@ namespace gr {
{
//std::cerr << "tpb_thread_body: " << block << std::endl;
-#ifdef _MSC_VER
- #include <Windows.h>
+#if defined(_MSC_VER) || defined(__MINGW32__)
+ #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()));
diff --git a/gnuradio-runtime/python/gnuradio/__init__.py b/gnuradio-runtime/python/gnuradio/__init__.py
index dd7b89650b..263ac28e6e 100644
--- a/gnuradio-runtime/python/gnuradio/__init__.py
+++ b/gnuradio-runtime/python/gnuradio/__init__.py
@@ -38,12 +38,9 @@ if path.endswith(path_ending):
__path__.append(os.path.join(build_path, 'gr-audio', 'python'))
__path__.append(os.path.join(build_path, 'gr-qtgui', 'python'))
__path__.append(os.path.join(build_path, 'gr-wxgui', 'python'))
- __path__.append(os.path.join(build_path, 'gr-atsc', 'python'))
- __path__.append(os.path.join(build_path, 'gr-noaa', 'python'))
__path__.append(os.path.join(build_path, 'gr-pager', 'python'))
__path__.append(os.path.join(build_path, 'gr-video-sdl', 'python'))
__path__.append(os.path.join(build_path, 'gr-vocoder', 'python'))
- __path__.append(os.path.join(build_path, 'gr-fcd', 'python'))
__path__.append(os.path.join(build_path, 'gr-comedi', 'python'))
__path__.append(os.path.join(build_path, 'gr-channels', 'python'))
__path__.append(os.path.join(build_path, 'gr-fec', 'python'))
diff --git a/gnuradio-runtime/python/gnuradio/eng_option.py b/gnuradio-runtime/python/gnuradio/eng_option.py
index 5d8660f0f2..ae000fe442 100644
--- a/gnuradio-runtime/python/gnuradio/eng_option.py
+++ b/gnuradio-runtime/python/gnuradio/eng_option.py
@@ -39,25 +39,9 @@ def check_intx (option, opt, value):
raise OptionValueError (
"option %s: invalid integer value: %r" % (opt, value))
-def check_subdev (option, opt, value):
- """
- Value has the form: (A|B)(:0|1)?
-
- Returns:
- a 2-tuple (0|1, 0|1)
- """
- d = { 'A' : (0, 0), 'A:0' : (0, 0), 'A:1' : (0, 1), 'A:2' : (0, 2),
- 'B' : (1, 0), 'B:0' : (1, 0), 'B:1' : (1, 1), 'B:2' : (1, 2) }
- try:
- return d[value.upper()]
- except:
- raise OptionValueError(
- "option %s: invalid subdev: '%r', must be one of %s" % (opt, value, ', '.join(sorted(d.keys()))))
-
class eng_option (Option):
TYPES = Option.TYPES + ("eng_float", "intx", "subdev")
TYPE_CHECKER = copy (Option.TYPE_CHECKER)
TYPE_CHECKER["eng_float"] = check_eng_float
TYPE_CHECKER["intx"] = check_intx
- TYPE_CHECKER["subdev"] = check_subdev