Initial Patch of Auction House bot rev. 135
[auctionmangos.git] / dep / ACE_wrappers / ace / gethrtime.cpp
blob69de03153a1fd59a16312b50574a2246a17ce1a2
1 // $Id: gethrtime.cpp 80826 2008-03-04 14:51:23Z wotte $
2 //
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"
16 extern "C"
17 ACE_hrtime_t
18 ACE_GETHRTIME_NAME (void)
20 #if defined (ACE_HAS_PENTIUM)
21 // ACE_TRACE ("ACE_GETHRTIME_NAME");
23 #if defined (ACE_LACKS_LONGLONG_T)
24 double now;
25 #else /* ! ACE_LACKS_LONGLONG_T */
26 ACE_hrtime_t now;
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++.
35 // asm ("rdtsc");
36 // asm ("movl %edx,-16(%ebp)");
37 // asm ("movl %eax,-12(%ebp)");
38 #else
39 # error unsupported compiler
40 #endif
42 #if defined (ACE_LACKS_LONGLONG_T)
43 // ACE_U_LongLong doesn't have the same layout as now, so construct
44 // it "properly".
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),
48 sizeof (ACE_UINT32));
50 const ACE_hrtime_t ret (least, most);
51 return ret;
52 #else /* ! ACE_LACKS_LONGLONG_T */
53 return now;
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 */
60 #endif /* ghs */