|
1 | | -/* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. |
| 1 | +/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. |
2 | 2 |
|
3 | 3 | This program is free software; you can redistribute it and/or modify |
4 | 4 | it under the terms of the GNU General Public License as published by |
@@ -124,6 +124,42 @@ void init_timers(void) |
124 | 124 | Pick best replacements. |
125 | 125 | */ |
126 | 126 |
|
| 127 | + /* |
| 128 | + For WAIT, the cycle timer is used by default. However, it is not available |
| 129 | + on all architectures. Fall back to the nanosecond timer in this case. It is |
| 130 | + unlikely that neither cycle nor nanosecond are available, but we continue |
| 131 | + probing less resolution timers anyway for consistency with other events. |
| 132 | + */ |
| 133 | + |
| 134 | + if (cycle_to_pico != 0) |
| 135 | + { |
| 136 | + /* Normal case. */ |
| 137 | + wait_timer= TIMER_NAME_CYCLE; |
| 138 | + } |
| 139 | + else if (nanosec_to_pico != 0) |
| 140 | + { |
| 141 | + /* Robustness, no known cases. */ |
| 142 | + wait_timer= TIMER_NAME_NANOSEC; |
| 143 | + } |
| 144 | + else if (microsec_to_pico != 0) |
| 145 | + { |
| 146 | + /* Robustness, no known cases. */ |
| 147 | + wait_timer= TIMER_NAME_MICROSEC; |
| 148 | + } |
| 149 | + else if (millisec_to_pico != 0) |
| 150 | + { |
| 151 | + /* Robustness, no known cases. */ |
| 152 | + wait_timer= TIMER_NAME_MILLISEC; |
| 153 | + } |
| 154 | + else |
| 155 | + { |
| 156 | + /* |
| 157 | + Will never be reached on any architecture, but must provide a default if |
| 158 | + no other timers are available. |
| 159 | + */ |
| 160 | + wait_timer= TIMER_NAME_TICK; |
| 161 | + } |
| 162 | + |
127 | 163 | /* |
128 | 164 | For STAGE and STATEMENT, a timer with a fixed frequency is better. |
129 | 165 | The prefered timer is nanosecond, or lower resolutions. |
@@ -174,7 +210,7 @@ void init_timers(void) |
174 | 210 | else if (millisec_to_pico != 0) |
175 | 211 | { |
176 | 212 | /* Robustness, no known cases. */ |
177 | | - idle_timer= TIMER_NAME_MILLISEC; |
| 213 | + wait_timer= TIMER_NAME_MILLISEC; |
178 | 214 | } |
179 | 215 | else if (tick_to_pico != 0) |
180 | 216 | { |
|
0 commit comments