diff options
| author | Martin Braun <martin.braun@ettus.com> | 2018-08-16 14:25:24 -0700 | 
|---|---|---|
| committer | Brent Stapleton <bstapleton@g.hmc.edu> | 2018-08-20 16:56:43 -0700 | 
| commit | 8e3ea14c9406f3f3e5fe613bfe59906447a195e0 (patch) | |
| tree | 9e7924432f7c3be99693faed5478a8b95c3ecb97 /host/lib | |
| parent | 3b42e6f029f0d3de0f54d720964357aa0a32986f (diff) | |
| download | uhd-8e3ea14c9406f3f3e5fe613bfe59906447a195e0.tar.gz uhd-8e3ea14c9406f3f3e5fe613bfe59906447a195e0.tar.bz2 uhd-8e3ea14c9406f3f3e5fe613bfe59906447a195e0.zip  | |
uhd: Remove usage of time_t (except when required)
The C/C++ standards don't define what time_t is, only that it is
arithmetic (and real for C11, and integral for C++). It should not be
used in portable software and is only used as the return value for some
libc calls.
A common definition for time_t is int64_t, so we'll switch to that
permanently in our own APIs. System APIs will of course stick with
time_t.
Diffstat (limited to 'host/lib')
| -rw-r--r-- | host/lib/types/metadata_c.cpp | 8 | ||||
| -rw-r--r-- | host/lib/types/time_spec.cpp | 8 | ||||
| -rw-r--r-- | host/lib/usrp/gps_ctrl.cpp | 2 | ||||
| -rw-r--r-- | host/lib/usrp/gpsd_iface.cpp | 2 | ||||
| -rw-r--r-- | host/lib/usrp/usrp_c.cpp | 12 | ||||
| -rw-r--r-- | host/lib/utils/system_time.cpp | 2 | 
6 files changed, 17 insertions, 17 deletions
diff --git a/host/lib/types/metadata_c.cpp b/host/lib/types/metadata_c.cpp index 352e5278f..35e3d76c9 100644 --- a/host/lib/types/metadata_c.cpp +++ b/host/lib/types/metadata_c.cpp @@ -43,7 +43,7 @@ uhd_error uhd_rx_metadata_has_time_spec(  uhd_error uhd_rx_metadata_time_spec(      uhd_rx_metadata_handle h, -    time_t *full_secs_out, +    int64_t *full_secs_out,      double *frac_secs_out  ){      UHD_SAFE_C_SAVE_ERROR(h, @@ -149,7 +149,7 @@ uhd_error uhd_rx_metadata_last_error(  uhd_error uhd_tx_metadata_make(      uhd_tx_metadata_handle* handle,      bool has_time_spec, -    time_t full_secs, +    int64_t full_secs,      double frac_secs,      bool start_of_burst,      bool end_of_burst @@ -185,7 +185,7 @@ uhd_error uhd_tx_metadata_has_time_spec(  uhd_error uhd_tx_metadata_time_spec(      uhd_tx_metadata_handle h, -    time_t *full_secs_out, +    int64_t *full_secs_out,      double *frac_secs_out  ){      UHD_SAFE_C_SAVE_ERROR(h, @@ -265,7 +265,7 @@ uhd_error uhd_async_metadata_has_time_spec(  uhd_error uhd_async_metadata_time_spec(      uhd_async_metadata_handle h, -    time_t *full_secs_out, +    int64_t *full_secs_out,      double *frac_secs_out  ){      UHD_SAFE_C_SAVE_ERROR(h, diff --git a/host/lib/types/time_spec.cpp b/host/lib/types/time_spec.cpp index 907e97d1a..403c3336c 100644 --- a/host/lib/types/time_spec.cpp +++ b/host/lib/types/time_spec.cpp @@ -14,7 +14,7 @@ using namespace uhd;   * Time spec constructors   **********************************************************************/  #define time_spec_init(full, frac) { \ -    const time_t _full = time_t(full); \ +    const int64_t _full = int64_t(full); \      const double _frac = double(frac); \      const int _frac_int = int(_frac); \      _full_secs = _full + _frac_int; \ @@ -33,11 +33,11 @@ time_spec_t::time_spec_t(double secs){      time_spec_init(0, secs);  } -time_spec_t::time_spec_t(time_t full_secs, double frac_secs){ +time_spec_t::time_spec_t(int64_t full_secs, double frac_secs){      time_spec_init(full_secs, frac_secs);  } -time_spec_t::time_spec_t(time_t full_secs, long tick_count, double tick_rate){ +time_spec_t::time_spec_t(int64_t full_secs, long tick_count, double tick_rate){      const double frac_secs = tick_count/tick_rate;      time_spec_init(full_secs, frac_secs);  } @@ -45,7 +45,7 @@ time_spec_t::time_spec_t(time_t full_secs, long tick_count, double tick_rate){  time_spec_t time_spec_t::from_ticks(long long ticks, double tick_rate){      const long long rate_i = (long long)(tick_rate);      const double rate_f = tick_rate - rate_i; -    const time_t secs_full = time_t(ticks/rate_i); +    const int64_t secs_full = int64_t(ticks/rate_i);      const long long ticks_error = ticks - (secs_full*rate_i);      const double ticks_frac = ticks_error - secs_full*rate_f;      return time_spec_t(secs_full, ticks_frac/tick_rate); diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp index 67803bec6..717654151 100644 --- a/host/lib/usrp/gps_ctrl.cpp +++ b/host/lib/usrp/gps_ctrl.cpp @@ -372,7 +372,7 @@ private:      return gps_time; //keep gcc from complaining    } -  time_t get_epoch_time(void) { +  int64_t get_epoch_time(void) {        return (get_time() - from_time_t(0)).total_seconds();    } diff --git a/host/lib/usrp/gpsd_iface.cpp b/host/lib/usrp/gpsd_iface.cpp index 6b47b6be5..b34132fa0 100644 --- a/host/lib/usrp/gpsd_iface.cpp +++ b/host/lib/usrp/gpsd_iface.cpp @@ -131,7 +131,7 @@ private: // member functions          return _gps_data.fix.mode >= MODE_2D;      } -    std::time_t _epoch_time(void) +    int64_t _epoch_time(void)      {          boost::shared_lock<boost::shared_mutex> l(_d_mutex);          return (boost::posix_time::from_time_t(_gps_data.fix.time) diff --git a/host/lib/usrp/usrp_c.cpp b/host/lib/usrp/usrp_c.cpp index 1eb52d9af..94f0f4eba 100644 --- a/host/lib/usrp/usrp_c.cpp +++ b/host/lib/usrp/usrp_c.cpp @@ -435,7 +435,7 @@ uhd_error uhd_usrp_get_mboard_name(  uhd_error uhd_usrp_get_time_now(      uhd_usrp_handle h,      size_t mboard, -    time_t *full_secs_out, +    int64_t *full_secs_out,      double *frac_secs_out  ){      UHD_SAFE_C_SAVE_ERROR(h, @@ -448,7 +448,7 @@ uhd_error uhd_usrp_get_time_now(  uhd_error uhd_usrp_get_time_last_pps(      uhd_usrp_handle h,      size_t mboard, -    time_t *full_secs_out, +    int64_t *full_secs_out,      double *frac_secs_out  ){      UHD_SAFE_C_SAVE_ERROR(h, @@ -460,7 +460,7 @@ uhd_error uhd_usrp_get_time_last_pps(  uhd_error uhd_usrp_set_time_now(      uhd_usrp_handle h, -    time_t full_secs, +    int64_t full_secs,      double frac_secs,      size_t mboard  ){ @@ -472,7 +472,7 @@ uhd_error uhd_usrp_set_time_now(  uhd_error uhd_usrp_set_time_next_pps(      uhd_usrp_handle h, -    time_t full_secs, +    int64_t full_secs,      double frac_secs,      size_t mboard  ){ @@ -484,7 +484,7 @@ uhd_error uhd_usrp_set_time_next_pps(  uhd_error uhd_usrp_set_time_unknown_pps(      uhd_usrp_handle h, -    time_t full_secs, +    int64_t full_secs,      double frac_secs  ){      UHD_SAFE_C_SAVE_ERROR(h, @@ -505,7 +505,7 @@ uhd_error uhd_usrp_get_time_synchronized(  uhd_error uhd_usrp_set_command_time(      uhd_usrp_handle h, -    time_t full_secs, +    int64_t full_secs,      double frac_secs,      size_t mboard  ){ diff --git a/host/lib/utils/system_time.cpp b/host/lib/utils/system_time.cpp index 2434eb949..20b6dc429 100644 --- a/host/lib/utils/system_time.cpp +++ b/host/lib/utils/system_time.cpp @@ -45,7 +45,7 @@ time_spec_t uhd::get_system_time(void){      pt::ptime time_now = pt::microsec_clock::universal_time();      pt::time_duration time_dur = time_now - pt::from_time_t(0);      return time_spec_t( -        time_t(time_dur.total_seconds()), +        int64_t(time_dur.total_seconds()),          long(time_dur.fractional_seconds()),          double(pt::time_duration::ticks_per_second())      );  | 
