fix _lrotl used to give wrong answer on LLP64 (cherry picked from commit c8b67428e03b305bd9fcd8b34860751fc6f345d3)
diff --git a/mingw-w64-headers/crt/intrin.h b/mingw-w64-headers/crt/intrin.h index db4d7cd..0b2343f 100644 --- a/mingw-w64-headers/crt/intrin.h +++ b/mingw-w64-headers/crt/intrin.h
@@ -72,6 +72,10 @@ #include <x86intrin.h> +/* Before 4.9.2, x86intrin.h had broken versions of these. */ +#undef _lrotl +#undef _lrotr + #if defined(__cplusplus) } #endif @@ -430,19 +434,8 @@ __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 492f2dd..dfc5ae4 100644 --- a/mingw-w64-headers/crt/stdlib.h +++ b/mingw-w64-headers/crt/stdlib.h
@@ -536,19 +536,27 @@ _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") + +#if defined(__INTRIN_H_) || \ + (defined(_X86INTRIN_H_INCLUDED) && \ + ((__MINGW_GCC_VERSION >= 40902) || defined(__LP64__) || defined(_X86_))) + +/* We already have bug-free prototypes and inline definitions for _lrotl + and _lrotr from either intrin.h or x86intrin.h. */ + +#else + +/* Remove buggy x86intrin.h definitions if present (see gcc bug 61662). */ #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") + +/* These prototypes work for x86, x64 (native Windows), and cyginwin64. */ +unsigned long __cdecl _lrotl(unsigned long,int); +unsigned long __cdecl _lrotr(unsigned long,int); + +#endif /* defined(__INTRIN_H_) || \ + (defined(_X86INTRIN_H_INCLUDED) && \ + ((__MINGW_GCC_VERSION >= 40902) || defined(__LP64__))) */ _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 f570638..ce2b15c 100644 --- a/mingw-w64-headers/include/psdk_inc/intrin-impl.h +++ b/mingw-w64-headers/include/psdk_inc/intrin-impl.h
@@ -505,6 +505,30 @@ 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)