cpus: make icount warp behave well with respect to stop/cont
[qemu/ar7.git] / include / qemu / timer.h
blobd9df0940d95087cb7b3ec82dd8e7c65e78df182e
1 #ifndef QEMU_TIMER_H
2 #define QEMU_TIMER_H
4 #include "qemu/typedefs.h"
5 #include "qemu-common.h"
6 #include "qemu/notify.h"
8 /* timers */
10 #define SCALE_MS 1000000
11 #define SCALE_US 1000
12 #define SCALE_NS 1
14 /**
15 * QEMUClockType:
17 * The following clock types are available:
19 * @QEMU_CLOCK_REALTIME: Real time clock
21 * The real time clock should be used only for stuff which does not
22 * change the virtual machine state, as it is run even if the virtual
23 * machine is stopped. The real time clock has a frequency of 1000
24 * Hz.
26 * @QEMU_CLOCK_VIRTUAL: virtual clock
28 * The virtual clock is only run during the emulation. It is stopped
29 * when the virtual machine is stopped. Virtual timers use a high
30 * precision clock, usually cpu cycles (use ticks_per_sec).
32 * @QEMU_CLOCK_HOST: host clock
34 * The host clock should be use 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). The host clock has the same precision as
38 * the virtual clock.
40 * @QEMU_CLOCK_VIRTUAL_RT: realtime clock used for icount warp
42 * Outside icount mode, this clock is the same as @QEMU_CLOCK_VIRTUAL.
43 * In icount mode, this clock counts nanoseconds while the virtual
44 * machine is running. It is used to increase @QEMU_CLOCK_VIRTUAL
45 * while the CPUs are sleeping and thus not executing instructions.
48 typedef enum {
49 QEMU_CLOCK_REALTIME = 0,
50 QEMU_CLOCK_VIRTUAL = 1,
51 QEMU_CLOCK_HOST = 2,
52 QEMU_CLOCK_VIRTUAL_RT = 3,
53 QEMU_CLOCK_MAX
54 } QEMUClockType;
56 typedef struct QEMUTimerList QEMUTimerList;
58 struct QEMUTimerListGroup {
59 QEMUTimerList *tl[QEMU_CLOCK_MAX];
62 typedef void QEMUTimerCB(void *opaque);
63 typedef void QEMUTimerListNotifyCB(void *opaque);
65 struct QEMUTimer {
66 int64_t expire_time; /* in nanoseconds */
67 QEMUTimerList *timer_list;
68 QEMUTimerCB *cb;
69 void *opaque;
70 QEMUTimer *next;
71 int scale;
74 extern QEMUTimerListGroup main_loop_tlg;
77 * QEMUClockType
81 * qemu_clock_get_ns;
82 * @type: the clock type
84 * Get the nanosecond value of a clock with
85 * type @type
87 * Returns: the clock value in nanoseconds
89 int64_t qemu_clock_get_ns(QEMUClockType type);
91 /**
92 * qemu_clock_get_ms;
93 * @type: the clock type
95 * Get the millisecond value of a clock with
96 * type @type
98 * Returns: the clock value in milliseconds
100 static inline int64_t qemu_clock_get_ms(QEMUClockType type)
102 return qemu_clock_get_ns(type) / SCALE_MS;
106 * qemu_clock_get_us;
107 * @type: the clock type
109 * Get the microsecond value of a clock with
110 * type @type
112 * Returns: the clock value in microseconds
114 static inline int64_t qemu_clock_get_us(QEMUClockType type)
116 return qemu_clock_get_ns(type) / SCALE_US;
120 * qemu_clock_has_timers:
121 * @type: the clock type
123 * Determines whether a clock's default timer list
124 * has timers attached
126 * Note that this function should not be used when other threads also access
127 * the timer list. The return value may be outdated by the time it is acted
128 * upon.
130 * Returns: true if the clock's default timer list
131 * has timers attached
133 bool qemu_clock_has_timers(QEMUClockType type);
136 * qemu_clock_expired:
137 * @type: the clock type
139 * Determines whether a clock's default timer list
140 * has an expired clock.
142 * Returns: true if the clock's default timer list has
143 * an expired timer
145 bool qemu_clock_expired(QEMUClockType type);
148 * qemu_clock_use_for_deadline:
149 * @type: the clock type
151 * Determine whether a clock should be used for deadline
152 * calculations. Some clocks, for instance vm_clock with
153 * use_icount set, do not count in nanoseconds. Such clocks
154 * are not used for deadline calculations, and are presumed
155 * to interrupt any poll using qemu_notify/aio_notify
156 * etc.
158 * Returns: true if the clock runs in nanoseconds and
159 * should be used for a deadline.
161 bool qemu_clock_use_for_deadline(QEMUClockType type);
164 * qemu_clock_deadline_ns_all:
165 * @type: the clock type
167 * Calculate the deadline across all timer lists associated
168 * with a clock (as opposed to just the default one)
169 * in nanoseconds, or -1 if no timer is set to expire.
171 * Returns: time until expiry in nanoseconds or -1
173 int64_t qemu_clock_deadline_ns_all(QEMUClockType type);
176 * qemu_clock_get_main_loop_timerlist:
177 * @type: the clock type
179 * Return the default timer list assocatiated with a clock.
181 * Returns: the default timer list
183 QEMUTimerList *qemu_clock_get_main_loop_timerlist(QEMUClockType type);
186 * qemu_clock_nofify:
187 * @type: the clock type
189 * Call the notifier callback connected with the default timer
190 * list linked to the clock, or qemu_notify() if none.
192 void qemu_clock_notify(QEMUClockType type);
195 * qemu_clock_enable:
196 * @type: the clock type
197 * @enabled: true to enable, false to disable
199 * Enable or disable a clock
200 * Disabling the clock will wait for related timerlists to stop
201 * executing qemu_run_timers. Thus, this functions should not
202 * be used from the callback of a timer that is based on @clock.
203 * Doing so would cause a deadlock.
205 * Caller should hold BQL.
207 void qemu_clock_enable(QEMUClockType type, bool enabled);
210 * qemu_clock_warp:
211 * @type: the clock type
213 * Warp a clock to a new value
215 void qemu_clock_warp(QEMUClockType type);
218 * qemu_clock_register_reset_notifier:
219 * @type: the clock type
220 * @notifier: the notifier function
222 * Register a notifier function to call when the clock
223 * concerned is reset.
225 void qemu_clock_register_reset_notifier(QEMUClockType type,
226 Notifier *notifier);
229 * qemu_clock_unregister_reset_notifier:
230 * @type: the clock type
231 * @notifier: the notifier function
233 * Unregister a notifier function to call when the clock
234 * concerned is reset.
236 void qemu_clock_unregister_reset_notifier(QEMUClockType type,
237 Notifier *notifier);
240 * qemu_clock_run_timers:
241 * @type: clock on which to operate
243 * Run all the timers associated with the default timer list
244 * of a clock.
246 * Returns: true if any timer ran.
248 bool qemu_clock_run_timers(QEMUClockType type);
251 * qemu_clock_run_all_timers:
253 * Run all the timers associated with the default timer list
254 * of every clock.
256 * Returns: true if any timer ran.
258 bool qemu_clock_run_all_timers(void);
261 * QEMUTimerList
265 * timerlist_new:
266 * @type: the clock type to associate with the timerlist
267 * @cb: the callback to call on notification
268 * @opaque: the opaque pointer to pass to the callback
270 * Create a new timerlist associated with the clock of
271 * type @type.
273 * Returns: a pointer to the QEMUTimerList created
275 QEMUTimerList *timerlist_new(QEMUClockType type,
276 QEMUTimerListNotifyCB *cb, void *opaque);
279 * timerlist_free:
280 * @timer_list: the timer list to free
282 * Frees a timer_list. It must have no active timers.
284 void timerlist_free(QEMUTimerList *timer_list);
287 * timerlist_has_timers:
288 * @timer_list: the timer list to operate on
290 * Determine whether a timer list has active timers
292 * Note that this function should not be used when other threads also access
293 * the timer list. The return value may be outdated by the time it is acted
294 * upon.
296 * Returns: true if the timer list has timers.
298 bool timerlist_has_timers(QEMUTimerList *timer_list);
301 * timerlist_expired:
302 * @timer_list: the timer list to operate on
304 * Determine whether a timer list has any timers which
305 * are expired.
307 * Returns: true if the timer list has timers which
308 * have expired.
310 bool timerlist_expired(QEMUTimerList *timer_list);
313 * timerlist_deadline_ns:
314 * @timer_list: the timer list to operate on
316 * Determine the deadline for a timer_list, i.e.
317 * the number of nanoseconds until the first timer
318 * expires. Return -1 if there are no timers.
320 * Returns: the number of nanoseconds until the earliest
321 * timer expires -1 if none
323 int64_t timerlist_deadline_ns(QEMUTimerList *timer_list);
326 * timerlist_get_clock:
327 * @timer_list: the timer list to operate on
329 * Determine the clock type associated with a timer list.
331 * Returns: the clock type associated with the
332 * timer list.
334 QEMUClockType timerlist_get_clock(QEMUTimerList *timer_list);
337 * timerlist_run_timers:
338 * @timer_list: the timer list to use
340 * Call all expired timers associated with the timer list.
342 * Returns: true if any timer expired
344 bool timerlist_run_timers(QEMUTimerList *timer_list);
347 * timerlist_notify:
348 * @timer_list: the timer list to use
350 * call the notifier callback associated with the timer list.
352 void timerlist_notify(QEMUTimerList *timer_list);
355 * QEMUTimerListGroup
359 * timerlistgroup_init:
360 * @tlg: the timer list group
361 * @cb: the callback to call when a notify is required
362 * @opaque: the opaque pointer to be passed to the callback.
364 * Initialise a timer list group. This must already be
365 * allocated in memory and zeroed. The notifier callback is
366 * called whenever a clock in the timer list group is
367 * reenabled or whenever a timer associated with any timer
368 * list is modified. If @cb is specified as null, qemu_notify()
369 * is used instead.
371 void timerlistgroup_init(QEMUTimerListGroup *tlg,
372 QEMUTimerListNotifyCB *cb, void *opaque);
375 * timerlistgroup_deinit:
376 * @tlg: the timer list group
378 * Deinitialise a timer list group. This must already be
379 * initialised. Note the memory is not freed.
381 void timerlistgroup_deinit(QEMUTimerListGroup *tlg);
384 * timerlistgroup_run_timers:
385 * @tlg: the timer list group
387 * Run the timers associated with a timer list group.
388 * This will run timers on multiple clocks.
390 * Returns: true if any timer callback ran
392 bool timerlistgroup_run_timers(QEMUTimerListGroup *tlg);
395 * timerlistgroup_deadline_ns:
396 * @tlg: the timer list group
398 * Determine the deadline of the soonest timer to
399 * expire associated with any timer list linked to
400 * the timer list group. Only clocks suitable for
401 * deadline calculation are included.
403 * Returns: the deadline in nanoseconds or -1 if no
404 * timers are to expire.
406 int64_t timerlistgroup_deadline_ns(QEMUTimerListGroup *tlg);
409 * QEMUTimer
413 * timer_init:
414 * @ts: the timer to be initialised
415 * @timer_list: the timer list to attach the timer to
416 * @scale: the scale value for the timer
417 * @cb: the callback to be called when the timer expires
418 * @opaque: the opaque pointer to be passed to the callback
420 * Initialise a new timer and associate it with @timer_list.
421 * The caller is responsible for allocating the memory.
423 * You need not call an explicit deinit call. Simply make
424 * sure it is not on a list with timer_del.
426 void timer_init(QEMUTimer *ts,
427 QEMUTimerList *timer_list, int scale,
428 QEMUTimerCB *cb, void *opaque);
431 * timer_new_tl:
432 * @timer_list: the timer list to attach the timer to
433 * @scale: the scale value for the timer
434 * @cb: the callback to be called when the timer expires
435 * @opaque: the opaque pointer to be passed to the callback
437 * Creeate a new timer and associate it with @timer_list.
438 * The memory is allocated by the function.
440 * This is not the preferred interface unless you know you
441 * are going to call timer_free. Use timer_init instead.
443 * Returns: a pointer to the timer
445 static inline QEMUTimer *timer_new_tl(QEMUTimerList *timer_list,
446 int scale,
447 QEMUTimerCB *cb,
448 void *opaque)
450 QEMUTimer *ts = g_malloc0(sizeof(QEMUTimer));
451 timer_init(ts, timer_list, scale, cb, opaque);
452 return ts;
456 * timer_new:
457 * @type: the clock type to use
458 * @scale: the scale value for the timer
459 * @cb: the callback to be called when the timer expires
460 * @opaque: the opaque pointer to be passed to the callback
462 * Creeate a new timer and associate it with the default
463 * timer list for the clock type @type.
465 * Returns: a pointer to the timer
467 static inline QEMUTimer *timer_new(QEMUClockType type, int scale,
468 QEMUTimerCB *cb, void *opaque)
470 return timer_new_tl(main_loop_tlg.tl[type], scale, cb, opaque);
474 * timer_new_ns:
475 * @clock: the clock to associate with the timer
476 * @callback: the callback to call when the timer expires
477 * @opaque: the opaque pointer to pass to the callback
479 * Create a new timer with nanosecond scale on the default timer list
480 * associated with the clock.
482 * Returns: a pointer to the newly created timer
484 static inline QEMUTimer *timer_new_ns(QEMUClockType type, QEMUTimerCB *cb,
485 void *opaque)
487 return timer_new(type, SCALE_NS, cb, opaque);
491 * timer_new_us:
492 * @clock: the clock to associate with the timer
493 * @callback: the callback to call when the timer expires
494 * @opaque: the opaque pointer to pass to the callback
496 * Create a new timer with microsecond scale on the default timer list
497 * associated with the clock.
499 * Returns: a pointer to the newly created timer
501 static inline QEMUTimer *timer_new_us(QEMUClockType type, QEMUTimerCB *cb,
502 void *opaque)
504 return timer_new(type, SCALE_US, cb, opaque);
508 * timer_new_ms:
509 * @clock: the clock to associate with the timer
510 * @callback: the callback to call when the timer expires
511 * @opaque: the opaque pointer to pass to the callback
513 * Create a new timer with millisecond scale on the default timer list
514 * associated with the clock.
516 * Returns: a pointer to the newly created timer
518 static inline QEMUTimer *timer_new_ms(QEMUClockType type, QEMUTimerCB *cb,
519 void *opaque)
521 return timer_new(type, SCALE_MS, cb, opaque);
525 * timer_free:
526 * @ts: the timer
528 * Free a timer (it must not be on the active list)
530 void timer_free(QEMUTimer *ts);
533 * timer_del:
534 * @ts: the timer
536 * Delete a timer from the active list.
538 * This function is thread-safe but the timer and its timer list must not be
539 * freed while this function is running.
541 void timer_del(QEMUTimer *ts);
544 * timer_mod_ns:
545 * @ts: the timer
546 * @expire_time: the expiry time in nanoseconds
548 * Modify a timer to expire at @expire_time
550 * This function is thread-safe but the timer and its timer list must not be
551 * freed while this function is running.
553 void timer_mod_ns(QEMUTimer *ts, int64_t expire_time);
556 * timer_mod_anticipate_ns:
557 * @ts: the timer
558 * @expire_time: the expiry time in nanoseconds
560 * Modify a timer to expire at @expire_time or the current time,
561 * whichever comes earlier.
563 * This function is thread-safe but the timer and its timer list must not be
564 * freed while this function is running.
566 void timer_mod_anticipate_ns(QEMUTimer *ts, int64_t expire_time);
569 * timer_mod:
570 * @ts: the timer
571 * @expire_time: the expire time in the units associated with the timer
573 * Modify a timer to expiry at @expire_time, taking into
574 * account the scale associated with the timer.
576 * This function is thread-safe but the timer and its timer list must not be
577 * freed while this function is running.
579 void timer_mod(QEMUTimer *ts, int64_t expire_timer);
582 * timer_mod_anticipate:
583 * @ts: the timer
584 * @expire_time: the expiry time in nanoseconds
586 * Modify a timer to expire at @expire_time or the current time, whichever
587 * comes earlier, taking into account the scale associated with the timer.
589 * This function is thread-safe but the timer and its timer list must not be
590 * freed while this function is running.
592 void timer_mod_anticipate(QEMUTimer *ts, int64_t expire_time);
595 * timer_pending:
596 * @ts: the timer
598 * Determines whether a timer is pending (i.e. is on the
599 * active list of timers, whether or not it has not yet expired).
601 * Returns: true if the timer is pending
603 bool timer_pending(QEMUTimer *ts);
606 * timer_expired:
607 * @ts: the timer
609 * Determines whether a timer has expired.
611 * Returns: true if the timer has expired
613 bool timer_expired(QEMUTimer *timer_head, int64_t current_time);
616 * timer_expire_time_ns:
617 * @ts: the timer
619 * Determine the expiry time of a timer
621 * Returns: the expiry time in nanoseconds
623 uint64_t timer_expire_time_ns(QEMUTimer *ts);
626 * timer_get:
627 * @f: the file
628 * @ts: the timer
630 * Read a timer @ts from a file @f
632 void timer_get(QEMUFile *f, QEMUTimer *ts);
635 * timer_put:
636 * @f: the file
637 * @ts: the timer
639 void timer_put(QEMUFile *f, QEMUTimer *ts);
642 * General utility functions
646 * qemu_timeout_ns_to_ms:
647 * @ns: nanosecond timeout value
649 * Convert a nanosecond timeout value (or -1) to
650 * a millisecond value (or -1), always rounding up.
652 * Returns: millisecond timeout value
654 int qemu_timeout_ns_to_ms(int64_t ns);
657 * qemu_poll_ns:
658 * @fds: Array of file descriptors
659 * @nfds: number of file descriptors
660 * @timeout: timeout in nanoseconds
662 * Perform a poll like g_poll but with a timeout in nanoseconds.
663 * See g_poll documentation for further details.
665 * Returns: number of fds ready
667 int qemu_poll_ns(GPollFD *fds, guint nfds, int64_t timeout);
670 * qemu_soonest_timeout:
671 * @timeout1: first timeout in nanoseconds (or -1 for infinite)
672 * @timeout2: second timeout in nanoseconds (or -1 for infinite)
674 * Calculates the soonest of two timeout values. -1 means infinite, which
675 * is later than any other value.
677 * Returns: soonest timeout value in nanoseconds (or -1 for infinite)
679 static inline int64_t qemu_soonest_timeout(int64_t timeout1, int64_t timeout2)
681 /* we can abuse the fact that -1 (which means infinite) is a maximal
682 * value when cast to unsigned. As this is disgusting, it's kept in
683 * one inline function.
685 return ((uint64_t) timeout1 < (uint64_t) timeout2) ? timeout1 : timeout2;
689 * initclocks:
691 * Initialise the clock & timer infrastructure
693 void init_clocks(void);
695 int64_t cpu_get_ticks(void);
696 /* Caller must hold BQL */
697 void cpu_enable_ticks(void);
698 /* Caller must hold BQL */
699 void cpu_disable_ticks(void);
701 static inline int64_t get_ticks_per_sec(void)
703 return 1000000000LL;
707 * Low level clock functions
710 /* real time host monotonic timer */
711 static inline int64_t get_clock_realtime(void)
713 struct timeval tv;
715 gettimeofday(&tv, NULL);
716 return tv.tv_sec * 1000000000LL + (tv.tv_usec * 1000);
719 /* Warning: don't insert tracepoints into these functions, they are
720 also used by simpletrace backend and tracepoints would cause
721 an infinite recursion! */
722 #ifdef _WIN32
723 extern int64_t clock_freq;
725 static inline int64_t get_clock(void)
727 LARGE_INTEGER ti;
728 QueryPerformanceCounter(&ti);
729 return muldiv64(ti.QuadPart, get_ticks_per_sec(), clock_freq);
732 #else
734 extern int use_rt_clock;
736 static inline int64_t get_clock(void)
738 #ifdef CLOCK_MONOTONIC
739 if (use_rt_clock) {
740 struct timespec ts;
741 clock_gettime(CLOCK_MONOTONIC, &ts);
742 return ts.tv_sec * 1000000000LL + ts.tv_nsec;
743 } else
744 #endif
746 /* XXX: using gettimeofday leads to problems if the date
747 changes, so it should be avoided. */
748 return get_clock_realtime();
751 #endif
753 /* icount */
754 int64_t cpu_get_icount_raw(void);
755 int64_t cpu_get_icount(void);
756 int64_t cpu_get_clock(void);
757 int64_t cpu_get_clock_offset(void);
758 int64_t cpu_icount_to_ns(int64_t icount);
760 /*******************************************/
761 /* host CPU ticks (if available) */
763 #if defined(_ARCH_PPC)
765 static inline int64_t cpu_get_real_ticks(void)
767 int64_t retval;
768 #ifdef _ARCH_PPC64
769 /* This reads timebase in one 64bit go and includes Cell workaround from:
770 http://ozlabs.org/pipermail/linuxppc-dev/2006-October/027052.html
772 __asm__ __volatile__ ("mftb %0\n\t"
773 "cmpwi %0,0\n\t"
774 "beq- $-8"
775 : "=r" (retval));
776 #else
777 /* http://ozlabs.org/pipermail/linuxppc-dev/1999-October/003889.html */
778 unsigned long junk;
779 __asm__ __volatile__ ("mfspr %1,269\n\t" /* mftbu */
780 "mfspr %L0,268\n\t" /* mftb */
781 "mfspr %0,269\n\t" /* mftbu */
782 "cmpw %0,%1\n\t"
783 "bne $-16"
784 : "=r" (retval), "=r" (junk));
785 #endif
786 return retval;
789 #elif defined(__i386__)
791 static inline int64_t cpu_get_real_ticks(void)
793 int64_t val;
794 asm volatile ("rdtsc" : "=A" (val));
795 return val;
798 #elif defined(__x86_64__)
800 static inline int64_t cpu_get_real_ticks(void)
802 uint32_t low,high;
803 int64_t val;
804 asm volatile("rdtsc" : "=a" (low), "=d" (high));
805 val = high;
806 val <<= 32;
807 val |= low;
808 return val;
811 #elif defined(__hppa__)
813 static inline int64_t cpu_get_real_ticks(void)
815 int val;
816 asm volatile ("mfctl %%cr16, %0" : "=r"(val));
817 return val;
820 #elif defined(__ia64)
822 static inline int64_t cpu_get_real_ticks(void)
824 int64_t val;
825 asm volatile ("mov %0 = ar.itc" : "=r"(val) :: "memory");
826 return val;
829 #elif defined(__s390__)
831 static inline int64_t cpu_get_real_ticks(void)
833 int64_t val;
834 asm volatile("stck 0(%1)" : "=m" (val) : "a" (&val) : "cc");
835 return val;
838 #elif defined(__sparc__)
840 static inline int64_t cpu_get_real_ticks (void)
842 #if defined(_LP64)
843 uint64_t rval;
844 asm volatile("rd %%tick,%0" : "=r"(rval));
845 return rval;
846 #else
847 /* We need an %o or %g register for this. For recent enough gcc
848 there is an "h" constraint for that. Don't bother with that. */
849 union {
850 uint64_t i64;
851 struct {
852 uint32_t high;
853 uint32_t low;
854 } i32;
855 } rval;
856 asm volatile("rd %%tick,%%g1; srlx %%g1,32,%0; mov %%g1,%1"
857 : "=r"(rval.i32.high), "=r"(rval.i32.low) : : "g1");
858 return rval.i64;
859 #endif
862 #elif defined(__mips__) && \
863 ((defined(__mips_isa_rev) && __mips_isa_rev >= 2) || defined(__linux__))
865 * binutils wants to use rdhwr only on mips32r2
866 * but as linux kernel emulate it, it's fine
867 * to use it.
870 #define MIPS_RDHWR(rd, value) { \
871 __asm__ __volatile__ (".set push\n\t" \
872 ".set mips32r2\n\t" \
873 "rdhwr %0, "rd"\n\t" \
874 ".set pop" \
875 : "=r" (value)); \
878 static inline int64_t cpu_get_real_ticks(void)
880 /* On kernels >= 2.6.25 rdhwr <reg>, $2 and $3 are emulated */
881 uint32_t count;
882 static uint32_t cyc_per_count = 0;
884 if (!cyc_per_count) {
885 MIPS_RDHWR("$3", cyc_per_count);
888 MIPS_RDHWR("$2", count);
889 return (int64_t)(count * cyc_per_count);
892 #elif defined(__alpha__)
894 static inline int64_t cpu_get_real_ticks(void)
896 uint64_t cc;
897 uint32_t cur, ofs;
899 asm volatile("rpcc %0" : "=r"(cc));
900 cur = cc;
901 ofs = cc >> 32;
902 return cur - ofs;
905 #else
906 /* The host CPU doesn't have an easily accessible cycle counter.
907 Just return a monotonically increasing value. This will be
908 totally wrong, but hopefully better than nothing. */
909 static inline int64_t cpu_get_real_ticks (void)
911 static int64_t ticks = 0;
912 return ticks++;
914 #endif
916 #ifdef CONFIG_PROFILER
917 static inline int64_t profile_getclock(void)
919 return cpu_get_real_ticks();
922 extern int64_t qemu_time, qemu_time_start;
923 extern int64_t tlb_flush_time;
924 extern int64_t dev_time;
925 #endif
927 #endif