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