]>
git.ipfire.org Git - thirdparty/squid.git/blob - lib/profiler/get_tick.h
1 #ifndef _PROFILER_GET_TICK_H_
2 #define _PROFILER_GET_TICK_H_
9 typedef int64_t hrtime_t
;
12 #if defined(__GNUC__) && ( defined(__i386) || defined(__i386__) )
13 static inline hrtime_t
18 asm volatile ("rdtsc":"=A" (regs
));
20 /* We need return value, we rely on CC to optimise out needless subf calls */
21 /* Note that "rdtsc" is relatively slow OP and stalls the CPU pipes, so use it wisely */
24 #elif defined(__GNUC__) && ( defined(__x86_64) || defined(__x86_64__) )
25 static inline hrtime_t
29 // Based on an example in Wikipedia
30 /* We cannot use "=A", since this would use %rax on x86_64 */
31 asm volatile ("rdtsc" : "=a" (lo
), "=d" (hi
));
32 return (hrtime_t
)hi
<< 32 | lo
;
35 #elif defined(__GNUC__) && defined(__alpha)
36 static inline hrtime_t
41 asm volatile ("rpcc %0" : "=r" (regs
));
45 #elif defined(_M_IX86) && defined(_MSC_VER) /* x86 platform on Microsoft C Compiler ONLY */
46 static __inline hrtime_t
54 mov eax
,DWORD PTR regs
[0]
55 mov edx
,DWORD PTR regs
[4]
61 /* This CPU is unsupported. Short-circuit, no profiling here */
63 #undef USE_XPROF_STATS
64 #define USE_XPROF_STATS 0
67 #endif /* USE_XPROF_STATS */
68 #endif /* _PROFILING_H_ */