aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/utils
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/utils')
-rw-r--r--host/lib/utils/CMakeLists.txt1
-rw-r--r--host/lib/utils/assert.cpp24
-rw-r--r--host/lib/utils/gain_group.cpp8
-rw-r--r--host/lib/utils/images.cpp4
-rw-r--r--host/lib/utils/load_modules.cpp10
-rw-r--r--host/lib/utils/paths.cpp1
-rw-r--r--host/lib/utils/thread_priority.cpp14
-rw-r--r--host/lib/utils/warning.cpp4
8 files changed, 20 insertions, 46 deletions
diff --git a/host/lib/utils/CMakeLists.txt b/host/lib/utils/CMakeLists.txt
index a4d3b2db2..c0d99b37e 100644
--- a/host/lib/utils/CMakeLists.txt
+++ b/host/lib/utils/CMakeLists.txt
@@ -110,7 +110,6 @@ SET_SOURCE_FILES_PROPERTIES(
# Append sources
########################################################################
LIBUHD_APPEND_SOURCES(
- ${CMAKE_CURRENT_SOURCE_DIR}/assert.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gain_group.cpp
${CMAKE_CURRENT_SOURCE_DIR}/images.cpp
${CMAKE_CURRENT_SOURCE_DIR}/load_modules.cpp
diff --git a/host/lib/utils/assert.cpp b/host/lib/utils/assert.cpp
deleted file mode 100644
index 7ace9024c..000000000
--- a/host/lib/utils/assert.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-//
-// 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/>.
-//
-
-#include <uhd/utils/assert.hpp>
-
-using namespace uhd;
-
-assert_error::assert_error(const std::string &what) : std::runtime_error(what){
- /* NOP */
-}
diff --git a/host/lib/utils/gain_group.cpp b/host/lib/utils/gain_group.cpp
index 07aa21115..3af8a543d 100644
--- a/host/lib/utils/gain_group.cpp
+++ b/host/lib/utils/gain_group.cpp
@@ -18,7 +18,7 @@
#include <uhd/utils/gain_group.hpp>
#include <uhd/types/dict.hpp>
#include <uhd/utils/algorithm.hpp>
-#include <uhd/utils/assert.hpp>
+#include <uhd/exception.hpp>
#include <boost/foreach.hpp>
#include <boost/bind.hpp>
#include <algorithm>
@@ -107,7 +107,7 @@ public:
double gain_left_to_distribute = gain;
BOOST_FOREACH(const gain_fcns_t &fcns, all_fcns){
const gain_range_t range = fcns.get_range();
- gain_bucket.push_back(floor_step(std::clip(
+ gain_bucket.push_back(floor_step(uhd::clip(
gain_left_to_distribute, range.start(), range.stop()
), max_step));
gain_left_to_distribute -= gain_bucket.back();
@@ -131,7 +131,7 @@ public:
//fill in the largest step sizes first that are less than the remainder
BOOST_FOREACH(size_t i, indexes_step_size_dec){
const gain_range_t range = all_fcns.at(i).get_range();
- double additional_gain = floor_step(std::clip(
+ double additional_gain = floor_step(uhd::clip(
gain_bucket.at(i) + gain_left_to_distribute, range.start(), range.stop()
), range.step()) - gain_bucket.at(i);
gain_bucket.at(i) += additional_gain;
@@ -167,7 +167,7 @@ private:
//! get the gain function sets in order (highest priority first)
std::vector<gain_fcns_t> get_all_fcns(void){
std::vector<gain_fcns_t> all_fcns;
- BOOST_FOREACH(size_t key, std::sorted(_registry.keys())){
+ BOOST_FOREACH(size_t key, uhd::sorted(_registry.keys())){
const std::vector<gain_fcns_t> &fcns = _registry[key];
all_fcns.insert(all_fcns.begin(), fcns.begin(), fcns.end());
}
diff --git a/host/lib/utils/images.cpp b/host/lib/utils/images.cpp
index 395e542c1..3756f035a 100644
--- a/host/lib/utils/images.cpp
+++ b/host/lib/utils/images.cpp
@@ -16,9 +16,9 @@
//
#include <uhd/utils/images.hpp>
+#include <uhd/exception.hpp>
#include <boost/foreach.hpp>
#include <boost/filesystem.hpp>
-#include <stdexcept>
#include <vector>
namespace fs = boost::filesystem;
@@ -36,5 +36,5 @@ std::string uhd::find_image_path(const std::string &image_name){
fs::path image_path = path / image_name;
if (fs::exists(image_path)) return image_path.file_string();
}
- throw std::runtime_error("Could not find path for image: " + image_name);
+ throw uhd::io_error("Could not find path for image: " + image_name);
}
diff --git a/host/lib/utils/load_modules.cpp b/host/lib/utils/load_modules.cpp
index fa9b22438..ad39960bb 100644
--- a/host/lib/utils/load_modules.cpp
+++ b/host/lib/utils/load_modules.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 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
@@ -16,11 +16,11 @@
//
#include <uhd/utils/static.hpp>
+#include <uhd/exception.hpp>
#include <boost/format.hpp>
#include <boost/foreach.hpp>
#include <boost/filesystem.hpp>
#include <iostream>
-#include <stdexcept>
#include <string>
#include <vector>
@@ -33,7 +33,7 @@ namespace fs = boost::filesystem;
#include <dlfcn.h>
static void load_module(const std::string &file_name){
if (dlopen(file_name.c_str(), RTLD_LAZY) == NULL){
- throw std::runtime_error(str(
+ throw uhd::os_error(str(
boost::format("dlopen failed to load \"%s\"") % file_name
));
}
@@ -45,7 +45,7 @@ static void load_module(const std::string &file_name){
#include <windows.h>
static void load_module(const std::string &file_name){
if (LoadLibrary(file_name.c_str()) == NULL){
- throw std::runtime_error(str(
+ throw uhd::os_error(str(
boost::format("LoadLibrary failed to load \"%s\"") % file_name
));
}
@@ -55,7 +55,7 @@ static void load_module(const std::string &file_name){
#ifdef HAVE_LOAD_MODULES_DUMMY
static void load_module(const std::string &file_name){
- throw std::runtime_error(str(
+ throw uhd::not_implemented_error(str(
boost::format("Module loading not supported: Cannot load \"%s\"") % file_name
));
}
diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp
index 8d604d849..329695873 100644
--- a/host/lib/utils/paths.cpp
+++ b/host/lib/utils/paths.cpp
@@ -22,7 +22,6 @@
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <boost/bind.hpp>
-#include <stdexcept>
#include <string>
#include <vector>
diff --git a/host/lib/utils/thread_priority.cpp b/host/lib/utils/thread_priority.cpp
index 18f372ec0..bd34055e8 100644
--- a/host/lib/utils/thread_priority.cpp
+++ b/host/lib/utils/thread_priority.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 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
@@ -17,8 +17,8 @@
#include <uhd/utils/thread_priority.hpp>
#include <uhd/utils/warning.hpp>
+#include <uhd/exception.hpp>
#include <boost/format.hpp>
-#include <stdexcept>
#include <iostream>
bool uhd::set_thread_priority_safe(float priority, bool realtime){
@@ -59,13 +59,13 @@ static void check_priority_range(float priority){
//get the priority bounds for the selected policy
int min_pri = sched_get_priority_min(policy);
int max_pri = sched_get_priority_max(policy);
- if (min_pri == -1 or max_pri == -1) throw std::runtime_error("error in sched_get_priority_min/max");
+ if (min_pri == -1 or max_pri == -1) throw uhd::os_error("error in sched_get_priority_min/max");
//set the new priority and policy
sched_param sp;
sp.sched_priority = int(priority*(max_pri - min_pri)) + min_pri;
int ret = pthread_setschedparam(pthread_self(), policy, &sp);
- if (ret != 0) throw std::runtime_error("error in pthread_setschedparam");
+ if (ret != 0) throw uhd::os_error("error in pthread_setschedparam");
}
#endif /* HAVE_PTHREAD_SETSCHEDPARAM */
@@ -81,7 +81,7 @@ static void check_priority_range(float priority){
//set the priority class on the process
int pri_class = (realtime)? REALTIME_PRIORITY_CLASS : NORMAL_PRIORITY_CLASS;
if (SetPriorityClass(GetCurrentProcess(), pri_class) == 0)
- throw std::runtime_error("error in SetPriorityClass");
+ throw uhd::os_error("error in SetPriorityClass");
//scale the priority value to the constants
int priorities[] = {
@@ -92,7 +92,7 @@ static void check_priority_range(float priority){
//set the thread priority on the thread
if (SetThreadPriority(GetCurrentThread(), priorities[pri_index]) == 0)
- throw std::runtime_error("error in SetThreadPriority");
+ throw uhd::os_error("error in SetThreadPriority");
}
#endif /* HAVE_WIN_SETTHREADPRIORITY */
@@ -101,7 +101,7 @@ static void check_priority_range(float priority){
**********************************************************************/
#ifdef HAVE_LOAD_MODULES_DUMMY
void uhd::set_thread_priority(float, bool){
- throw std::runtime_error("set thread priority not implemented");
+ throw uhd::not_implemented_error("set thread priority not implemented");
}
#endif /* HAVE_LOAD_MODULES_DUMMY */
diff --git a/host/lib/utils/warning.cpp b/host/lib/utils/warning.cpp
index bc4c79b6e..6a94a0a2c 100644
--- a/host/lib/utils/warning.cpp
+++ b/host/lib/utils/warning.cpp
@@ -16,12 +16,12 @@
//
#include <uhd/utils/warning.hpp>
+#include <uhd/exception.hpp>
#include <boost/tokenizer.hpp>
#include <uhd/utils/static.hpp>
#include <uhd/types/dict.hpp>
#include <boost/foreach.hpp>
#include <sstream>
-#include <stdexcept>
#include <iostream>
#include <vector>
@@ -76,7 +76,7 @@ void warning::register_handler(
}
warning::handler_t warning::unregister_handler(const std::string &name){
- if (not get_registry().has_key(name)) throw std::runtime_error(
+ if (not get_registry().has_key(name)) throw uhd::key_error(
"The warning registry does not have a handler registered to " + name
);
return get_registry().pop(name);