少年修仙传客户端基础资源
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
/**
 * \file
 * Memory barrier inline functions
 *
 * Author:
 *    Mark Probst (mark.probst@gmail.com)
 *
 * (C) 2007 Novell, Inc
 */
 
#ifndef _MONO_UTILS_MONO_MEMBAR_H_
#define _MONO_UTILS_MONO_MEMBAR_H_
 
#include <config.h>
 
#include <glib.h>
 
 
#ifdef TARGET_WASM
 
static inline void mono_memory_barrier (void)
{
}
 
static inline void mono_memory_read_barrier (void)
{
}
 
static inline void mono_memory_write_barrier (void)
{
}
 
#elif _MSC_VER
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <intrin.h>
 
static inline void mono_memory_barrier (void)
{
    /* NOTE: _ReadWriteBarrier and friends only prevent the
       compiler from reordering loads and stores. To prevent
       the CPU from doing the same, we have to use the
       MemoryBarrier macro which expands to e.g. a serializing
       XCHG instruction on x86. Also note that the MemoryBarrier
       macro does *not* imply _ReadWriteBarrier, so that call
       cannot be eliminated. */
    _ReadWriteBarrier ();
    MemoryBarrier ();
}
 
static inline void mono_memory_read_barrier (void)
{
    _ReadBarrier ();
    MemoryBarrier ();
}
 
static inline void mono_memory_write_barrier (void)
{
    _WriteBarrier ();
    MemoryBarrier ();
}
#elif defined(USE_GCC_ATOMIC_OPS)
static inline void mono_memory_barrier (void)
{
    __sync_synchronize ();
}
 
static inline void mono_memory_read_barrier (void)
{
    mono_memory_barrier ();
}
 
static inline void mono_memory_write_barrier (void)
{
    mono_memory_barrier ();
}
 
#elif defined(PLATFORM_UNITY) && defined(UNITY_USE_PLATFORM_STUBS)
 
static inline void mono_memory_barrier (void)
{
    g_assert(0 && "This function is not yet implemented for the Unity platform.");
}
 
static inline void mono_memory_read_barrier (void)
{
    g_assert(0 && "This function is not yet implemented for the Unity platform.");
}
 
static inline void mono_memory_write_barrier (void)
{
    g_assert(0 && "This function is not yet implemented for the Unity platform.");
}
 
#else 
#error "Don't know how to do memory barriers!"
#endif
 
#endif    /* _MONO_UTILS_MONO_MEMBAR_H_ */