core: (fixes #720) remove timeval and related functions from WallClock

This commit is contained in:
Tommaso Pecorella
2022-08-07 22:47:17 -05:00
committed by Tommaso Pecorella
parent 9738d6b267
commit 652e2fbef2
2 changed files with 0 additions and 69 deletions

View File

@@ -18,7 +18,6 @@
#include <ctime> // clock_t
#include <chrono>
#include <sys/time.h>
#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<long> (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

View File

@@ -24,9 +24,6 @@
#include <condition_variable>
#include <mutex>
// 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 <tt>struct timeval</tt> 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. */