13#if !defined(__i386__) && !defined(__x86_64__)
14#error "This header is only meant to be used on x86 and x64 architecture"
132static __inline__
unsigned int __attribute__((__always_inline__, __nodebug__, __target__(
"rdpid")))
134 return __builtin_ia32_rdpid();
146static __inline__
int __attribute__((__always_inline__, __nodebug__, __target__(
"rdrnd")))
147_rdrand16_step(
unsigned short *
__p)
149 return (
int)__builtin_ia32_rdrand16_step(
__p);
161static __inline__
int __attribute__((__always_inline__, __nodebug__, __target__(
"rdrnd")))
162_rdrand32_step(
unsigned int *
__p)
164 return (
int)__builtin_ia32_rdrand32_step(
__p);
176static __inline__
int __attribute__((__always_inline__, __nodebug__, __target__(
"rdrnd")))
177_rdrand64_step(
unsigned long long *
__p)
180 return (
int)__builtin_ia32_rdrand64_step(
__p);
184 unsigned int __lo, __hi;
185 unsigned int __res_lo = __builtin_ia32_rdrand32_step(&__lo);
186 unsigned int __res_hi = __builtin_ia32_rdrand32_step(&__hi);
187 if (__res_lo && __res_hi) {
188 *
__p = ((
unsigned long long)__hi << 32) | (
unsigned long long)__lo;
205static __inline__
unsigned int __attribute__((__always_inline__, __nodebug__, __target__(
"fsgsbase")))
208 return __builtin_ia32_rdfsbase32();
218static __inline__
unsigned long long __attribute__((__always_inline__, __nodebug__, __target__(
"fsgsbase")))
221 return __builtin_ia32_rdfsbase64();
231static __inline__
unsigned int __attribute__((__always_inline__, __nodebug__, __target__(
"fsgsbase")))
234 return __builtin_ia32_rdgsbase32();
244static __inline__
unsigned long long __attribute__((__always_inline__, __nodebug__, __target__(
"fsgsbase")))
247 return __builtin_ia32_rdgsbase64();
258static __inline__
void __attribute__((__always_inline__, __nodebug__, __target__(
"fsgsbase")))
259_writefsbase_u32(
unsigned int __V)
261 __builtin_ia32_wrfsbase32(__V);
272static __inline__
void __attribute__((__always_inline__, __nodebug__, __target__(
"fsgsbase")))
273_writefsbase_u64(
unsigned long long __V)
275 __builtin_ia32_wrfsbase64(__V);
286static __inline__
void __attribute__((__always_inline__, __nodebug__, __target__(
"fsgsbase")))
287_writegsbase_u32(
unsigned int __V)
289 __builtin_ia32_wrgsbase32(__V);
300static __inline__
void __attribute__((__always_inline__, __nodebug__, __target__(
"fsgsbase")))
301_writegsbase_u64(
unsigned long long __V)
303 __builtin_ia32_wrgsbase64(__V);
323static __inline__
short __attribute__((__always_inline__, __nodebug__, __target__(
"movbe")))
324_loadbe_i16(
void const *
__P) {
328 return (
short)__builtin_bswap16(((
const struct __loadu_i16*)
__P)->
__v);
341static __inline__
void __attribute__((__always_inline__, __nodebug__, __target__(
"movbe")))
343 struct __storeu_i16 {
346 ((
struct __storeu_i16*)
__P)->
__v = __builtin_bswap16((
unsigned short)
__D);
358static __inline__
int __attribute__((__always_inline__, __nodebug__, __target__(
"movbe")))
359_loadbe_i32(
void const *
__P) {
363 return (
int)__builtin_bswap32(((
const struct __loadu_i32*)
__P)->
__v);
376static __inline__
void __attribute__((__always_inline__, __nodebug__, __target__(
"movbe")))
377_storebe_i32(
void *
__P,
int __D) {
378 struct __storeu_i32 {
381 ((
struct __storeu_i32*)
__P)->
__v = __builtin_bswap32((
unsigned int)
__D);
394static __inline__
long long __attribute__((__always_inline__, __nodebug__, __target__(
"movbe")))
395_loadbe_i64(
void const *
__P) {
397 unsigned long long __v;
399 return (
long long)__builtin_bswap64(((
const struct __loadu_i64*)
__P)->
__v);
412static __inline__
void __attribute__((__always_inline__, __nodebug__, __target__(
"movbe")))
413_storebe_i64(
void *
__P,
long long __D) {
414 struct __storeu_i64 {
415 unsigned long long __v;
417 ((
struct __storeu_i64*)
__P)->
__v = __builtin_bswap64((
unsigned long long)
__D);
523#if defined(_MSC_VER) && __has_extension(gnu_asm)
525#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
532#if defined(__i386__) || defined(__x86_64__)
534_InterlockedExchange_HLEAcquire(
long volatile *_Target,
long _Value) {
535 __asm__ __volatile__(
".byte 0xf2 ; lock ; xchg {%0, %1|%1, %0}"
536 :
"+r" (_Value),
"+m" (*_Target) ::
"memory");
540_InterlockedExchange_HLERelease(
long volatile *_Target,
long _Value) {
541 __asm__ __volatile__(
".byte 0xf3 ; lock ; xchg {%0, %1|%1, %0}"
542 :
"+r" (_Value),
"+m" (*_Target) ::
"memory");
546#if defined(__x86_64__)
548_InterlockedExchange64_HLEAcquire(__int64
volatile *_Target, __int64 _Value) {
549 __asm__ __volatile__(
".byte 0xf2 ; lock ; xchg {%0, %1|%1, %0}"
550 :
"+r" (_Value),
"+m" (*_Target) ::
"memory");
554_InterlockedExchange64_HLERelease(__int64
volatile *_Target, __int64 _Value) {
555 __asm__ __volatile__(
".byte 0xf3 ; lock ; xchg {%0, %1|%1, %0}"
556 :
"+r" (_Value),
"+m" (*_Target) ::
"memory");
563#if defined(__i386__) || defined(__x86_64__)
565_InterlockedCompareExchange_HLEAcquire(
long volatile *_Destination,
566 long _Exchange,
long _Comparand) {
567 __asm__ __volatile__(
".byte 0xf2 ; lock ; cmpxchg {%2, %1|%1, %2}"
568 :
"+a" (_Comparand),
"+m" (*_Destination)
569 :
"r" (_Exchange) :
"memory");
573_InterlockedCompareExchange_HLERelease(
long volatile *_Destination,
574 long _Exchange,
long _Comparand) {
575 __asm__ __volatile__(
".byte 0xf3 ; lock ; cmpxchg {%2, %1|%1, %2}"
576 :
"+a" (_Comparand),
"+m" (*_Destination)
577 :
"r" (_Exchange) :
"memory");
581#if defined(__x86_64__)
583_InterlockedCompareExchange64_HLEAcquire(__int64
volatile *_Destination,
584 __int64 _Exchange, __int64 _Comparand) {
585 __asm__ __volatile__(
".byte 0xf2 ; lock ; cmpxchg {%2, %1|%1, %2}"
586 :
"+a" (_Comparand),
"+m" (*_Destination)
587 :
"r" (_Exchange) :
"memory");
591_InterlockedCompareExchange64_HLERelease(__int64
volatile *_Destination,
592 __int64 _Exchange, __int64 _Comparand) {
593 __asm__ __volatile__(
".byte 0xf3 ; lock ; cmpxchg {%2, %1|%1, %2}"
594 :
"+a" (_Comparand),
"+m" (*_Destination)
595 :
"r" (_Exchange) :
"memory");
603#undef __DEFAULT_FN_ATTRS
_Float16 __2f16 __attribute__((ext_vector_type(2)))
Zeroes the upper 128 bits (bits 255:128) of all YMM registers.
#define __DEFAULT_FN_ATTRS
static __inline__ uint32_t volatile uint32_t * __p
__asm__("swp %0, %1, [%2]" :"=r"(__v) :"r"(__x), "r"(__p) :"memory")
static __inline__ void short __D
__inline unsigned int unsigned int unsigned int * __P