10b57cec5SDimitry Andric /* ===-------- intrin.h ---------------------------------------------------=== 20b57cec5SDimitry Andric * 30b57cec5SDimitry Andric * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric * See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric * 70b57cec5SDimitry Andric *===-----------------------------------------------------------------------=== 80b57cec5SDimitry Andric */ 90b57cec5SDimitry Andric 100b57cec5SDimitry Andric /* Only include this if we're compiling for the windows platform. */ 110b57cec5SDimitry Andric #ifndef _MSC_VER 120b57cec5SDimitry Andric #include_next <intrin.h> 130b57cec5SDimitry Andric #else 140b57cec5SDimitry Andric 150b57cec5SDimitry Andric #ifndef __INTRIN_H 160b57cec5SDimitry Andric #define __INTRIN_H 170b57cec5SDimitry Andric 180b57cec5SDimitry Andric /* First include the standard intrinsics. */ 190b57cec5SDimitry Andric #if defined(__i386__) || defined(__x86_64__) 200b57cec5SDimitry Andric #include <x86intrin.h> 210b57cec5SDimitry Andric #endif 220b57cec5SDimitry Andric 230b57cec5SDimitry Andric #if defined(__arm__) 240b57cec5SDimitry Andric #include <armintr.h> 250b57cec5SDimitry Andric #endif 260b57cec5SDimitry Andric 270b57cec5SDimitry Andric #if defined(__aarch64__) 280b57cec5SDimitry Andric #include <arm64intr.h> 290b57cec5SDimitry Andric #endif 300b57cec5SDimitry Andric 310b57cec5SDimitry Andric /* For the definition of jmp_buf. */ 320b57cec5SDimitry Andric #if __STDC_HOSTED__ 330b57cec5SDimitry Andric #include <setjmp.h> 340b57cec5SDimitry Andric #endif 350b57cec5SDimitry Andric 360b57cec5SDimitry Andric /* Define the default attributes for the functions in this file. */ 370b57cec5SDimitry Andric #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__)) 380b57cec5SDimitry Andric 39480093f4SDimitry Andric #if __x86_64__ 40480093f4SDimitry Andric #define __LPTRINT_TYPE__ __int64 41480093f4SDimitry Andric #else 42480093f4SDimitry Andric #define __LPTRINT_TYPE__ long 43480093f4SDimitry Andric #endif 44480093f4SDimitry Andric 450b57cec5SDimitry Andric #ifdef __cplusplus 460b57cec5SDimitry Andric extern "C" { 470b57cec5SDimitry Andric #endif 480b57cec5SDimitry Andric 490b57cec5SDimitry Andric #if defined(__MMX__) 500b57cec5SDimitry Andric /* And the random ones that aren't in those files. */ 510b57cec5SDimitry Andric __m64 _m_from_float(float); 520b57cec5SDimitry Andric float _m_to_float(__m64); 530b57cec5SDimitry Andric #endif 540b57cec5SDimitry Andric 550b57cec5SDimitry Andric /* Other assorted instruction intrinsics. */ 560b57cec5SDimitry Andric void __addfsbyte(unsigned long, unsigned char); 570b57cec5SDimitry Andric void __addfsdword(unsigned long, unsigned long); 580b57cec5SDimitry Andric void __addfsword(unsigned long, unsigned short); 590b57cec5SDimitry Andric void __code_seg(const char *); 600b57cec5SDimitry Andric static __inline__ 610b57cec5SDimitry Andric void __cpuid(int[4], int); 620b57cec5SDimitry Andric static __inline__ 630b57cec5SDimitry Andric void __cpuidex(int[4], int, int); 640b57cec5SDimitry Andric static __inline__ 650b57cec5SDimitry Andric __int64 __emul(int, int); 660b57cec5SDimitry Andric static __inline__ 670b57cec5SDimitry Andric unsigned __int64 __emulu(unsigned int, unsigned int); 680b57cec5SDimitry Andric unsigned int __getcallerseflags(void); 690b57cec5SDimitry Andric static __inline__ 700b57cec5SDimitry Andric void __halt(void); 710b57cec5SDimitry Andric unsigned char __inbyte(unsigned short); 720b57cec5SDimitry Andric void __inbytestring(unsigned short, unsigned char *, unsigned long); 730b57cec5SDimitry Andric void __incfsbyte(unsigned long); 740b57cec5SDimitry Andric void __incfsdword(unsigned long); 750b57cec5SDimitry Andric void __incfsword(unsigned long); 760b57cec5SDimitry Andric unsigned long __indword(unsigned short); 770b57cec5SDimitry Andric void __indwordstring(unsigned short, unsigned long *, unsigned long); 780b57cec5SDimitry Andric void __int2c(void); 790b57cec5SDimitry Andric void __invlpg(void *); 800b57cec5SDimitry Andric unsigned short __inword(unsigned short); 810b57cec5SDimitry Andric void __inwordstring(unsigned short, unsigned short *, unsigned long); 820b57cec5SDimitry Andric void __lidt(void *); 830b57cec5SDimitry Andric unsigned __int64 __ll_lshift(unsigned __int64, int); 840b57cec5SDimitry Andric __int64 __ll_rshift(__int64, int); 850b57cec5SDimitry Andric static __inline__ 860b57cec5SDimitry Andric void __movsb(unsigned char *, unsigned char const *, size_t); 870b57cec5SDimitry Andric static __inline__ 880b57cec5SDimitry Andric void __movsd(unsigned long *, unsigned long const *, size_t); 890b57cec5SDimitry Andric static __inline__ 900b57cec5SDimitry Andric void __movsw(unsigned short *, unsigned short const *, size_t); 910b57cec5SDimitry Andric static __inline__ 920b57cec5SDimitry Andric void __nop(void); 930b57cec5SDimitry Andric void __nvreg_restore_fence(void); 940b57cec5SDimitry Andric void __nvreg_save_fence(void); 950b57cec5SDimitry Andric void __outbyte(unsigned short, unsigned char); 960b57cec5SDimitry Andric void __outbytestring(unsigned short, unsigned char *, unsigned long); 970b57cec5SDimitry Andric void __outdword(unsigned short, unsigned long); 980b57cec5SDimitry Andric void __outdwordstring(unsigned short, unsigned long *, unsigned long); 990b57cec5SDimitry Andric void __outword(unsigned short, unsigned short); 1000b57cec5SDimitry Andric void __outwordstring(unsigned short, unsigned short *, unsigned long); 1010b57cec5SDimitry Andric unsigned long __readcr0(void); 1020b57cec5SDimitry Andric unsigned long __readcr2(void); 103480093f4SDimitry Andric unsigned __LPTRINT_TYPE__ __readcr3(void); 1040b57cec5SDimitry Andric unsigned long __readcr4(void); 1050b57cec5SDimitry Andric unsigned long __readcr8(void); 1060b57cec5SDimitry Andric unsigned int __readdr(unsigned int); 1070b57cec5SDimitry Andric #ifdef __i386__ 1080b57cec5SDimitry Andric static __inline__ 1090b57cec5SDimitry Andric unsigned char __readfsbyte(unsigned long); 1100b57cec5SDimitry Andric static __inline__ 1110b57cec5SDimitry Andric unsigned __int64 __readfsqword(unsigned long); 1120b57cec5SDimitry Andric static __inline__ 1130b57cec5SDimitry Andric unsigned short __readfsword(unsigned long); 1140b57cec5SDimitry Andric #endif 1150b57cec5SDimitry Andric static __inline__ 1160b57cec5SDimitry Andric unsigned __int64 __readmsr(unsigned long); 1170b57cec5SDimitry Andric unsigned __int64 __readpmc(unsigned long); 1180b57cec5SDimitry Andric unsigned long __segmentlimit(unsigned long); 1190b57cec5SDimitry Andric void __sidt(void *); 1200b57cec5SDimitry Andric static __inline__ 1210b57cec5SDimitry Andric void __stosb(unsigned char *, unsigned char, size_t); 1220b57cec5SDimitry Andric static __inline__ 1230b57cec5SDimitry Andric void __stosd(unsigned long *, unsigned long, size_t); 1240b57cec5SDimitry Andric static __inline__ 1250b57cec5SDimitry Andric void __stosw(unsigned short *, unsigned short, size_t); 1260b57cec5SDimitry Andric void __svm_clgi(void); 1270b57cec5SDimitry Andric void __svm_invlpga(void *, int); 1280b57cec5SDimitry Andric void __svm_skinit(int); 1290b57cec5SDimitry Andric void __svm_stgi(void); 1300b57cec5SDimitry Andric void __svm_vmload(size_t); 1310b57cec5SDimitry Andric void __svm_vmrun(size_t); 1320b57cec5SDimitry Andric void __svm_vmsave(size_t); 1330b57cec5SDimitry Andric void __ud2(void); 1340b57cec5SDimitry Andric unsigned __int64 __ull_rshift(unsigned __int64, int); 1350b57cec5SDimitry Andric void __vmx_off(void); 1360b57cec5SDimitry Andric void __vmx_vmptrst(unsigned __int64 *); 1370b57cec5SDimitry Andric void __wbinvd(void); 1380b57cec5SDimitry Andric void __writecr0(unsigned int); 1390b57cec5SDimitry Andric static __inline__ 140480093f4SDimitry Andric void __writecr3(unsigned __INTPTR_TYPE__); 1410b57cec5SDimitry Andric void __writecr4(unsigned int); 1420b57cec5SDimitry Andric void __writecr8(unsigned int); 1430b57cec5SDimitry Andric void __writedr(unsigned int, unsigned int); 1440b57cec5SDimitry Andric void __writefsbyte(unsigned long, unsigned char); 1450b57cec5SDimitry Andric void __writefsdword(unsigned long, unsigned long); 1460b57cec5SDimitry Andric void __writefsqword(unsigned long, unsigned __int64); 1470b57cec5SDimitry Andric void __writefsword(unsigned long, unsigned short); 1480b57cec5SDimitry Andric void __writemsr(unsigned long, unsigned __int64); 1490b57cec5SDimitry Andric static __inline__ 1500b57cec5SDimitry Andric void *_AddressOfReturnAddress(void); 1510b57cec5SDimitry Andric static __inline__ 1520b57cec5SDimitry Andric unsigned char _BitScanForward(unsigned long *_Index, unsigned long _Mask); 1530b57cec5SDimitry Andric static __inline__ 1540b57cec5SDimitry Andric unsigned char _BitScanReverse(unsigned long *_Index, unsigned long _Mask); 1550b57cec5SDimitry Andric unsigned char _bittest(long const *, long); 1560b57cec5SDimitry Andric unsigned char _bittestandcomplement(long *, long); 1570b57cec5SDimitry Andric unsigned char _bittestandreset(long *, long); 1580b57cec5SDimitry Andric unsigned char _bittestandset(long *, long); 1590b57cec5SDimitry Andric void __cdecl _disable(void); 1600b57cec5SDimitry Andric void __cdecl _enable(void); 1610b57cec5SDimitry Andric long _InterlockedAddLargeStatistic(__int64 volatile *_Addend, long _Value); 1620b57cec5SDimitry Andric unsigned char _interlockedbittestandreset(long volatile *, long); 1630b57cec5SDimitry Andric unsigned char _interlockedbittestandset(long volatile *, long); 1640b57cec5SDimitry Andric void *_InterlockedCompareExchangePointer_HLEAcquire(void *volatile *, void *, 1650b57cec5SDimitry Andric void *); 1660b57cec5SDimitry Andric void *_InterlockedCompareExchangePointer_HLERelease(void *volatile *, void *, 1670b57cec5SDimitry Andric void *); 1680b57cec5SDimitry Andric long _InterlockedExchangeAdd_HLEAcquire(long volatile *, long); 1690b57cec5SDimitry Andric long _InterlockedExchangeAdd_HLERelease(long volatile *, long); 1700b57cec5SDimitry Andric __int64 _InterlockedExchangeAdd64_HLEAcquire(__int64 volatile *, __int64); 1710b57cec5SDimitry Andric __int64 _InterlockedExchangeAdd64_HLERelease(__int64 volatile *, __int64); 1720b57cec5SDimitry Andric static __inline__ void 1730b57cec5SDimitry Andric __attribute__((__deprecated__("use other intrinsics or C++11 atomics instead"))) 1740b57cec5SDimitry Andric _ReadBarrier(void); 1750b57cec5SDimitry Andric static __inline__ void 1760b57cec5SDimitry Andric __attribute__((__deprecated__("use other intrinsics or C++11 atomics instead"))) 1770b57cec5SDimitry Andric _ReadWriteBarrier(void); 1780b57cec5SDimitry Andric unsigned int _rorx_u32(unsigned int, const unsigned int); 1790b57cec5SDimitry Andric int _sarx_i32(int, unsigned int); 1800b57cec5SDimitry Andric #if __STDC_HOSTED__ 1810b57cec5SDimitry Andric int __cdecl _setjmp(jmp_buf); 1820b57cec5SDimitry Andric #endif 1830b57cec5SDimitry Andric unsigned int _shlx_u32(unsigned int, unsigned int); 1840b57cec5SDimitry Andric unsigned int _shrx_u32(unsigned int, unsigned int); 1850b57cec5SDimitry Andric void _Store_HLERelease(long volatile *, long); 1860b57cec5SDimitry Andric void _Store64_HLERelease(__int64 volatile *, __int64); 1870b57cec5SDimitry Andric void _StorePointer_HLERelease(void *volatile *, void *); 1880b57cec5SDimitry Andric static __inline__ void 1890b57cec5SDimitry Andric __attribute__((__deprecated__("use other intrinsics or C++11 atomics instead"))) 1900b57cec5SDimitry Andric _WriteBarrier(void); 1910b57cec5SDimitry Andric unsigned __int32 xbegin(void); 1920b57cec5SDimitry Andric void _xend(void); 1930b57cec5SDimitry Andric 1940b57cec5SDimitry Andric /* These additional intrinsics are turned on in x64/amd64/x86_64 mode. */ 1950b57cec5SDimitry Andric #ifdef __x86_64__ 1960b57cec5SDimitry Andric void __addgsbyte(unsigned long, unsigned char); 1970b57cec5SDimitry Andric void __addgsdword(unsigned long, unsigned long); 1980b57cec5SDimitry Andric void __addgsqword(unsigned long, unsigned __int64); 1990b57cec5SDimitry Andric void __addgsword(unsigned long, unsigned short); 2000b57cec5SDimitry Andric static __inline__ 2010b57cec5SDimitry Andric void __faststorefence(void); 2020b57cec5SDimitry Andric void __incgsbyte(unsigned long); 2030b57cec5SDimitry Andric void __incgsdword(unsigned long); 2040b57cec5SDimitry Andric void __incgsqword(unsigned long); 2050b57cec5SDimitry Andric void __incgsword(unsigned long); 2060b57cec5SDimitry Andric static __inline__ 2070b57cec5SDimitry Andric void __movsq(unsigned long long *, unsigned long long const *, size_t); 2080b57cec5SDimitry Andric static __inline__ 2090b57cec5SDimitry Andric unsigned char __readgsbyte(unsigned long); 2100b57cec5SDimitry Andric static __inline__ 2110b57cec5SDimitry Andric unsigned long __readgsdword(unsigned long); 2120b57cec5SDimitry Andric static __inline__ 2130b57cec5SDimitry Andric unsigned __int64 __readgsqword(unsigned long); 2140b57cec5SDimitry Andric unsigned short __readgsword(unsigned long); 2150b57cec5SDimitry Andric unsigned __int64 __shiftleft128(unsigned __int64 _LowPart, 2160b57cec5SDimitry Andric unsigned __int64 _HighPart, 2170b57cec5SDimitry Andric unsigned char _Shift); 2180b57cec5SDimitry Andric unsigned __int64 __shiftright128(unsigned __int64 _LowPart, 2190b57cec5SDimitry Andric unsigned __int64 _HighPart, 2200b57cec5SDimitry Andric unsigned char _Shift); 2210b57cec5SDimitry Andric static __inline__ 2220b57cec5SDimitry Andric void __stosq(unsigned __int64 *, unsigned __int64, size_t); 2230b57cec5SDimitry Andric unsigned char __vmx_on(unsigned __int64 *); 2240b57cec5SDimitry Andric unsigned char __vmx_vmclear(unsigned __int64 *); 2250b57cec5SDimitry Andric unsigned char __vmx_vmlaunch(void); 2260b57cec5SDimitry Andric unsigned char __vmx_vmptrld(unsigned __int64 *); 2270b57cec5SDimitry Andric unsigned char __vmx_vmread(size_t, size_t *); 2280b57cec5SDimitry Andric unsigned char __vmx_vmresume(void); 2290b57cec5SDimitry Andric unsigned char __vmx_vmwrite(size_t, size_t); 2300b57cec5SDimitry Andric void __writegsbyte(unsigned long, unsigned char); 2310b57cec5SDimitry Andric void __writegsdword(unsigned long, unsigned long); 2320b57cec5SDimitry Andric void __writegsqword(unsigned long, unsigned __int64); 2330b57cec5SDimitry Andric void __writegsword(unsigned long, unsigned short); 2340b57cec5SDimitry Andric unsigned char _bittest64(__int64 const *, __int64); 2350b57cec5SDimitry Andric unsigned char _bittestandcomplement64(__int64 *, __int64); 2360b57cec5SDimitry Andric unsigned char _bittestandreset64(__int64 *, __int64); 2370b57cec5SDimitry Andric unsigned char _bittestandset64(__int64 *, __int64); 2380b57cec5SDimitry Andric long _InterlockedAnd_np(long volatile *_Value, long _Mask); 2390b57cec5SDimitry Andric short _InterlockedAnd16_np(short volatile *_Value, short _Mask); 2400b57cec5SDimitry Andric __int64 _InterlockedAnd64_np(__int64 volatile *_Value, __int64 _Mask); 2410b57cec5SDimitry Andric char _InterlockedAnd8_np(char volatile *_Value, char _Mask); 2420b57cec5SDimitry Andric unsigned char _interlockedbittestandreset64(__int64 volatile *, __int64); 2430b57cec5SDimitry Andric unsigned char _interlockedbittestandset64(__int64 volatile *, __int64); 2440b57cec5SDimitry Andric long _InterlockedCompareExchange_np(long volatile *_Destination, long _Exchange, 2450b57cec5SDimitry Andric long _Comparand); 2460b57cec5SDimitry Andric unsigned char _InterlockedCompareExchange128(__int64 volatile *_Destination, 2470b57cec5SDimitry Andric __int64 _ExchangeHigh, 2480b57cec5SDimitry Andric __int64 _ExchangeLow, 2490b57cec5SDimitry Andric __int64 *_CompareandResult); 2500b57cec5SDimitry Andric unsigned char _InterlockedCompareExchange128_np(__int64 volatile *_Destination, 2510b57cec5SDimitry Andric __int64 _ExchangeHigh, 2520b57cec5SDimitry Andric __int64 _ExchangeLow, 2530b57cec5SDimitry Andric __int64 *_ComparandResult); 2540b57cec5SDimitry Andric short _InterlockedCompareExchange16_np(short volatile *_Destination, 2550b57cec5SDimitry Andric short _Exchange, short _Comparand); 2560b57cec5SDimitry Andric __int64 _InterlockedCompareExchange64_np(__int64 volatile *_Destination, 2570b57cec5SDimitry Andric __int64 _Exchange, __int64 _Comparand); 2580b57cec5SDimitry Andric void *_InterlockedCompareExchangePointer_np(void *volatile *_Destination, 2590b57cec5SDimitry Andric void *_Exchange, void *_Comparand); 2600b57cec5SDimitry Andric long _InterlockedOr_np(long volatile *_Value, long _Mask); 2610b57cec5SDimitry Andric short _InterlockedOr16_np(short volatile *_Value, short _Mask); 2620b57cec5SDimitry Andric __int64 _InterlockedOr64_np(__int64 volatile *_Value, __int64 _Mask); 2630b57cec5SDimitry Andric char _InterlockedOr8_np(char volatile *_Value, char _Mask); 2640b57cec5SDimitry Andric long _InterlockedXor_np(long volatile *_Value, long _Mask); 2650b57cec5SDimitry Andric short _InterlockedXor16_np(short volatile *_Value, short _Mask); 2660b57cec5SDimitry Andric __int64 _InterlockedXor64_np(__int64 volatile *_Value, __int64 _Mask); 2670b57cec5SDimitry Andric char _InterlockedXor8_np(char volatile *_Value, char _Mask); 2680b57cec5SDimitry Andric unsigned __int64 _rorx_u64(unsigned __int64, const unsigned int); 2690b57cec5SDimitry Andric __int64 _sarx_i64(__int64, unsigned int); 2700b57cec5SDimitry Andric unsigned __int64 _shlx_u64(unsigned __int64, unsigned int); 2710b57cec5SDimitry Andric unsigned __int64 _shrx_u64(unsigned __int64, unsigned int); 2720b57cec5SDimitry Andric static __inline__ 2730b57cec5SDimitry Andric __int64 __mulh(__int64, __int64); 2740b57cec5SDimitry Andric static __inline__ 2750b57cec5SDimitry Andric unsigned __int64 __umulh(unsigned __int64, unsigned __int64); 2760b57cec5SDimitry Andric static __inline__ 2770b57cec5SDimitry Andric __int64 _mul128(__int64, __int64, __int64*); 2780b57cec5SDimitry Andric static __inline__ 2790b57cec5SDimitry Andric unsigned __int64 _umul128(unsigned __int64, 2800b57cec5SDimitry Andric unsigned __int64, 2810b57cec5SDimitry Andric unsigned __int64*); 2820b57cec5SDimitry Andric 2830b57cec5SDimitry Andric #endif /* __x86_64__ */ 2840b57cec5SDimitry Andric 2850b57cec5SDimitry Andric #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) 2860b57cec5SDimitry Andric 2870b57cec5SDimitry Andric static __inline__ 2880b57cec5SDimitry Andric unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask); 2890b57cec5SDimitry Andric static __inline__ 2900b57cec5SDimitry Andric unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask); 2910b57cec5SDimitry Andric 292*5ffd83dbSDimitry Andric #endif 293*5ffd83dbSDimitry Andric 294*5ffd83dbSDimitry Andric #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) 2950b57cec5SDimitry Andric static __inline__ 2960b57cec5SDimitry Andric __int64 _InterlockedDecrement64(__int64 volatile *_Addend); 2970b57cec5SDimitry Andric static __inline__ 2980b57cec5SDimitry Andric __int64 _InterlockedExchange64(__int64 volatile *_Target, __int64 _Value); 2990b57cec5SDimitry Andric static __inline__ 3000b57cec5SDimitry Andric __int64 _InterlockedExchangeAdd64(__int64 volatile *_Addend, __int64 _Value); 3010b57cec5SDimitry Andric static __inline__ 3020b57cec5SDimitry Andric __int64 _InterlockedExchangeSub64(__int64 volatile *_Subend, __int64 _Value); 3030b57cec5SDimitry Andric static __inline__ 3040b57cec5SDimitry Andric __int64 _InterlockedIncrement64(__int64 volatile *_Addend); 3050b57cec5SDimitry Andric static __inline__ 3060b57cec5SDimitry Andric __int64 _InterlockedOr64(__int64 volatile *_Value, __int64 _Mask); 3070b57cec5SDimitry Andric static __inline__ 3080b57cec5SDimitry Andric __int64 _InterlockedXor64(__int64 volatile *_Value, __int64 _Mask); 3090b57cec5SDimitry Andric static __inline__ 3100b57cec5SDimitry Andric __int64 _InterlockedAnd64(__int64 volatile *_Value, __int64 _Mask); 3110b57cec5SDimitry Andric 3120b57cec5SDimitry Andric #endif 3130b57cec5SDimitry Andric 3140b57cec5SDimitry Andric /*----------------------------------------------------------------------------*\ 3150b57cec5SDimitry Andric |* Interlocked Exchange Add 3160b57cec5SDimitry Andric \*----------------------------------------------------------------------------*/ 3170b57cec5SDimitry Andric #if defined(__arm__) || defined(__aarch64__) 3180b57cec5SDimitry Andric char _InterlockedExchangeAdd8_acq(char volatile *_Addend, char _Value); 3190b57cec5SDimitry Andric char _InterlockedExchangeAdd8_nf(char volatile *_Addend, char _Value); 3200b57cec5SDimitry Andric char _InterlockedExchangeAdd8_rel(char volatile *_Addend, char _Value); 3210b57cec5SDimitry Andric short _InterlockedExchangeAdd16_acq(short volatile *_Addend, short _Value); 3220b57cec5SDimitry Andric short _InterlockedExchangeAdd16_nf(short volatile *_Addend, short _Value); 3230b57cec5SDimitry Andric short _InterlockedExchangeAdd16_rel(short volatile *_Addend, short _Value); 3240b57cec5SDimitry Andric long _InterlockedExchangeAdd_acq(long volatile *_Addend, long _Value); 3250b57cec5SDimitry Andric long _InterlockedExchangeAdd_nf(long volatile *_Addend, long _Value); 3260b57cec5SDimitry Andric long _InterlockedExchangeAdd_rel(long volatile *_Addend, long _Value); 3270b57cec5SDimitry Andric __int64 _InterlockedExchangeAdd64_acq(__int64 volatile *_Addend, __int64 _Value); 3280b57cec5SDimitry Andric __int64 _InterlockedExchangeAdd64_nf(__int64 volatile *_Addend, __int64 _Value); 3290b57cec5SDimitry Andric __int64 _InterlockedExchangeAdd64_rel(__int64 volatile *_Addend, __int64 _Value); 3300b57cec5SDimitry Andric #endif 3310b57cec5SDimitry Andric /*----------------------------------------------------------------------------*\ 3320b57cec5SDimitry Andric |* Interlocked Increment 3330b57cec5SDimitry Andric \*----------------------------------------------------------------------------*/ 3340b57cec5SDimitry Andric #if defined(__arm__) || defined(__aarch64__) 3350b57cec5SDimitry Andric short _InterlockedIncrement16_acq(short volatile *_Value); 3360b57cec5SDimitry Andric short _InterlockedIncrement16_nf(short volatile *_Value); 3370b57cec5SDimitry Andric short _InterlockedIncrement16_rel(short volatile *_Value); 3380b57cec5SDimitry Andric long _InterlockedIncrement_acq(long volatile *_Value); 3390b57cec5SDimitry Andric long _InterlockedIncrement_nf(long volatile *_Value); 3400b57cec5SDimitry Andric long _InterlockedIncrement_rel(long volatile *_Value); 3410b57cec5SDimitry Andric __int64 _InterlockedIncrement64_acq(__int64 volatile *_Value); 3420b57cec5SDimitry Andric __int64 _InterlockedIncrement64_nf(__int64 volatile *_Value); 3430b57cec5SDimitry Andric __int64 _InterlockedIncrement64_rel(__int64 volatile *_Value); 3440b57cec5SDimitry Andric #endif 3450b57cec5SDimitry Andric /*----------------------------------------------------------------------------*\ 3460b57cec5SDimitry Andric |* Interlocked Decrement 3470b57cec5SDimitry Andric \*----------------------------------------------------------------------------*/ 3480b57cec5SDimitry Andric #if defined(__arm__) || defined(__aarch64__) 3490b57cec5SDimitry Andric short _InterlockedDecrement16_acq(short volatile *_Value); 3500b57cec5SDimitry Andric short _InterlockedDecrement16_nf(short volatile *_Value); 3510b57cec5SDimitry Andric short _InterlockedDecrement16_rel(short volatile *_Value); 3520b57cec5SDimitry Andric long _InterlockedDecrement_acq(long volatile *_Value); 3530b57cec5SDimitry Andric long _InterlockedDecrement_nf(long volatile *_Value); 3540b57cec5SDimitry Andric long _InterlockedDecrement_rel(long volatile *_Value); 3550b57cec5SDimitry Andric __int64 _InterlockedDecrement64_acq(__int64 volatile *_Value); 3560b57cec5SDimitry Andric __int64 _InterlockedDecrement64_nf(__int64 volatile *_Value); 3570b57cec5SDimitry Andric __int64 _InterlockedDecrement64_rel(__int64 volatile *_Value); 3580b57cec5SDimitry Andric #endif 3590b57cec5SDimitry Andric /*----------------------------------------------------------------------------*\ 3600b57cec5SDimitry Andric |* Interlocked And 3610b57cec5SDimitry Andric \*----------------------------------------------------------------------------*/ 3620b57cec5SDimitry Andric #if defined(__arm__) || defined(__aarch64__) 3630b57cec5SDimitry Andric char _InterlockedAnd8_acq(char volatile *_Value, char _Mask); 3640b57cec5SDimitry Andric char _InterlockedAnd8_nf(char volatile *_Value, char _Mask); 3650b57cec5SDimitry Andric char _InterlockedAnd8_rel(char volatile *_Value, char _Mask); 3660b57cec5SDimitry Andric short _InterlockedAnd16_acq(short volatile *_Value, short _Mask); 3670b57cec5SDimitry Andric short _InterlockedAnd16_nf(short volatile *_Value, short _Mask); 3680b57cec5SDimitry Andric short _InterlockedAnd16_rel(short volatile *_Value, short _Mask); 3690b57cec5SDimitry Andric long _InterlockedAnd_acq(long volatile *_Value, long _Mask); 3700b57cec5SDimitry Andric long _InterlockedAnd_nf(long volatile *_Value, long _Mask); 3710b57cec5SDimitry Andric long _InterlockedAnd_rel(long volatile *_Value, long _Mask); 3720b57cec5SDimitry Andric __int64 _InterlockedAnd64_acq(__int64 volatile *_Value, __int64 _Mask); 3730b57cec5SDimitry Andric __int64 _InterlockedAnd64_nf(__int64 volatile *_Value, __int64 _Mask); 3740b57cec5SDimitry Andric __int64 _InterlockedAnd64_rel(__int64 volatile *_Value, __int64 _Mask); 3750b57cec5SDimitry Andric #endif 3760b57cec5SDimitry Andric /*----------------------------------------------------------------------------*\ 3770b57cec5SDimitry Andric |* Bit Counting and Testing 3780b57cec5SDimitry Andric \*----------------------------------------------------------------------------*/ 3790b57cec5SDimitry Andric #if defined(__arm__) || defined(__aarch64__) 3800b57cec5SDimitry Andric unsigned char _interlockedbittestandset_acq(long volatile *_BitBase, 3810b57cec5SDimitry Andric long _BitPos); 3820b57cec5SDimitry Andric unsigned char _interlockedbittestandset_nf(long volatile *_BitBase, 3830b57cec5SDimitry Andric long _BitPos); 3840b57cec5SDimitry Andric unsigned char _interlockedbittestandset_rel(long volatile *_BitBase, 3850b57cec5SDimitry Andric long _BitPos); 3860b57cec5SDimitry Andric unsigned char _interlockedbittestandreset_acq(long volatile *_BitBase, 3870b57cec5SDimitry Andric long _BitPos); 3880b57cec5SDimitry Andric unsigned char _interlockedbittestandreset_nf(long volatile *_BitBase, 3890b57cec5SDimitry Andric long _BitPos); 3900b57cec5SDimitry Andric unsigned char _interlockedbittestandreset_rel(long volatile *_BitBase, 3910b57cec5SDimitry Andric long _BitPos); 3920b57cec5SDimitry Andric #endif 3930b57cec5SDimitry Andric /*----------------------------------------------------------------------------*\ 3940b57cec5SDimitry Andric |* Interlocked Or 3950b57cec5SDimitry Andric \*----------------------------------------------------------------------------*/ 3960b57cec5SDimitry Andric #if defined(__arm__) || defined(__aarch64__) 3970b57cec5SDimitry Andric char _InterlockedOr8_acq(char volatile *_Value, char _Mask); 3980b57cec5SDimitry Andric char _InterlockedOr8_nf(char volatile *_Value, char _Mask); 3990b57cec5SDimitry Andric char _InterlockedOr8_rel(char volatile *_Value, char _Mask); 4000b57cec5SDimitry Andric short _InterlockedOr16_acq(short volatile *_Value, short _Mask); 4010b57cec5SDimitry Andric short _InterlockedOr16_nf(short volatile *_Value, short _Mask); 4020b57cec5SDimitry Andric short _InterlockedOr16_rel(short volatile *_Value, short _Mask); 4030b57cec5SDimitry Andric long _InterlockedOr_acq(long volatile *_Value, long _Mask); 4040b57cec5SDimitry Andric long _InterlockedOr_nf(long volatile *_Value, long _Mask); 4050b57cec5SDimitry Andric long _InterlockedOr_rel(long volatile *_Value, long _Mask); 4060b57cec5SDimitry Andric __int64 _InterlockedOr64_acq(__int64 volatile *_Value, __int64 _Mask); 4070b57cec5SDimitry Andric __int64 _InterlockedOr64_nf(__int64 volatile *_Value, __int64 _Mask); 4080b57cec5SDimitry Andric __int64 _InterlockedOr64_rel(__int64 volatile *_Value, __int64 _Mask); 4090b57cec5SDimitry Andric #endif 4100b57cec5SDimitry Andric /*----------------------------------------------------------------------------*\ 4110b57cec5SDimitry Andric |* Interlocked Xor 4120b57cec5SDimitry Andric \*----------------------------------------------------------------------------*/ 4130b57cec5SDimitry Andric #if defined(__arm__) || defined(__aarch64__) 4140b57cec5SDimitry Andric char _InterlockedXor8_acq(char volatile *_Value, char _Mask); 4150b57cec5SDimitry Andric char _InterlockedXor8_nf(char volatile *_Value, char _Mask); 4160b57cec5SDimitry Andric char _InterlockedXor8_rel(char volatile *_Value, char _Mask); 4170b57cec5SDimitry Andric short _InterlockedXor16_acq(short volatile *_Value, short _Mask); 4180b57cec5SDimitry Andric short _InterlockedXor16_nf(short volatile *_Value, short _Mask); 4190b57cec5SDimitry Andric short _InterlockedXor16_rel(short volatile *_Value, short _Mask); 4200b57cec5SDimitry Andric long _InterlockedXor_acq(long volatile *_Value, long _Mask); 4210b57cec5SDimitry Andric long _InterlockedXor_nf(long volatile *_Value, long _Mask); 4220b57cec5SDimitry Andric long _InterlockedXor_rel(long volatile *_Value, long _Mask); 4230b57cec5SDimitry Andric __int64 _InterlockedXor64_acq(__int64 volatile *_Value, __int64 _Mask); 4240b57cec5SDimitry Andric __int64 _InterlockedXor64_nf(__int64 volatile *_Value, __int64 _Mask); 4250b57cec5SDimitry Andric __int64 _InterlockedXor64_rel(__int64 volatile *_Value, __int64 _Mask); 4260b57cec5SDimitry Andric #endif 4270b57cec5SDimitry Andric /*----------------------------------------------------------------------------*\ 4280b57cec5SDimitry Andric |* Interlocked Exchange 4290b57cec5SDimitry Andric \*----------------------------------------------------------------------------*/ 4300b57cec5SDimitry Andric #if defined(__arm__) || defined(__aarch64__) 4310b57cec5SDimitry Andric char _InterlockedExchange8_acq(char volatile *_Target, char _Value); 4320b57cec5SDimitry Andric char _InterlockedExchange8_nf(char volatile *_Target, char _Value); 4330b57cec5SDimitry Andric char _InterlockedExchange8_rel(char volatile *_Target, char _Value); 4340b57cec5SDimitry Andric short _InterlockedExchange16_acq(short volatile *_Target, short _Value); 4350b57cec5SDimitry Andric short _InterlockedExchange16_nf(short volatile *_Target, short _Value); 4360b57cec5SDimitry Andric short _InterlockedExchange16_rel(short volatile *_Target, short _Value); 4370b57cec5SDimitry Andric long _InterlockedExchange_acq(long volatile *_Target, long _Value); 4380b57cec5SDimitry Andric long _InterlockedExchange_nf(long volatile *_Target, long _Value); 4390b57cec5SDimitry Andric long _InterlockedExchange_rel(long volatile *_Target, long _Value); 4400b57cec5SDimitry Andric __int64 _InterlockedExchange64_acq(__int64 volatile *_Target, __int64 _Value); 4410b57cec5SDimitry Andric __int64 _InterlockedExchange64_nf(__int64 volatile *_Target, __int64 _Value); 4420b57cec5SDimitry Andric __int64 _InterlockedExchange64_rel(__int64 volatile *_Target, __int64 _Value); 4430b57cec5SDimitry Andric #endif 4440b57cec5SDimitry Andric /*----------------------------------------------------------------------------*\ 4450b57cec5SDimitry Andric |* Interlocked Compare Exchange 4460b57cec5SDimitry Andric \*----------------------------------------------------------------------------*/ 4470b57cec5SDimitry Andric #if defined(__arm__) || defined(__aarch64__) 4480b57cec5SDimitry Andric char _InterlockedCompareExchange8_acq(char volatile *_Destination, 4490b57cec5SDimitry Andric char _Exchange, char _Comparand); 4500b57cec5SDimitry Andric char _InterlockedCompareExchange8_nf(char volatile *_Destination, 4510b57cec5SDimitry Andric char _Exchange, char _Comparand); 4520b57cec5SDimitry Andric char _InterlockedCompareExchange8_rel(char volatile *_Destination, 4530b57cec5SDimitry Andric char _Exchange, char _Comparand); 4540b57cec5SDimitry Andric short _InterlockedCompareExchange16_acq(short volatile *_Destination, 4550b57cec5SDimitry Andric short _Exchange, short _Comparand); 4560b57cec5SDimitry Andric short _InterlockedCompareExchange16_nf(short volatile *_Destination, 4570b57cec5SDimitry Andric short _Exchange, short _Comparand); 4580b57cec5SDimitry Andric short _InterlockedCompareExchange16_rel(short volatile *_Destination, 4590b57cec5SDimitry Andric short _Exchange, short _Comparand); 4600b57cec5SDimitry Andric long _InterlockedCompareExchange_acq(long volatile *_Destination, 4610b57cec5SDimitry Andric long _Exchange, long _Comparand); 4620b57cec5SDimitry Andric long _InterlockedCompareExchange_nf(long volatile *_Destination, 4630b57cec5SDimitry Andric long _Exchange, long _Comparand); 4640b57cec5SDimitry Andric long _InterlockedCompareExchange_rel(long volatile *_Destination, 4650b57cec5SDimitry Andric long _Exchange, long _Comparand); 4660b57cec5SDimitry Andric __int64 _InterlockedCompareExchange64_acq(__int64 volatile *_Destination, 4670b57cec5SDimitry Andric __int64 _Exchange, __int64 _Comparand); 4680b57cec5SDimitry Andric __int64 _InterlockedCompareExchange64_nf(__int64 volatile *_Destination, 4690b57cec5SDimitry Andric __int64 _Exchange, __int64 _Comparand); 4700b57cec5SDimitry Andric __int64 _InterlockedCompareExchange64_rel(__int64 volatile *_Destination, 4710b57cec5SDimitry Andric __int64 _Exchange, __int64 _Comparand); 4720b57cec5SDimitry Andric #endif 4730b57cec5SDimitry Andric 4740b57cec5SDimitry Andric /*----------------------------------------------------------------------------*\ 4750b57cec5SDimitry Andric |* movs, stos 4760b57cec5SDimitry Andric \*----------------------------------------------------------------------------*/ 4770b57cec5SDimitry Andric #if defined(__i386__) || defined(__x86_64__) 4780b57cec5SDimitry Andric static __inline__ void __DEFAULT_FN_ATTRS 4790b57cec5SDimitry Andric __movsb(unsigned char *__dst, unsigned char const *__src, size_t __n) { 4800b57cec5SDimitry Andric __asm__ __volatile__("rep movsb" : "+D"(__dst), "+S"(__src), "+c"(__n) 4810b57cec5SDimitry Andric : : "memory"); 4820b57cec5SDimitry Andric } 4830b57cec5SDimitry Andric static __inline__ void __DEFAULT_FN_ATTRS 4840b57cec5SDimitry Andric __movsd(unsigned long *__dst, unsigned long const *__src, size_t __n) { 4850b57cec5SDimitry Andric __asm__ __volatile__("rep movsl" : "+D"(__dst), "+S"(__src), "+c"(__n) 4860b57cec5SDimitry Andric : : "memory"); 4870b57cec5SDimitry Andric } 4880b57cec5SDimitry Andric static __inline__ void __DEFAULT_FN_ATTRS 4890b57cec5SDimitry Andric __movsw(unsigned short *__dst, unsigned short const *__src, size_t __n) { 4900b57cec5SDimitry Andric __asm__ __volatile__("rep movsw" : "+D"(__dst), "+S"(__src), "+c"(__n) 4910b57cec5SDimitry Andric : : "memory"); 4920b57cec5SDimitry Andric } 4930b57cec5SDimitry Andric static __inline__ void __DEFAULT_FN_ATTRS 4940b57cec5SDimitry Andric __stosd(unsigned long *__dst, unsigned long __x, size_t __n) { 4950b57cec5SDimitry Andric __asm__ __volatile__("rep stosl" : "+D"(__dst), "+c"(__n) : "a"(__x) 4960b57cec5SDimitry Andric : "memory"); 4970b57cec5SDimitry Andric } 4980b57cec5SDimitry Andric static __inline__ void __DEFAULT_FN_ATTRS 4990b57cec5SDimitry Andric __stosw(unsigned short *__dst, unsigned short __x, size_t __n) { 5000b57cec5SDimitry Andric __asm__ __volatile__("rep stosw" : "+D"(__dst), "+c"(__n) : "a"(__x) 5010b57cec5SDimitry Andric : "memory"); 5020b57cec5SDimitry Andric } 5030b57cec5SDimitry Andric #endif 5040b57cec5SDimitry Andric #ifdef __x86_64__ 5050b57cec5SDimitry Andric static __inline__ void __DEFAULT_FN_ATTRS 5060b57cec5SDimitry Andric __movsq(unsigned long long *__dst, unsigned long long const *__src, size_t __n) { 5070b57cec5SDimitry Andric __asm__ __volatile__("rep movsq" : "+D"(__dst), "+S"(__src), "+c"(__n) 5080b57cec5SDimitry Andric : : "memory"); 5090b57cec5SDimitry Andric } 5100b57cec5SDimitry Andric static __inline__ void __DEFAULT_FN_ATTRS 5110b57cec5SDimitry Andric __stosq(unsigned __int64 *__dst, unsigned __int64 __x, size_t __n) { 5120b57cec5SDimitry Andric __asm__ __volatile__("rep stosq" : "+D"(__dst), "+c"(__n) : "a"(__x) 5130b57cec5SDimitry Andric : "memory"); 5140b57cec5SDimitry Andric } 5150b57cec5SDimitry Andric #endif 5160b57cec5SDimitry Andric 5170b57cec5SDimitry Andric /*----------------------------------------------------------------------------*\ 5180b57cec5SDimitry Andric |* Misc 5190b57cec5SDimitry Andric \*----------------------------------------------------------------------------*/ 5200b57cec5SDimitry Andric #if defined(__i386__) || defined(__x86_64__) 5210b57cec5SDimitry Andric static __inline__ void __DEFAULT_FN_ATTRS 5220b57cec5SDimitry Andric __cpuid(int __info[4], int __level) { 5230b57cec5SDimitry Andric __asm__ ("cpuid" : "=a"(__info[0]), "=b" (__info[1]), "=c"(__info[2]), "=d"(__info[3]) 5240b57cec5SDimitry Andric : "a"(__level), "c"(0)); 5250b57cec5SDimitry Andric } 5260b57cec5SDimitry Andric static __inline__ void __DEFAULT_FN_ATTRS 5270b57cec5SDimitry Andric __cpuidex(int __info[4], int __level, int __ecx) { 5280b57cec5SDimitry Andric __asm__ ("cpuid" : "=a"(__info[0]), "=b" (__info[1]), "=c"(__info[2]), "=d"(__info[3]) 5290b57cec5SDimitry Andric : "a"(__level), "c"(__ecx)); 5300b57cec5SDimitry Andric } 5310b57cec5SDimitry Andric static __inline__ void __DEFAULT_FN_ATTRS 5320b57cec5SDimitry Andric __halt(void) { 5330b57cec5SDimitry Andric __asm__ volatile ("hlt"); 5340b57cec5SDimitry Andric } 5350b57cec5SDimitry Andric #endif 5360b57cec5SDimitry Andric 5370b57cec5SDimitry Andric #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) 5380b57cec5SDimitry Andric static __inline__ void __DEFAULT_FN_ATTRS 5390b57cec5SDimitry Andric __nop(void) { 5400b57cec5SDimitry Andric __asm__ volatile ("nop"); 5410b57cec5SDimitry Andric } 5420b57cec5SDimitry Andric #endif 5430b57cec5SDimitry Andric 5440b57cec5SDimitry Andric /*----------------------------------------------------------------------------*\ 5450b57cec5SDimitry Andric |* MS AArch64 specific 5460b57cec5SDimitry Andric \*----------------------------------------------------------------------------*/ 5470b57cec5SDimitry Andric #if defined(__aarch64__) 5480b57cec5SDimitry Andric unsigned __int64 __getReg(int); 5490b57cec5SDimitry Andric long _InterlockedAdd(long volatile *Addend, long Value); 5500b57cec5SDimitry Andric __int64 _ReadStatusReg(int); 5510b57cec5SDimitry Andric void _WriteStatusReg(int, __int64); 5520b57cec5SDimitry Andric 5530b57cec5SDimitry Andric unsigned short __cdecl _byteswap_ushort(unsigned short val); 5540b57cec5SDimitry Andric unsigned long __cdecl _byteswap_ulong (unsigned long val); 5550b57cec5SDimitry Andric unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64 val); 5560b57cec5SDimitry Andric #endif 5570b57cec5SDimitry Andric 5580b57cec5SDimitry Andric /*----------------------------------------------------------------------------*\ 5590b57cec5SDimitry Andric |* Privileged intrinsics 5600b57cec5SDimitry Andric \*----------------------------------------------------------------------------*/ 5610b57cec5SDimitry Andric #if defined(__i386__) || defined(__x86_64__) 5620b57cec5SDimitry Andric static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS 5630b57cec5SDimitry Andric __readmsr(unsigned long __register) { 5640b57cec5SDimitry Andric // Loads the contents of a 64-bit model specific register (MSR) specified in 5650b57cec5SDimitry Andric // the ECX register into registers EDX:EAX. The EDX register is loaded with 5660b57cec5SDimitry Andric // the high-order 32 bits of the MSR and the EAX register is loaded with the 5670b57cec5SDimitry Andric // low-order 32 bits. If less than 64 bits are implemented in the MSR being 5680b57cec5SDimitry Andric // read, the values returned to EDX:EAX in unimplemented bit locations are 5690b57cec5SDimitry Andric // undefined. 5700b57cec5SDimitry Andric unsigned long __edx; 5710b57cec5SDimitry Andric unsigned long __eax; 5720b57cec5SDimitry Andric __asm__ ("rdmsr" : "=d"(__edx), "=a"(__eax) : "c"(__register)); 5730b57cec5SDimitry Andric return (((unsigned __int64)__edx) << 32) | (unsigned __int64)__eax; 5740b57cec5SDimitry Andric } 575480093f4SDimitry Andric #endif 5760b57cec5SDimitry Andric 577480093f4SDimitry Andric static __inline__ unsigned __LPTRINT_TYPE__ __DEFAULT_FN_ATTRS 5780b57cec5SDimitry Andric __readcr3(void) { 579480093f4SDimitry Andric unsigned __LPTRINT_TYPE__ __cr3_val; 580480093f4SDimitry Andric __asm__ __volatile__ ("mov %%cr3, %0" : "=r"(__cr3_val) : : "memory"); 5810b57cec5SDimitry Andric return __cr3_val; 5820b57cec5SDimitry Andric } 5830b57cec5SDimitry Andric 5840b57cec5SDimitry Andric static __inline__ void __DEFAULT_FN_ATTRS 585480093f4SDimitry Andric __writecr3(unsigned __INTPTR_TYPE__ __cr3_val) { 586480093f4SDimitry Andric __asm__ ("mov %0, %%cr3" : : "r"(__cr3_val) : "memory"); 5870b57cec5SDimitry Andric } 5880b57cec5SDimitry Andric 5890b57cec5SDimitry Andric #ifdef __cplusplus 5900b57cec5SDimitry Andric } 5910b57cec5SDimitry Andric #endif 5920b57cec5SDimitry Andric 593480093f4SDimitry Andric #undef __LPTRINT_TYPE__ 594480093f4SDimitry Andric 5950b57cec5SDimitry Andric #undef __DEFAULT_FN_ATTRS 5960b57cec5SDimitry Andric 5970b57cec5SDimitry Andric #endif /* __INTRIN_H */ 5980b57cec5SDimitry Andric #endif /* _MSC_VER */ 599