summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-09-15 16:39:15 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-09-15 16:39:15 +0000
commit7b2f504cb3dd32d432343b0a88c53a527a278942 (patch)
tree02975d62799a968b14a2a0cb20ba698dabd26ae7
parentab164ab3caa0a212ea80df2fd36af8dc77d50563 (diff)
downloadATCD-7b2f504cb3dd32d432343b0a88c53a527a278942.tar.gz
(gethrtime, Linux only): inlined and added Alpha support
-rw-r--r--ace/OS.cpp32
-rw-r--r--ace/OS.i28
2 files changed, 29 insertions, 31 deletions
diff --git a/ace/OS.cpp b/ace/OS.cpp
index f6f00120814..0105c260d5e 100644
--- a/ace/OS.cpp
+++ b/ace/OS.cpp
@@ -25,7 +25,9 @@
// This is lock defines a monitor that is shared by all threads
// calling certain ACE_OS methods.
static ACE_Thread_Mutex ace_os_monitor_lock;
-static u_int ace_tss_cleanup_lock = ACE_Object_Manager::ACE_TSS_CLEANUP_LOCK;
+#if defined (ACE_WIN32) || defined (ACE_HAS_TSS_EMULATION)
+ static u_int ace_tss_cleanup_lock = ACE_Object_Manager::ACE_TSS_CLEANUP_LOCK;
+#endif /* ACE_WIN32 || ACE_HAS_TSS_EMULATION */
#if defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
int
@@ -189,34 +191,6 @@ ACE_U_LongLong::output (FILE *file) const
}
#endif /* !ACE_WIN32 && ! ACE_HAS_LONGLONG_T */
-#if defined (ACE_HAS_PENTIUM) && defined (__GNUC__)
-ACE_hrtime_t
-ACE_OS::gethrtime (void)
-{
- // ACE_TRACE ("ACE_OS::gethrtime");
-
- // See comments for ACE_WIN32 version of ACE_OS::gethrtime () in OS.i.
- //
- // This function can't be inline because it depends on the location
- // of the following variables on the stack.
- //
- // Moreover, the GCC compiler with -Wall will flag these as
- // potentially being used without being initialized, but the
- // assembly code insures that they ARE initialized. So, that
- // warning can be ignored.
- volatile u_long least, most;
-
- asm ("rdtsc");
- asm ("movl %eax, -4(%ebp)"); // least
- asm ("movl %edx, -8(%ebp)"); // most
-
- // This code relies on the subtle semantics of operator precedence,
- // but David Levine wants it this way to encourage C++ programmers
- // to learn their precedence rules.
- return (ACE_hrtime_t) most << 32 | least;
-}
-#endif /* ACE_HAS_PENTIUM && __GNUC__ */
-
#if defined (ACE_HAS_POWERPC) && defined (ghs)
void
ACE_OS::readPPCTimeBase (u_long &most, u_long &least)
diff --git a/ace/OS.i b/ace/OS.i
index bc7d65eac24..b60c7f911bb 100644
--- a/ace/OS.i
+++ b/ace/OS.i
@@ -6862,7 +6862,6 @@ ACE_U_LongLong::operator-= (const ACE_U_LongLong &ll)
}
#endif /* ! ACE_WIN32 && ! ACE_HAS_LONGLONG_T */
-#if !defined (ACE_HAS_PENTIUM) || !defined (__GNUC__)
ACE_INLINE ACE_hrtime_t
ACE_OS::gethrtime (void)
{
@@ -6876,6 +6875,32 @@ ACE_OS::gethrtime (void)
::time_base_to_time(&tb, TIMEBASE_SZ);
return tb.tb_high * 1000000000L + tb.tb_low;
+#elif defined (linux)
+# if defined (ACE_HAS_PENTIUM)
+ volatile ACE_hrtime_t now;
+
+ // See comments about the RDTSC Pentium instruction for the ACE_WIN32
+ // version of ACE_OS::gethrtime (), below.
+ //
+ // Read the high-res tick counter directly into memory variable "now".
+ // The A constraint signifies a 64-bit int.
+ asm volatile ("rdtsc" : "=A" (now) : : "memory");
+
+ return now;
+# elif defined (__alpha)
+ volatile ACE_hrtime_t now;
+
+ // The following statement is based on code published by:
+ // Mosberger, David, "How to Make Your Applications Fly, Part 1",
+ // Linux Journal Issue 42, October 1997, page 50.
+ // It reads the high-res tick counter directly into memory variable "now".
+ asm volatile ("rpcc %0" : "=r" (now) : : "memory");
+
+ return now;
+# else
+ const ACE_Time_Value now = ACE_OS::gettimeofday ();
+ return now.msec () * 1000000L /* nanoseconds/millsecond */;
+# endif /* i386 || __alpha */
#elif defined (ACE_HAS_PENTIUM)
// for WIN32 only (see OS.cpp for the GCC version) . . .
// Issue the RDTSC assembler instruction to get the number of clock
@@ -6920,7 +6945,6 @@ ACE_OS::gethrtime (void)
return now.msec () * 1000000L /* nanoseconds/millsecond */;
#endif /* ACE_HAS_HI_RES_TIMER */
}
-#endif /* ! ACE_HAS_PENTIUM || ! __GNUC__ */
ACE_INLINE int
ACE_OS::fdetach (const char *file)