From 652e2fbef24968ba067900db9c5a823a52153cdd Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Sun, 7 Aug 2022 22:47:17 -0500 Subject: [PATCH] core: (fixes #720) remove timeval and related functions from WallClock --- src/core/model/wall-clock-synchronizer.cc | 35 ----------------------- src/core/model/wall-clock-synchronizer.h | 34 ---------------------- 2 files changed, 69 deletions(-) diff --git a/src/core/model/wall-clock-synchronizer.cc b/src/core/model/wall-clock-synchronizer.cc index bde47dc24..078b68f13 100644 --- a/src/core/model/wall-clock-synchronizer.cc +++ b/src/core/model/wall-clock-synchronizer.cc @@ -18,7 +18,6 @@ #include // clock_t #include -#include #include "log.h" #include "wall-clock-synchronizer.h" @@ -393,38 +392,4 @@ WallClockSynchronizer::GetNormalizedRealtime (void) return GetRealtime () - m_realtimeOriginNano; } -void -WallClockSynchronizer::NsToTimeval (int64_t ns, struct timeval *tv) -{ - NS_LOG_FUNCTION (this << ns << tv); - NS_ASSERT ((ns % US_PER_NS) == 0); - tv->tv_sec = static_cast (ns / NS_PER_SEC); - tv->tv_usec = (ns % NS_PER_SEC) / US_PER_NS; -} - -uint64_t -WallClockSynchronizer::TimevalToNs (struct timeval *tv) -{ - NS_LOG_FUNCTION (this << tv); - uint64_t nsResult = tv->tv_sec * NS_PER_SEC + tv->tv_usec * US_PER_NS; - NS_ASSERT ((nsResult % US_PER_NS) == 0); - return nsResult; -} - -void -WallClockSynchronizer::TimevalAdd ( - struct timeval *tv1, - struct timeval *tv2, - struct timeval *result) -{ - NS_LOG_FUNCTION (this << tv1 << tv2 << result); - result->tv_sec = tv1->tv_sec + tv2->tv_sec; - result->tv_usec = tv1->tv_usec + tv2->tv_usec; - if (result->tv_usec > (int64_t)US_PER_SEC) - { - ++result->tv_sec; - result->tv_usec %= US_PER_SEC; - } -} - } // namespace ns3 diff --git a/src/core/model/wall-clock-synchronizer.h b/src/core/model/wall-clock-synchronizer.h index 10aa6df91..7f3bc60b0 100644 --- a/src/core/model/wall-clock-synchronizer.h +++ b/src/core/model/wall-clock-synchronizer.h @@ -24,9 +24,6 @@ #include #include -// Forward declaration -struct timeval; - /** * @file * @ingroup realtime @@ -67,10 +64,6 @@ namespace ns3 { * * @todo Add more on jiffies, sleep, processes, etc. * - * @internal - * Nanosleep takes a struct timeval as an input so we have to - * deal with conversion between Time and @c timeval here. - * They are both interpreted as elapsed times. */ class WallClockSynchronizer : public Synchronizer { @@ -168,33 +161,6 @@ protected: */ uint64_t GetNormalizedRealtime (void); - /** - * @brief Convert an absolute time in ns to a @c timeval - * - * @param [in] ns Absolute time in ns. - * @param [out] tv Converted @c timeval. - */ - void NsToTimeval (int64_t ns, struct timeval *tv); - /** - * @brief Convert a @c timeval to absolute time, in ns. - * - * @param [in] tv The input @c timeval. - * @returns The absolute time, in ns. - */ - uint64_t TimevalToNs (struct timeval *tv); - - /** - * @brief Add two @c timeval. - * - * @param [in] tv1 The first @c timeval. - * @param [in] tv2 The second @c timeval. - * @param [out] result The sum of @c tv1 and @c tv2. - */ - void TimevalAdd ( - struct timeval *tv1, - struct timeval *tv2, - struct timeval *result); - /** Size of the system clock tick, as reported by @c clock_getres, in ns. */ uint64_t m_jiffy; /** Time recorded by DoEventStart. */