aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/include/uhdlib/utils
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/include/uhdlib/utils')
-rw-r--r--host/lib/include/uhdlib/utils/atomic.hpp99
-rw-r--r--host/lib/include/uhdlib/utils/auto_timer.hpp168
-rw-r--r--host/lib/include/uhdlib/utils/compat_check.hpp44
-rw-r--r--host/lib/include/uhdlib/utils/config_parser.hpp36
-rw-r--r--host/lib/include/uhdlib/utils/eeprom_utils.hpp54
-rw-r--r--host/lib/include/uhdlib/utils/ihex.hpp11
-rw-r--r--host/lib/include/uhdlib/utils/isatty.hpp52
-rw-r--r--host/lib/include/uhdlib/utils/math.hpp5
-rw-r--r--host/lib/include/uhdlib/utils/narrow.hpp7
-rw-r--r--host/lib/include/uhdlib/utils/paths.hpp13
-rw-r--r--host/lib/include/uhdlib/utils/prefs.hpp133
-rw-r--r--host/lib/include/uhdlib/utils/semaphore.hpp2
-rw-r--r--host/lib/include/uhdlib/utils/system_time.hpp12
13 files changed, 307 insertions, 329 deletions
diff --git a/host/lib/include/uhdlib/utils/atomic.hpp b/host/lib/include/uhdlib/utils/atomic.hpp
index 303df1bc9..98b1cfa7b 100644
--- a/host/lib/include/uhdlib/utils/atomic.hpp
+++ b/host/lib/include/uhdlib/utils/atomic.hpp
@@ -14,62 +14,65 @@
#include <atomic>
#include <chrono>
-namespace uhd{
+namespace uhd {
- /*! DEPRECATED -- Will be removed in coming versions of UHD.
- *
- * Spin-wait on a condition with a timeout.
- * \param cond an atomic variable to compare
- * \param value compare to atomic for true/false
- * \param timeout the timeout in seconds
- * \return true for cond == value, false for timeout
- */
- template<typename T>
- UHD_INLINE bool spin_wait_with_timeout(
- std::atomic<T> &cond,
- const T value,
- const double timeout
- ){
- if (cond == value) return true;
- const auto exit_time = std::chrono::high_resolution_clock::now()
- + std::chrono::microseconds(int64_t(timeout * 1e6));
- while (cond != value) {
- if (std::chrono::high_resolution_clock::now() > exit_time) {
- return false;
- }
- boost::this_thread::interruption_point();
- boost::this_thread::yield();
- }
+/*! DEPRECATED -- Will be removed in coming versions of UHD.
+ *
+ * Spin-wait on a condition with a timeout.
+ * \param cond an atomic variable to compare
+ * \param value compare to atomic for true/false
+ * \param timeout the timeout in seconds
+ * \return true for cond == value, false for timeout
+ */
+template <typename T>
+UHD_INLINE bool spin_wait_with_timeout(
+ std::atomic<T>& cond, const T value, const double timeout)
+{
+ if (cond == value)
return true;
+ const auto exit_time = std::chrono::high_resolution_clock::now()
+ + std::chrono::microseconds(int64_t(timeout * 1e6));
+ while (cond != value) {
+ if (std::chrono::high_resolution_clock::now() > exit_time) {
+ return false;
+ }
+ boost::this_thread::interruption_point();
+ boost::this_thread::yield();
}
+ return true;
+}
- /*! DEPRECATED -- Will be removed in coming versions of UHD.
- *
- * Claimer class to provide synchronization for multi-thread access.
- * Claiming enables buffer classes to be used with a buffer queue.
- */
- class simple_claimer{
- public:
- simple_claimer(void){
- this->release();
- }
+/*! DEPRECATED -- Will be removed in coming versions of UHD.
+ *
+ * Claimer class to provide synchronization for multi-thread access.
+ * Claiming enables buffer classes to be used with a buffer queue.
+ */
+class simple_claimer
+{
+public:
+ simple_claimer(void)
+ {
+ this->release();
+ }
- UHD_INLINE void release(void){
- _locked = false;
- }
+ UHD_INLINE void release(void)
+ {
+ _locked = false;
+ }
- UHD_INLINE bool claim_with_wait(const double timeout){
- if (spin_wait_with_timeout(_locked, false, timeout)){
- _locked = true;
- return true;
- }
- return false;
+ UHD_INLINE bool claim_with_wait(const double timeout)
+ {
+ if (spin_wait_with_timeout(_locked, false, timeout)) {
+ _locked = true;
+ return true;
}
+ return false;
+ }
- private:
- std::atomic<bool> _locked;
- };
+private:
+ std::atomic<bool> _locked;
+};
-} //namespace uhd
+} // namespace uhd
#endif /* INCLUDED_UHD_UTILS_ATOMIC_HPP */
diff --git a/host/lib/include/uhdlib/utils/auto_timer.hpp b/host/lib/include/uhdlib/utils/auto_timer.hpp
index 227750a2f..5d1c88911 100644
--- a/host/lib/include/uhdlib/utils/auto_timer.hpp
+++ b/host/lib/include/uhdlib/utils/auto_timer.hpp
@@ -17,46 +17,50 @@
#ifdef UHD_PLATFORM_WIN32
// Defines struct tm
-#include "time.h"
-
-#include <windows.h>
-
-#include <uhd/utils/msg.hpp>
+# include "time.h"
+# include <uhd/utils/msg.hpp>
+# include <windows.h>
/*!
- * Inserts a timer that logs the duration of its existence (construction to destruction) and the context string to UHD_MSG
- * \param context The context string to log in addition to the duration. String buffer MUST be maintained by caling code throughout lifetime of timer object.
+ * Inserts a timer that logs the duration of its existence (construction to destruction)
+ * and the context string to UHD_MSG \param context The context string to log in addition
+ * to the duration. String buffer MUST be maintained by caling code throughout lifetime of
+ * timer object.
*/
-#define PROFILE_TIMING(context) \
- uhd::_auto_timer::auto_timer ___at(context);
+# define PROFILE_TIMING(context) uhd::_auto_timer::auto_timer ___at(context);
/*!
- * Inserts a timer that logs the duration (if exceeds threshold) of its existence (construction to destruction) and the context string to UHD_MSG
- * \param context The context string to log in addition to the duration. String buffer MUST be maintained by caling code throughout lifetime of timer object.
- * \param threshold Only if the lifetime of the timer exceeds this value will it be logged
+ * Inserts a timer that logs the duration (if exceeds threshold) of its existence
+ * (construction to destruction) and the context string to UHD_MSG \param context The
+ * context string to log in addition to the duration. String buffer MUST be maintained by
+ * caling code throughout lifetime of timer object. \param threshold Only if the lifetime
+ * of the timer exceeds this value will it be logged
*/
-#define PROFILE_TIMING_WITH_THRESHOLD(context,threshold) \
- uhd::_auto_timer::auto_timer ___at(context,threshold);
+# define PROFILE_TIMING_WITH_THRESHOLD(context, threshold) \
+ uhd::_auto_timer::auto_timer ___at(context, threshold);
- /*!
- * Inserts a timer that logs the duration of its existence (construction to destruction) and the context string to UHD_MSG
- * \param context The context string to log in addition to the duration. String buffer MUST be maintained by caling code throughout lifetime of timer object.
- * \param unitScale Report duration in ms or us (kUnitScaleMS or kUnitScaleUS)
+/*!
+ * Inserts a timer that logs the duration of its existence (construction to destruction)
+ * and the context string to UHD_MSG \param context The context string to log in addition
+ * to the duration. String buffer MUST be maintained by caling code throughout lifetime of
+ * timer object. \param unitScale Report duration in ms or us (kUnitScaleMS or
+ * kUnitScaleUS)
*/
-#define PROFILE_TIMING_WITH_SCALE(context,unitScale) \
- uhd::_auto_timer::auto_timer ___at(context,0,unitScale);
-
- /*!
- * Inserts a timer that logs the duration (if exceeds threshold) of its existence (construction to destruction) and the context string to UHD_MSG
- * \param context The context string to log in addition to the duration. String buffer MUST be maintained by caling code throughout lifetime of timer object.
- * \param threshold Only if the lifetime of the timer exceeds this value will it be logged
- * \param unitScale Report duration in ms or us (kUnitScaleMS or kUnitScaleUS)
+# define PROFILE_TIMING_WITH_SCALE(context, unitScale) \
+ uhd::_auto_timer::auto_timer ___at(context, 0, unitScale);
+
+/*!
+ * Inserts a timer that logs the duration (if exceeds threshold) of its existence
+ * (construction to destruction) and the context string to UHD_MSG \param context The
+ * context string to log in addition to the duration. String buffer MUST be maintained by
+ * caling code throughout lifetime of timer object. \param threshold Only if the lifetime
+ * of the timer exceeds this value will it be logged \param unitScale Report duration in
+ * ms or us (kUnitScaleMS or kUnitScaleUS)
*/
-#define PROFILE_TIMING_WITH_THRESHOLD_AND_SCALE(context,threshold,unitScale) \
- uhd::_auto_timer::auto_timer ___at(context,threshold,unitScale);
+# define PROFILE_TIMING_WITH_THRESHOLD_AND_SCALE(context, threshold, unitScale) \
+ uhd::_auto_timer::auto_timer ___at(context, threshold, unitScale);
-namespace uhd {
- namespace _auto_timer {
+namespace uhd { namespace _auto_timer {
static const uint64_t kUnitScaleMS = 1000;
static const uint64_t kUnitScaleUS = 1000000;
@@ -65,72 +69,66 @@ static const uint64_t kUnitScaleUS = 1000000;
class auto_timer
{
public:
-
- auto_timer(
- const char* context,
- uint64_t reporting_threshold = 0,
- uint64_t unit_scale = kUnitScaleUS) :
- _context(context),
- _reporting_threshold(reporting_threshold),
- _unit_scale(unit_scale)
- {
- ::QueryPerformanceCounter(&_start_time);
- switch (unit_scale)
- {
- case kUnitScaleMS:
- _unit_scale_str = "ms";
- break;
- case kUnitScaleUS:
- default:
- _unit_scale_str = "us";
- break;
- }
- }
-
- ~auto_timer()
- {
- LARGE_INTEGER freq;
- uint64_t diff_time = 0;
-
- ::QueryPerformanceCounter(&_end_time);
- QueryPerformanceFrequency(&freq);
- diff_time =
- (uint64_t)(_end_time.QuadPart - _start_time.QuadPart)*
- _unit_scale /
- freq.QuadPart;
-
- if (diff_time >= _reporting_threshold)
- {
- UHD_MSG(status) << "^ " << _context << "\t" << std::dec << diff_time << _unit_scale_str << std::endl;
- }
-
- }
+ auto_timer(const char* context,
+ uint64_t reporting_threshold = 0,
+ uint64_t unit_scale = kUnitScaleUS)
+ : _context(context)
+ , _reporting_threshold(reporting_threshold)
+ , _unit_scale(unit_scale)
+ {
+ ::QueryPerformanceCounter(&_start_time);
+ switch (unit_scale) {
+ case kUnitScaleMS:
+ _unit_scale_str = "ms";
+ break;
+ case kUnitScaleUS:
+ default:
+ _unit_scale_str = "us";
+ break;
+ }
+ }
+
+ ~auto_timer()
+ {
+ LARGE_INTEGER freq;
+ uint64_t diff_time = 0;
+
+ ::QueryPerformanceCounter(&_end_time);
+ QueryPerformanceFrequency(&freq);
+ diff_time = (uint64_t)(_end_time.QuadPart - _start_time.QuadPart) * _unit_scale
+ / freq.QuadPart;
+
+ if (diff_time >= _reporting_threshold) {
+ UHD_MSG(status) << "^ " << _context << "\t" << std::dec << diff_time
+ << _unit_scale_str << std::endl;
+ }
+ }
private:
- // Usage
- auto_timer();
- auto_timer(const auto_timer&);
+ // Usage
+ auto_timer();
+ auto_timer(const auto_timer&);
- LARGE_INTEGER _start_time;
- LARGE_INTEGER _end_time;
- uint64_t _unit_scale;
- uint64_t _reporting_threshold;
- const char* _context;
- char* _unit_scale_str;
+ LARGE_INTEGER _start_time;
+ LARGE_INTEGER _end_time;
+ uint64_t _unit_scale;
+ uint64_t _reporting_threshold;
+ const char* _context;
+ char* _unit_scale_str;
}; // class auto_timer
-}} //namespace uhd::_auto_timer
+}} // namespace uhd::_auto_timer
-#else //non-windows platforms
+#else // non-windows platforms
-#define PROFILE_TIMING(context)
+# define PROFILE_TIMING(context)
-#define PROFILE_TIMING_WITH_THRESHOLD(context,threshold)
+# define PROFILE_TIMING_WITH_THRESHOLD(context, threshold)
-#define PROFILE_TIMING_WITH_SCALE(context,unitScale)
+# define PROFILE_TIMING_WITH_SCALE(context, unitScale)
-#define PROFILE_TIMING_WITH_THRESHOLD_AND_SCALE(context,threshold,unitScale)
+# define PROFILE_TIMING_WITH_THRESHOLD_AND_SCALE(context, threshold, unitScale)
#endif
diff --git a/host/lib/include/uhdlib/utils/compat_check.hpp b/host/lib/include/uhdlib/utils/compat_check.hpp
index 8fe96d118..708c5ab16 100644
--- a/host/lib/include/uhdlib/utils/compat_check.hpp
+++ b/host/lib/include/uhdlib/utils/compat_check.hpp
@@ -12,31 +12,27 @@
namespace uhd {
- /*! Checks for FPGA compatibility, and throws an exception on mismatch.
- *
- * \throws uhd::runtime_error on mismatch.
- */
- void assert_fpga_compat(
- const size_t uhd_major,
- const size_t uhd_minor,
- const uint64_t fpga_compat,
- const std::string& fpga_component,
- const std::string& log_component,
- const bool fail_on_minor_behind=false
- );
+/*! Checks for FPGA compatibility, and throws an exception on mismatch.
+ *
+ * \throws uhd::runtime_error on mismatch.
+ */
+void assert_fpga_compat(const size_t uhd_major,
+ const size_t uhd_minor,
+ const uint64_t fpga_compat,
+ const std::string& fpga_component,
+ const std::string& log_component,
+ const bool fail_on_minor_behind = false);
- /*! Checks for FPGA compatibility, and throws an exception on mismatch.
- *
- * \throws uhd::runtime_error on mismatch.
- */
- void assert_fpga_compat(
- const size_t uhd_major,
- const size_t uhd_minor,
- const uint32_t fpga_compat,
- const std::string& fpga_component,
- const std::string& log_component,
- const bool fail_on_minor_behind=false
- );
+/*! Checks for FPGA compatibility, and throws an exception on mismatch.
+ *
+ * \throws uhd::runtime_error on mismatch.
+ */
+void assert_fpga_compat(const size_t uhd_major,
+ const size_t uhd_minor,
+ const uint32_t fpga_compat,
+ const std::string& fpga_component,
+ const std::string& log_component,
+ const bool fail_on_minor_behind = false);
} /* namespace uhd */
diff --git a/host/lib/include/uhdlib/utils/config_parser.hpp b/host/lib/include/uhdlib/utils/config_parser.hpp
index 0cff0868d..13a6346e8 100644
--- a/host/lib/include/uhdlib/utils/config_parser.hpp
+++ b/host/lib/include/uhdlib/utils/config_parser.hpp
@@ -35,20 +35,20 @@ public:
*
* \throws uhd::runtime_error if the parsing failed.
*/
- config_parser(const std::string &path="");
+ config_parser(const std::string& path = "");
/*! Load another config file and update the current values.
*
* If a value exists in both the new and current file, the new value wins.
*/
- void read_file(const std::string &path);
+ void read_file(const std::string& path);
//! Return a list of sections
std::vector<std::string> sections();
//! Return a list of options (keys) in a section, or an empty list if
// section does not exist
- std::vector<std::string> options(const std::string &section);
+ std::vector<std::string> options(const std::string& section);
/*! Return the value of a key
*
@@ -57,15 +57,12 @@ public:
* \param def Default value, in case the key does not exist
*/
template <typename T>
- T get(
- const std::string &section,
- const std::string &key,
- const T &def
- ) {
+ T get(const std::string& section, const std::string& key, const T& def)
+ {
try {
const auto child = _pt.get_child(section);
return child.get<T>(key, def);
- } catch (const boost::property_tree::ptree_bad_path &) {
+ } catch (const boost::property_tree::ptree_bad_path&) {
return def;
}
}
@@ -78,27 +75,20 @@ public:
* \throws uhd::key_error if the key or the section don't exist
*/
template <typename T>
- T get(
- const std::string &section,
- const std::string &key
- ) {
+ T get(const std::string& section, const std::string& key)
+ {
try {
const auto child = _pt.get_child(section);
return child.get<T>(key);
- } catch (const boost::property_tree::ptree_bad_path &) {
- throw uhd::key_error(
- std::string("[config_parser] Key ") + key +
- " not found in section " + section
- );
+ } catch (const boost::property_tree::ptree_bad_path&) {
+ throw uhd::key_error(std::string("[config_parser] Key ") + key
+ + " not found in section " + section);
}
}
template <typename T>
- void set(
- const std::string &section,
- const std::string &key,
- const T &value
- ) {
+ void set(const std::string& section, const std::string& key, const T& value)
+ {
_pt.put<T>(section + "." + key, value);
}
diff --git a/host/lib/include/uhdlib/utils/eeprom_utils.hpp b/host/lib/include/uhdlib/utils/eeprom_utils.hpp
index 5104e1530..53390b200 100644
--- a/host/lib/include/uhdlib/utils/eeprom_utils.hpp
+++ b/host/lib/include/uhdlib/utils/eeprom_utils.hpp
@@ -7,19 +7,19 @@
#include <uhd/types/byte_vector.hpp>
#include <uhd/types/dict.hpp>
#include <uhd/types/mac_addr.hpp>
-#include <boost/asio/ip/address_v4.hpp>
#include <uhd/utils/log.hpp>
+#include <boost/asio/ip/address_v4.hpp>
#include <string>
#include <vector>
-static const size_t SERIAL_LEN = 9;
+static const size_t SERIAL_LEN = 9;
static const size_t NAME_MAX_LEN = 32 - SERIAL_LEN;
//! convert a string to a byte vector to write to eeprom
-uhd::byte_vector_t string_to_uint16_bytes(const std::string &num_str);
+uhd::byte_vector_t string_to_uint16_bytes(const std::string& num_str);
//! convert a byte vector read from eeprom to a string
-std::string uint16_bytes_to_string(const uhd::byte_vector_t &bytes);
+std::string uint16_bytes_to_string(const uhd::byte_vector_t& bytes);
/*!
* Check for duplicate values within a given set of keys. Assumes the desire
@@ -37,21 +37,18 @@ std::string uint16_bytes_to_string(const uhd::byte_vector_t &bytes);
* \return true if duplicates are found, false if not
*/
template <typename field_type>
-bool check_for_duplicates(
- const std::string& error_label,
+bool check_for_duplicates(const std::string& error_label,
const uhd::dict<std::string, std::string>& new_eeprom,
const uhd::dict<std::string, std::string>& curr_eeprom,
const std::string& category,
- const std::vector<std::string>& keys
-) {
+ const std::vector<std::string>& keys)
+{
bool has_duplicates = false;
- for (size_t i = 0; i < keys.size(); i++)
- {
+ for (size_t i = 0; i < keys.size(); i++) {
bool found_duplicate = false;
- auto key = keys[i];
+ auto key = keys[i];
- if (not new_eeprom.has_key(key))
- {
+ if (not new_eeprom.has_key(key)) {
continue;
}
@@ -59,38 +56,33 @@ bool check_for_duplicates(
// Check other values in new_eeprom for duplicate
// Starting at key index i+1 so the same duplicate is not found twice
- for (size_t j = i+1; j < keys.size(); j++)
- {
+ for (size_t j = i + 1; j < keys.size(); j++) {
auto other_key = keys[j];
- if (not new_eeprom.has_key(other_key))
- {
+ if (not new_eeprom.has_key(other_key)) {
continue;
}
auto other_value = field_type::from_string(new_eeprom[other_key]).to_string();
- if (value == other_value)
- {
+ if (value == other_value) {
// Value is a duplicate of another supplied value
- UHD_LOG_ERROR(error_label, "Duplicate " << category << " "
- << new_eeprom[key] << " is supplied for both " << key
- << " and " << other_key);
+ UHD_LOG_ERROR(error_label,
+ "Duplicate " << category << " " << new_eeprom[key]
+ << " is supplied for both " << key << " and "
+ << other_key);
found_duplicate = true;
}
}
// Check all keys in curr_eeprom for duplicate value
- for (auto other_key: keys)
- {
+ for (auto other_key : keys) {
// Skip any keys in new_eeprom
- if (new_eeprom.has_key(other_key))
- {
+ if (new_eeprom.has_key(other_key)) {
continue;
}
- if (value == curr_eeprom[other_key])
- {
+ if (value == curr_eeprom[other_key]) {
// Value is duplicate of one in the EEPROM
- UHD_LOG_ERROR(error_label, "Duplicate " << category << " "
- << new_eeprom[key] << " is already in use for "
- << other_key);
+ UHD_LOG_ERROR(error_label,
+ "Duplicate " << category << " " << new_eeprom[key]
+ << " is already in use for " << other_key);
found_duplicate = true;
}
}
diff --git a/host/lib/include/uhdlib/utils/ihex.hpp b/host/lib/include/uhdlib/utils/ihex.hpp
index ac12a83b5..58e4d5637 100644
--- a/host/lib/include/uhdlib/utils/ihex.hpp
+++ b/host/lib/include/uhdlib/utils/ihex.hpp
@@ -8,9 +8,8 @@
#ifndef INCLUDED_IHEX_READER_HPP
#define INCLUDED_IHEX_READER_HPP
-#include <functional>
-#include <functional>
#include <stdint.h>
+#include <functional>
#include <string>
#include <vector>
@@ -20,12 +19,13 @@ class ihex_reader
{
public:
// Arguments are: lower address bits, upper address bits, buff, length
- typedef std::function<int(uint16_t,uint16_t,unsigned char*,uint16_t)> record_handle_type;
+ typedef std::function<int(uint16_t, uint16_t, unsigned char*, uint16_t)>
+ record_handle_type;
/*
* \param ihex_filename Path to the *.ihx file
*/
- ihex_reader(const std::string &ihex_filename);
+ ihex_reader(const std::string& ihex_filename);
/*! Read an Intel HEX file and handle it record by record.
*
@@ -46,7 +46,7 @@ public:
*
* \throws uhd::io_error if the HEX file is corrupted or unreadable.
*/
- void to_bin_file(const std::string &bin_filename);
+ void to_bin_file(const std::string& bin_filename);
/*! Copy the ihex file into a buffer.
*
@@ -66,4 +66,3 @@ private:
}; /* namespace uhd */
#endif /* INCLUDED_IHEX_READER_HPP */
-
diff --git a/host/lib/include/uhdlib/utils/isatty.hpp b/host/lib/include/uhdlib/utils/isatty.hpp
index cb8d07afb..03ca23893 100644
--- a/host/lib/include/uhdlib/utils/isatty.hpp
+++ b/host/lib/include/uhdlib/utils/isatty.hpp
@@ -14,40 +14,40 @@ namespace uhd {
#ifdef UHD_PLATFORM_WIN32
-# include <io.h>
-
- /*! Portable version of isatty()
- *
- * We call it is_a_tty() to distinguish from the from the POSIX version.
- * Also, we simply return a Boolean since the Windows version doesn't set
- * errno.
- */
- bool is_a_tty(const int fd)
- {
- return uhd::narrow_cast<bool>(_isatty(fd));
- }
+# include <io.h>
+
+/*! Portable version of isatty()
+ *
+ * We call it is_a_tty() to distinguish from the from the POSIX version.
+ * Also, we simply return a Boolean since the Windows version doesn't set
+ * errno.
+ */
+bool is_a_tty(const int fd)
+{
+ return uhd::narrow_cast<bool>(_isatty(fd));
+}
#elif _POSIX_C_SOURCE >= _200112L
# include <unistd.h>
- /*! Portable version of isatty()
- *
- * We call it is_a_tty() to distinguish from the from the POSIX version.
- * Also, we simply return a Boolean since the Windows version doesn't set
- * errno.
- */
- bool is_a_tty(const int fd)
- {
- return isatty(fd);
- }
+/*! Portable version of isatty()
+ *
+ * We call it is_a_tty() to distinguish from the from the POSIX version.
+ * Also, we simply return a Boolean since the Windows version doesn't set
+ * errno.
+ */
+bool is_a_tty(const int fd)
+{
+ return isatty(fd);
+}
#else
- bool is_a_tty(const int fd)
- {
- return false;
- }
+bool is_a_tty(const int fd)
+{
+ return false;
+}
#endif
diff --git a/host/lib/include/uhdlib/utils/math.hpp b/host/lib/include/uhdlib/utils/math.hpp
index bcb1b4395..924459ec9 100644
--- a/host/lib/include/uhdlib/utils/math.hpp
+++ b/host/lib/include/uhdlib/utils/math.hpp
@@ -18,8 +18,9 @@ namespace uhd { namespace math {
/*! log2(num), rounded up to the nearest integer.
*/
template <class T>
-T ceil_log2(T num){
- return std::ceil(std::log(num)/std::log(T(2)));
+T ceil_log2(T num)
+{
+ return std::ceil(std::log(num) / std::log(T(2)));
}
/**
diff --git a/host/lib/include/uhdlib/utils/narrow.hpp b/host/lib/include/uhdlib/utils/narrow.hpp
index 25acb63d4..daedd55db 100644
--- a/host/lib/include/uhdlib/utils/narrow.hpp
+++ b/host/lib/include/uhdlib/utils/narrow.hpp
@@ -50,7 +50,7 @@
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4127) // conditional expression is constant
-#endif // _MSC_VER
+#endif // _MSC_VER
namespace uhd {
@@ -83,8 +83,9 @@ inline T narrow(U u)
if (static_cast<U>(t) != u) {
throw narrowing_error("");
}
- if (!std::integral_constant<bool, std::is_signed<T>::value == std::is_signed<U>::value>::value
- && ((t < T{}) != (u < U{}))) {
+ if (!std::integral_constant<bool,
+ std::is_signed<T>::value == std::is_signed<U>::value>::value
+ && ((t < T{}) != (u < U{}))) {
throw narrowing_error("");
}
return t;
diff --git a/host/lib/include/uhdlib/utils/paths.hpp b/host/lib/include/uhdlib/utils/paths.hpp
index d74973301..7f0dc4046 100644
--- a/host/lib/include/uhdlib/utils/paths.hpp
+++ b/host/lib/include/uhdlib/utils/paths.hpp
@@ -11,14 +11,13 @@
namespace uhd {
- /*! Expand environment variables in paths, like Python's
- * os.path.expandvars().
- *
- * If expansion fails, will simply return the original path.
- */
- std::string path_expandvars(const std::string& path);
+/*! Expand environment variables in paths, like Python's
+ * os.path.expandvars().
+ *
+ * If expansion fails, will simply return the original path.
+ */
+std::string path_expandvars(const std::string& path);
} /* namespace uhd */
#endif /* INCLUDED_UHDLIB_UTILS_PATHS_HPP */
-
diff --git a/host/lib/include/uhdlib/utils/prefs.hpp b/host/lib/include/uhdlib/utils/prefs.hpp
index e528450cd..6d75ac7ea 100644
--- a/host/lib/include/uhdlib/utils/prefs.hpp
+++ b/host/lib/include/uhdlib/utils/prefs.hpp
@@ -13,76 +13,75 @@
namespace uhd { namespace prefs {
- /*! Return a reference to an object representing the UHD config file
- * state.
- *
- * Note: Don't call this in static initializers.
- */
- config_parser& get_uhd_config();
+/*! Return a reference to an object representing the UHD config file
+ * state.
+ *
+ * Note: Don't call this in static initializers.
+ */
+config_parser& get_uhd_config();
- /*! Convenience function to update device args with settings from
- * config files.
- *
- * Assume the user has a configuration file as such:
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.ini}
- * [type=b200]
- * master_clock_rate=20e6
- *
- * [serial=f42f9b] ; Let's assume this is another B200
- * master_clock_rate=10e6
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * If get_usrp_args() gets called with "type" key equal to "b200", it will
- * first apply the `master_clock_rate=20e6` settings, as if they had been
- * passed in as device args into the initialization sequence. If the device
- * happens to have the serial number listed above, i.e., "serial" equals
- * "f42f9b", then the new value `master_clock_rate=10e6` will get applied.
- *
- * If the user actually specified their own value of `master_clock_rate`,
- * that value would get applied.
- *
- *
- * \param user_args After getting the device args from the config
- * files, all of these key/value pairs will be applied
- * and will overwrite the settings from config files
- * if they exist.
- */
- uhd::device_addr_t get_usrp_args(const uhd::device_addr_t &user_args);
+/*! Convenience function to update device args with settings from
+ * config files.
+ *
+ * Assume the user has a configuration file as such:
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.ini}
+ * [type=b200]
+ * master_clock_rate=20e6
+ *
+ * [serial=f42f9b] ; Let's assume this is another B200
+ * master_clock_rate=10e6
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * If get_usrp_args() gets called with "type" key equal to "b200", it will
+ * first apply the `master_clock_rate=20e6` settings, as if they had been
+ * passed in as device args into the initialization sequence. If the device
+ * happens to have the serial number listed above, i.e., "serial" equals
+ * "f42f9b", then the new value `master_clock_rate=10e6` will get applied.
+ *
+ * If the user actually specified their own value of `master_clock_rate`,
+ * that value would get applied.
+ *
+ *
+ * \param user_args After getting the device args from the config
+ * files, all of these key/value pairs will be applied
+ * and will overwrite the settings from config files
+ * if they exist.
+ */
+uhd::device_addr_t get_usrp_args(const uhd::device_addr_t& user_args);
- /*! Convenience function to update global DPDK args with settings from
- * config files.
- *
- * Searches for a profile attached to the dpdk-conf key, like this:
- * [dpdk-conf=myconfig]
- * num_mbufs=4095
- * mbuf_cache_size=315
- * mtu=8000
- *
- * \param user_args After getting the device args from the config
- * files, all of these key/value pairs will be applied
- * and will overwrite the settings from config files
- * if they exist.
- */
- uhd::device_addr_t get_dpdk_args(const uhd::device_addr_t &user_args);
+/*! Convenience function to update global DPDK args with settings from
+ * config files.
+ *
+ * Searches for a profile attached to the dpdk-conf key, like this:
+ * [dpdk-conf=myconfig]
+ * num_mbufs=4095
+ * mbuf_cache_size=315
+ * mtu=8000
+ *
+ * \param user_args After getting the device args from the config
+ * files, all of these key/value pairs will be applied
+ * and will overwrite the settings from config files
+ * if they exist.
+ */
+uhd::device_addr_t get_dpdk_args(const uhd::device_addr_t& user_args);
- /*! Convenience function to update per-NIC DPDK args with settings from
- * config files.
- *
- * Grabs settings based on provided MAC address. Sections created like so:
- * [dpdk-mac=00:01:02:03:04:05]
- * dpdk-ipv4 = 192.168.20.1/24
- * dpdk-io-cpu = 1
- *
- * [dpdk-mac=00:01:02:03:04:06]
- * dpdk-ipv4 = 192.168.40.1/24
- * dpdk-io-cpu = 1
- *
- * \param user_args After getting the device args from the config
- * files, all of these key/value pairs will be applied
- * and will overwrite the settings from config files
- * if they exist.
- */
- uhd::device_addr_t get_dpdk_nic_args(const uhd::device_addr_t &user_args);
+/*! Convenience function to update per-NIC DPDK args with settings from
+ * config files.
+ *
+ * Grabs settings based on provided MAC address. Sections created like so:
+ * [dpdk-mac=00:01:02:03:04:05]
+ * dpdk-ipv4 = 192.168.20.1/24
+ * dpdk-io-cpu = 1
+ *
+ * [dpdk-mac=00:01:02:03:04:06]
+ * dpdk-ipv4 = 192.168.40.1/24
+ * dpdk-io-cpu = 1
+ *
+ * \param user_args After getting the device args from the config
+ * files, all of these key/value pairs will be applied
+ * and will overwrite the settings from config files
+ * if they exist.
+ */
+uhd::device_addr_t get_dpdk_nic_args(const uhd::device_addr_t& user_args);
}} /* namespace uhd::prefs */
#endif /* INCLUDED_LIBUHD_UTILS_PREFS_HPP */
-
diff --git a/host/lib/include/uhdlib/utils/semaphore.hpp b/host/lib/include/uhdlib/utils/semaphore.hpp
index ae77ed102..fc869d64a 100644
--- a/host/lib/include/uhdlib/utils/semaphore.hpp
+++ b/host/lib/include/uhdlib/utils/semaphore.hpp
@@ -9,7 +9,7 @@
#include <mutex>
#ifndef INCLUDED_UHDLIB_UTILS_SEMAPHORE_HPP
-#define INCLUDED_UHDLIB_UTILS_SEMAPHORE_HPP
+# define INCLUDED_UHDLIB_UTILS_SEMAPHORE_HPP
namespace uhd {
diff --git a/host/lib/include/uhdlib/utils/system_time.hpp b/host/lib/include/uhdlib/utils/system_time.hpp
index 30cd5a673..1465460d2 100644
--- a/host/lib/include/uhdlib/utils/system_time.hpp
+++ b/host/lib/include/uhdlib/utils/system_time.hpp
@@ -8,11 +8,11 @@
namespace uhd {
- /*!
- * Get the system time in time_spec_t format.
- * Uses the highest precision clock available.
- * \return the system time as a time_spec_t
- */
- time_spec_t get_system_time(void);
+/*!
+ * Get the system time in time_spec_t format.
+ * Uses the highest precision clock available.
+ * \return the system time as a time_spec_t
+ */
+time_spec_t get_system_time(void);
}; /* namespace uhd */