81 #if TIME_WITH_SYS_TIME 
   82 # include <sys/time.h> 
   86 #  include <sys/time.h> 
   92 #define INLINE_ELAPSED(INL) static INL double elapsed(ticks t1, ticks t0) \ 
   94      return (double)t1 - (double)t0;            \ 
  102 #if defined(HAVE_GETHRTIME) && defined(HAVE_HRTIME_T) && !defined(HAVE_TICK_COUNTER) 
  103 typedef hrtime_t ticks;
 
  105 #define getticks gethrtime 
  107 INLINE_ELAPSED(
inline)
 
  109 #define HAVE_TICK_COUNTER 
  114 #if defined(HAVE_READ_REAL_TIME) && defined(HAVE_TIME_BASE_TO_TIME) && !defined(HAVE_TICK_COUNTER) 
  115 typedef timebasestruct_t ticks;
 
  117 static __inline ticks getticks(
void)
 
  120      read_real_time(&t, TIMEBASE_SZ);
 
  124 static __inline 
double elapsed(ticks t1, ticks t0) 
 
  126      time_base_to_time(&t1, TIMEBASE_SZ);
 
  127      time_base_to_time(&t0, TIMEBASE_SZ);
 
  128      return (((
double)t1.tb_high - (
double)t0.tb_high) * 1.0e9 + 
 
  129        ((
double)t1.tb_low - (
double)t0.tb_low));
 
  132 #define HAVE_TICK_COUNTER 
  139 #if ((((defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))) || (defined(__MWERKS__) && defined(macintosh)))) || (defined(__IBM_GCC_ASM) && (defined(__powerpc__) || defined(__ppc__))))  && !defined(HAVE_TICK_COUNTER) 
  140 typedef unsigned long long ticks;
 
  142 static __inline__ ticks getticks(
void)
 
  144      unsigned int tbl, tbu0, tbu1;
 
  147     __asm__ __volatile__ (
"mftbu %0" : 
"=r"(tbu0));
 
  148     __asm__ __volatile__ (
"mftb %0" : 
"=r"(tbl));
 
  149     __asm__ __volatile__ (
"mftbu %0" : 
"=r"(tbu1));
 
  150      } 
while (tbu0 != tbu1);
 
  152      return (((
unsigned long long)tbu0) << 32) | tbl;
 
  155 INLINE_ELAPSED(__inline__)
 
  157 #define HAVE_TICK_COUNTER 
  162 #if defined(HAVE_MACH_ABSOLUTE_TIME) && defined(HAVE_MACH_MACH_TIME_H) && !defined(HAVE_TICK_COUNTER) 
  163 #include <mach/mach_time.h> 
  164 typedef uint64_t ticks;
 
  165 #define getticks mach_absolute_time 
  166 INLINE_ELAPSED(__inline__)
 
  167 #define HAVE_TICK_COUNTER 
  174 #if (defined(__GNUC__) || defined(__ICC)) && defined(__i386__)  && !defined(HAVE_TICK_COUNTER) 
  175 typedef unsigned long long ticks;
 
  177 static __inline__ ticks getticks(
void)
 
  181      __asm__ __volatile__(
"rdtsc": 
"=A" (ret));
 
  186 INLINE_ELAPSED(__inline__)
 
  188 #define HAVE_TICK_COUNTER 
  189 #define TIME_MIN 5000.0    
  193 #if defined(_MSC_VER) && _MSC_VER >= 1200 && _M_IX86 >= 500 && !defined(HAVE_TICK_COUNTER) 
  195 typedef LARGE_INTEGER ticks;
 
  196 #define RDTSC __asm __emit 0fh __asm __emit 031h  
  198 static __inline ticks getticks(
void)
 
  204     mov retval.HighPart, edx
 
  205     mov retval.LowPart, eax
 
  210 static __inline 
