4 #include "qemu/bitops.h"
5 #include "qemu/notify.h"
6 #include "qemu/host-utils.h"
8 #define NANOSECONDS_PER_SECOND 1000000000LL
12 #define SCALE_MS 1000000
19 * The following clock types are available:
21 * @QEMU_CLOCK_REALTIME: Real time clock
23 * The real time clock should be used only for stuff which does not
24 * change the virtual machine state, as it runs even if the virtual
27 * @QEMU_CLOCK_VIRTUAL: virtual clock
29 * The virtual clock only runs during the emulation. It stops
30 * when the virtual machine is stopped.
32 * @QEMU_CLOCK_HOST: host clock
34 * The host clock should be used for device models that emulate accurate
35 * real time sources. It will continue to run when the virtual machine
36 * is suspended, and it will reflect system time changes the host may
37 * undergo (e.g. due to NTP).
39 * @QEMU_CLOCK_VIRTUAL_RT: realtime clock used for icount warp
41 * Outside icount mode, this clock is the same as @QEMU_CLOCK_VIRTUAL.
42 * In icount mode, this clock counts nanoseconds while the virtual
43 * machine is running. It is used to increase @QEMU_CLOCK_VIRTUAL
44 * while the CPUs are sleeping and thus not executing instructions.
48 QEMU_CLOCK_REALTIME
= 0,
49 QEMU_CLOCK_VIRTUAL
= 1,
51 QEMU_CLOCK_VIRTUAL_RT
= 3,
56 * QEMU Timer attributes:
58 * An individual timer may be given one or multiple attributes when initialized.
59 * Each attribute corresponds to one bit. Attributes modify the processing
60 * of timers when they fire.
62 * The following attributes are available:
64 * QEMU_TIMER_ATTR_EXTERNAL: drives external subsystem
65 * QEMU_TIMER_ATTR_ALL: mask for all existing attributes
67 * Timers with this attribute do not recorded in rr mode, therefore it could be
68 * used for the subsystems that operate outside the guest core. Applicable only
69 * with virtual clock type.
72 #define QEMU_TIMER_ATTR_EXTERNAL ((int)BIT(0))
73 #define QEMU_TIMER_ATTR_ALL 0xffffffff
75 typedef struct QEMUTimerList QEMUTimerList
;
77 struct QEMUTimerListGroup
{
78 QEMUTimerList
*tl
[QEMU_CLOCK_MAX
];
81 typedef void QEMUTimerCB(void *opaque
);
82 typedef void QEMUTimerListNotifyCB(void *opaque
, QEMUClockType type
);
85 int64_t expire_time
; /* in nanoseconds */
86 QEMUTimerList
*timer_list
;
94 extern QEMUTimerListGroup main_loop_tlg
;
98 * @type: the clock type
100 * Get the nanosecond value of a clock with
103 * Returns: the clock value in nanoseconds
105 int64_t qemu_clock_get_ns(QEMUClockType type
);
109 * @type: the clock type
111 * Get the millisecond value of a clock with
114 * Returns: the clock value in milliseconds
116 static inline int64_t qemu_clock_get_ms(QEMUClockType type
)
118 return qemu_clock_get_ns(type
) / SCALE_MS
;
123 * @type: the clock type
125 * Get the microsecond value of a clock with
128 * Returns: the clock value in microseconds
130 static inline int64_t qemu_clock_get_us(QEMUClockType type
)
132 return qemu_clock_get_ns(type
) / SCALE_US
;
136 * qemu_clock_has_timers:
137 * @type: the clock type
139 * Determines whether a clock's default timer list
140 * has timers attached
142 * Note that this function should not be used when other threads also access
143 * the timer list. The return value may be outdated by the time it is acted
146 * Returns: true if the clock's default timer list
147 * has timers attached
149 bool qemu_clock_has_timers(QEMUClockType type
);
152 * qemu_clock_expired:
153 * @type: the clock type
155 * Determines whether a clock's default timer list
156 * has an expired timer.
158 * Returns: true if the clock's default timer list has
161 bool qemu_clock_expired(QEMUClockType type
);
164 * qemu_clock_use_for_deadline:
165 * @type: the clock type
167 * Determine whether a clock should be used for deadline
168 * calculations. Some clocks, for instance vm_clock with
169 * icount_enabled() set, do not count in nanoseconds.
170 * Such clocks are not used for deadline calculations, and are presumed
171 * to interrupt any poll using qemu_notify/aio_notify
174 * Returns: true if the clock runs in nanoseconds and
175 * should be used for a deadline.
177 bool qemu_clock_use_for_deadline(QEMUClockType type
);
180 * qemu_clock_deadline_ns_all:
181 * @type: the clock type
182 * @attr_mask: mask for the timer attributes that are included
183 * in deadline calculation
185 * Calculate the deadline across all timer lists associated
186 * with a clock (as opposed to just the default one)
187 * in nanoseconds, or -1 if no timer is set to expire.
189 * Returns: time until expiry in nanoseconds or -1
191 int64_t qemu_clock_deadline_ns_all(QEMUClockType type
, int attr_mask
);
194 * qemu_clock_get_main_loop_timerlist:
195 * @type: the clock type
197 * Return the default timer list associated with a clock.
199 * Returns: the default timer list
201 QEMUTimerList
*qemu_clock_get_main_loop_timerlist(QEMUClockType type
);
205 * @type: the clock type
207 * Call the notifier callback connected with the default timer
208 * list linked to the clock, or qemu_notify() if none.
210 void qemu_clock_notify(QEMUClockType type
);
214 * @type: the clock type
215 * @enabled: true to enable, false to disable
217 * Enable or disable a clock
218 * Disabling the clock will wait for related timerlists to stop
219 * executing qemu_run_timers. Thus, this functions should not
220 * be used from the callback of a timer that is based on @clock.
221 * Doing so would cause a deadlock.
223 * Caller should hold BQL.
225 void qemu_clock_enable(QEMUClockType type
, bool enabled
);
228 * qemu_clock_run_timers:
229 * @type: clock on which to operate
231 * Run all the timers associated with the default timer list
234 * Returns: true if any timer ran.
236 bool qemu_clock_run_timers(QEMUClockType type
);
239 * qemu_clock_run_all_timers:
241 * Run all the timers associated with the default timer list
244 * Returns: true if any timer ran.
246 bool qemu_clock_run_all_timers(void);
255 * @type: the clock type to associate with the timerlist
256 * @cb: the callback to call on notification
257 * @opaque: the opaque pointer to pass to the callback
259 * Create a new timerlist associated with the clock of
262 * Returns: a pointer to the QEMUTimerList created
264 QEMUTimerList
*timerlist_new(QEMUClockType type
,
265 QEMUTimerListNotifyCB
*cb
, void *opaque
);
269 * @timer_list: the timer list to free
271 * Frees a timer_list. It must have no active timers.
273 void timerlist_free(QEMUTimerList
*timer_list
);
276 * timerlist_has_timers:
277 * @timer_list: the timer list to operate on
279 * Determine whether a timer list has active timers
281 * Note that this function should not be used when other threads also access
282 * the timer list. The return value may be outdated by the time it is acted
285 * Returns: true if the timer list has timers.
287 bool timerlist_has_timers(QEMUTimerList
*timer_list
);
291 * @timer_list: the timer list to operate on
293 * Determine whether a timer list has any timers which
296 * Returns: true if the timer list has timers which
299 bool timerlist_expired(QEMUTimerList
*timer_list
);
302 * timerlist_deadline_ns:
303 * @timer_list: the timer list to operate on
305 * Determine the deadline for a timer_list, i.e.
306 * the number of nanoseconds until the first timer
307 * expires. Return -1 if there are no timers.
309 * Returns: the number of nanoseconds until the earliest
310 * timer expires -1 if none
312 int64_t timerlist_deadline_ns(QEMUTimerList
*timer_list
);
315 * timerlist_get_clock:
316 * @timer_list: the timer list to operate on
318 * Determine the clock type associated with a timer list.
320 * Returns: the clock type associated with the
323 QEMUClockType
timerlist_get_clock(QEMUTimerList
*timer_list
);
326 * timerlist_run_timers:
327 * @timer_list: the timer list to use
329 * Call all expired timers associated with the timer list.
331 * Returns: true if any timer expired
333 bool timerlist_run_timers(QEMUTimerList
*timer_list
);
337 * @timer_list: the timer list to use
339 * call the notifier callback associated with the timer list.
341 void timerlist_notify(QEMUTimerList
*timer_list
);
348 * timerlistgroup_init:
349 * @tlg: the timer list group
350 * @cb: the callback to call when a notify is required
351 * @opaque: the opaque pointer to be passed to the callback.
353 * Initialise a timer list group. This must already be
354 * allocated in memory and zeroed. The notifier callback is
355 * called whenever a clock in the timer list group is
356 * reenabled or whenever a timer associated with any timer
357 * list is modified. If @cb is specified as null, qemu_notify()
360 void timerlistgroup_init(QEMUTimerListGroup
*tlg
,
361 QEMUTimerListNotifyCB
*cb
, void *opaque
);
364 * timerlistgroup_deinit:
365 * @tlg: the timer list group
367 * Deinitialise a timer list group. This must already be
368 * initialised. Note the memory is not freed.
370 void timerlistgroup_deinit(QEMUTimerListGroup
*tlg
);
373 * timerlistgroup_run_timers:
374 * @tlg: the timer list group
376 * Run the timers associated with a timer list group.
377 * This will run timers on multiple clocks.
379 * Returns: true if any timer callback ran
381 bool timerlistgroup_run_timers(QEMUTimerListGroup
*tlg
);
384 * timerlistgroup_deadline_ns:
385 * @tlg: the timer list group
387 * Determine the deadline of the soonest timer to
388 * expire associated with any timer list linked to
389 * the timer list group. Only clocks suitable for
390 * deadline calculation are included.
392 * Returns: the deadline in nanoseconds or -1 if no
393 * timers are to expire.
395 int64_t timerlistgroup_deadline_ns(QEMUTimerListGroup
*tlg
);
403 * @ts: the timer to be initialised
404 * @timer_list_group: (optional) the timer list group to attach the timer to
405 * @type: the clock type to use
406 * @scale: the scale value for the timer
407 * @attributes: 0, or one or more OR'ed QEMU_TIMER_ATTR_<id> values
408 * @cb: the callback to be called when the timer expires
409 * @opaque: the opaque pointer to be passed to the callback
411 * Initialise a timer with the given scale and attributes,
412 * and associate it with timer list for given clock @type in @timer_list_group
413 * (or default timer list group, if NULL).
414 * The caller is responsible for allocating the memory.
416 * You need not call an explicit deinit call. Simply make
417 * sure it is not on a list with timer_del.
419 void timer_init_full(QEMUTimer
*ts
,
420 QEMUTimerListGroup
*timer_list_group
, QEMUClockType type
,
421 int scale
, int attributes
,
422 QEMUTimerCB
*cb
, void *opaque
);
426 * @ts: the timer to be initialised
427 * @type: the clock to associate with the timer
428 * @scale: the scale value for the timer
429 * @cb: the callback to call when the timer expires
430 * @opaque: the opaque pointer to pass to the callback
432 * Initialize a timer with the given scale on the default timer list
433 * associated with the clock.
434 * See timer_init_full for details.
436 static inline void timer_init(QEMUTimer
*ts
, QEMUClockType type
, int scale
,
437 QEMUTimerCB
*cb
, void *opaque
)
439 timer_init_full(ts
, NULL
, type
, scale
, 0, cb
, opaque
);
444 * @ts: the timer to be initialised
445 * @type: the clock to associate with the timer
446 * @cb: the callback to call when the timer expires
447 * @opaque: the opaque pointer to pass to the callback
449 * Initialize a timer with nanosecond scale on the default timer list
450 * associated with the clock.
451 * See timer_init_full for details.
453 static inline void timer_init_ns(QEMUTimer
*ts
, QEMUClockType type
,
454 QEMUTimerCB
*cb
, void *opaque
)
456 timer_init(ts
, type
, SCALE_NS
, cb
, opaque
);
461 * @ts: the timer to be initialised
462 * @type: the clock to associate with the timer
463 * @cb: the callback to call when the timer expires
464 * @opaque: the opaque pointer to pass to the callback
466 * Initialize a timer with microsecond scale on the default timer list
467 * associated with the clock.
468 * See timer_init_full for details.
470 static inline void timer_init_us(QEMUTimer
*ts
, QEMUClockType type
,
471 QEMUTimerCB
*cb
, void *opaque
)
473 timer_init(ts
, type
, SCALE_US
, cb
, opaque
);
478 * @ts: the timer to be initialised
479 * @type: the clock to associate with the timer
480 * @cb: the callback to call when the timer expires
481 * @opaque: the opaque pointer to pass to the callback
483 * Initialize a timer with millisecond scale on the default timer list
484 * associated with the clock.
485 * See timer_init_full for details.
487 static inline void timer_init_ms(QEMUTimer
*ts
, QEMUClockType type
,
488 QEMUTimerCB
*cb
, void *opaque
)
490 timer_init(ts
, type
, SCALE_MS
, cb
, opaque
);
495 * @timer_list_group: (optional) the timer list group to attach the timer to
496 * @type: the clock type to use
497 * @scale: the scale value for the timer
498 * @attributes: 0, or one or more OR'ed QEMU_TIMER_ATTR_<id> values
499 * @cb: the callback to be called when the timer expires
500 * @opaque: the opaque pointer to be passed to the callback
502 * Create a new timer with the given scale and attributes,
503 * and associate it with timer list for given clock @type in @timer_list_group
504 * (or default timer list group, if NULL).
505 * The memory is allocated by the function.
507 * This is not the preferred interface unless you know you
508 * are going to call timer_free. Use timer_init or timer_init_full instead.
510 * The default timer list has one special feature: in icount mode,
511 * %QEMU_CLOCK_VIRTUAL timers are run in the vCPU thread. This is
512 * not true of other timer lists, which are typically associated
513 * with an AioContext---each of them runs its timer callbacks in its own
516 * Returns: a pointer to the timer
518 static inline QEMUTimer
*timer_new_full(QEMUTimerListGroup
*timer_list_group
,
520 int scale
, int attributes
,
521 QEMUTimerCB
*cb
, void *opaque
)
523 QEMUTimer
*ts
= g_malloc0(sizeof(QEMUTimer
));
524 timer_init_full(ts
, timer_list_group
, type
, scale
, attributes
, cb
, opaque
);
530 * @type: the clock type to use
531 * @scale: the scale value for the timer
532 * @cb: the callback to be called when the timer expires
533 * @opaque: the opaque pointer to be passed to the callback
535 * Create a new timer with the given scale,
536 * and associate it with the default timer list for the clock type @type.
537 * See timer_new_full for details.
539 * Returns: a pointer to the timer
541 static inline QEMUTimer
*timer_new(QEMUClockType type
, int scale
,
542 QEMUTimerCB
*cb
, void *opaque
)
544 return timer_new_full(NULL
, type
, scale
, 0, cb
, opaque
);
549 * @type: the clock type to associate with the timer
550 * @cb: the callback to call when the timer expires
551 * @opaque: the opaque pointer to pass to the callback
553 * Create a new timer with nanosecond scale on the default timer list
554 * associated with the clock.
555 * See timer_new_full for details.
557 * Returns: a pointer to the newly created timer
559 static inline QEMUTimer
*timer_new_ns(QEMUClockType type
, QEMUTimerCB
*cb
,
562 return timer_new(type
, SCALE_NS
, cb
, opaque
);
567 * @type: the clock type to associate with the timer
568 * @cb: the callback to call when the timer expires
569 * @opaque: the opaque pointer to pass to the callback
571 * Create a new timer with microsecond scale on the default timer list
572 * associated with the clock.
573 * See timer_new_full for details.
575 * Returns: a pointer to the newly created timer
577 static inline QEMUTimer
*timer_new_us(QEMUClockType type
, QEMUTimerCB
*cb
,
580 return timer_new(type
, SCALE_US
, cb
, opaque
);
585 * @type: the clock type to associate with the timer
586 * @cb: the callback to call when the timer expires
587 * @opaque: the opaque pointer to pass to the callback
589 * Create a new timer with millisecond scale on the default timer list
590 * associated with the clock.
591 * See timer_new_full for details.
593 * Returns: a pointer to the newly created timer
595 static inline QEMUTimer
*timer_new_ms(QEMUClockType type
, QEMUTimerCB
*cb
,
598 return timer_new(type
, SCALE_MS
, cb
, opaque
);
603 * @ts: the timer to be de-initialised
605 * Deassociate the timer from any timerlist. You should
606 * call timer_del before. After this call, any further
607 * timer_del call cannot cause dangling pointer accesses
608 * even if the previously used timerlist is freed.
610 void timer_deinit(QEMUTimer
*ts
);
616 * Free a timer (it must not be on the active list)
618 static inline void timer_free(QEMUTimer
*ts
)
627 * Delete a timer from the active list.
629 * This function is thread-safe but the timer and its timer list must not be
630 * freed while this function is running.
632 void timer_del(QEMUTimer
*ts
);
637 * @expire_time: the expiry time in nanoseconds
639 * Modify a timer to expire at @expire_time
641 * This function is thread-safe but the timer and its timer list must not be
642 * freed while this function is running.
644 void timer_mod_ns(QEMUTimer
*ts
, int64_t expire_time
);
647 * timer_mod_anticipate_ns:
649 * @expire_time: the expiry time in nanoseconds
651 * Modify a timer to expire at @expire_time or the current time,
652 * whichever comes earlier.
654 * This function is thread-safe but the timer and its timer list must not be
655 * freed while this function is running.
657 void timer_mod_anticipate_ns(QEMUTimer
*ts
, int64_t expire_time
);
662 * @expire_time: the expire time in the units associated with the timer
664 * Modify a timer to expiry at @expire_time, taking into
665 * account the scale associated with the timer.
667 * This function is thread-safe but the timer and its timer list must not be
668 * freed while this function is running.
670 void timer_mod(QEMUTimer
*ts
, int64_t expire_timer
);
673 * timer_mod_anticipate:
675 * @expire_time: the expire time in the units associated with the timer
677 * Modify a timer to expire at @expire_time or the current time, whichever
678 * comes earlier, taking into account the scale associated with the timer.
680 * This function is thread-safe but the timer and its timer list must not be
681 * freed while this function is running.
683 void timer_mod_anticipate(QEMUTimer
*ts
, int64_t expire_time
);
689 * Determines whether a timer is pending (i.e. is on the
690 * active list of timers, whether or not it has not yet expired).
692 * Returns: true if the timer is pending
694 bool timer_pending(QEMUTimer
*ts
);
699 * @current_time: the current time
701 * Determines whether a timer has expired.
703 * Returns: true if the timer has expired
705 bool timer_expired(QEMUTimer
*timer_head
, int64_t current_time
);
708 * timer_expire_time_ns:
711 * Determine the expiry time of a timer
713 * Returns: the expiry time in nanoseconds
715 uint64_t timer_expire_time_ns(QEMUTimer
*ts
);
722 * Read a timer @ts from a file @f
724 void timer_get(QEMUFile
*f
, QEMUTimer
*ts
);
731 void timer_put(QEMUFile
*f
, QEMUTimer
*ts
);
734 * General utility functions
738 * qemu_timeout_ns_to_ms:
739 * @ns: nanosecond timeout value
741 * Convert a nanosecond timeout value (or -1) to
742 * a millisecond value (or -1), always rounding up.
744 * Returns: millisecond timeout value
746 int qemu_timeout_ns_to_ms(int64_t ns
);
750 * @fds: Array of file descriptors
751 * @nfds: number of file descriptors
752 * @timeout: timeout in nanoseconds
754 * Perform a poll like g_poll but with a timeout in nanoseconds.
755 * See g_poll documentation for further details.
757 * Returns: number of fds ready
759 int qemu_poll_ns(GPollFD
*fds
, guint nfds
, int64_t timeout
);
762 * qemu_soonest_timeout:
763 * @timeout1: first timeout in nanoseconds (or -1 for infinite)
764 * @timeout2: second timeout in nanoseconds (or -1 for infinite)
766 * Calculates the soonest of two timeout values. -1 means infinite, which
767 * is later than any other value.
769 * Returns: soonest timeout value in nanoseconds (or -1 for infinite)
771 static inline int64_t qemu_soonest_timeout(int64_t timeout1
, int64_t timeout2
)
773 /* we can abuse the fact that -1 (which means infinite) is a maximal
774 * value when cast to unsigned. As this is disgusting, it's kept in
775 * one inline function.
777 return ((uint64_t) timeout1
< (uint64_t) timeout2
) ? timeout1
: timeout2
;
783 * Initialise the clock & timer infrastructure
785 void init_clocks(QEMUTimerListNotifyCB
*notify_cb
);
787 static inline int64_t get_max_clock_jump(void)
789 /* This should be small enough to prevent excessive interrupts from being
790 * generated by the RTC on clock jumps, but large enough to avoid frequent
791 * unnecessary resets in idle VMs.
793 return 60 * NANOSECONDS_PER_SECOND
;
797 * Low level clock functions
800 /* get host real time in nanosecond */
801 static inline int64_t get_clock_realtime(void)
805 gettimeofday(&tv
, NULL
);
806 return tv
.tv_sec
* 1000000000LL + (tv
.tv_usec
* 1000);
809 /* Warning: don't insert tracepoints into these functions, they are
810 also used by simpletrace backend and tracepoints would cause
811 an infinite recursion! */
813 extern int64_t clock_freq
;
815 static inline int64_t get_clock(void)
818 QueryPerformanceCounter(&ti
);
819 return muldiv64(ti
.QuadPart
, NANOSECONDS_PER_SECOND
, clock_freq
);
824 extern int use_rt_clock
;
826 static inline int64_t get_clock(void)
830 clock_gettime(CLOCK_MONOTONIC
, &ts
);
831 return ts
.tv_sec
* 1000000000LL + ts
.tv_nsec
;
833 /* XXX: using gettimeofday leads to problems if the date
834 changes, so it should be avoided. */
835 return get_clock_realtime();
840 /*******************************************/
841 /* host CPU ticks (if available) */
843 #if defined(_ARCH_PPC)
845 static inline int64_t cpu_get_host_ticks(void)
849 /* This reads timebase in one 64bit go and includes Cell workaround from:
850 http://ozlabs.org/pipermail/linuxppc-dev/2006-October/027052.html
852 __asm__
__volatile__ ("mftb %0\n\t"
857 /* http://ozlabs.org/pipermail/linuxppc-dev/1999-October/003889.html */
859 __asm__
__volatile__ ("mfspr %1,269\n\t" /* mftbu */
860 "mfspr %L0,268\n\t" /* mftb */
861 "mfspr %0,269\n\t" /* mftbu */
864 : "=r" (retval
), "=r" (junk
));
869 #elif defined(__i386__)
871 static inline int64_t cpu_get_host_ticks(void)
874 asm volatile ("rdtsc" : "=A" (val
));
878 #elif defined(__x86_64__)
880 static inline int64_t cpu_get_host_ticks(void)
884 asm volatile("rdtsc" : "=a" (low
), "=d" (high
));
891 #elif defined(__hppa__)
893 static inline int64_t cpu_get_host_ticks(void)
896 asm volatile ("mfctl %%cr16, %0" : "=r"(val
));
900 #elif defined(__s390__)
902 static inline int64_t cpu_get_host_ticks(void)
905 asm volatile("stck 0(%1)" : "=m" (val
) : "a" (&val
) : "cc");
909 #elif defined(__sparc__)
911 static inline int64_t cpu_get_host_ticks (void)
915 asm volatile("rd %%tick,%0" : "=r"(rval
));
918 /* We need an %o or %g register for this. For recent enough gcc
919 there is an "h" constraint for that. Don't bother with that. */
927 asm volatile("rd %%tick,%%g1; srlx %%g1,32,%0; mov %%g1,%1"
928 : "=r"(rval
.i32
.high
), "=r"(rval
.i32
.low
) : : "g1");
933 #elif defined(__mips__) && \
934 ((defined(__mips_isa_rev) && __mips_isa_rev >= 2) || defined(__linux__))
936 * binutils wants to use rdhwr only on mips32r2
937 * but as linux kernel emulate it, it's fine
941 #define MIPS_RDHWR(rd, value) { \
942 __asm__ __volatile__ (".set push\n\t" \
943 ".set mips32r2\n\t" \
944 "rdhwr %0, "rd"\n\t" \
949 static inline int64_t cpu_get_host_ticks(void)
951 /* On kernels >= 2.6.25 rdhwr <reg>, $2 and $3 are emulated */
953 static uint32_t cyc_per_count
= 0;
955 if (!cyc_per_count
) {
956 MIPS_RDHWR("$3", cyc_per_count
);
959 MIPS_RDHWR("$2", count
);
960 return (int64_t)(count
* cyc_per_count
);
963 #elif defined(__alpha__)
965 static inline int64_t cpu_get_host_ticks(void)
970 asm volatile("rpcc %0" : "=r"(cc
));
977 /* The host CPU doesn't have an easily accessible cycle counter.
978 Just return a monotonically increasing value. This will be
979 totally wrong, but hopefully better than nothing. */
980 static inline int64_t cpu_get_host_ticks(void)
986 #ifdef CONFIG_PROFILER
987 static inline int64_t profile_getclock(void)
992 extern int64_t dev_time
;