| 1 |
/* ===-------- intrin.h ---------------------------------------------------=== |
| 2 |
* |
| 3 |
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
* See https://llvm.org/LICENSE.txt for license information. |
| 5 |
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
* |
| 7 |
*===-----------------------------------------------------------------------=== |
| 8 |
*/ |
| 9 |
|
| 10 |
/* Only include this if we're compiling for the windows platform. */ |
| 11 |
#ifndef _MSC_VER |
| 12 |
#include_next <intrin0.h> |
| 13 |
#else |
| 14 |
|
| 15 |
#ifndef __INTRIN0_H |
| 16 |
#define __INTRIN0_H |
| 17 |
|
| 18 |
#if defined(__x86_64__) && !defined(__arm64ec__) |
| 19 |
#include <adcintrin.h> |
| 20 |
#endif |
| 21 |
|
| 22 |
#ifdef __cplusplus |
| 23 |
extern "C" { |
| 24 |
#endif |
| 25 |
|
| 26 |
unsigned char _BitScanForward(unsigned long *_Index, unsigned long _Mask); |
| 27 |
unsigned char _BitScanReverse(unsigned long *_Index, unsigned long _Mask); |
| 28 |
void _ReadWriteBarrier(void); |
| 29 |
|
| 30 |
#if defined(__aarch64__) || defined(__arm64ec__) |
| 31 |
unsigned int _CountLeadingZeros(unsigned long); |
| 32 |
unsigned int _CountLeadingZeros64(unsigned _int64); |
| 33 |
unsigned char _InterlockedCompareExchange128_acq(__int64 volatile *_Destination, |
| 34 |
__int64 _ExchangeHigh, |
| 35 |
__int64 _ExchangeLow, |
| 36 |
__int64 *_ComparandResult); |
| 37 |
unsigned char _InterlockedCompareExchange128_nf(__int64 volatile *_Destination, |
| 38 |
__int64 _ExchangeHigh, |
| 39 |
__int64 _ExchangeLow, |
| 40 |
__int64 *_ComparandResult); |
| 41 |
unsigned char _InterlockedCompareExchange128_rel(__int64 volatile *_Destination, |
| 42 |
__int64 _ExchangeHigh, |
| 43 |
__int64 _ExchangeLow, |
| 44 |
__int64 *_ComparandResult); |
| 45 |
#endif |
| 46 |
|
| 47 |
#if defined(__x86_64__) && !defined(__arm64ec__) |
| 48 |
unsigned __int64 _umul128(unsigned __int64, unsigned __int64, |
| 49 |
unsigned __int64 *); |
| 50 |
unsigned __int64 __shiftleft128(unsigned __int64 _LowPart, |
| 51 |
unsigned __int64 _HighPart, |
| 52 |
unsigned char _Shift); |
| 53 |
unsigned __int64 __shiftright128(unsigned __int64 _LowPart, |
| 54 |
unsigned __int64 _HighPart, |
| 55 |
unsigned char _Shift); |
| 56 |
#endif |
| 57 |
|
| 58 |
#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)) |
| 59 |
void _mm_pause(void); |
| 60 |
#endif |
| 61 |
|
| 62 |
#if defined(__x86_64__) || defined(__aarch64__) |
| 63 |
unsigned char _InterlockedCompareExchange128(__int64 volatile *_Destination, |
| 64 |
__int64 _ExchangeHigh, |
| 65 |
__int64 _ExchangeLow, |
| 66 |
__int64 *_ComparandResult); |
| 67 |
#endif |
| 68 |
|
| 69 |
#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) |
| 70 |
unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask); |
| 71 |
unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask); |
| 72 |
#endif |
| 73 |
|
| 74 |
#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \ |
| 75 |
defined(__aarch64__) |
| 76 |
__int64 _InterlockedDecrement64(__int64 volatile *_Addend); |
| 77 |
__int64 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value); |
| 78 |
__int64 _InterlockedExchangeAdd64(__int64 volatile *_Addend, __int64 _Value); |
| 79 |
__int64 _InterlockedExchangeSub64(__int64 volatile *_Subend, __int64 _Value); |
| 80 |
__int64 _InterlockedIncrement64(__int64 volatile *_Addend); |
| 81 |
__int64 _InterlockedOr64(__int64 volatile *_Value, __int64 _Mask); |
| 82 |
__int64 _InterlockedXor64(__int64 volatile *_Value, __int64 _Mask); |
| 83 |
__int64 _InterlockedAnd64(__int64 volatile *_Value, __int64 _Mask); |
| 84 |
#endif |
| 85 |
|
| 86 |
#if defined(__arm__) || defined(__aarch64__) || defined(__arm64ec__) |
| 87 |
/*----------------------------------------------------------------------------*\ |
| 88 |
|* Interlocked Exchange Add |
| 89 |
\*----------------------------------------------------------------------------*/ |
| 90 |
char _InterlockedExchangeAdd8_acq(char volatile *_Addend, char _Value); |
| 91 |
char _InterlockedExchangeAdd8_nf(char volatile *_Addend, char _Value); |
| 92 |
char _InterlockedExchangeAdd8_rel(char volatile *_Addend, char _Value); |
| 93 |
short _InterlockedExchangeAdd16_acq(short volatile *_Addend, short _Value); |
| 94 |
short _InterlockedExchangeAdd16_nf(short volatile *_Addend, short _Value); |
| 95 |
short _InterlockedExchangeAdd16_rel(short volatile *_Addend, short _Value); |
| 96 |
long _InterlockedExchangeAdd_acq(long volatile *_Addend, long _Value); |
| 97 |
long _InterlockedExchangeAdd_nf(long volatile *_Addend, long _Value); |
| 98 |
long _InterlockedExchangeAdd_rel(long volatile *_Addend, long _Value); |
| 99 |
__int64 _InterlockedExchangeAdd64_acq(__int64 volatile *_Addend, |
| 100 |
__int64 _Value); |
| 101 |
__int64 _InterlockedExchangeAdd64_nf(__int64 volatile *_Addend, __int64 _Value); |
| 102 |
__int64 _InterlockedExchangeAdd64_rel(__int64 volatile *_Addend, |
| 103 |
__int64 _Value); |
| 104 |
|
| 105 |
/*----------------------------------------------------------------------------*\ |
| 106 |
|* Interlocked Increment |
| 107 |
\*----------------------------------------------------------------------------*/ |
| 108 |
short _InterlockedIncrement16_acq(short volatile *_Value); |
| 109 |
short _InterlockedIncrement16_nf(short volatile *_Value); |
| 110 |
short _InterlockedIncrement16_rel(short volatile *_Value); |
| 111 |
long _InterlockedIncrement_acq(long volatile *_Value); |
| 112 |
long _InterlockedIncrement_nf(long volatile *_Value); |
| 113 |
long _InterlockedIncrement_rel(long volatile *_Value); |
| 114 |
__int64 _InterlockedIncrement64_acq(__int64 volatile *_Value); |
| 115 |
__int64 _InterlockedIncrement64_nf(__int64 volatile *_Value); |
| 116 |
__int64 _InterlockedIncrement64_rel(__int64 volatile *_Value); |
| 117 |
|
| 118 |
/*----------------------------------------------------------------------------*\ |
| 119 |
|* Interlocked Decrement |
| 120 |
\*----------------------------------------------------------------------------*/ |
| 121 |
short _InterlockedDecrement16_acq(short volatile *_Value); |
| 122 |
short _InterlockedDecrement16_nf(short volatile *_Value); |
| 123 |
short _InterlockedDecrement16_rel(short volatile *_Value); |
| 124 |
long _InterlockedDecrement_acq(long volatile *_Value); |
| 125 |
long _InterlockedDecrement_nf(long volatile *_Value); |
| 126 |
long _InterlockedDecrement_rel(long volatile *_Value); |
| 127 |
__int64 _InterlockedDecrement64_acq(__int64 volatile *_Value); |
| 128 |
__int64 _InterlockedDecrement64_nf(__int64 volatile *_Value); |
| 129 |
__int64 _InterlockedDecrement64_rel(__int64 volatile *_Value); |
| 130 |
|
| 131 |
/*----------------------------------------------------------------------------*\ |
| 132 |
|* Interlocked And |
| 133 |
\*----------------------------------------------------------------------------*/ |
| 134 |
char _InterlockedAnd8_acq(char volatile *_Value, char _Mask); |
| 135 |
char _InterlockedAnd8_nf(char volatile *_Value, char _Mask); |
| 136 |
char _InterlockedAnd8_rel(char volatile *_Value, char _Mask); |
| 137 |
short _InterlockedAnd16_acq(short volatile *_Value, short _Mask); |
| 138 |
short _InterlockedAnd16_nf(short volatile *_Value, short _Mask); |
| 139 |
short _InterlockedAnd16_rel(short volatile *_Value, short _Mask); |
| 140 |
long _InterlockedAnd_acq(long volatile *_Value, long _Mask); |
| 141 |
long _InterlockedAnd_nf(long volatile *_Value, long _Mask); |
| 142 |
long _InterlockedAnd_rel(long volatile *_Value, long _Mask); |
| 143 |
__int64 _InterlockedAnd64_acq(__int64 volatile *_Value, __int64 _Mask); |
| 144 |
__int64 _InterlockedAnd64_nf(__int64 volatile *_Value, __int64 _Mask); |
| 145 |
__int64 _InterlockedAnd64_rel(__int64 volatile *_Value, __int64 _Mask); |
| 146 |
|
| 147 |
/*----------------------------------------------------------------------------*\ |
| 148 |
|* Bit Counting and Testing |
| 149 |
\*----------------------------------------------------------------------------*/ |
| 150 |
unsigned char _interlockedbittestandset_acq(long volatile *_BitBase, |
| 151 |
long _BitPos); |
| 152 |
unsigned char _interlockedbittestandset_nf(long volatile *_BitBase, |
| 153 |
long _BitPos); |
| 154 |
unsigned char _interlockedbittestandset_rel(long volatile *_BitBase, |
| 155 |
long _BitPos); |
| 156 |
unsigned char _interlockedbittestandreset_acq(long volatile *_BitBase, |
| 157 |
long _BitPos); |
| 158 |
unsigned char _interlockedbittestandreset_nf(long volatile *_BitBase, |
| 159 |
long _BitPos); |
| 160 |
unsigned char _interlockedbittestandreset_rel(long volatile *_BitBase, |
| 161 |
long _BitPos); |
| 162 |
|
| 163 |
/*----------------------------------------------------------------------------*\ |
| 164 |
|* Interlocked Or |
| 165 |
\*----------------------------------------------------------------------------*/ |
| 166 |
char _InterlockedOr8_acq(char volatile *_Value, char _Mask); |
| 167 |
char _InterlockedOr8_nf(char volatile *_Value, char _Mask); |
| 168 |
char _InterlockedOr8_rel(char volatile *_Value, char _Mask); |
| 169 |
short _InterlockedOr16_acq(short volatile *_Value, short _Mask); |
| 170 |
short _InterlockedOr16_nf(short volatile *_Value, short _Mask); |
| 171 |
short _InterlockedOr16_rel(short volatile *_Value, short _Mask); |
| 172 |
long _InterlockedOr_acq(long volatile *_Value, long _Mask); |
| 173 |
long _InterlockedOr_nf(long volatile *_Value, long _Mask); |
| 174 |
long _InterlockedOr_rel(long volatile *_Value, long _Mask); |
| 175 |
__int64 _InterlockedOr64_acq(__int64 volatile *_Value, __int64 _Mask); |
| 176 |
__int64 _InterlockedOr64_nf(__int64 volatile *_Value, __int64 _Mask); |
| 177 |
__int64 _InterlockedOr64_rel(__int64 volatile *_Value, __int64 _Mask); |
| 178 |
|
| 179 |
/*----------------------------------------------------------------------------*\ |
| 180 |
|* Interlocked Xor |
| 181 |
\*----------------------------------------------------------------------------*/ |
| 182 |
char _InterlockedXor8_acq(char volatile *_Value, char _Mask); |
| 183 |
char _InterlockedXor8_nf(char volatile *_Value, char _Mask); |
| 184 |
char _InterlockedXor8_rel(char volatile *_Value, char _Mask); |
| 185 |
short _InterlockedXor16_acq(short volatile *_Value, short _Mask); |
| 186 |
short _InterlockedXor16_nf(short volatile *_Value, short _Mask); |
| 187 |
short _InterlockedXor16_rel(short volatile *_Value, short _Mask); |
| 188 |
long _InterlockedXor_acq(long volatile *_Value, long _Mask); |
| 189 |
long _InterlockedXor_nf(long volatile *_Value, long _Mask); |
| 190 |
long _InterlockedXor_rel(long volatile *_Value, long _Mask); |
| 191 |
__int64 _InterlockedXor64_acq(__int64 volatile *_Value, __int64 _Mask); |
| 192 |
__int64 _InterlockedXor64_nf(__int64 volatile *_Value, __int64 _Mask); |
| 193 |
__int64 _InterlockedXor64_rel(__int64 volatile *_Value, __int64 _Mask); |
| 194 |
|
| 195 |
/*----------------------------------------------------------------------------*\ |
| 196 |
|* Interlocked Exchange |
| 197 |
\*----------------------------------------------------------------------------*/ |
| 198 |
char _InterlockedExchange8_acq(char volatile *_Target, char _Value); |
| 199 |
char _InterlockedExchange8_nf(char volatile *_Target, char _Value); |
| 200 |
char _InterlockedExchange8_rel(char volatile *_Target, char _Value); |
| 201 |
short _InterlockedExchange16_acq(short volatile *_Target, short _Value); |
| 202 |
short _InterlockedExchange16_nf(short volatile *_Target, short _Value); |
| 203 |
short _InterlockedExchange16_rel(short volatile *_Target, short _Value); |
| 204 |
long _InterlockedExchange_acq(long volatile *_Target, long _Value); |
| 205 |
long _InterlockedExchange_nf(long volatile *_Target, long _Value); |
| 206 |
long _InterlockedExchange_rel(long volatile *_Target, long _Value); |
| 207 |
__int64 _InterlockedExchange64_acq(__int64 volatile *_Target, __int64 _Value); |
| 208 |
__int64 _InterlockedExchange64_nf(__int64 volatile *_Target, __int64 _Value); |
| 209 |
__int64 _InterlockedExchange64_rel(__int64 volatile *_Target, __int64 _Value); |
| 210 |
void *_InterlockedExchangePointer_acq(void *volatile *_Target, void *_Value); |
| 211 |
void *_InterlockedExchangePointer_nf(void *volatile *_Target, void *_Value); |
| 212 |
void *_InterlockedExchangePointer_rel(void *volatile *_Target, void *_Value); |
| 213 |
|
| 214 |
/*----------------------------------------------------------------------------*\ |
| 215 |
|* Interlocked Compare Exchange |
| 216 |
\*----------------------------------------------------------------------------*/ |
| 217 |
char _InterlockedCompareExchange8_acq(char volatile *_Destination, |
| 218 |
char _Exchange, char _Comparand); |
| 219 |
char _InterlockedCompareExchange8_nf(char volatile *_Destination, |
| 220 |
char _Exchange, char _Comparand); |
| 221 |
char _InterlockedCompareExchange8_rel(char volatile *_Destination, |
| 222 |
char _Exchange, char _Comparand); |
| 223 |
short _InterlockedCompareExchange16_acq(short volatile *_Destination, |
| 224 |
short _Exchange, short _Comparand); |
| 225 |
short _InterlockedCompareExchange16_nf(short volatile *_Destination, |
| 226 |
short _Exchange, short _Comparand); |
| 227 |
short _InterlockedCompareExchange16_rel(short volatile *_Destination, |
| 228 |
short _Exchange, short _Comparand); |
| 229 |
long _InterlockedCompareExchange_acq(long volatile *_Destination, |
| 230 |
long _Exchange, long _Comparand); |
| 231 |
long _InterlockedCompareExchange_nf(long volatile *_Destination, long _Exchange, |
| 232 |
long _Comparand); |
| 233 |
long _InterlockedCompareExchange_rel(long volatile *_Destination, |
| 234 |
long _Exchange, long _Comparand); |
| 235 |
__int64 _InterlockedCompareExchange64_acq(__int64 volatile *_Destination, |
| 236 |
__int64 _Exchange, |
| 237 |
__int64 _Comparand); |
| 238 |
__int64 _InterlockedCompareExchange64_nf(__int64 volatile *_Destination, |
| 239 |
__int64 _Exchange, __int64 _Comparand); |
| 240 |
__int64 _InterlockedCompareExchange64_rel(__int64 volatile *_Destination, |
| 241 |
__int64 _Exchange, |
| 242 |
__int64 _Comparand); |
| 243 |
void *_InterlockedCompareExchangePointer_acq(void *volatile *_Destination, |
| 244 |
void *_Exchange, void *_Comparand); |
| 245 |
void *_InterlockedCompareExchangePointer_nf(void *volatile *_Destination, |
| 246 |
void *_Exchange, void *_Comparand); |
| 247 |
void *_InterlockedCompareExchangePointer_rel(void *volatile *_Destination, |
| 248 |
void *_Exchange, void *_Comparand); |
| 249 |
#endif |
| 250 |
|
| 251 |
#ifdef __cplusplus |
| 252 |
} |
| 253 |
#endif |
| 254 |
|
| 255 |
#endif /* __INTRIN0_H */ |
| 256 |
#endif /* _MSC_VER */ |