gethrtime.cpp

Go to the documentation of this file.
00001 // gethrtime.cpp,v 4.11 2005/10/31 09:39:35 jwillemsen Exp
00002 //
00003 // Build this file with g++.  It can be linked in to a ACE application
00004 // that was compiled with GreenHills.  It wouldn't be necessary if I
00005 // knew a way to correctly move values from registers to a 64-bit
00006 // variable in GHS asm code.  That's easy with g++ asm.
00007 
00008 #include "ace/config-all.h"
00009 
00010 ACE_RCSID(ace, gethrtime, "gethrtime.cpp,v 4.11 2005/10/31 09:39:35 jwillemsen Exp")
00011 
00012 #if defined (ghs) && (defined (i386) || defined(__i386__))
00013 
00014 #include "ace/OS_NS_time.h"
00015 
00016 extern "C"
00017 ACE_hrtime_t
00018 ACE_GETHRTIME_NAME (void)
00019 {
00020 #if defined (ACE_HAS_PENTIUM)
00021   // ACE_TRACE ("ACE_GETHRTIME_NAME");
00022 
00023 #if defined (ACE_LACKS_LONGLONG_T)
00024   double now;
00025 #else  /* ! ACE_LACKS_LONGLONG_T */
00026   ACE_hrtime_t now;
00027 #endif /* ! ACE_LACKS_LONGLONG_T */
00028 
00029   // See comments about the RDTSC Pentium instruction for the
00030   // ACE_WIN32 version of ACE_OS::gethrtime () in ace/OS.i.
00031   //
00032   // Read the high-res tick counter directly into memory variable
00033   // "now".  The A constraint signifies a 64-bit int.
00034 #if defined (__GNUG__)
00035   asm volatile ("rdtsc" : "=A" (now) : : "memory");
00036 // #elif defined (ghs)
00037 // The following doesn't work.  For now, this file must be compile with g++.
00038 //  asm ("rdtsc");
00039 //  asm ("movl %edx,-16(%ebp)");
00040 //  asm ("movl %eax,-12(%ebp)");
00041 #else
00042 # error unsupported compiler
00043 #endif
00044 
00045 #if defined (ACE_LACKS_LONGLONG_T)
00046   // ACE_U_LongLong doesn't have the same layout as now, so construct
00047   // it "properly".
00048   ACE_UINT32 least, most;
00049   ACE_OS::memcpy (&least, &now, sizeof (ACE_UINT32));
00050   ACE_OS::memcpy (&most, (unsigned char *) &now + sizeof (ACE_UINT32),
00051                   sizeof (ACE_UINT32));
00052 
00053   const ACE_hrtime_t ret (least, most);
00054   return ret;
00055 #else  /* ! ACE_LACKS_LONGLONG_T */
00056   return now;
00057 #endif /* ! ACE_LACKS_LONGLONG_T */
00058 
00059 #else  /* ! ACE_HAS_PENTIUM */
00060 # error This file can _only_ be compiled with ACE_HAS_PENTIUM.
00061 #endif /* ! ACE_HAS_PENTIUM */
00062 }
00063 #endif /* ghs */

Generated on Thu Nov 9 09:41:51 2006 for ACE by doxygen 1.3.6