1 /******************************************************************************
3 * Copyright © International Business Machines Corp., 2006-2008
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 * To be included in some testcases.
28 * Darren Hart <dvhltc@us.ibm.com>
29 * Giuseppe Cavallaro <peppe.cavallarost.com>
32 * It directly comes from the librttest.h (see its HISTORY).
34 *****************************************************************************/
36 #undef TSC_UNSUPPORTED
40 #define rdtscll(val) __asm__ __volatile__("rdtsc" : "=A" (val))
41 #elif defined(__x86_64__)
42 #define rdtscll(val) \
45 __asm__ __volatile__ ("rdtsc" : "=a" (low), "=d" (high)); \
46 val = (uint64_t)high << 32 | low; \
48 #elif defined(__powerpc__)
49 #if defined(__powerpc64__) /* 64bit version */
50 #define rdtscll(val) \
52 __asm__ __volatile__ ("mfspr %0, 268" : "=r" (val)); \
54 #else /*__powerpc__ 32bit version */
55 #define rdtscll(val) \
57 uint32_t tbhi, tblo ; \
58 __asm__ __volatile__ ("mftbu %0" : "=r" (tbhi)); \
59 __asm__ __volatile__ ("mftbl %0" : "=r" (tblo)); \
60 val = 1000 * ((uint64_t) tbhi << 32) | tblo; \
64 #warning TSC UNSUPPORTED
65 /* All tests will be compiled also for the
66 * architecture without TSC support (e.g. SH).
67 * At run-time these will fail with ENOTSUP.
69 #define rdtscll(val) do { } while (0)
70 #define TSC_UNSUPPORTED