From 755569e66f7a939aa9392a79bf637d823fb78b84 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 17 Nov 2010 09:03:25 -0800 Subject: uhd: ranges symbol fix, try extern macro --- host/include/uhd/config.hpp | 3 +++ host/include/uhd/types/ranges.hpp | 4 ++-- host/lib/types.cpp | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) (limited to 'host') diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp index 2918c2340..043e8d884 100644 --- a/host/include/uhd/config.hpp +++ b/host/include/uhd/config.hpp @@ -75,13 +75,16 @@ #ifdef UHD_DLL // defined if UHD is compiled as a DLL #ifdef UHD_DLL_EXPORTS // defined if we are building the UHD DLL (instead of using it) #define UHD_API UHD_HELPER_DLL_EXPORT + #define EXIMP_TEMPLATE extern #else #define UHD_API UHD_HELPER_DLL_IMPORT + #define EXIMP_TEMPLATE #endif // UHD_DLL_EXPORTS #define UHD_LOCAL UHD_HELPER_DLL_LOCAL #else // UHD_DLL is not defined: this means UHD is a static lib. #define UHD_API #define UHD_LOCAL + #define EXIMP_TEMPLATE #endif // UHD_DLL // Define force inline macro diff --git a/host/include/uhd/types/ranges.hpp b/host/include/uhd/types/ranges.hpp index 623bdca19..25120de40 100644 --- a/host/include/uhd/types/ranges.hpp +++ b/host/include/uhd/types/ranges.hpp @@ -105,11 +105,11 @@ namespace uhd{ }; //! export a symbol for the gain range type - template struct UHD_API meta_range_t; + EXIMP_TEMPLATE template struct UHD_API meta_range_t; typedef meta_range_t gain_range_t; //! export a symbol for the freq range type - template struct UHD_API meta_range_t; + EXIMP_TEMPLATE template struct UHD_API meta_range_t; typedef meta_range_t freq_range_t; diff --git a/host/lib/types.cpp b/host/lib/types.cpp index 8ccb664d5..bea20a4aa 100644 --- a/host/lib/types.cpp +++ b/host/lib/types.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,12 @@ using namespace uhd; +/*********************************************************************** + * ranges template instantiation + **********************************************************************/ +template struct uhd::meta_range_t; +template struct uhd::meta_range_t; + /*********************************************************************** * tune request **********************************************************************/ -- cgit v1.2.3 From d7317dac9360f26444da4043ca066a46749917b3 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 17 Nov 2010 09:21:04 -0800 Subject: udp: added polling alternative to select for mac --- host/lib/transport/udp_simple.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'host') diff --git a/host/lib/transport/udp_simple.cpp b/host/lib/transport/udp_simple.cpp index 5829b462b..6799ac7b2 100644 --- a/host/lib/transport/udp_simple.cpp +++ b/host/lib/transport/udp_simple.cpp @@ -35,6 +35,8 @@ using namespace uhd::transport; static bool wait_available( boost::asio::ip::udp::socket &socket, double timeout ){ + #if defined(UHD_PLATFORM_LINUX) || defined(UHD_PLATFORM_WIN32) + //setup timeval for timeout timeval tv; tv.tv_sec = 0; @@ -46,6 +48,17 @@ static bool wait_available( FD_SET(socket.native(), &rset); return ::select(socket.native()+1, &rset, NULL, NULL, &tv) > 0; + + #else /*defined(UHD_PLATFORM_LINUX) || defined(UHD_PLATFORM_WIN32)*/ + + //FIXME: why does select fail on macintosh? + for (size_t i = 0; i < size_t(timeout*1e3); i++){ + if (socket.available()) return true; + boost::this_thread::sleep(boost::posix_time::milliseconds(1)); + } + return false; + + #endif /*defined(UHD_PLATFORM_LINUX) || defined(UHD_PLATFORM_WIN32)*/ } /*********************************************************************** -- cgit v1.2.3 From 8e8c93a268e8e8eec268a5c829f360154ff9d7d0 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 17 Nov 2010 09:54:56 -0800 Subject: uhd: git diff --- host/test/convert_types_test.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'host') diff --git a/host/test/convert_types_test.cpp b/host/test/convert_types_test.cpp index 2148302b6..378e184de 100644 --- a/host/test/convert_types_test.cpp +++ b/host/test/convert_types_test.cpp @@ -38,6 +38,9 @@ template const void * pod2ptr(const T &pod){ return boost::asio::buffer_cast(boost::asio::buffer(pod)); } +#define MY_CHECK_CLOSE(a, b, f) if ((std::abs(a) > (f) and std::abs(b) > (f))) \ + BOOST_CHECK_CLOSE_FRACTION(a, b, f) + /*********************************************************************** * Loopback runner: * convert input buffer into intermediate buffer @@ -130,8 +133,8 @@ static void test_convert_types_fc32( //run the loopback and test loopback(nsamps, io_type, otw_type, input, output); for (size_t i = 0; i < nsamps; i++){ - BOOST_CHECK_CLOSE_FRACTION(input[i].real(), output[i].real(), float(0.01)); - BOOST_CHECK_CLOSE_FRACTION(input[i].imag(), output[i].imag(), float(0.01)); + MY_CHECK_CLOSE(input[i].real(), output[i].real(), float(0.01)); + MY_CHECK_CLOSE(input[i].imag(), output[i].imag(), float(0.01)); } } @@ -195,8 +198,8 @@ BOOST_AUTO_TEST_CASE(test_convert_types_fc32_to_sc16){ //test that the inputs and outputs match for (size_t i = 0; i < nsamps; i++){ - BOOST_CHECK_CLOSE_FRACTION(input[i].real(), output[i].real()/float(32767), float(0.01)); - BOOST_CHECK_CLOSE_FRACTION(input[i].imag(), output[i].imag()/float(32767), float(0.01)); + MY_CHECK_CLOSE(input[i].real(), output[i].real()/float(32767), float(0.01)); + MY_CHECK_CLOSE(input[i].imag(), output[i].imag()/float(32767), float(0.01)); } } @@ -236,7 +239,7 @@ BOOST_AUTO_TEST_CASE(test_convert_types_sc16_to_fc32){ //test that the inputs and outputs match for (size_t i = 0; i < nsamps; i++){ - BOOST_CHECK_CLOSE_FRACTION(input[i].real()/float(32767), output[i].real(), float(0.01)); - BOOST_CHECK_CLOSE_FRACTION(input[i].imag()/float(32767), output[i].imag(), float(0.01)); + MY_CHECK_CLOSE(input[i].real()/float(32767), output[i].real(), float(0.01)); + MY_CHECK_CLOSE(input[i].imag()/float(32767), output[i].imag(), float(0.01)); } } -- cgit v1.2.3 From daa537d329f8e758b86db3d98500f211e4736f55 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 17 Nov 2010 10:02:37 -0800 Subject: uhd: added to printable string methods for ranges --- host/include/uhd/types/ranges.hpp | 9 ++++++++- host/include/uhd/types/ranges.ipp | 19 ++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'host') diff --git a/host/include/uhd/types/ranges.hpp b/host/include/uhd/types/ranges.hpp index 25120de40..8a7ca0310 100644 --- a/host/include/uhd/types/ranges.hpp +++ b/host/include/uhd/types/ranges.hpp @@ -21,6 +21,7 @@ #include #include #include +#include namespace uhd{ @@ -55,8 +56,11 @@ namespace uhd{ //! Get the step value for this range. const T step(void) const; + //! Convert this range to a printable string + const std::string to_pp_string(void) const; + private: - UHD_PIMPL_DECL(impl) _impl; + UHD_PIMPL_DECL(impl) _impl; }; /*! @@ -102,6 +106,9 @@ namespace uhd{ */ const T clip(const T &value, bool clip_step = false) const; + //! Convert this meta-range to a printable string + const std::string to_pp_string(void) const; + }; //! export a symbol for the gain range type diff --git a/host/include/uhd/types/ranges.ipp b/host/include/uhd/types/ranges.ipp index 8b602a24d..29f389fca 100644 --- a/host/include/uhd/types/ranges.ipp +++ b/host/include/uhd/types/ranges.ipp @@ -22,7 +22,7 @@ #include #include #include -#include +#include namespace uhd{ @@ -66,6 +66,15 @@ namespace uhd{ return _impl->step; } + template const std::string range_t::to_pp_string(void) const{ + std::stringstream ss; + ss << "(" << this->start(); + if (this->start() != this->stop()) ss << ", " << this->stop(); + if (this->step() != T(0)) ss << ", " << this->step(); + ss << ")"; + return ss.str(); + } + /******************************************************************* * meta_range_t implementation code ******************************************************************/ @@ -163,6 +172,14 @@ namespace uhd{ return last_stop; } + template const std::string meta_range_t::to_pp_string(void) const{ + std::stringstream ss; + BOOST_FOREACH(const range_t &r, (*this)){ + ss << r.to_pp_string() << std::endl; + } + return ss.str(); + } + } //namespace uhd #endif /* INCLUDED_UHD_TYPES_RANGES_IPP */ -- cgit v1.2.3 From 56876b0ec80371dbbc3817c36d9e9bbfa396814d Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 17 Nov 2010 10:30:51 -0800 Subject: uhd: tweaking the export template instance macro --- host/include/uhd/config.hpp | 9 ++++++--- host/include/uhd/types/ranges.hpp | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'host') diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp index 043e8d884..316d60c2b 100644 --- a/host/include/uhd/config.hpp +++ b/host/include/uhd/config.hpp @@ -56,14 +56,17 @@ #define UHD_HELPER_DLL_IMPORT __declspec(dllimport) #define UHD_HELPER_DLL_EXPORT __declspec(dllexport) #define UHD_HELPER_DLL_LOCAL + #define UHD_HELPER_EXIMP_TMPL #elif defined(__GNUG__) && __GNUG__ >= 4 #define UHD_HELPER_DLL_IMPORT __attribute__ ((visibility("default"))) #define UHD_HELPER_DLL_EXPORT __attribute__ ((visibility("default"))) #define UHD_HELPER_DLL_LOCAL __attribute__ ((visibility("hidden"))) + #define UHD_HELPER_EXIMP_TMPL extern #else #define UHD_HELPER_DLL_IMPORT #define UHD_HELPER_DLL_EXPORT #define UHD_HELPER_DLL_LOCAL + #define UHD_HELPER_EXIMP_TMPL extern #endif // Now we use the generic helper definitions above to define UHD_API and UHD_LOCAL. @@ -75,16 +78,16 @@ #ifdef UHD_DLL // defined if UHD is compiled as a DLL #ifdef UHD_DLL_EXPORTS // defined if we are building the UHD DLL (instead of using it) #define UHD_API UHD_HELPER_DLL_EXPORT - #define EXIMP_TEMPLATE extern + #define UHD_EXIMP_TMPL UHD_HELPER_EXIMP_TMPL #else #define UHD_API UHD_HELPER_DLL_IMPORT - #define EXIMP_TEMPLATE + #define UHD_EXIMP_TMPL #endif // UHD_DLL_EXPORTS #define UHD_LOCAL UHD_HELPER_DLL_LOCAL #else // UHD_DLL is not defined: this means UHD is a static lib. #define UHD_API #define UHD_LOCAL - #define EXIMP_TEMPLATE + #define UHD_EXIMP_TMPL #endif // UHD_DLL // Define force inline macro diff --git a/host/include/uhd/types/ranges.hpp b/host/include/uhd/types/ranges.hpp index 8a7ca0310..1bd87b468 100644 --- a/host/include/uhd/types/ranges.hpp +++ b/host/include/uhd/types/ranges.hpp @@ -112,11 +112,11 @@ namespace uhd{ }; //! export a symbol for the gain range type - EXIMP_TEMPLATE template struct UHD_API meta_range_t; + UHD_EXIMP_TMPL template struct UHD_API meta_range_t; typedef meta_range_t gain_range_t; //! export a symbol for the freq range type - EXIMP_TEMPLATE template struct UHD_API meta_range_t; + UHD_EXIMP_TMPL template struct UHD_API meta_range_t; typedef meta_range_t freq_range_t; -- cgit v1.2.3