4 #include "qemu-common.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 is run even if the virtual
25 * machine is stopped. The real time clock has a frequency of 1000
28 * @QEMU_CLOCK_VIRTUAL: virtual clock
30 * The virtual clock is only run during the emulation. It is stopped
31 * when the virtual machine is stopped. Virtual timers use a high
32 * precision clock, usually cpu cycles (use ticks_per_sec).
34 * @QEMU_CLOCK_HOST: host clock
36 * The host clock should be use for device models that emulate accurate
37 * real time sources. It will continue to run when the virtual machine
38 * is suspended, and it will reflect system time changes the host may
39 * undergo (e.g. due to NTP). The host clock has the same precision as
42 * @QEMU_CLOCK_VIRTUAL_RT: realtime clock used for icount warp
44 * Outside icount mode, this clock is the same as @QEMU_CLOCK_VIRTUAL.
45 * In icount mode, this clock counts nanoseconds while the virtual
46 * machine is running. It is used to increase @QEMU_CLOCK_VIRTUAL
47 * while the CPUs are sleeping and thus not executing instructions.
51 QEMU_CLOCK_REALTIME
= 0,
52 QEMU_CLOCK_VIRTUAL
= 1,
54 QEMU_CLOCK_VIRTUAL_RT
= 3,
58 typedef struct QEMUTimerList QEMUTimerList
;
60 struct QEMUTimerListGroup
{
61 QEMUTimerList
*tl
[QEMU_CLOCK_MAX
];
64 typedef void QEMUTimerCB(void *opaque
);
65 typedef void QEMUTimerListNotifyCB(void *opaque
);
68 int64_t expire_time
; /* in nanoseconds */
69 QEMUTimerList
*timer_list
;
76 extern QEMUTimerListGroup main_loop_tlg
;
84 * @type: the clock type
86 * Get the nanosecond value of a clock with
89 * Returns: the clock value in nanoseconds
91 int64_t qemu_clock_get_ns(QEMUClockType type
);
95 * @type: the clock type
97 * Get the millisecond value of a clock with
100 * Returns: the clock value in milliseconds
102 static inline int64_t qemu_clock_get_ms(QEMUClockType type
)
104 return qemu_clock_get_ns(type
) / SCALE_MS
;
109 * @type: the clock type
111 * Get the microsecond value of a clock with
114 * Returns: the clock value in microseconds
116 static inline int64_t qemu_clock_get_us(QEMUClockType type
)
118 return qemu_clock_get_ns(type
) / SCALE_US
;
122 * qemu_clock_has_timers:
123 * @type: the clock type
125 * Determines whether a clock's default timer list
126 * has timers attached
128 * Note that this function should not be used when other threads also access
129 * the timer list. The return value may be outdated by the time it is acted
132 * Returns: true if the clock's default timer list
133 * has timers attached
135 bool qemu_clock_has_timers(QEMUClockType type
);
138 * qemu_clock_expired:
139 * @type: the clock type
141 * Determines whether a clock's default timer list
142 * has an expired clock.
144 * Returns: true if the clock's default timer list has
147 bool qemu_clock_expired(QEMUClockType type
);
150 * qemu_clock_use_for_deadline:
151 * @type: the clock type
153 * Determine whether a clock should be used for deadline
154 * calculations. Some clocks, for instance vm_clock with
155 * use_icount set, do not count in nanoseconds. Such clocks
156 * are not used for deadline calculations, and are presumed
157 * to interrupt any poll using qemu_notify/aio_notify
160 * Returns: true if the clock runs in nanoseconds and
161 * should be used for a deadline.
163 bool qemu_clock_use_for_deadline(QEMUClockType type
);
166 * qemu_clock_deadline_ns_all:
167 * @type: the clock type
169 * Calculate the deadline across all timer lists associated
170 * with a clock (as opposed to just the default one)
171 * in nanoseconds, or -1 if no timer is set to expire.
173 * Returns: time until expiry in nanoseconds or -1
175 int64_t qemu_clock_deadline_ns_all(QEMUClockType type
);
178 * qemu_clock_get_main_loop_timerlist:
179 * @type: the clock type
181 * Return the default timer list assocatiated with a clock.
183 * Returns: the default timer list
185 QEMUTimerList
*qemu_clock_get_main_loop_timerlist(QEMUClockType type
);
189 * @type: the clock type
191 * Call the notifier callback connected with the default timer
192 * list linked to the clock, or qemu_notify() if none.
194 void qemu_clock_notify(QEMUClockType type
);
198 * @type: the clock type
199 * @enabled: true to enable, false to disable
201 * Enable or disable a clock
202 * Disabling the clock will wait for related timerlists to stop
203 * executing qemu_run_timers. Thus, this functions should not
204 * be used from the callback of a timer that is based on @clock.
205 * Doing so would cause a deadlock.
207 * Caller should hold BQL.
209 void qemu_clock_enable(QEMUClockType type
, bool enabled
);
212 * qemu_start_warp_timer:
214 * Starts a timer for virtual clock update
216 void qemu_start_warp_timer(void);
219 * qemu_clock_register_reset_notifier:
220 * @type: the clock type
221 * @notifier: the notifier function
223 * Register a notifier function to call when the clock
224 * concerned is reset.
226 void qemu_clock_register_reset_notifier(QEMUClockType type
,
230 * qemu_clock_unregister_reset_notifier:
231 * @type: the clock type
232 * @notifier: the notifier function
234 * Unregister a notifier function to call when the clock
235 * concerned is reset.
237 void qemu_clock_unregister_reset_notifier(QEMUClockType type
,
241 * qemu_clock_run_timers:
242 * @type: clock on which to operate
244 * Run all the timers associated with the default timer list
247 * Returns: true if any timer ran.
249 bool qemu_clock_run_timers(QEMUClockType type
);
252 * qemu_clock_run_all_timers:
254 * Run all the timers associated with the default timer list
257 * Returns: true if any timer ran.
259 bool qemu_clock_run_all_timers(void);
267 * @type: the clock type to associate with the timerlist
268 * @cb: the callback to call on notification
269 * @opaque: the opaque pointer to pass to the callback
271 * Create a new timerlist associated with the clock of
274 * Returns: a pointer to the QEMUTimerList created
276 QEMUTimerList
*timerlist_new(QEMUClockType type
,
277 QEMUTimerListNotifyCB
*cb
, void *opaque
);
281 * @timer_list: the timer list to free
283 * Frees a timer_list. It must have no active timers.
285 void timerlist_free(QEMUTimerList
*timer_list
);
288 * timerlist_has_timers:
289 * @timer_list: the timer list to operate on
291 * Determine whether a timer list has active timers
293 * Note that this function should not be used when other threads also access
294 * the timer list. The return value may be outdated by the time it is acted
297 * Returns: true if the timer list has timers.
299 bool timerlist_has_timers(QEMUTimerList
*timer_list
);
303 * @timer_list: the timer list to operate on
305 * Determine whether a timer list has any timers which
308 * Returns: true if the timer list has timers which
311 bool timerlist_expired(QEMUTimerList
*timer_list
);
314 * timerlist_deadline_ns:
315 * @timer_list: the timer list to operate on
317 * Determine the deadline for a timer_list, i.e.
318 * the number of nanoseconds until the first timer
319 * expires. Return -1 if there are no timers.
321 * Returns: the number of nanoseconds until the earliest
322 * timer expires -1 if none
324 int64_t timerlist_deadline_ns(QEMUTimerList
*timer_list
);
327 * timerlist_get_clock:
328 * @timer_list: the timer list to operate on
330 * Determine the clock type associated with a timer list.
332 * Returns: the clock type associated with the
335 QEMUClockType
timerlist_get_clock(QEMUTimerList
*timer_list
);
338 * timerlist_run_timers:
339 * @timer_list: the timer list to use
341 * Call all expired timers associated with the timer list.
343 * Returns: true if any timer expired
345 bool timerlist_run_timers(QEMUTimerList
*timer_list
);
349 * @timer_list: the timer list to use
351 * call the notifier callback associated with the timer list.
353 void timerlist_notify(QEMUTimerList
*timer_list
);
360 * timerlistgroup_init:
361 * @tlg: the timer list group
362 * @cb: the callback to call when a notify is required
363 * @opaque: the opaque pointer to be passed to the callback.
365 * Initialise a timer list group. This must already be
366 * allocated in memory and zeroed. The notifier callback is
367 * called whenever a clock in the timer list group is
368 * reenabled or whenever a timer associated with any timer
369 * list is modified. If @cb is specified as null, qemu_notify()
372 void timerlistgroup_init(QEMUTimerListGroup
*tlg
,
373 QEMUTimerListNotifyCB
*cb
, void *opaque
);
376 * timerlistgroup_deinit:
377 * @tlg: the timer list group
379 * Deinitialise a timer list group. This must already be
380 * initialised. Note the memory is not freed.
382 void timerlistgroup_deinit(QEMUTimerListGroup
*tlg
);
385 * timerlistgroup_run_timers:
386 * @tlg: the timer list group
388 * Run the timers associated with a timer list group.
389 * This will run timers on multiple clocks.
391 * Returns: true if any timer callback ran
393 bool timerlistgroup_run_timers(QEMUTimerListGroup
*tlg
);
396 * timerlistgroup_deadline_ns:
397 * @tlg: the timer list group
399 * Determine the deadline of the soonest timer to
400 * expire associated with any timer list linked to
401 * the timer list group. Only clocks suitable for
402 * deadline calculation are included.
404 * Returns: the deadline in nanoseconds or -1 if no
405 * timers are to expire.
407 int64_t timerlistgroup_deadline_ns(QEMUTimerListGroup
*tlg
);
415 * @ts: the timer to be initialised
416 * @timer_list: the timer list to attach the timer to
417 * @scale: the scale value for the timer
418 * @cb: the callback to be called when the timer expires
419 * @opaque: the opaque pointer to be passed to the callback
421 * Initialise a new timer and associate it with @timer_list.
422 * The caller is responsible for allocating the memory.
424 * You need not call an explicit deinit call. Simply make
425 * sure it is not on a list with timer_del.
427 void timer_init_tl(QEMUTimer
*ts
,
428 QEMUTimerList
*timer_list
, int scale
,
429 QEMUTimerCB
*cb
, void *opaque
);
433 * @type: the clock to associate with the timer
434 * @scale: the scale value for the timer
435 * @cb: the callback to call when the timer expires
436 * @opaque: the opaque pointer to pass to the callback
438 * Initialize a timer with the given scale on the default timer list
439 * associated with the clock.
441 * You need not call an explicit deinit call. Simply make
442 * sure it is not on a list with timer_del.
444 static inline void timer_init(QEMUTimer
*ts
, QEMUClockType type
, int scale
,
445 QEMUTimerCB
*cb
, void *opaque
)
447 timer_init_tl(ts
, main_loop_tlg
.tl
[type
], scale
, cb
, opaque
);
452 * @type: the clock to associate with the timer
453 * @cb: the callback to call when the timer expires
454 * @opaque: the opaque pointer to pass to the callback
456 * Initialize a timer with nanosecond scale on the default timer list
457 * associated with the clock.
459 * You need not call an explicit deinit call. Simply make
460 * sure it is not on a list with timer_del.
462 static inline void timer_init_ns(QEMUTimer
*ts
, QEMUClockType type
,
463 QEMUTimerCB
*cb
, void *opaque
)
465 timer_init(ts
, type
, SCALE_NS
, cb
, opaque
);
470 * @type: the clock to associate with the timer
471 * @cb: the callback to call when the timer expires
472 * @opaque: the opaque pointer to pass to the callback
474 * Initialize a timer with microsecond scale on the default timer list
475 * associated with the clock.
477 * You need not call an explicit deinit call. Simply make
478 * sure it is not on a list with timer_del.
480 static inline void timer_init_us(QEMUTimer
*ts
, QEMUClockType type
,
481 QEMUTimerCB
*cb
, void *opaque
)
483 timer_init(ts
, type
, SCALE_US
, cb
, opaque
);
488 * @type: the clock to associate with the timer
489 * @cb: the callback to call when the timer expires
490 * @opaque: the opaque pointer to pass to the callback
492 * Initialize a timer with millisecond scale on the default timer list
493 * associated with the clock.
495 * You need not call an explicit deinit call. Simply make
496 * sure it is not on a list with timer_del.
498 static inline void timer_init_ms(QEMUTimer
*ts
, QEMUClockType type
,
499 QEMUTimerCB
*cb
, void *opaque
)
501 timer_init(ts
, type
, SCALE_MS
, cb
, opaque
);
506 * @timer_list: the timer list to attach the timer to
507 * @scale: the scale value for the timer
508 * @cb: the callback to be called when the timer expires
509 * @opaque: the opaque pointer to be passed to the callback
511 * Creeate a new timer and associate it with @timer_list.
512 * The memory is allocated by the function.
514 * This is not the preferred interface unless you know you
515 * are going to call timer_free. Use timer_init instead.
517 * Returns: a pointer to the timer
519 static inline QEMUTimer
*timer_new_tl(QEMUTimerList
*timer_list
,
524 QEMUTimer
*ts
= g_malloc0(sizeof(QEMUTimer
));
525 timer_init_tl(ts
, timer_list
, scale
, cb
, opaque
);
531 * @type: the clock type to use
532 * @scale: the scale value for the timer
533 * @cb: the callback to be called when the timer expires
534 * @opaque: the opaque pointer to be passed to the callback
536 * Creeate a new timer and associate it with the default
537 * timer list for the clock type @type.
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_tl(main_loop_tlg
.tl
[type
], scale
, cb
, opaque
);
549 * @clock: the clock to associate with the timer
550 * @callback: 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.
556 * Returns: a pointer to the newly created timer
558 static inline QEMUTimer
*timer_new_ns(QEMUClockType type
, QEMUTimerCB
*cb
,
561 return timer_new(type
, SCALE_NS
, cb
, opaque
);
566 * @clock: the clock to associate with the timer
567 * @callback: the callback to call when the timer expires
568 * @opaque: the opaque pointer to pass to the callback
570 * Create a new timer with microsecond scale on the default timer list
571 * associated with the clock.
573 * Returns: a pointer to the newly created timer
575 static inline QEMUTimer
*timer_new_us(QEMUClockType type
, QEMUTimerCB
*cb
,
578 return timer_new(type
, SCALE_US
, cb
, opaque
);
583 * @clock: the clock to associate with the timer
584 * @callback: the callback to call when the timer expires
585 * @opaque: the opaque pointer to pass to the callback
587 * Create a new timer with millisecond scale on the default timer list
588 * associated with the clock.
590 * Returns: a pointer to the newly created timer
592 static inline QEMUTimer
*timer_new_ms(QEMUClockType type
, QEMUTimerCB
*cb
,
595 return timer_new(type
, SCALE_MS
, cb
, opaque
);
600 * @ts: the timer to be de-initialised
602 * Deassociate the timer from any timerlist. You should
603 * call timer_del before. After this call, any further
604 * timer_del call cannot cause dangling pointer accesses
605 * even if the previously used timerlist is freed.
607 void timer_deinit(QEMUTimer
*ts
);
613 * Free a timer (it must not be on the active list)
615 void timer_free(QEMUTimer
*ts
);
621 * Delete a timer from the active list.
623 * This function is thread-safe but the timer and its timer list must not be
624 * freed while this function is running.
626 void timer_del(QEMUTimer
*ts
);
631 * @expire_time: the expiry time in nanoseconds
633 * Modify a timer to expire at @expire_time
635 * This function is thread-safe but the timer and its timer list must not be
636 * freed while this function is running.
638 void timer_mod_ns(QEMUTimer
*ts
, int64_t expire_time
);
641 * timer_mod_anticipate_ns:
643 * @expire_time: the expiry time in nanoseconds
645 * Modify a timer to expire at @expire_time or the current time,
646 * whichever comes earlier.
648 * This function is thread-safe but the timer and its timer list must not be
649 * freed while this function is running.
651 void timer_mod_anticipate_ns(QEMUTimer
*ts
, int64_t expire_time
);
656 * @expire_time: the expire time in the units associated with the timer
658 * Modify a timer to expiry at @expire_time, taking into
659 * account the scale associated with the timer.
661 * This function is thread-safe but the timer and its timer list must not be
662 * freed while this function is running.
664 void timer_mod(QEMUTimer
*ts
, int64_t expire_timer
);
667 * timer_mod_anticipate:
669 * @expire_time: the expiry time in nanoseconds
671 * Modify a timer to expire at @expire_time or the current time, whichever
672 * comes earlier, taking into account the scale associated with the timer.
674 * This function is thread-safe but the timer and its timer list must not be
675 * freed while this function is running.
677 void timer_mod_anticipate(QEMUTimer
*ts
, int64_t expire_time
);
683 * Determines whether a timer is pending (i.e. is on the
684 * active list of timers, whether or not it has not yet expired).
686 * Returns: true if the timer is pending
688 bool timer_pending(QEMUTimer
*ts
);
694 * Determines whether a timer has expired.
696 * Returns: true if the timer has expired
698 bool timer_expired(QEMUTimer
*timer_head
, int64_t current_time
);
701 * timer_expire_time_ns:
704 * Determine the expiry time of a timer
706 * Returns: the expiry time in nanoseconds
708 uint64_t timer_expire_time_ns(QEMUTimer
*ts
);
715 * Read a timer @ts from a file @f
717 void timer_get(QEMUFile
*f
, QEMUTimer
*ts
);
724 void timer_put(QEMUFile
*f
, QEMUTimer
*ts
);
727 * General utility functions
731 * qemu_timeout_ns_to_ms:
732 * @ns: nanosecond timeout value
734 * Convert a nanosecond timeout value (or -1) to
735 * a millisecond value (or -1), always rounding up.
737 * Returns: millisecond timeout value
739 int qemu_timeout_ns_to_ms(int64_t ns
);
743 * @fds: Array of file descriptors
744 * @nfds: number of file descriptors
745 * @timeout: timeout in nanoseconds
747 * Perform a poll like g_poll but with a timeout in nanoseconds.
748 * See g_poll documentation for further details.
750 * Returns: number of fds ready
752 int qemu_poll_ns(GPollFD
*fds
, guint nfds
, int64_t timeout
);
755 * qemu_soonest_timeout:
756 * @timeout1: first timeout in nanoseconds (or -1 for infinite)
757 * @timeout2: second timeout in nanoseconds (or -1 for infinite)
759 * Calculates the soonest of two timeout values. -1 means infinite, which
760 * is later than any other value.
762 * Returns: soonest timeout value in nanoseconds (or -1 for infinite)
764 static inline int64_t qemu_soonest_timeout(int64_t timeout1
, int64_t timeout2
)
766 /* we can abuse the fact that -1 (which means infinite) is a maximal
767 * value when cast to unsigned. As this is disgusting, it's kept in
768 * one inline function.
770 return ((uint64_t) timeout1
< (uint64_t) timeout2
) ? timeout1
: timeout2
;
776 * Initialise the clock & timer infrastructure
778 void init_clocks(void);
780 int64_t cpu_get_ticks(void);
781 /* Caller must hold BQL */
782 void cpu_enable_ticks(void);
783 /* Caller must hold BQL */
784 void cpu_disable_ticks(void);
786 static inline int64_t get_max_clock_jump(void)
788 /* This should be small enough to prevent excessive interrupts from being
789 * generated by the RTC on clock jumps, but large enough to avoid frequent
790 * unnecessary resets in idle VMs.
792 return 60 * NANOSECONDS_PER_SECOND
;
796 * Low level clock functions
799 /* real time host monotonic timer */
800 static inline int64_t get_clock_realtime(void)
804 gettimeofday(&tv
, NULL
);
805 return tv
.tv_sec
* 1000000000LL + (tv
.tv_usec
* 1000);
808 /* Warning: don't insert tracepoints into these functions, they are
809 also used by simpletrace backend and tracepoints would cause
810 an infinite recursion! */
812 extern int64_t clock_freq
;
814 static inline int64_t get_clock(void)
817 QueryPerformanceCounter(&ti
);
818 return muldiv64(ti
.QuadPart
, NANOSECONDS_PER_SECOND
, clock_freq
);
823 extern int use_rt_clock
;
825 static inline int64_t get_clock(void)
827 #ifdef CLOCK_MONOTONIC
830 clock_gettime(CLOCK_MONOTONIC
, &ts
);
831 return ts
.tv_sec
* 1000000000LL + ts
.tv_nsec
;
835 /* XXX: using gettimeofday leads to problems if the date
836 changes, so it should be avoided. */
837 return get_clock_realtime();
843 int64_t cpu_get_icount_raw(void);
844 int64_t cpu_get_icount(void);
845 int64_t cpu_get_clock(void);
846 int64_t cpu_icount_to_ns(int64_t icount
);
848 /*******************************************/
849 /* host CPU ticks (if available) */
851 #if defined(_ARCH_PPC)
853 static inline int64_t cpu_get_host_ticks(void)
857 /* This reads timebase in one 64bit go and includes Cell workaround from:
858 http://ozlabs.org/pipermail/linuxppc-dev/2006-October/027052.html
860 __asm__
__volatile__ ("mftb %0\n\t"
865 /* http://ozlabs.org/pipermail/linuxppc-dev/1999-October/003889.html */
867 __asm__
__volatile__ ("mfspr %1,269\n\t" /* mftbu */
868 "mfspr %L0,268\n\t" /* mftb */
869 "mfspr %0,269\n\t" /* mftbu */
872 : "=r" (retval
), "=r" (junk
));
877 #elif defined(__i386__)
879 static inline int64_t cpu_get_host_ticks(void)
882 asm volatile ("rdtsc" : "=A" (val
));
886 #elif defined(__x86_64__)
888 static inline int64_t cpu_get_host_ticks(void)
892 asm volatile("rdtsc" : "=a" (low
), "=d" (high
));
899 #elif defined(__hppa__)
901 static inline int64_t cpu_get_host_ticks(void)
904 asm volatile ("mfctl %%cr16, %0" : "=r"(val
));
908 #elif defined(__ia64)
910 static inline int64_t cpu_get_host_ticks(void)
913 asm volatile ("mov %0 = ar.itc" : "=r"(val
) :: "memory");
917 #elif defined(__s390__)
919 static inline int64_t cpu_get_host_ticks(void)
922 asm volatile("stck 0(%1)" : "=m" (val
) : "a" (&val
) : "cc");
926 #elif defined(__sparc__)
928 static inline int64_t cpu_get_host_ticks (void)
932 asm volatile("rd %%tick,%0" : "=r"(rval
));
935 /* We need an %o or %g register for this. For recent enough gcc
936 there is an "h" constraint for that. Don't bother with that. */
944 asm volatile("rd %%tick,%%g1; srlx %%g1,32,%0; mov %%g1,%1"
945 : "=r"(rval
.i32
.high
), "=r"(rval
.i32
.low
) : : "g1");
950 #elif defined(__mips__) && \
951 ((defined(__mips_isa_rev) && __mips_isa_rev >= 2) || defined(__linux__))
953 * binutils wants to use rdhwr only on mips32r2
954 * but as linux kernel emulate it, it's fine
958 #define MIPS_RDHWR(rd, value) { \
959 __asm__ __volatile__ (".set push\n\t" \
960 ".set mips32r2\n\t" \
961 "rdhwr %0, "rd"\n\t" \
966 static inline int64_t cpu_get_host_ticks(void)
968 /* On kernels >= 2.6.25 rdhwr <reg>, $2 and $3 are emulated */
970 static uint32_t cyc_per_count
= 0;
972 if (!cyc_per_count
) {
973 MIPS_RDHWR("$3", cyc_per_count
);
976 MIPS_RDHWR("$2", count
);
977 return (int64_t)(count
* cyc_per_count
);
980 #elif defined(__alpha__)
982 static inline int64_t cpu_get_host_ticks(void)
987 asm volatile("rpcc %0" : "=r"(cc
));
994 /* The host CPU doesn't have an easily accessible cycle counter.
995 Just return a monotonically increasing value. This will be
996 totally wrong, but hopefully better than nothing. */
997 static inline int64_t cpu_get_host_ticks (void)
999 static int64_t ticks
= 0;
1004 #ifdef CONFIG_PROFILER
1005 static inline int64_t profile_getclock(void)
1010 extern int64_t tcg_time
;
1011 extern int64_t dev_time
;