[w32file] Remove dead code
[mono.git] / mono / utils / mono-time.h
1 /**
2  * \file
3  */
4
5 #ifndef __UTILS_MONO_TIME_H__
6 #define __UTILS_MONO_TIME_H__
7
8 #include <mono/utils/mono-compiler.h>
9 #include <glib.h>
10
11 #ifdef HAVE_SYS_TIME_H
12 #include <sys/time.h>
13 #endif
14
15 /* Returns the number of milliseconds from boot time: this should be monotonic
16  *
17  * Prefer to use mono_msec_ticks for elapsed time calculation. */
18 gint64 mono_msec_boottime (void);
19
20 /* Returns the number of milliseconds ticks from unspecified time: this should be monotonic */
21 gint64 mono_msec_ticks (void);
22
23 /* Returns the number of 100ns ticks from unspecified time: this should be monotonic */
24 gint64 mono_100ns_ticks (void);
25
26 /* Returns the number of 100ns ticks since 1/1/1601, UTC timezone */
27 gint64 mono_100ns_datetime (void);
28
29 #ifndef HOST_WIN32
30 gint64 mono_100ns_datetime_from_timeval (struct timeval tv);
31 #endif
32
33 /* Stopwatch class for internal runtime use */
34 typedef struct {
35         gint64 start, stop;
36 } MonoStopwatch;
37
38 static inline void
39 mono_stopwatch_start (MonoStopwatch *w)
40 {
41         w->start = mono_100ns_ticks ();
42         w->stop = 0;
43 }
44
45 static inline void
46 mono_stopwatch_stop (MonoStopwatch *w)
47 {
48         w->stop = mono_100ns_ticks ();
49 }
50
51 static inline guint64
52 mono_stopwatch_elapsed (MonoStopwatch *w)
53 {
54         return (w->stop - w->start) / 10;
55 }
56
57 static inline guint64
58 mono_stopwatch_elapsed_ms (MonoStopwatch *w)
59 {
60         return (mono_stopwatch_elapsed (w) + 500) / 1000;
61 }
62
63 #endif /* __UTILS_MONO_TIME_H__ */
64