double elapsed(ticks t1, ticks t0)
 
  212      return (
double)t1.QuadPart - (double)t0.QuadPart;
 
  215 #define HAVE_TICK_COUNTER 
  216 #define TIME_MIN 5000.0    
  223 #if (defined(__GNUC__) || defined(__ICC) || defined(__SUNPRO_C)) && defined(__x86_64__)  && !defined(HAVE_TICK_COUNTER) 
  224 typedef unsigned long long ticks;
 
  226 static __inline__ ticks getticks(
void)
 
  229      asm volatile(
"rdtsc" : 
"=a" (a), 
"=d" (d)); 
 
  230      return ((ticks)a) | (((ticks)d) << 32); 
 
  233 INLINE_ELAPSED(__inline__)
 
  235 #define HAVE_TICK_COUNTER 
  241 #if defined(__PGI) && defined(__x86_64__) && !defined(HAVE_TICK_COUNTER)  
  242 typedef unsigned long long ticks;
 
  243 static ticks getticks(
void)
 
  245     asm(
" rdtsc; shl    $0x20,%rdx; mov    %eax,%eax; or     %rdx,%rax;    ");
 
  247 INLINE_ELAPSED(__inline__)
 
  248 #define HAVE_TICK_COUNTER 
  252 #if defined(_MSC_VER) && _MSC_VER >= 1400 && (defined(_M_AMD64) || defined(_M_X64)) && !defined(HAVE_TICK_COUNTER) 
  255 #pragma intrinsic(__rdtsc) 
  256 typedef unsigned __int64 ticks;
 
  257 #define getticks __rdtsc 
  258 INLINE_ELAPSED(__inline)
 
  260 #define HAVE_TICK_COUNTER 
  269 #if (defined(__EDG_VERSION) || defined(__ECC)) && defined(__ia64__) && !defined(HAVE_TICK_COUNTER) 
  270 typedef unsigned long ticks;
 
  271 #include <ia64intrin.h> 
  273 static __inline__ ticks getticks(
void)
 
  275      return __getReg(_IA64_REG_AR_ITC);
 
  278 INLINE_ELAPSED(__inline__)
 
  280 #define HAVE_TICK_COUNTER 
  284 #if defined(__GNUC__) && defined(__ia64__) && !defined(HAVE_TICK_COUNTER) 
  285 typedef unsigned long ticks;
 
  287 static __inline__ ticks getticks(
void)
 
  291      __asm__ __volatile__ (
"mov %0=ar.itc" : 
"=r"(ret));
 
  295 INLINE_ELAPSED(__inline__)
 
  297 #define HAVE_TICK_COUNTER 
  301 #if defined(__hpux) && defined(__ia64) && !defined(HAVE_TICK_COUNTER) 
  302 #include <machine/sys/inline.h> 
  303 typedef unsigned long ticks;
 
  305 static inline ticks getticks(
void)
 
  309      ret = _Asm_mov_from_ar (_AREG_ITC);
 
  313 INLINE_ELAPSED(
inline)
 
  315 #define HAVE_TICK_COUNTER 
  319 #if defined(_MSC_VER) && defined(_M_IA64) && !defined(HAVE_TICK_COUNTER) 
  320 typedef unsigned __int64 ticks;
 
  325 ticks __getReg(
int whichReg);
 
  326 #pragma intrinsic(__getReg) 
  328 static __inline ticks getticks(
void)
 
  331      temp = __getReg(3116);
 
  335 INLINE_ELAPSED(
inline)
 
  337 #define HAVE_TICK_COUNTER 
  344 #if defined(__hppa__) || defined(__hppa) && !defined(HAVE_TICK_COUNTER) 
  345 typedef unsigned long ticks;
 
  348 static __inline__ ticks getticks(
void)
 
  352      __asm__ __volatile__(
"mfctl 16, %0": 
"=r" (ret));
 
  357 #  include <machine/inline.h> 
  358 static inline unsigned long getticks(
void)
 
  366 INLINE_ELAPSED(
inline)
 
  368 #define HAVE_TICK_COUNTER 
  373 #if defined(__GNUC__) && defined(__s390__) && !defined(HAVE_TICK_COUNTER) 
  374 typedef unsigned long long ticks;
 
  376 static __inline__ ticks getticks(
void)
 
  379      __asm__(
"stck 0(%0)" : : 
"a" (&(cycles)) : 
"memory", 
"cc");
 
  383 INLINE_ELAPSED(__inline__)
 
  385 #define HAVE_TICK_COUNTER 
  388 #if defined(__GNUC__) && defined(__alpha__) && !defined(HAVE_TICK_COUNTER) 
  393 typedef unsigned int ticks;
 
  395 static __inline__ ticks getticks(
void)
 
  398      __asm__ __volatile__ (
"rpcc %0" : 
"=r"(cc));
 
  399      return (cc & 0xFFFFFFFF);
 
  402 INLINE_ELAPSED(__inline__)
 
  404 #define HAVE_TICK_COUNTER 
  408 #if defined(__GNUC__) && defined(__sparc_v9__) && !defined(HAVE_TICK_COUNTER) 
  409 typedef unsigned long ticks;
 
  411 static __inline__ ticks getticks(
void)
 
  414      __asm__ __volatile__(
"rd %%tick, %0" : 
"=r" (ret));
 
  418 INLINE_ELAPSED(__inline__)
 
  420 #define HAVE_TICK_COUNTER 
  424 #if (defined(__DECC) || defined(__DECCXX)) && defined(__alpha) && defined(HAVE_C_ASM_H) && !defined(HAVE_TICK_COUNTER) 
  426 typedef unsigned int ticks;
 
  428 static __inline ticks getticks(
void)
 
  431      cc = 
asm(
"rpcc %v0");
 
  432      return (cc & 0xFFFFFFFF);
 
  435 INLINE_ELAPSED(__inline)
 
  437 #define HAVE_TICK_COUNTER 
  441 #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_SGI_CYCLE) && !defined(HAVE_TICK_COUNTER) 
  442 typedef struct timespec ticks;
 
  444 static inline ticks getticks(
void)
 
  447      clock_gettime(CLOCK_SGI_CYCLE, &t);
 
  451 static inline double elapsed(ticks t1, ticks t0)
 
  453      return ((
double)t1.tv_sec - (
double)t0.tv_sec) * 1.0E9 +
 
  454     ((double)t1.tv_nsec - (
double)t0.tv_nsec);
 
  456 #define HAVE_TICK_COUNTER 
  461 #if defined(HAVE__RTC) && !defined(HAVE_TICK_COUNTER) 
  462 #ifdef HAVE_INTRINSICS_H 
  463 #  include <intrinsics.h> 
  466 typedef long long ticks;
 
  468 #define getticks _rtc 
  470 INLINE_ELAPSED(
inline)
 
  472 #define HAVE_TICK_COUNTER 
  477 #if defined(HAVE_MIPS_ZBUS_TIMER) && HAVE_MIPS_ZBUS_TIMER 
  478 #if defined(__mips__) && !defined(HAVE_TICK_COUNTER) 
  479 #include <sys/mman.h> 
  483 typedef uint64_t ticks;
 
  485 static inline ticks getticks(
void)
 
  487   static uint64_t* addr = 0;
 
  491     uint32_t rq_addr = 0x10030000;
 
  495     pgsize = getpagesize();
 
  496     fd = open (
"/dev/mem", O_RDONLY | O_SYNC, 0);
 
  501     addr = mmap(0, pgsize, PROT_READ, MAP_SHARED, fd, rq_addr);
 
  503     if (addr == (uint64_t *)-1) {
 
  512 INLINE_ELAPSED(
inline)
 
  514 #define HAVE_TICK_COUNTER