diff options
author | Josh Blum <josh@joshknows.com> | 2011-04-19 17:47:36 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-04-19 17:47:36 -0700 |
commit | fdee3ba82b997c709e6822aa000df8adb61c56a5 (patch) | |
tree | ed566f55ef024fd2a45d053a719010e1b2c49366 /host/lib/utils | |
parent | ee424d797fc37a8c3c2a82a58218bf1e85456226 (diff) | |
parent | 290bb75de236cb53c54bb4599cc2dde924f9800e (diff) | |
download | uhd-fdee3ba82b997c709e6822aa000df8adb61c56a5.tar.gz uhd-fdee3ba82b997c709e6822aa000df8adb61c56a5.tar.bz2 uhd-fdee3ba82b997c709e6822aa000df8adb61c56a5.zip |
Merge branch 'master' into next
Conflicts:
fpga/usrp2/top/u2plus/Makefile.N200
Diffstat (limited to 'host/lib/utils')
-rw-r--r-- | host/lib/utils/CMakeLists.txt | 18 | ||||
-rw-r--r-- | host/lib/utils/images.cpp | 6 | ||||
-rw-r--r-- | host/lib/utils/load_modules.cpp | 4 | ||||
-rw-r--r-- | host/lib/utils/paths.cpp | 32 | ||||
-rw-r--r-- | host/lib/utils/thread_priority.cpp | 9 |
5 files changed, 38 insertions, 31 deletions
diff --git a/host/lib/utils/CMakeLists.txt b/host/lib/utils/CMakeLists.txt index c0d99b37e..1314f7475 100644 --- a/host/lib/utils/CMakeLists.txt +++ b/host/lib/utils/CMakeLists.txt @@ -36,6 +36,11 @@ CHECK_CXX_SOURCE_COMPILES(" " HAVE_PTHREAD_SETSCHEDPARAM ) +IF(CYGWIN) + #SCHED_RR non-operational on cygwin + SET(HAVE_PTHREAD_SETSCHEDPARAM False) +ENDIF(CYGWIN) + CHECK_CXX_SOURCE_COMPILES(" #include <windows.h> int main(){ @@ -107,6 +112,19 @@ SET_SOURCE_FILES_PROPERTIES( ) ######################################################################## +# Define UHD_PKG_DATA_PATH for paths.cpp +######################################################################## +FILE(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${PKG_DATA_DIR} UHD_PKG_DATA_PATH) +STRING(REPLACE "\\" "\\\\" UHD_PKG_DATA_PATH ${UHD_PKG_DATA_PATH}) +MESSAGE(STATUS "Full package data directory: ${UHD_PKG_DATA_PATH}") + +SET_SOURCE_FILES_PROPERTIES( + ${CMAKE_CURRENT_SOURCE_DIR}/paths.cpp + PROPERTIES COMPILE_DEFINITIONS + "UHD_PKG_DATA_PATH=\"${UHD_PKG_DATA_PATH}\"" +) + +######################################################################## # Append sources ######################################################################## LIBUHD_APPEND_SOURCES( diff --git a/host/lib/utils/images.cpp b/host/lib/utils/images.cpp index 3756f035a..a124cc208 100644 --- a/host/lib/utils/images.cpp +++ b/host/lib/utils/images.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 @@ -30,11 +30,11 @@ std::vector<fs::path> get_image_paths(void); //defined in paths.cpp **********************************************************************/ std::string uhd::find_image_path(const std::string &image_name){ if (fs::exists(image_name)){ - return fs::system_complete(image_name).file_string(); + return fs::system_complete(image_name).string(); } BOOST_FOREACH(const fs::path &path, get_image_paths()){ fs::path image_path = path / image_name; - if (fs::exists(image_path)) return image_path.file_string(); + if (fs::exists(image_path)) return image_path.string(); } 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 ad39960bb..bee0d5304 100644 --- a/host/lib/utils/load_modules.cpp +++ b/host/lib/utils/load_modules.cpp @@ -72,7 +72,7 @@ static void load_module(const std::string &file_name){ */ static void load_module_path(const fs::path &path){ if (not fs::exists(path)){ - //std::cerr << boost::format("Module path \"%s\" not found.") % path.file_string() << std::endl; + //std::cerr << boost::format("Module path \"%s\" not found.") % path.string() << std::endl; return; } @@ -90,7 +90,7 @@ static void load_module_path(const fs::path &path){ //its not a directory, try to load it try{ - load_module(path.file_string()); + load_module(path.string()); } catch(const std::exception &err){ std::cerr << boost::format("Error: %s") % err.what() << std::endl; diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp index 329695873..a3dd377e5 100644 --- a/host/lib/utils/paths.cpp +++ b/host/lib/utils/paths.cpp @@ -15,17 +15,15 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // -#include "constants.hpp" #include <uhd/config.hpp> #include <boost/tokenizer.hpp> -#include <boost/program_options.hpp> #include <boost/filesystem.hpp> #include <boost/foreach.hpp> #include <boost/bind.hpp> +#include <cstdlib> #include <string> #include <vector> -namespace po = boost::program_options; namespace fs = boost::filesystem; /*********************************************************************** @@ -44,22 +42,14 @@ namespace fs = boost::filesystem; /*********************************************************************** * Get a list of paths for an environment variable **********************************************************************/ -static std::string name_mapper(const std::string &key, const std::string &var_name){ - return (var_name == key)? var_name : ""; +static std::string get_env_var(const std::string &var_name, const std::string &def_val = ""){ + const char *var_value_ptr = std::getenv(var_name.c_str()); + return (var_value_ptr == NULL)? def_val : var_value_ptr; } static std::vector<fs::path> get_env_paths(const std::string &var_name){ - //register the options - std::string var_value; - po::options_description desc; - desc.add_options() - (var_name.c_str(), po::value<std::string>(&var_value)->default_value("")) - ; - //parse environment variables - po::variables_map vm; - po::store(po::parse_environment(desc, boost::bind(&name_mapper, var_name, _1)), vm); - po::notify(vm); + std::string var_value = get_env_var(var_name); //convert to filesystem path, filter blank paths std::vector<fs::path> paths; @@ -74,18 +64,18 @@ static std::vector<fs::path> get_env_paths(const std::string &var_name){ /*********************************************************************** * Get a list of special purpose paths **********************************************************************/ +static fs::path get_uhd_pkg_data_path(void){ + return fs::path(get_env_var("UHD_PKG_DATA_PATH", UHD_PKG_DATA_PATH)); +} + std::vector<fs::path> get_image_paths(void){ std::vector<fs::path> paths = get_env_paths("UHD_IMAGE_PATH"); - paths.push_back(fs::path(LOCAL_PKG_DATA_DIR) / "images"); - if (not std::string(INSTALLER_PKG_DATA_DIR).empty()) - paths.push_back(fs::path(INSTALLER_PKG_DATA_DIR) / "images"); + paths.push_back(get_uhd_pkg_data_path() / "images"); return paths; } std::vector<fs::path> get_module_paths(void){ std::vector<fs::path> paths = get_env_paths("UHD_MODULE_PATH"); - paths.push_back(fs::path(LOCAL_PKG_DATA_DIR) / "modules"); - if (not std::string(INSTALLER_PKG_DATA_DIR).empty()) - paths.push_back(fs::path(INSTALLER_PKG_DATA_DIR) / "modules"); + paths.push_back(get_uhd_pkg_data_path() / "modules"); return paths; } diff --git a/host/lib/utils/thread_priority.cpp b/host/lib/utils/thread_priority.cpp index bd34055e8..a63bdf5ce 100644 --- a/host/lib/utils/thread_priority.cpp +++ b/host/lib/utils/thread_priority.cpp @@ -27,18 +27,17 @@ bool uhd::set_thread_priority_safe(float priority, bool realtime){ return true; }catch(const std::exception &e){ uhd::warning::post(str(boost::format( + "Unable to set the thread priority. Performance may be negatively affected.\n" + "Please see the general application notes in the manual for instructions.\n" "%s\n" - "Failed to set thread priority %d (%s):\n" - "Performance may be negatively affected.\n" - "See the general application notes.\n" - ) % e.what() % priority % (realtime?"realtime":""))); + ) % e.what())); return false; } } static void check_priority_range(float priority){ if (priority > +1.0 or priority < -1.0) - throw std::range_error("priority out of range [-1.0, +1.0]"); + throw uhd::value_error("priority out of range [-1.0, +1.0]"); } /*********************************************************************** |