00001 #ifndef FWCore_Utilities_HRRealTime_H
00002 #define FWCore_Utilities_HRRealTime_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 namespace edm {
00016 namespace details {
00017
00018
00019
00020
00021 #if defined(__i386__)
00022
00023 static __inline__ unsigned long long rdtsc(void)
00024 {
00025 unsigned long long int x;
00026 __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
00027 return x;
00028 }
00029 #elif defined(__x86_64__)
00030
00031
00032 static __inline__ unsigned long long rdtsc(void)
00033 {
00034 unsigned hi, lo;
00035 __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
00036 return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
00037 }
00038
00039 #elif defined(__powerpc__)
00040
00041
00042 static __inline__ unsigned long long rdtsc(void)
00043 {
00044 unsigned long long int result=0;
00045 unsigned long int upper, lower,tmp;
00046 __asm__ volatile(
00047 "0: \n"
00048 "\tmftbu %0 \n"
00049 "\tmftb %1 \n"
00050 "\tmftbu %2 \n"
00051 "\tcmpw %2,%0 \n"
00052 "\tbne 0b \n"
00053 : "=r"(upper),"=r"(lower),"=r"(tmp)
00054 );
00055 result = upper;
00056 result = result<<32;
00057 result = result|lower;
00058
00059 return(result);
00060 }
00061 #else
00062 #error The file FWCore/Utilities/interface/RealTime.h needs to be set up for your CPU type.
00063
00064 #endif
00065 }
00066 }
00067
00068 namespace edm {
00069
00070 typedef long long int HRTimeDiffType;
00071 typedef unsigned long long int HRTimeType;
00072
00073
00074 inline HRTimeType hrRealTime() {
00075 return details::rdtsc();
00076 }
00077
00078 }
00079
00080
00081 #endif // FWCore_Utilities__HRRealTime_H