00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _CLOCKTICKS_H_
00012 #define _CLOCKTICKS_H_
00013
00014
00015
00016
00017
00018 #if defined(__INTEL_COMPILER) && defined(__ia64__)
00019 #include <ia64intrin.h>
00020 #include <ia64regs.h>
00021 #include "BaseNamespaceHeader.H"
00022
00023 inline unsigned long long int ch_ticks()
00024 {
00025 volatile unsigned long long int rtn = __getReg(_IA64_REG_AR_ITC);
00026 return rtn;
00027 }
00028 #define CH_TICKS
00029
00030 #elif defined(__x86_64__) || defined(__i386__) || defined(__i686__)
00031 #include "BaseNamespaceHeader.H"
00032
00033 union clockunion{
00034 unsigned int i[2];
00035 unsigned long long int l;
00036 };
00037
00038 inline unsigned long long int ch_ticks()
00039 {
00040 volatile clockunion ret;
00041 __asm__ __volatile__ ("rdtsc" : "=a"(ret.i[0]), "=d"(ret.i[1]));
00042 return ret.l;
00043
00044
00045
00046
00047
00048 }
00049 #define CH_TICKS
00050
00051 #elif defined(_POWER) || defined(_POWERPC) || defined(__POWERPC__)
00052 #include "BaseNamespaceHeader.H"
00053
00054 inline unsigned long long int ch_ticks()
00055 {
00056 volatile unsigned long long int tbr;
00057 __asm__ __volatile__("mftb %[tbr]" : [tbr] "=r" (tbr):);
00058 return tbr;
00059 }
00060 #define CH_TICKS
00061 #endif
00062
00063
00064 #include "BaseNamespaceFooter.H"
00065 #endif