summaryrefslogtreecommitdiff
path: root/ace
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-09-16 16:41:09 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-09-16 16:41:09 +0000
commit26e75d1d6e8ff54a22e3c662f0442691d003c6fd (patch)
treee5fe2ecc7a9d2054eda127a4d5f643f474f59a8f /ace
parent7f9cc4879fd85bcd1bfe8b22670b2f0d4747071a (diff)
downloadATCD-26e75d1d6e8ff54a22e3c662f0442691d003c6fd.tar.gz
added ACE_HAS_POWERPC_TIMER support
Diffstat (limited to 'ace')
-rw-r--r--ace/High_Res_Timer.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/ace/High_Res_Timer.cpp b/ace/High_Res_Timer.cpp
index 544d32a90de..e40ee9e4cbe 100644
--- a/ace/High_Res_Timer.cpp
+++ b/ace/High_Res_Timer.cpp
@@ -16,13 +16,13 @@ ACE_ALLOC_HOOK_DEFINE(ACE_High_Res_Timer)
// 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.
-#if defined (ACE_HAS_PENTIUM) && !defined (ACE_HAS_HI_RES_TIMER)
+#if (defined (ACE_HAS_PENTIUM) || defined (ACE_HAS_POWERPC_TIMER)) && \
+ !defined (ACE_HAS_HI_RES_TIMER)
# include "ace/Object_Manager.h"
# include "ace/Synch.h"
# if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
-
u_long
ACE_High_Res_Timer::get_registry_scale_factor (void)
{
@@ -57,17 +57,16 @@ ACE_High_Res_Timer::get_registry_scale_factor (void)
return speed;
}
-/* static */
// 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;
-# elif defined (ghs) || defined (__GNUG__)
+# else
// Initialize the global_scale_factor_ to 1. The first
// ACE_High_Res_Timer instance construction will override this
// value.
- ACE_UINT32 ACE_High_Res_Timer::global_scale_factor_ = 1u;
-# else
+ /* static */
ACE_UINT32 ACE_High_Res_Timer::global_scale_factor_ = 1u;
# endif /* ! ACE_WIN32 && ! ghs && ! __GNUG__ */
#elif defined (ACE_HAS_HI_RES_TIMER) || defined (ACE_HAS_AIX_HI_RES_TIMER) || \
@@ -80,13 +79,15 @@ ACE_High_Res_Timer::get_registry_scale_factor (void)
#else
// Don't convert at all, by default. Application code may have to
// override this using a call to global_scale_factor ().
+ /* static */
ACE_UINT32 ACE_High_Res_Timer::global_scale_factor_ = 1u;
#endif /* ACE_WIN32 */
ACE_UINT32
ACE_High_Res_Timer::global_scale_factor ()
{
-#if defined (ACE_HAS_PENTIUM) && !defined (ACE_HAS_HI_RES_TIMER) && \
+#if (defined (ACE_HAS_PENTIUM) || defined (ACE_HAS_POWERPC_TIMER)) && \
+ !defined (ACE_HAS_HI_RES_TIMER) && \
((defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || \
defined (ghs) || defined (__GNUG__))
// Check if the global scale factor needs to be set, and do if so.
@@ -130,7 +131,8 @@ ACE_High_Res_Timer::global_scale_factor ()
ACE_High_Res_Timer::calibrate ();
}
}
-#endif /* ACE_HAS_PENTIUM && ! ACE_HAS_HIGH_RES_TIMER &&
+#endif /* (ACE_HAS_PENTIUM || ACE_HAS_POWERPC_TIMER) && \
+ ! ACE_HAS_HIGH_RES_TIMER &&
((WIN32 && ! WINCE) || ghs || __GNUG__) */
return global_scale_factor_;
@@ -176,7 +178,9 @@ ACE_High_Res_Timer::calibrate (const ACE_UINT32 usec,
ACE_Stats_Value actual_sleep (0);
actual_sleeps.mean (actual_sleep);
- const ACE_UINT32 scale_factor = ticks.whole () / actual_sleep.whole () /
+ // The addition of 5 below rounds instead of truncates.
+ const ACE_UINT32 scale_factor =
+ (ticks.whole () / actual_sleep.whole () + 5) /
10u /* usec/100 usec */;
ACE_High_Res_Timer::global_scale_factor (scale_factor);