AtomicImpl-c-api.h
2.64 KB
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
#pragma once
#include <stdint.h>
#ifndef NOMINMAX
#define NOMINMAX
#endif
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#define INC_OLE2 1
#include <intrin.h>
#if defined(__cplusplus)
extern "C" {
#endif
static inline int32_t UnityPalCompareExchange(volatile int32_t* dest, int32_t exchange, int32_t comparand)
{
return _InterlockedCompareExchange((long volatile*)dest, exchange, comparand);
}
static inline int64_t UnityPalCompareExchange64(volatile int64_t* dest, int64_t exchange, int64_t comparand)
{
return _InterlockedCompareExchange64((long long volatile*)dest, exchange, comparand);
}
static inline void* UnityPalCompareExchangePointer(void* volatile* dest, void* exchange, void* comparand)
{
#if defined(_M_IX86)
return (void*)_InterlockedCompareExchange((long volatile*)dest, (int32_t)exchange, (int32_t)comparand);
#else
return _InterlockedCompareExchangePointer(dest, exchange, comparand);
#endif
}
static inline int32_t UnityPalAdd(volatile int32_t* location1, int32_t value)
{
return (_InterlockedExchangeAdd((long volatile*)location1, value) + value);
}
#if IL2CPP_ENABLE_INTERLOCKED_64_REQUIRED_ALIGNMENT
static inline int64_t UnityPalAdd64(volatile int64_t* location1, int64_t value)
{
return (_InterlockedExchangeAdd64((long long volatile*)location1, value) + value);
}
#endif
static inline int32_t UnityPalIncrement(volatile int32_t* value)
{
return _InterlockedIncrement((long volatile*)value);
}
#if IL2CPP_ENABLE_INTERLOCKED_64_REQUIRED_ALIGNMENT
static inline int64_t UnityPalIncrement64(volatile int64_t* value)
{
return _InterlockedIncrement64(value);
}
#endif
static inline int32_t UnityPalDecrement(volatile int32_t* value)
{
return _InterlockedDecrement((long volatile*)value);
}
#if IL2CPP_ENABLE_INTERLOCKED_64_REQUIRED_ALIGNMENT
static inline int64_t UnityPalDecrement64(volatile int64_t* value)
{
return _InterlockedDecrement64((long long volatile*)value);
}
static inline int64_t UnityPalExchange64(volatile int64_t* dest, int64_t exchange)
{
return _InterlockedExchange64(dest, exchange);
}
#endif
static inline int32_t UnityPalExchange(volatile int32_t* dest, int32_t exchange)
{
return _InterlockedExchange((long volatile*)dest, exchange);
}
static inline void* UnityPalExchangePointer(void* volatile* dest, void* exchange)
{
#if defined(_M_IX86)
return (void*)_InterlockedExchange((long volatile*)dest, (int32_t)exchange);
#else
return _InterlockedExchangePointer(dest, exchange);
#endif
}
static inline int64_t UnityPalRead64(volatile int64_t* addr)
{
return _InterlockedCompareExchange64((long long volatile*)addr, 0, 0);
}
#if defined(__cplusplus)
}
#endif