]>
git.ipfire.org Git - thirdparty/squid.git/blob - lib/profiler/get_tick.h
2 * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef _PROFILER_GET_TICK_H_
10 #define _PROFILER_GET_TICK_H_
15 * Ensure that any changes here are synchronised with SQUID_CHECK_FUNCTIONAL_CPU_PROFILER
19 typedef int64_t hrtime_t
;
22 #if defined(__GNUC__) && ( defined(__i386) || defined(__i386__) )
23 static inline hrtime_t
28 asm volatile ("rdtsc":"=A" (regs
));
30 /* We need return value, we rely on CC to optimise out needless subf calls */
31 /* Note that "rdtsc" is relatively slow OP and stalls the CPU pipes, so use it wisely */
34 #elif defined(__GNUC__) && ( defined(__x86_64) || defined(__x86_64__) )
35 static inline hrtime_t
39 // Based on an example in Wikipedia
40 /* We cannot use "=A", since this would use %rax on x86_64 */
41 asm volatile ("rdtsc" : "=a" (lo
), "=d" (hi
));
42 return (hrtime_t
)hi
<< 32 | lo
;
45 #elif defined(__GNUC__) && defined(__alpha)
46 static inline hrtime_t
51 asm volatile ("rpcc %0" : "=r" (regs
));
55 #elif defined(_M_IX86) && defined(_MSC_VER) /* x86 platform on Microsoft C Compiler ONLY */
56 static __inline hrtime_t
64 mov eax
,DWORD PTR regs
[0]
65 mov edx
,DWORD PTR regs
[4]
71 /* This CPU is unsupported. Short-circuit, no profiling here */
72 // #error for configure tests to prevent library construction
73 #error This CPU is unsupported. No profiling available here.
76 #endif /* USE_XPROF_STATS */
77 #endif /* _PROFILING_H_ */