257 lines · c
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-exception6 *7 *===-----------------------------------------------------------------------===8 */9 10/* Only include this if we're compiling for the windows platform. */11#ifndef _MSC_VER12#include_next <intrin0.h>13#else14 15#ifndef __INTRIN0_H16#define __INTRIN0_H17 18#if defined(__x86_64__) && !defined(__arm64ec__)19#include <adcintrin.h>20#endif21 22#ifdef __cplusplus23extern "C" {24#endif25 26unsigned char _BitScanForward(unsigned long *_Index, unsigned long _Mask);27unsigned char _BitScanReverse(unsigned long *_Index, unsigned long _Mask);28void _ReadWriteBarrier(void);29 30#if defined(__aarch64__) || defined(__arm64ec__)31unsigned int _CountLeadingZeros(unsigned long);32unsigned int _CountLeadingZeros64(unsigned _int64);33unsigned char _InterlockedCompareExchange128_acq(__int64 volatile *_Destination,34 __int64 _ExchangeHigh,35 __int64 _ExchangeLow,36 __int64 *_ComparandResult);37unsigned char _InterlockedCompareExchange128_nf(__int64 volatile *_Destination,38 __int64 _ExchangeHigh,39 __int64 _ExchangeLow,40 __int64 *_ComparandResult);41unsigned char _InterlockedCompareExchange128_rel(__int64 volatile *_Destination,42 __int64 _ExchangeHigh,43 __int64 _ExchangeLow,44 __int64 *_ComparandResult);45#endif46 47#if defined(__x86_64__) && !defined(__arm64ec__)48unsigned __int64 _umul128(unsigned __int64, unsigned __int64,49 unsigned __int64 *);50unsigned __int64 __shiftleft128(unsigned __int64 _LowPart,51 unsigned __int64 _HighPart,52 unsigned char _Shift);53unsigned __int64 __shiftright128(unsigned __int64 _LowPart,54 unsigned __int64 _HighPart,55 unsigned char _Shift);56#endif57 58#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__))59void _mm_pause(void);60#endif61 62#if defined(__x86_64__) || defined(__aarch64__)63unsigned char _InterlockedCompareExchange128(__int64 volatile *_Destination,64 __int64 _ExchangeHigh,65 __int64 _ExchangeLow,66 __int64 *_ComparandResult);67#endif68 69#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)70unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask);71unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask);72#endif73 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#endif85 86#if defined(__arm__) || defined(__aarch64__) || defined(__arm64ec__)87/*----------------------------------------------------------------------------*\88|* Interlocked Exchange Add89\*----------------------------------------------------------------------------*/90char _InterlockedExchangeAdd8_acq(char volatile *_Addend, char _Value);91char _InterlockedExchangeAdd8_nf(char volatile *_Addend, char _Value);92char _InterlockedExchangeAdd8_rel(char volatile *_Addend, char _Value);93short _InterlockedExchangeAdd16_acq(short volatile *_Addend, short _Value);94short _InterlockedExchangeAdd16_nf(short volatile *_Addend, short _Value);95short _InterlockedExchangeAdd16_rel(short volatile *_Addend, short _Value);96long _InterlockedExchangeAdd_acq(long volatile *_Addend, long _Value);97long _InterlockedExchangeAdd_nf(long volatile *_Addend, long _Value);98long _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 Increment107\*----------------------------------------------------------------------------*/108short _InterlockedIncrement16_acq(short volatile *_Value);109short _InterlockedIncrement16_nf(short volatile *_Value);110short _InterlockedIncrement16_rel(short volatile *_Value);111long _InterlockedIncrement_acq(long volatile *_Value);112long _InterlockedIncrement_nf(long volatile *_Value);113long _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 Decrement120\*----------------------------------------------------------------------------*/121short _InterlockedDecrement16_acq(short volatile *_Value);122short _InterlockedDecrement16_nf(short volatile *_Value);123short _InterlockedDecrement16_rel(short volatile *_Value);124long _InterlockedDecrement_acq(long volatile *_Value);125long _InterlockedDecrement_nf(long volatile *_Value);126long _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 And133\*----------------------------------------------------------------------------*/134char _InterlockedAnd8_acq(char volatile *_Value, char _Mask);135char _InterlockedAnd8_nf(char volatile *_Value, char _Mask);136char _InterlockedAnd8_rel(char volatile *_Value, char _Mask);137short _InterlockedAnd16_acq(short volatile *_Value, short _Mask);138short _InterlockedAnd16_nf(short volatile *_Value, short _Mask);139short _InterlockedAnd16_rel(short volatile *_Value, short _Mask);140long _InterlockedAnd_acq(long volatile *_Value, long _Mask);141long _InterlockedAnd_nf(long volatile *_Value, long _Mask);142long _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 Testing149\*----------------------------------------------------------------------------*/150unsigned char _interlockedbittestandset_acq(long volatile *_BitBase,151 long _BitPos);152unsigned char _interlockedbittestandset_nf(long volatile *_BitBase,153 long _BitPos);154unsigned char _interlockedbittestandset_rel(long volatile *_BitBase,155 long _BitPos);156unsigned char _interlockedbittestandreset_acq(long volatile *_BitBase,157 long _BitPos);158unsigned char _interlockedbittestandreset_nf(long volatile *_BitBase,159 long _BitPos);160unsigned char _interlockedbittestandreset_rel(long volatile *_BitBase,161 long _BitPos);162 163/*----------------------------------------------------------------------------*\164|* Interlocked Or165\*----------------------------------------------------------------------------*/166char _InterlockedOr8_acq(char volatile *_Value, char _Mask);167char _InterlockedOr8_nf(char volatile *_Value, char _Mask);168char _InterlockedOr8_rel(char volatile *_Value, char _Mask);169short _InterlockedOr16_acq(short volatile *_Value, short _Mask);170short _InterlockedOr16_nf(short volatile *_Value, short _Mask);171short _InterlockedOr16_rel(short volatile *_Value, short _Mask);172long _InterlockedOr_acq(long volatile *_Value, long _Mask);173long _InterlockedOr_nf(long volatile *_Value, long _Mask);174long _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 Xor181\*----------------------------------------------------------------------------*/182char _InterlockedXor8_acq(char volatile *_Value, char _Mask);183char _InterlockedXor8_nf(char volatile *_Value, char _Mask);184char _InterlockedXor8_rel(char volatile *_Value, char _Mask);185short _InterlockedXor16_acq(short volatile *_Value, short _Mask);186short _InterlockedXor16_nf(short volatile *_Value, short _Mask);187short _InterlockedXor16_rel(short volatile *_Value, short _Mask);188long _InterlockedXor_acq(long volatile *_Value, long _Mask);189long _InterlockedXor_nf(long volatile *_Value, long _Mask);190long _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 Exchange197\*----------------------------------------------------------------------------*/198char _InterlockedExchange8_acq(char volatile *_Target, char _Value);199char _InterlockedExchange8_nf(char volatile *_Target, char _Value);200char _InterlockedExchange8_rel(char volatile *_Target, char _Value);201short _InterlockedExchange16_acq(short volatile *_Target, short _Value);202short _InterlockedExchange16_nf(short volatile *_Target, short _Value);203short _InterlockedExchange16_rel(short volatile *_Target, short _Value);204long _InterlockedExchange_acq(long volatile *_Target, long _Value);205long _InterlockedExchange_nf(long volatile *_Target, long _Value);206long _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);210void *_InterlockedExchangePointer_acq(void *volatile *_Target, void *_Value);211void *_InterlockedExchangePointer_nf(void *volatile *_Target, void *_Value);212void *_InterlockedExchangePointer_rel(void *volatile *_Target, void *_Value);213 214/*----------------------------------------------------------------------------*\215|* Interlocked Compare Exchange216\*----------------------------------------------------------------------------*/217char _InterlockedCompareExchange8_acq(char volatile *_Destination,218 char _Exchange, char _Comparand);219char _InterlockedCompareExchange8_nf(char volatile *_Destination,220 char _Exchange, char _Comparand);221char _InterlockedCompareExchange8_rel(char volatile *_Destination,222 char _Exchange, char _Comparand);223short _InterlockedCompareExchange16_acq(short volatile *_Destination,224 short _Exchange, short _Comparand);225short _InterlockedCompareExchange16_nf(short volatile *_Destination,226 short _Exchange, short _Comparand);227short _InterlockedCompareExchange16_rel(short volatile *_Destination,228 short _Exchange, short _Comparand);229long _InterlockedCompareExchange_acq(long volatile *_Destination,230 long _Exchange, long _Comparand);231long _InterlockedCompareExchange_nf(long volatile *_Destination, long _Exchange,232 long _Comparand);233long _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);243void *_InterlockedCompareExchangePointer_acq(void *volatile *_Destination,244 void *_Exchange, void *_Comparand);245void *_InterlockedCompareExchangePointer_nf(void *volatile *_Destination,246 void *_Exchange, void *_Comparand);247void *_InterlockedCompareExchangePointer_rel(void *volatile *_Destination,248 void *_Exchange, void *_Comparand);249#endif250 251#ifdef __cplusplus252}253#endif254 255#endif /* __INTRIN0_H */256#endif /* _MSC_VER */257