And while I think it would be a good idea to add this function to intrin-impl.h so that this "intrinsic" function would be, well, intrinsic (instead of imported), that seems like a discussion for another day.
Hey, it's another day...I originally thought it would make sense to do this incrementally, but perhaps I should have gone straight to the final answer. This patch adds _lrotl/_lrotr to intrin-impl instead of just fixing the prototypes. Shouldn't be any surprises. Note that this is a replacement for the other patch, not in addition to.
dw
diff --git a/mingw-w64-headers/crt/intrin.h b/mingw-w64-headers/crt/intrin.h index db4d7cd..88c585b 100644 --- a/mingw-w64-headers/crt/intrin.h +++ b/mingw-w64-headers/crt/intrin.h @@ -72,6 +72,10 @@ extern "C" { #include <x86intrin.h> +/* Before 4.9.2, ia32intrin.h had broken versions of these. */ +#undef _lrotl +#undef _lrotr + #if defined(__cplusplus) } #endif @@ -430,19 +434,8 @@ extern "C" { __MACHINEIA64(__MINGW_EXTENSION __int64 __load128_acq(void *,__int64 *)) __MACHINEZ(void __cdecl longjmp(jmp_buf,int)) -#pragma push_macro ("_lrotl") -#undef _lrotl -#pragma push_macro ("_lrotr") -#undef _lrotr -#ifdef __x86_64__ - __MACHINE(__MINGW_EXTENSION unsigned long long __cdecl _lrotl(unsigned long long,int)) - __MACHINE(__MINGW_EXTENSION unsigned long long __cdecl _lrotr(unsigned long long,int)) -#else - __MACHINE(unsigned __LONG32 __cdecl _lrotl(unsigned __LONG32,int)) - __MACHINE(unsigned __LONG32 __cdecl _lrotr(unsigned __LONG32,int)) -#endif -#pragma pop_macro ("_lrotl") -#pragma pop_macro ("_lrotr") + /* __MACHINE(unsigned long __cdecl _lrotl(unsigned long,int)) moved to psdk_inc/intrin-impl.h */ + /* __MACHINE(unsigned long __cdecl _lrotr(unsigned long,int)) moved to psdk_inc/intrin-impl.h */ __MACHINEI(__MINGW_EXTENSION unsigned __int64 __ll_lshift(unsigned __int64,int)) __MACHINEI(__MINGW_EXTENSION __int64 __ll_rshift(__int64,int)) diff --git a/mingw-w64-headers/crt/stdlib.h b/mingw-w64-headers/crt/stdlib.h index e38d481..18a569d 100644 --- a/mingw-w64-headers/crt/stdlib.h +++ b/mingw-w64-headers/crt/stdlib.h @@ -526,19 +526,20 @@ float __cdecl __MINGW_NOTHROW strtof(const char * __restrict__ _Str,char ** __re _CRTIMP int __cdecl _atodbl_l(_CRT_DOUBLE *_Result,char *_Str,_locale_t _Locale); _CRTIMP int __cdecl _atoldbl_l(_LDOUBLE *_Result,char *_Str,_locale_t _Locale); _CRTIMP int __cdecl _atoflt_l(_CRT_FLOAT *_Result,char *_Str,_locale_t _Locale); -#pragma push_macro ("_lrotr") -#pragma push_macro ("_lrotl") -#undef _lrotr -#undef _lrotl -#ifdef __x86_64__ - __MINGW_EXTENSION unsigned long long __cdecl _lrotl(unsigned long long _Val,int _Shift); - __MINGW_EXTENSION unsigned long long __cdecl _lrotr(unsigned long long _Val,int _Shift); -#else - unsigned long __cdecl _lrotl(unsigned long _Val,int _Shift); - unsigned long __cdecl _lrotr(unsigned long _Val,int _Shift); -#endif -#pragma pop_macro ("_lrotl") -#pragma pop_macro ("_lrotr") + + /* If x86intrin.h has already been included, we already have these definitions */ +#ifndef _X86INTRIN_H_INCLUDED +/* When using 4 byte longs (x86 or x64+native Windows) */ +#ifndef __LP64__ + /* use the 32bit rotates in MSVCRT.dll */ + unsigned long __cdecl _lrotl(unsigned long,int); + unsigned long __cdecl _lrotr(unsigned long,int); +#else /* __LP64__ */ +/* Under systems that use 8 byte longs (like 64bit cygwin), we need 8 byte rotates */ +#define _lrotl(a,b) _rotl64((a), (b)) +#define _lrotr(a,b) _rotr64((a), (b)) +#endif /* __LP64__ */ +#endif /* _X86INTRIN_H_INCLUDED */ _CRTIMP void __cdecl _makepath(char *_Path,const char *_Drive,const char *_Dir,const char *_Filename,const char *_Ext); _onexit_t __cdecl _onexit(_onexit_t _Func); diff --git a/mingw-w64-headers/include/psdk_inc/intrin-impl.h b/mingw-w64-headers/include/psdk_inc/intrin-impl.h index 8ccff53..8b186f6 100644 --- a/mingw-w64-headers/include/psdk_inc/intrin-impl.h +++ b/mingw-w64-headers/include/psdk_inc/intrin-impl.h @@ -498,6 +498,30 @@ supports ReadWriteBarrier, map all 3 to do the same. */ extern "C" { #endif +/* Before 4.9.2, ia32intrin.h had broken versions of these. */ +#undef _lrotl +#undef _lrotr + +#if __INTRINSIC_PROLOG(_lrotl) +unsigned long _lrotl(unsigned long __X, int __C); +__INTRINSICS_USEINLINE +unsigned long _lrotl(unsigned long __X, int __C) +{ + return (__X << __C) | (__X >> ((sizeof(long) * 8) - __C)); +} +#define __INTRINSIC_DEFINED__lrotl +#endif /* __INTRINSIC_PROLOG */ + +#if __INTRINSIC_PROLOG(_lrotr) +unsigned long _lrotr(unsigned long __X, int __C); +__INTRINSICS_USEINLINE +unsigned long _lrotr(unsigned long __X, int __C) +{ + return (__X >> __C) | (__X << ((sizeof(long) * 8) - __C)); +} +#define __INTRINSIC_DEFINED__lrotr +#endif /* __INTRINSIC_PROLOG */ + #if defined(__x86_64__) || defined(_AMD64_) #if __INTRINSIC_PROLOG(__faststorefence)
------------------------------------------------------------------------------ Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck Code Sight - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public