Make gc/vxsort/isa_detection.cpp portable (#41517)
authorJan Kotas <jkotas@microsoft.com>
Fri, 28 Aug 2020 17:13:47 +0000 (10:13 -0700)
committerGitHub <noreply@github.com>
Fri, 28 Aug 2020 17:13:47 +0000 (10:13 -0700)
Fixes #41515

src/coreclr/src/gc/CMakeLists.txt
src/coreclr/src/gc/sample/CMakeLists.txt
src/coreclr/src/gc/vxsort/isa_detection.cpp
src/coreclr/src/gc/vxsort/isa_detection_dummy.cpp [deleted file]

index b802602..c68bbce 100644 (file)
@@ -42,7 +42,7 @@ endif(CLR_CMAKE_HOST_UNIX)
 if (CLR_CMAKE_TARGET_ARCH_AMD64 AND CLR_CMAKE_TARGET_WIN32)
   set ( GC_SOURCES
     ${GC_SOURCES}
-    vxsort/isa_detection_dummy.cpp
+    vxsort/isa_detection.cpp
     vxsort/do_vxsort_avx2.cpp
     vxsort/do_vxsort_avx512.cpp
     vxsort/machine_traits.avx2.cpp
index e7849c8..88dae6f 100644 (file)
@@ -27,7 +27,7 @@ set(SOURCES
 if (CLR_CMAKE_TARGET_ARCH_AMD64 AND CLR_CMAKE_TARGET_WIN32)
   set ( SOURCES
     ${SOURCES}
-    ../vxsort/isa_detection_dummy.cpp
+    ../vxsort/isa_detection.cpp
     ../vxsort/do_vxsort_avx2.cpp
     ../vxsort/do_vxsort_avx512.cpp
     ../vxsort/machine_traits.avx2.cpp
index 770c34f..2a60ea0 100644 (file)
@@ -2,7 +2,11 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 
 #include "common.h"
+
+#ifdef TARGET_WINDOWS
 #include <intrin.h>
+#include <windows.h>
+#endif
 
 #include "do_vxsort.h"
 
@@ -17,13 +21,11 @@ enum class SupportedISA
 
 static DWORD64 GetEnabledXStateFeaturesHelper()
 {
-    LIMITED_METHOD_CONTRACT;
-
     // On Windows we have an api(GetEnabledXStateFeatures) to check if AVX is supported
     typedef DWORD64(WINAPI* PGETENABLEDXSTATEFEATURES)();
     PGETENABLEDXSTATEFEATURES pfnGetEnabledXStateFeatures = NULL;
 
-    HMODULE hMod = WszLoadLibraryEx(WINDOWS_KERNEL32_DLLNAME_W, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
+    HMODULE hMod = LoadLibraryExW(L"kernel32.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
     if (hMod == NULL)
         return 0;
 
diff --git a/src/coreclr/src/gc/vxsort/isa_detection_dummy.cpp b/src/coreclr/src/gc/vxsort/isa_detection_dummy.cpp
deleted file mode 100644 (file)
index e277a76..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-#include "common.h"
-
-#include "do_vxsort.h"
-
-#if defined(TARGET_AMD64) && defined(TARGET_WINDOWS)
-
-void InitSupportedInstructionSet (int32_t)
-{
-}
-
-bool IsSupportedInstructionSet (InstructionSet)
-{
-    return false;
-}
-#endif // defined(TARGET_AMD64) && defined(TARGET_WINDOWS)
-