Browse Source

Remove unused pnUtTime functions.

Darryl Pogue 10 years ago
parent
commit
6fb7090eed
  1. 79
      Sources/Plasma/NucleusLib/pnUtils/pnUtTime.cpp
  2. 18
      Sources/Plasma/NucleusLib/pnUtils/pnUtTime.h

79
Sources/Plasma/NucleusLib/pnUtils/pnUtTime.cpp

@ -58,50 +58,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*
*****************************************************************************/
namespace pnUtilsExe {
uint32_t TimeGetTickCount () {
#if HS_BUILD_FOR_WIN32
return GetTickCount();
#else
struct timeval tv;
if (gettimeofday(&tv, NULL) != 0)
return 0;
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
#endif
}
/*****************************************************************************
*
* Time adjustment functions
*
* For debug builds, adjust the initial time value so that the high
* bit or the time value itself is about to wrap, to catch application
* bugs that don't handle wrapping or depend on the high bit's value.
*
***/
static uint32_t s_adjustment;
//===========================================================================
static void InitializeAdjustment () {
ASSERT(!s_adjustment);
uint32_t currTime = TimeGetTickCount();
uint32_t startBits = (currTime & 0x80) ? 0x7fff0000 : 0xffff0000;
uint32_t startMask = 0xffff0000;
s_adjustment = (((currTime & ~startMask) | startBits) - currTime) | 1;
ASSERT(s_adjustment);
}
//===========================================================================
AUTO_INIT_FUNC(AutoInitializeAdjustment) {
if (!s_adjustment)
InitializeAdjustment();
}
} using namespace pnUtilsExe;
/*****************************************************************************
*
@ -109,37 +65,14 @@ AUTO_INIT_FUNC(AutoInitializeAdjustment) {
*
***/
uint32_t TimeGetSecondsSince2001Utc () {
uint64_t time = TimeGetTime();
uint32_t seconds = (uint32_t)((time - kTime1601To2001) / kTimeIntervalsPerSecond);
return seconds;
}
uint64_t TimeGetTime () {
#ifdef HS_BUILD_FOR_WIN32
uint64_t time;
static_assert(sizeof(uint64_t) == sizeof(FILETIME), "FILETIME is not a uint64");
GetSystemTimeAsFileTime((FILETIME *) &time);
return time;
uint32_t TimeGetMs () {
#if HS_BUILD_FOR_WIN32
return GetTickCount();
#else
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts))
struct timeval tv;
if (gettimeofday(&tv, NULL) != 0)
return 0;
long long time = ts.tv_sec * 1000000000LL + ts.tv_nsec;
return time / 100;
#endif
}
uint32_t TimeGetMs () {
#ifdef HS_DEBUGGING
// For debug builds, return an adjusted timer value
if (!s_adjustment)
InitializeAdjustment();
return TimeGetTickCount() + s_adjustment;
#else
// For release builds, just return the operating system's timer
return TimeGetTickCount();
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
#endif
}

18
Sources/Plasma/NucleusLib/pnUtils/pnUtTime.h

@ -55,24 +55,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
* Time query functions
*
***/
const uint64_t kTimeIntervalsPerMs = 10000;
const uint64_t kTimeIntervalsPerSecond = 1000 * kTimeIntervalsPerMs;
const uint64_t kTimeIntervalsPerMinute = 60 * kTimeIntervalsPerSecond;
const uint64_t kTimeIntervalsPerHour = 60 * kTimeIntervalsPerMinute;
const uint64_t kTimeIntervalsPerDay = 24 * kTimeIntervalsPerHour;
// millisecond timer; wraps ~49 days
uint32_t TimeGetMs ();
// 100 nanosecond intervals; won't wrap in our lifetimes
uint64_t TimeGetTime ();
// Seconds elapsed since 00:00:00 January 1, 2001 UTC
uint32_t TimeGetSecondsSince2001Utc ();
// These magic numbers taken from Microsoft's "Shared Source CLI implementation" source code.
// http://msdn.microsoft.com/library/en-us/Dndotnet/html/mssharsourcecli.asp
static const uint64_t kTime1601To2001 = 12622780800 * kTimeIntervalsPerSecond;
#endif

Loading…
Cancel
Save