diff --git a/sdk/lib/ucrt/inc/corecrt_internal_simd.h b/sdk/lib/ucrt/inc/corecrt_internal_simd.h index 5770418e034..01a92229438 100644 --- a/sdk/lib/ucrt/inc/corecrt_internal_simd.h +++ b/sdk/lib/ucrt/inc/corecrt_internal_simd.h @@ -18,6 +18,24 @@ #if defined _CRT_SIMD_SUPPORT_AVAILABLE +#if defined(__clang__) +#define _UCRT_ENABLE_EXTENDED_ISA \ + _Pragma("clang attribute push(__attribute__((target(\"sse2,avx,avx2\"))), apply_to=function)") +#define _UCRT_RESTORE_DEFAULT_ISA \ + _Pragma("clang attribute pop") +#elif defined(__GNUC__) +#define _UCRT_ENABLE_EXTENDED_ISA \ + _Pragma("GCC push_options") \ + _Pragma("GCC target(\"avx2\")") +#define _UCRT_RESTORE_DEFAULT_ISA \ + _Pragma("GCC pop_options") +#else +#define _UCRT_ENABLE_EXTENDED_ISA +#define _UCRT_RESTORE_DEFAULT_ISA +#endif + +_UCRT_ENABLE_EXTENDED_ISA + extern "C" int __isa_available; enum class __crt_simd_isa @@ -155,4 +173,6 @@ } }; +_UCRT_RESTORE_DEFAULT_ISA + #endif // _CRT_SIMD_SUPPORT_AVAILABLE diff --git a/sdk/lib/ucrt/string/strnlen.cpp b/sdk/lib/ucrt/string/strnlen.cpp index 6cee4e85e0f..302086cb9f9 100644 --- a/sdk/lib/ucrt/string/strnlen.cpp +++ b/sdk/lib/ucrt/string/strnlen.cpp @@ -78,11 +78,13 @@ static __forceinline size_t __cdecl common_strnlen_c( #ifdef _CRT_SIMD_SUPPORT_AVAILABLE +_UCRT_ENABLE_EXTENDED_ISA + template _Check_return_ _When_(maximum_count > _String_length_(string), _Post_satisfies_(return == _String_length_(string))) _When_(maximum_count <= _String_length_(string), _Post_satisfies_(return == maximum_count)) - static __forceinline size_t __cdecl common_strnlen_simd( + static __inline size_t __cdecl common_strnlen_simd( Element const* const string, size_t const maximum_count ) throw() @@ -168,6 +170,8 @@ static __forceinline size_t __cdecl common_strnlen_c( return static_cast(it - string); } +_UCRT_RESTORE_DEFAULT_ISA + #endif // _CRT_SIMD_SUPPORT_AVAILABLE template