[cert-sync]: Make the new store the default and add '--legacy' for the old one.
[mono-project.git] / mono / utils / mono-time.h
blob438b9ef18815b1bdc0ee574c715638654f25f44f
1 #ifndef __UTILS_MONO_TIME_H__
2 #define __UTILS_MONO_TIME_H__
4 #include <mono/utils/mono-compiler.h>
5 #include <glib.h>
7 #ifdef HAVE_SYS_TIME_H
8 #include <sys/time.h>
9 #endif
11 /* Returns the number of milliseconds from boot time: this should be monotonic
13 * Prefer to use mono_msec_ticks for elapsed time calculation. */
14 gint64 mono_msec_boottime (void);
16 /* Returns the number of milliseconds ticks from unspecified time: this should be monotonic */
17 gint64 mono_msec_ticks (void);
19 /* Returns the number of 100ns ticks from unspecified time: this should be monotonic */
20 gint64 mono_100ns_ticks (void);
22 /* Returns the number of 100ns ticks since 1/1/1601, UTC timezone */
23 gint64 mono_100ns_datetime (void);
25 #ifndef HOST_WIN32
26 gint64 mono_100ns_datetime_from_timeval (struct timeval tv);
27 #endif
29 /* Stopwatch class for internal runtime use */
30 typedef struct {
31 gint64 start, stop;
32 } MonoStopwatch;
34 static inline void
35 mono_stopwatch_start (MonoStopwatch *w)
37 w->start = mono_100ns_ticks ();
38 w->stop = 0;
41 static inline void
42 mono_stopwatch_stop (MonoStopwatch *w)
44 w->stop = mono_100ns_ticks ();
47 static inline guint64
48 mono_stopwatch_elapsed (MonoStopwatch *w)
50 return (w->stop - w->start) / 10;
53 static inline guint64
54 mono_stopwatch_elapsed_ms (MonoStopwatch *w)
56 return (mono_stopwatch_elapsed (w) + 500) / 1000;
59 #endif /* __UTILS_MONO_TIME_H__ */