summaryrefslogtreecommitdiff
path: root/ace/High_Res_Timer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ace/High_Res_Timer.cpp')
-rw-r--r--ace/High_Res_Timer.cpp27
1 files changed, 8 insertions, 19 deletions
diff --git a/ace/High_Res_Timer.cpp b/ace/High_Res_Timer.cpp
index 7bfd15db279..e0f7813329a 100644
--- a/ace/High_Res_Timer.cpp
+++ b/ace/High_Res_Timer.cpp
@@ -23,12 +23,8 @@
ACE_RCSID(ace, High_Res_Timer, "$Id$")
-ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-
ACE_ALLOC_HOOK_DEFINE(ACE_High_Res_Timer)
-ACE_END_VERSIONED_NAMESPACE_DECL
-
// For Intel platforms, a scale factor is required for
// ACE_OS::gethrtime. We'll still set this to one to prevent division
// by zero errors.
@@ -40,34 +36,23 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# include "ace/Recursive_Thread_Mutex.h"
# include "ace/Object_Manager.h"
-ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-
// Initialize the global_scale_factor_ to 1. The first
// ACE_High_Res_Timer instance construction will override this
// value.
/* static */
ACE_UINT32 ACE_High_Res_Timer::global_scale_factor_ = 1u;
-ACE_END_VERSIONED_NAMESPACE_DECL
-
#else /* ! (ACE_WIN32 || ACE_HAS_POWERPC_TIMER || \
ACE_HAS_PENTIUM || ACE_HAS_ALPHA_TIMER) ||
ACE_HAS_HI_RES_TIMER */
-
-ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-
// A scale_factor of 1000 converts nanosecond ticks to microseconds.
// That is, on these platforms, 1 tick == 1 nanosecond.
/* static */
ACE_UINT32 ACE_High_Res_Timer::global_scale_factor_ = 1000u;
-
-ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ! (ACE_WIN32 || ACE_HAS_POWERPC_TIMER || \
ACE_HAS_PENTIUM || ACE_HAS_ALPHA_TIMER) ||
ACE_HAS_HI_RES_TIMER */
-ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-
// This is used to tell if the global_scale_factor_ has been
// set, and if high resolution timers are supported.
/* static */
@@ -386,9 +371,15 @@ ACE_High_Res_Timer::elapsed_time (struct timespec &elapsed_time) const
// Get just the microseconds (dropping any left over nanoseconds).
ACE_UINT32 useconds = (ACE_UINT32) (elapsed / global_scale_factor ());
+#if ! defined(ACE_HAS_BROKEN_TIMESPEC_MEMBERS)
elapsed_time.tv_sec = (time_t) (useconds / ACE_ONE_SECOND_IN_USECS);
// Transforms one second in microseconds into nanoseconds.
elapsed_time.tv_nsec = (time_t) ((useconds % ACE_ONE_SECOND_IN_USECS) * 1000u + nseconds);
+#else
+ elapsed_time.ts_sec = (time_t) (useconds / ACE_ONE_SECOND_IN_USECS);
+ // Transforms one second in microseconds into nanoseconds.
+ elapsed_time.ts_nsec = (time_t) ((useconds % ACE_ONE_SECOND_IN_USECS) * 1000u + nseconds);
+#endif /* ACE_HAS_BROKEN_TIMESPEC_MEMBERS */
}
#endif /* ACE_HAS_POSIX_TIME */
@@ -521,12 +512,12 @@ ACE_High_Res_Timer::print_total (const ACE_TCHAR *str,
#endif /* !ACE_HAS_WINCE */
int
-ACE_High_Res_Timer::get_env_global_scale_factor (const ACE_TCHAR *env)
+ACE_High_Res_Timer::get_env_global_scale_factor (const char *env)
{
#if !defined (ACE_HAS_WINCE)
if (env != 0)
{
- const char *env_value = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (env));
+ const char *env_value = ACE_OS::getenv (env);
if (env_value != 0)
{
int value = ACE_OS::atoi (env_value);
@@ -542,5 +533,3 @@ ACE_High_Res_Timer::get_env_global_scale_factor (const ACE_TCHAR *env)
#endif /* !ACE_HAS_WINCE */
return -1;
}
-
-ACE_END_VERSIONED_NAMESPACE_DECL