summaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-01-04 16:50:18 -0800
committerJosh Blum <josh@joshknows.com>2011-01-04 16:50:18 -0800
commit78085d3c101e0dbaf95393904c8c06ca5279cc42 (patch)
tree10372369d97f5c7baef0c35c2dd1558444ed8496 /host/include
parentfabfa8d9dd6670afb9c621b9ee12f8d602d7ccda (diff)
parentdf11c4d378ebe11ba4864d5a28559b8cb4af98c4 (diff)
downloaduhd-78085d3c101e0dbaf95393904c8c06ca5279cc42.tar.gz
uhd-78085d3c101e0dbaf95393904c8c06ca5279cc42.tar.bz2
uhd-78085d3c101e0dbaf95393904c8c06ca5279cc42.zip
Merge branch 'buffer_pool' into next
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/config.hpp100
-rw-r--r--host/include/uhd/transport/CMakeLists.txt1
-rw-r--r--host/include/uhd/transport/buffer_pool.hpp59
-rw-r--r--host/include/uhd/transport/if_addrs.hpp6
-rw-r--r--host/include/uhd/types/dict.hpp4
-rw-r--r--host/include/uhd/types/dict.ipp4
-rw-r--r--host/include/uhd/usrp/dboard_manager.hpp2
7 files changed, 108 insertions, 68 deletions
diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp
index 9a29fb246..62c2504e1 100644
--- a/host/include/uhd/config.hpp
+++ b/host/include/uhd/config.hpp
@@ -18,9 +18,10 @@
#ifndef INCLUDED_UHD_CONFIG_HPP
#define INCLUDED_UHD_CONFIG_HPP
-// suppress warnings
#include <boost/config.hpp>
+
#ifdef BOOST_MSVC
+// suppress warnings
//# pragma warning(push)
//# pragma warning(disable: 4511) // copy constructor can't not be generated
//# pragma warning(disable: 4512) // assignment operator can't not be generated
@@ -37,76 +38,43 @@
//# pragma warning(disable: 4511) // 'class' : copy constructor could not be generated
//# pragma warning(disable: 4250) // 'class' : inherits 'method' via dominance
# pragma warning(disable: 4200) // nonstandard extension used : zero-sized array in struct/union
-#endif
// define logical operators
-#ifdef BOOST_MSVC
- #include <ciso646>
-#endif
+#include <ciso646>
// define ssize_t
-#ifdef BOOST_MSVC
- #include <cstddef>
- typedef ptrdiff_t ssize_t;
-#endif
-
-// http://gcc.gnu.org/wiki/Visibility
-// Generic helper definitions for shared library support
-#if defined(BOOST_HAS_DECLSPEC)
- #define UHD_HELPER_DLL_IMPORT __declspec(dllimport)
- #define UHD_HELPER_DLL_EXPORT __declspec(dllexport)
- #define UHD_HELPER_DLL_LOCAL
- #define UHD_HELPER_EXIM_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_EXIM_TMPL extern
-#else
- #define UHD_HELPER_DLL_IMPORT
- #define UHD_HELPER_DLL_EXPORT
- #define UHD_HELPER_DLL_LOCAL
- #define UHD_HELPER_EXIM_TMPL extern
-#endif
+#include <cstddef>
+typedef ptrdiff_t ssize_t;
-// Now we use the generic helper definitions above to define UHD_API and UHD_LOCAL.
-// UHD_API is used for the public API symbols. It either DLL imports or DLL exports (or does nothing for static build)
-// UHD_LOCAL is used for non-api symbols.
+#endif //BOOST_MSVC
-#define UHD_DLL // defined here, put into configuration if we need to make static libs
-
-#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_EXIM_TMPL UHD_HELPER_EXIM_TMPL
- #else
- #define UHD_API UHD_HELPER_DLL_IMPORT
- #define UHD_EXIM_TMPL UHD_HELPER_EXIM_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_EXIM_TMPL
-#endif // UHD_DLL
-
-// Define force inline macro
-#if defined(BOOST_MSVC)
- #define UHD_INLINE __forceinline
+//define cross platform attribute macros
+#if defined(BOOST_MSVC) || defined(BOOST_HAS_DECLSPEC)
+ #define UHD_EXPORT __declspec(dllexport)
+ #define UHD_IMPORT __declspec(dllimport)
+ #define UHD_INLINE __forceinline
+ #define UHD_DEPRECATED __declspec(deprecated)
+ #define UHD_ALIGNED(x) __declspec(align(x))
#elif defined(__GNUG__) && __GNUG__ >= 4
- #define UHD_INLINE inline __attribute__((always_inline))
+ #define UHD_EXPORT __attribute__((visibility("default")))
+ #define UHD_IMPORT __attribute__((visibility("default")))
+ #define UHD_INLINE inline __attribute__((always_inline))
+ #define UHD_DEPRECATED __attribute__((deprecated))
+ #define UHD_ALIGNED(x) __attribute__((aligned(x)))
#else
- #define UHD_INLINE inline
+ #define UHD_EXPORT
+ #define UHD_IMPORT
+ #define UHD_INLINE inline
+ #define UHD_DEPRECATED
+ #define UHD_ALIGNED(x)
#endif
-// Define deprecated attribute macro
-#if defined(BOOST_MSVC)
- #define UHD_DEPRECATED __declspec(deprecated)
-#elif defined(__GNUG__) && __GNUG__ >= 4
- #define UHD_DEPRECATED __attribute__ ((deprecated))
+// Define API declaration macro
+#ifdef UHD_DLL_EXPORTS
+ #define UHD_API UHD_EXPORT
#else
- #define UHD_DEPRECATED
-#endif
+ #define UHD_API UHD_IMPORT
+#endif // UHD_DLL_EXPORTS
// Platform defines for conditional parts of headers:
// Taken from boost/config/select_platform_config.hpp,
@@ -117,6 +85,18 @@
#define UHD_PLATFORM_WIN32
#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
#define UHD_PLATFORM_MACOS
+#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+ #define UHD_PLATFORM_BSD
+#endif
+
+//On macos platform, explicit templates must be:
+// - defined with extern in the header file
+// - defined as a symbol in the source file
+#if defined(UHD_PLATFORM_MACOS) || defined(UHD_PLATFORM_BSD)
+ #define UHD_EXIM_TMPL extern
+ #define UHD_USE_EXIM_TMPL
+#else
+ #define UHD_EXIM_TMPL
#endif
#endif /* INCLUDED_UHD_CONFIG_HPP */
diff --git a/host/include/uhd/transport/CMakeLists.txt b/host/include/uhd/transport/CMakeLists.txt
index ec3b7b113..726306ec1 100644
--- a/host/include/uhd/transport/CMakeLists.txt
+++ b/host/include/uhd/transport/CMakeLists.txt
@@ -19,6 +19,7 @@
INSTALL(FILES
bounded_buffer.hpp
bounded_buffer.ipp
+ buffer_pool.hpp
convert_types.hpp
convert_types.ipp
if_addrs.hpp
diff --git a/host/include/uhd/transport/buffer_pool.hpp b/host/include/uhd/transport/buffer_pool.hpp
new file mode 100644
index 000000000..b6c683948
--- /dev/null
+++ b/host/include/uhd/transport/buffer_pool.hpp
@@ -0,0 +1,59 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_TRANSPORT_BUFFER_POOL_HPP
+#define INCLUDED_UHD_TRANSPORT_BUFFER_POOL_HPP
+
+#include <uhd/config.hpp>
+#include <boost/utility.hpp>
+#include <boost/shared_ptr.hpp>
+
+namespace uhd{ namespace transport{
+
+ /*!
+ * A buffer pool manages memory for a homogeneous set of buffers.
+ * Each buffer is the pool start at a 16-byte alignment boundary.
+ */
+ class UHD_API buffer_pool : boost::noncopyable{
+ public:
+ typedef boost::shared_ptr<buffer_pool> sptr;
+ typedef void * ptr_type;
+
+ /*!
+ * Make a new buffer pool.
+ * \param num_buffs the number of buffers to allocate
+ * \param buff_size the size of each buffer in bytes
+ * \param alignment the alignment boundary in bytes
+ * \return a new buffer pool buff_size X num_buffs
+ */
+ static sptr make(
+ const size_t num_buffs,
+ const size_t buff_size,
+ const size_t alignment = 16
+ );
+
+ //! Get a pointer to the buffer start at the specified index
+ virtual ptr_type at(const size_t index) const = 0;
+
+ //! Get the number of buffers in this pool
+ virtual size_t size(void) const = 0;
+ };
+
+}} //namespace
+
+
+#endif /* INCLUDED_UHD_TRANSPORT_BUFFER_POOL_HPP */
diff --git a/host/include/uhd/transport/if_addrs.hpp b/host/include/uhd/transport/if_addrs.hpp
index fbbb35e1d..84f24cb5a 100644
--- a/host/include/uhd/transport/if_addrs.hpp
+++ b/host/include/uhd/transport/if_addrs.hpp
@@ -15,8 +15,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
-#ifndef INCLUDED_UHD_IFADDRS_HPP
-#define INCLUDED_UHD_IFADDRS_HPP
+#ifndef INCLUDED_UHD_TRANSPORT_IF_ADDRS_HPP
+#define INCLUDED_UHD_TRANSPORT_IF_ADDRS_HPP
#include <uhd/config.hpp>
#include <string>
@@ -44,4 +44,4 @@ namespace uhd{ namespace transport{
}} //namespace
-#endif /* INCLUDED_UHD_IFADDRS_HPP */
+#endif /* INCLUDED_UHD_TRANSPORT_IF_ADDRS_HPP */
diff --git a/host/include/uhd/types/dict.hpp b/host/include/uhd/types/dict.hpp
index 6166140a0..a117efa6b 100644
--- a/host/include/uhd/types/dict.hpp
+++ b/host/include/uhd/types/dict.hpp
@@ -54,14 +54,14 @@ namespace uhd{
* Key order depends on insertion precedence.
* \return vector of keys
*/
- const std::vector<Key> keys(void) const;
+ std::vector<Key> keys(void) const;
/*!
* Get a list of the values in this dict.
* Value order depends on insertion precedence.
* \return vector of values
*/
- const std::vector<Val> vals(void) const;
+ std::vector<Val> vals(void) const;
/*!
* Does the dictionary contain this key?
diff --git a/host/include/uhd/types/dict.ipp b/host/include/uhd/types/dict.ipp
index f037d7988..efff9e955 100644
--- a/host/include/uhd/types/dict.ipp
+++ b/host/include/uhd/types/dict.ipp
@@ -59,7 +59,7 @@ namespace uhd{
}
template <typename Key, typename Val>
- const std::vector<Key> dict<Key, Val>::keys(void) const{
+ std::vector<Key> dict<Key, Val>::keys(void) const{
std::vector<Key> keys;
BOOST_FOREACH(const pair_t &p, _map){
keys.push_back(p.first);
@@ -68,7 +68,7 @@ namespace uhd{
}
template <typename Key, typename Val>
- const std::vector<Val> dict<Key, Val>::vals(void) const{
+ std::vector<Val> dict<Key, Val>::vals(void) const{
std::vector<Val> vals;
BOOST_FOREACH(const pair_t &p, _map){
vals.push_back(p.second);
diff --git a/host/include/uhd/usrp/dboard_manager.hpp b/host/include/uhd/usrp/dboard_manager.hpp
index c68f069f0..3c41c65a8 100644
--- a/host/include/uhd/usrp/dboard_manager.hpp
+++ b/host/include/uhd/usrp/dboard_manager.hpp
@@ -68,7 +68,7 @@ public:
const dboard_id_t &tx_dboard_id,
dboard_ctor_t dboard_ctor,
const std::string &name,
- const prop_names_t &subdev_names = prop_names_t(1, "")
+ const prop_names_t &subdev_names = prop_names_t(1, "0")
);
/*!