1 // $Id: gethrtime.cpp 80826 2008-03-04 14:51:23Z wotte $
3 // Build this file with g++. It can be linked in to a ACE application
4 // that was compiled with GreenHills. It wouldn't be necessary if I
5 // knew a way to correctly move values from registers to a 64-bit
6 // variable in GHS asm code. That's easy with g++ asm.
8 #include "ace/config-all.h"
10 ACE_RCSID(ace
, gethrtime
, "$Id: gethrtime.cpp 80826 2008-03-04 14:51:23Z wotte $")
12 #if defined (ghs) && (defined (i386) || defined(__i386__))
14 #include "ace/OS_NS_time.h"
18 ACE_GETHRTIME_NAME (void)
20 #if defined (ACE_HAS_PENTIUM)
21 // ACE_TRACE ("ACE_GETHRTIME_NAME");
23 #if defined (ACE_LACKS_LONGLONG_T)
25 #else /* ! ACE_LACKS_LONGLONG_T */
27 #endif /* ! ACE_LACKS_LONGLONG_T */
29 // Read the high-res tick counter directly into memory variable
30 // "now". The A constraint signifies a 64-bit int.
31 #if defined (__GNUG__)
32 asm volatile ("rdtsc" : "=A" (now
) : : "memory");
33 // #elif defined (ghs)
34 // The following doesn't work. For now, this file must be compile with g++.
36 // asm ("movl %edx,-16(%ebp)");
37 // asm ("movl %eax,-12(%ebp)");
39 # error unsupported compiler
42 #if defined (ACE_LACKS_LONGLONG_T)
43 // ACE_U_LongLong doesn't have the same layout as now, so construct
45 ACE_UINT32 least
, most
;
46 ACE_OS::memcpy (&least
, &now
, sizeof (ACE_UINT32
));
47 ACE_OS::memcpy (&most
, (unsigned char *) &now
+ sizeof (ACE_UINT32
),
50 const ACE_hrtime_t
ret (least
, most
);
52 #else /* ! ACE_LACKS_LONGLONG_T */
54 #endif /* ! ACE_LACKS_LONGLONG_T */
56 #else /* ! ACE_HAS_PENTIUM */
57 # error This file can _only_ be compiled with ACE_HAS_PENTIUM.
58 #endif /* ! ACE_HAS_PENTIUM */