summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-11-18 15:43:50 -0800
committerJosh Blum <josh@joshknows.com>2010-11-18 15:43:50 -0800
commitdd03a2a0dff2d34e7ffca95531eaa42c85fd756c (patch)
tree7ea89df802af80caed907d18173f990689662764
parent28d49657a959feeec9142094735fb4e184c3e9a4 (diff)
parent89ae5f3f651cff22226e2b2c0ce0ed796dad4c71 (diff)
downloaduhd-dd03a2a0dff2d34e7ffca95531eaa42c85fd756c.tar.gz
uhd-dd03a2a0dff2d34e7ffca95531eaa42c85fd756c.tar.bz2
uhd-dd03a2a0dff2d34e7ffca95531eaa42c85fd756c.zip
Merge branches 'master' and 'master' of ettus.sourcerepo.com:ettus/uhdpriv
-rw-r--r--host/include/uhd/config.hpp6
-rw-r--r--host/include/uhd/types/ranges.hpp5
-rw-r--r--host/lib/transport/udp_simple.cpp13
-rw-r--r--host/lib/types.cpp7
-rw-r--r--host/test/convert_types_test.cpp15
5 files changed, 38 insertions, 8 deletions
diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp
index 2918c2340..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,13 +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 UHD_EXIMP_TMPL UHD_HELPER_EXIMP_TMPL
#else
#define UHD_API UHD_HELPER_DLL_IMPORT
+ #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 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 b13f80ae4..03aa69ba8 100644
--- a/host/include/uhd/types/ranges.hpp
+++ b/host/include/uhd/types/ranges.hpp
@@ -22,6 +22,7 @@
#include <uhd/utils/pimpl.hpp>
#include <string>
#include <vector>
+#include <string>
namespace uhd{
@@ -112,11 +113,11 @@ namespace uhd{
};
//! export a symbol for the gain range type
- template struct UHD_API meta_range_t<float>;
+ UHD_EXIMP_TMPL template struct UHD_API meta_range_t<float>;
typedef meta_range_t<float> gain_range_t;
//! export a symbol for the freq range type
- template struct UHD_API meta_range_t<double>;
+ UHD_EXIMP_TMPL template struct UHD_API meta_range_t<double>;
typedef meta_range_t<double> freq_range_t;
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)*/
}
/***********************************************************************
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 <uhd/types/clock_config.hpp>
#include <uhd/types/stream_cmd.hpp>
#include <uhd/types/metadata.hpp>
+#include <uhd/types/ranges.hpp>
#include <uhd/types/time_spec.hpp>
#include <uhd/types/device_addr.hpp>
#include <uhd/types/mac_addr.hpp>
@@ -40,6 +41,12 @@
using namespace uhd;
/***********************************************************************
+ * ranges template instantiation
+ **********************************************************************/
+template struct uhd::meta_range_t<float>;
+template struct uhd::meta_range_t<double>;
+
+/***********************************************************************
* tune request
**********************************************************************/
tune_request_t::tune_request_t(double target_freq):
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 <typename T> const void * pod2ptr(const T &pod){
return boost::asio::buffer_cast<const void *>(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));
}
}