aboutsummaryrefslogtreecommitdiff
path: root/dep/acelite/ace/Time_Value.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dep/acelite/ace/Time_Value.cpp')
-rw-r--r--dep/acelite/ace/Time_Value.cpp69
1 files changed, 39 insertions, 30 deletions
diff --git a/dep/acelite/ace/Time_Value.cpp b/dep/acelite/ace/Time_Value.cpp
index 045df4d4e66..0b13cdedac9 100644
--- a/dep/acelite/ace/Time_Value.cpp
+++ b/dep/acelite/ace/Time_Value.cpp
@@ -1,4 +1,4 @@
-// $Id: Time_Value.cpp 92069 2010-09-28 11:38:59Z johnnyw $
+// $Id: Time_Value.cpp 96061 2012-08-16 09:36:07Z mcorino $
#include "ace/Time_Value.h"
@@ -9,6 +9,7 @@
#include "ace/Numeric_Limits.h"
#include "ace/If_Then_Else.h"
#include "ace/OS_NS_math.h"
+#include "ace/Time_Policy.h"
#ifdef ACE_HAS_CPP98_IOSTREAMS
#include <ostream>
@@ -33,6 +34,9 @@ const ACE_Time_Value ACE_Time_Value::max_time (
ACE_ALLOC_HOOK_DEFINE (ACE_Time_Value)
+ACE_Time_Value::~ACE_Time_Value()
+{}
+
/// Increment microseconds (the only reason this is here is to allow
/// the use of ACE_Atomic_Op with ACE_Time_Value).
ACE_Time_Value
@@ -81,13 +85,8 @@ ACE_Time_Value::operator -- (void)
///
/// In the beginning (Jan. 1, 1601), there was no time and no computer.
/// And Bill said: "Let there be time," and there was time....
-# if defined (ACE_LACKS_LONGLONG_T)
-const ACE_U_LongLong ACE_Time_Value::FILETIME_to_timval_skew =
-ACE_U_LongLong (0xd53e8000, 0x19db1de);
-# else
const DWORDLONG ACE_Time_Value::FILETIME_to_timval_skew =
ACE_INT64_LITERAL (0x19db1ded53e8000);
-# endif
/// Initializes the ACE_Time_Value object from a Win32 FILETIME
ACE_Time_Value::ACE_Time_Value (const FILETIME &file_time)
@@ -98,15 +97,7 @@ ACE_Time_Value::ACE_Time_Value (const FILETIME &file_time)
void ACE_Time_Value::set (const FILETIME &file_time)
{
- // Initializes the ACE_Time_Value object from a Win32 FILETIME
-#if defined (ACE_LACKS_LONGLONG_T)
- ACE_U_LongLong LL_100ns(file_time.dwLowDateTime, file_time.dwHighDateTime);
- LL_100ns -= ACE_Time_Value::FILETIME_to_timval_skew;
- // Convert 100ns units to seconds;
- this->tv_.tv_sec = (long) (LL_100ns / ((double) (10000 * 1000)));
- // Convert remainder to microseconds;
- this->tv_.tv_usec = (suseconds_t)((LL_100ns % ((ACE_UINT32)(10000 * 1000))) / 10);
-#else
+ // Initializes the ACE_Time_Value object from a Win32 FILETIME
// Don't use a struct initializer, gcc don't like it.
ULARGE_INTEGER _100ns;
_100ns.LowPart = file_time.dwLowDateTime;
@@ -115,10 +106,10 @@ void ACE_Time_Value::set (const FILETIME &file_time)
_100ns.QuadPart -= ACE_Time_Value::FILETIME_to_timval_skew;
// Convert 100ns units to seconds;
- this->tv_.tv_sec = (long) (_100ns.QuadPart / (10000 * 1000));
+ this->tv_.tv_sec = (time_t) (_100ns.QuadPart / (10000 * 1000));
// Convert remainder to microseconds;
this->tv_.tv_usec = (suseconds_t) ((_100ns.QuadPart % (10000 * 1000)) / 10);
-#endif // ACE_LACKS_LONGLONG_T
+
this->normalize ();
}
@@ -128,15 +119,6 @@ ACE_Time_Value::operator FILETIME () const
FILETIME file_time;
// ACE_OS_TRACE ("ACE_Time_Value::operator FILETIME");
-#if defined (ACE_LACKS_LONGLONG_T)
- ACE_U_LongLong LL_sec(this->tv_.tv_sec);
- ACE_U_LongLong LL_usec(this->tv_.tv_usec);
- ACE_U_LongLong LL_100ns = LL_sec * (ACE_UINT32)(10000 * 1000) +
- LL_usec * (ACE_UINT32)10 +
- ACE_Time_Value::FILETIME_to_timval_skew;
- file_time.dwLowDateTime = LL_100ns.lo();
- file_time.dwHighDateTime = LL_100ns.hi();
-#else
ULARGE_INTEGER _100ns;
_100ns.QuadPart = (((DWORDLONG) this->tv_.tv_sec * (10000 * 1000) +
this->tv_.tv_usec * 10) +
@@ -144,13 +126,40 @@ ACE_Time_Value::operator FILETIME () const
file_time.dwLowDateTime = _100ns.LowPart;
file_time.dwHighDateTime = _100ns.HighPart;
-#endif //ACE_LACKS_LONGLONG_T
return file_time;
}
-
#endif /* ACE_WIN32 */
+ACE_Time_Value
+ACE_Time_Value::now () const
+{
+ ACE_System_Time_Policy systp;
+ return systp ();
+}
+
+ACE_Time_Value
+ACE_Time_Value::to_relative_time () const
+{
+ ACE_System_Time_Policy systp;
+ return (*this) - systp ();
+}
+
+ACE_Time_Value
+ACE_Time_Value::to_absolute_time () const
+{
+ ACE_System_Time_Policy systp;
+ return (*this) + systp ();
+}
+
+ACE_Time_Value *
+ACE_Time_Value::duplicate () const
+{
+ ACE_Time_Value * tmp = 0;
+ ACE_NEW_RETURN (tmp, ACE_Time_Value (*this), 0);
+ return tmp;
+}
+
void
ACE_Time_Value::dump (void) const
{
@@ -213,13 +222,13 @@ ACE_Time_Value::normalize (bool saturate)
this->tv_.tv_usec += ACE_ONE_SECOND_IN_USECS;
}
// tv_sec in qnxnto is unsigned
-#if !defined ( __QNXNTO__)
+#if !defined ( __QNX__)
else if (this->tv_.tv_sec < 0 && this->tv_.tv_usec > 0)
{
++this->tv_.tv_sec;
this->tv_.tv_usec -= ACE_ONE_SECOND_IN_USECS;
}
-#endif /* __QNXNTO__ */
+#endif /* __QNX__ */
}