gethrtime.cpp

Go to the documentation of this file.
00001 // $Id: gethrtime.cpp 80826 2008-03-04 14:51:23Z wotte $
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, "$Id: gethrtime.cpp 80826 2008-03-04 14:51:23Z wotte $")
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   // Read the high-res tick counter directly into memory variable
00030   // "now".  The A constraint signifies a 64-bit int.
00031 #if defined (__GNUG__)
00032   asm volatile ("rdtsc" : "=A" (now) : : "memory");
00033 // #elif defined (ghs)
00034 // The following doesn't work.  For now, this file must be compile with g++.
00035 //  asm ("rdtsc");
00036 //  asm ("movl %edx,-16(%ebp)");
00037 //  asm ("movl %eax,-12(%ebp)");
00038 #else
00039 # error unsupported compiler
00040 #endif
00041 
00042 #if defined (ACE_LACKS_LONGLONG_T)
00043   // ACE_U_LongLong doesn't have the same layout as now, so construct
00044   // it "properly".
00045   ACE_UINT32 least, most;
00046   ACE_OS::memcpy (&least, &now, sizeof (ACE_UINT32));
00047   ACE_OS::memcpy (&most, (unsigned char *) &now + sizeof (ACE_UINT32),
00048                   sizeof (ACE_UINT32));
00049 
00050   const ACE_hrtime_t ret (least, most);
00051   return ret;
00052 #else  /* ! ACE_LACKS_LONGLONG_T */
00053   return now;
00054 #endif /* ! ACE_LACKS_LONGLONG_T */
00055 
00056 #else  /* ! ACE_HAS_PENTIUM */
00057 # error This file can _only_ be compiled with ACE_HAS_PENTIUM.
00058 #endif /* ! ACE_HAS_PENTIUM */
00059 }
00060 #endif /* ghs */

Generated on Tue Feb 2 17:18:39 2010 for ACE by  doxygen 1.4.7