[sdks] Bump Android NDK, build tools and platform tools versions
[mono-project.git] / mono / utils / mono-time.h
blob3f0634a544f2081d5a5af529ffafa1908f84dde8
1 /**
2 * \file
3 */
5 #ifndef __UTILS_MONO_TIME_H__
6 #define __UTILS_MONO_TIME_H__
8 #include <mono/utils/mono-compiler.h>
9 #include <glib.h>
10 #ifdef HAVE_SYS_TIME_H
11 #include <sys/time.h>
12 #endif
14 /* Returns the number of milliseconds from boot time: this should be monotonic
16 * Prefer to use mono_msec_ticks for elapsed time calculation. */
17 gint64 mono_msec_boottime (void);
19 /* Returns the number of milliseconds ticks from unspecified time: this should be monotonic */
20 gint64 mono_msec_ticks (void);
22 /* Returns the number of 100ns ticks from unspecified time: this should be monotonic */
23 gint64 mono_100ns_ticks (void);
25 /* Returns the number of 100ns ticks since 1/1/1601, UTC timezone */
26 gint64 mono_100ns_datetime (void);
28 #ifndef HOST_WIN32
29 gint64 mono_100ns_datetime_from_timeval (struct timeval tv);
30 #endif
32 /* Stopwatch class for internal runtime use */
33 typedef struct {
34 gint64 start, stop;
35 } MonoStopwatch;
37 static inline void
38 mono_stopwatch_start (MonoStopwatch *w)
40 w->start = mono_100ns_ticks ();
41 w->stop = 0;
44 static inline void
45 mono_stopwatch_stop (MonoStopwatch *w)
47 w->stop = mono_100ns_ticks ();
50 static inline guint64
51 mono_stopwatch_elapsed (MonoStopwatch *w)
53 return (w->stop - w->start) / 10;
56 static inline guint64
57 mono_stopwatch_elapsed_ms (MonoStopwatch *w)
59 return (mono_stopwatch_elapsed (w) + 500) / 1000;
62 // Expand non-portable strftime shorthands.
63 #define MONO_STRFTIME_F "%Y-%m-%d" // %F in some systems, but this works on all.
64 #define MONO_STRFTIME_T "%H:%M:%S" // %T in some systems, but this works on all.
66 #endif /* __UTILS_MONO_TIME_H__ */