[intrin_x86.h]

- cast return value of __sync_val_compare_and_swap to make clang happy
- add __cdecl to a number of intrinsics to make them (hopefully) compatible with crt header declarations.

svn path=/trunk/; revision=47442
This commit is contained in:
Timo Kreuzer 2010-05-30 13:02:29 +00:00
parent 64fc3cd5d7
commit 4af7c48119

View file

@ -114,7 +114,7 @@ __INTRIN_INLINE long _InterlockedCompareExchange(volatile long * const Destinati
__INTRIN_INLINE void * _InterlockedCompareExchangePointer(void * volatile * const Destination, void * const Exchange, void * const Comperand) __INTRIN_INLINE void * _InterlockedCompareExchangePointer(void * volatile * const Destination, void * const Exchange, void * const Comperand)
{ {
return __sync_val_compare_and_swap(Destination, Comperand, Exchange); return (void *)__sync_val_compare_and_swap(Destination, Comperand, Exchange);
} }
__INTRIN_INLINE long _InterlockedExchange(volatile long * const Target, const long Value) __INTRIN_INLINE long _InterlockedExchange(volatile long * const Target, const long Value)
@ -137,7 +137,7 @@ __INTRIN_INLINE void * _InterlockedExchangePointer(void * volatile * const Targe
{ {
/* NOTE: ditto */ /* NOTE: ditto */
__sync_synchronize(); __sync_synchronize();
return __sync_lock_test_and_set(Target, Value); return (void *)__sync_lock_test_and_set(Target, Value);
} }
__INTRIN_INLINE long _InterlockedExchangeAdd16(volatile short * const Addend, const short Value) __INTRIN_INLINE long _InterlockedExchangeAdd16(volatile short * const Addend, const short Value)
@ -879,14 +879,14 @@ __INTRIN_INLINE unsigned short _rotl16(unsigned short value, unsigned char shift
return retval; return retval;
} }
__INTRIN_INLINE unsigned int _rotl(unsigned int value, int shift) __INTRIN_INLINE unsigned int __cdecl _rotl(unsigned int value, int shift)
{ {
unsigned long retval; unsigned long retval;
__asm__("roll %b[shift], %k[retval]" : [retval] "=rm" (retval) : "[retval]" (value), [shift] "Nc" (shift)); __asm__("roll %b[shift], %k[retval]" : [retval] "=rm" (retval) : "[retval]" (value), [shift] "Nc" (shift));
return retval; return retval;
} }
__INTRIN_INLINE unsigned int _rotr(unsigned int value, int shift) __INTRIN_INLINE unsigned int __cdecl _rotr(unsigned int value, int shift)
{ {
unsigned long retval; unsigned long retval;
__asm__("rorl %b[shift], %k[retval]" : [retval] "=rm" (retval) : "[retval]" (value), [shift] "Nc" (shift)); __asm__("rorl %b[shift], %k[retval]" : [retval] "=rm" (retval) : "[retval]" (value), [shift] "Nc" (shift));
@ -956,14 +956,14 @@ __INTRIN_INLINE unsigned long long __ull_rshift(const unsigned long long Mask, i
return retval; return retval;
} }
__INTRIN_INLINE unsigned short _byteswap_ushort(unsigned short value) __INTRIN_INLINE unsigned short __cdecl _byteswap_ushort(unsigned short value)
{ {
unsigned short retval; unsigned short retval;
__asm__("rorw $8, %w[retval]" : [retval] "=rm" (retval) : "[retval]" (value)); __asm__("rorw $8, %w[retval]" : [retval] "=rm" (retval) : "[retval]" (value));
return retval; return retval;
} }
__INTRIN_INLINE unsigned long _byteswap_ulong(unsigned long value) __INTRIN_INLINE unsigned long __cdecl _byteswap_ulong(unsigned long value)
{ {
unsigned long retval; unsigned long retval;
__asm__("bswapl %[retval]" : [retval] "=r" (retval) : "[retval]" (value)); __asm__("bswapl %[retval]" : [retval] "=r" (retval) : "[retval]" (value));
@ -971,7 +971,7 @@ __INTRIN_INLINE unsigned long _byteswap_ulong(unsigned long value)
} }
#ifdef _M_AMD64 #ifdef _M_AMD64
__INTRIN_INLINE unsigned __int64 _byteswap_uint64(unsigned __int64 value) __INTRIN_INLINE unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64 value)
{ {
unsigned __int64 retval; unsigned __int64 retval;
__asm__("bswapq %[retval]" : [retval] "=r" (retval) : "[retval]" (value)); __asm__("bswapq %[retval]" : [retval] "=r" (retval) : "[retval]" (value));