Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

gethrtime.cpp

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

Generated on Mon Jun 16 11:19:45 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002