少年修仙传客户端基础资源
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/**
 * \file
 * Contains inline functions to explicitly mark data races that should not be changed.
 * This way, instruments like Clang's ThreadSanitizer can be told to ignore very specific instructions.
 *
 * Please keep this file and its methods organised:
 *  * Increment, Decrement, Add, Subtract, Write, Read
 *  * gint32 (""), guint32 ("Unsigned"),
 *      gint64 ("64"), guint64 ("Unsigned64"),
 *      gsize ("Size"), gboolean ("Bool"),
 *      gpointer ("Pointer")
 *
 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
 */
 
#ifndef _UNLOCKED_H_
#define _UNLOCKED_H_
 
#include <glib.h>
#include <mono/utils/mono-compiler.h>
 
#if MONO_HAS_CLANG_THREAD_SANITIZER
#define MONO_UNLOCKED_ATTRS MONO_NO_SANITIZE_THREAD MONO_NEVER_INLINE static
#elif defined(_MSC_VER)
#define MONO_UNLOCKED_ATTRS MONO_ALWAYS_INLINE static
#else
#define MONO_UNLOCKED_ATTRS MONO_ALWAYS_INLINE static inline
#endif
 
MONO_UNLOCKED_ATTRS
gint32
UnlockedIncrement (volatile gint32 *val)
{
    return ++*val;
}
 
MONO_UNLOCKED_ATTRS
gint64
UnlockedIncrement64 (volatile gint64 *val)
{
    return ++*val;
}
 
MONO_UNLOCKED_ATTRS
gint64
UnlockedDecrement64 (volatile gint64 *val)
{
    return --*val;
}
 
MONO_UNLOCKED_ATTRS
gint32
UnlockedDecrement (volatile gint32 *val)
{
    return --*val;
}
 
MONO_UNLOCKED_ATTRS
gint32
UnlockedAdd (volatile gint32 *dest, gint32 add)
{
    return *dest += add;
}
 
MONO_UNLOCKED_ATTRS
gint64
UnlockedAdd64 (volatile gint64 *dest, gint64 add)
{
    return *dest += add;
}
 
MONO_UNLOCKED_ATTRS
gdouble
UnlockedAddDouble (volatile gdouble *dest, gdouble add)
{
    return *dest += add;
}
 
MONO_UNLOCKED_ATTRS
gint64
UnlockedSubtract64 (volatile gint64 *dest, gint64 sub)
{
    return *dest -= sub;
}
 
MONO_UNLOCKED_ATTRS
void
UnlockedWrite (volatile gint32 *dest, gint32 val)
{
    *dest = val;
}
 
MONO_UNLOCKED_ATTRS
void
UnlockedWrite64 (volatile gint64 *dest, gint64 val)
{
    *dest = val;
}
 
MONO_UNLOCKED_ATTRS
void
UnlockedWriteBool (volatile gboolean *dest, gboolean val)
{
    *dest = val;
}
 
MONO_UNLOCKED_ATTRS
void
UnlockedWritePointer (volatile gpointer *dest, gpointer val)
{
    *dest = val;
}
 
MONO_UNLOCKED_ATTRS
gint32
UnlockedRead (volatile gint32 *src)
{
    return *src;
}
 
MONO_UNLOCKED_ATTRS
gint64
UnlockedRead64 (volatile gint64 *src)
{
    return *src;
}
 
MONO_UNLOCKED_ATTRS
gboolean
UnlockedReadBool (volatile gboolean *src)
{
    return *src;
}
 
MONO_UNLOCKED_ATTRS
gpointer
UnlockedReadPointer (volatile gpointer *src)
{
    return *src;
}
 
#endif /* _UNLOCKED_H_ */