]>
Commit | Line | Data |
---|---|---|
d5efd131 | 1 | /* High precision, low overhead timing functions. IA-64 version. |
2b778ceb | 2 | Copyright (C) 2001-2021 Free Software Foundation, Inc. |
d5efd131 | 3 | This file is part of the GNU C Library. |
d5efd131 MF |
4 | |
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library 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 the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
75efb018 | 16 | License along with the GNU C Library; if not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
d5efd131 MF |
18 | |
19 | #ifndef _HP_TIMING_H | |
20 | #define _HP_TIMING_H 1 | |
21 | ||
d5efd131 MF |
22 | /* We indeed have inlined functions. */ |
23 | #define HP_TIMING_INLINE (1) | |
24 | ||
25 | /* We use 64bit values for the times. */ | |
26 | typedef unsigned long int hp_timing_t; | |
27 | ||
d5efd131 MF |
28 | /* The Itanium/Merced has a bug where the ar.itc register value read |
29 | is not correct in some situations. The solution is to read again. | |
30 | For now we always do this until we know how to recognize a fixed | |
31 | processor implementation. */ | |
32 | #define REPEAT_READ(val) __builtin_expect ((long int) val == -1, 0) | |
33 | ||
34 | /* That's quite simple. Use the `ar.itc' instruction. */ | |
35 | #define HP_TIMING_NOW(Var) \ | |
36 | ({ unsigned long int __itc; \ | |
37 | do \ | |
38 | asm volatile ("mov %0=ar.itc" : "=r" (__itc) : : "memory"); \ | |
39 | while (REPEAT_READ (__itc)); \ | |
40 | Var = __itc; }) | |
41 | ||
86e1a7ff | 42 | #include <hp-timing-common.h> |
d5efd131 MF |
43 | |
44 | #endif /* hp-timing.h */ |