[x86/Linux] Use CDECL as STDAPICALLTYPE (#10969)
authorJonghyun Park <parjong@gmail.com>
Thu, 20 Apr 2017 16:05:51 +0000 (01:05 +0900)
committerBruce Forstall <brucefo@microsoft.com>
Thu, 20 Apr 2017 16:05:51 +0000 (09:05 -0700)
* [x86/Linux] Use CDECL as STDAPICALLTYPE

* Use system default calling convention for internal functions

17 files changed:
src/ToolBox/superpmi/superpmi-shared/coreclrcommoncallbacks.h [new file with mode: 0644]
src/ToolBox/superpmi/superpmi-shim-collector/coreclrcallbacks.cpp
src/ToolBox/superpmi/superpmi-shim-collector/coreclrcallbacks.h
src/ToolBox/superpmi/superpmi-shim-counter/coreclrcallbacks.cpp
src/ToolBox/superpmi/superpmi-shim-counter/coreclrcallbacks.h
src/ToolBox/superpmi/superpmi-shim-simple/coreclrcallbacks.cpp
src/ToolBox/superpmi/superpmi-shim-simple/coreclrcallbacks.h
src/ToolBox/superpmi/superpmi/coreclrcallbacks.cpp
src/ToolBox/superpmi/superpmi/coreclrcallbacks.h
src/dlls/mscoree/mscoree.cpp
src/inc/utilcode.h
src/pal/inc/rt/palrt.h
src/strongname/api/strongnamecoreclr.cpp
src/vm/ceemain.cpp
src/vm/corhost.cpp
src/vm/hosting.cpp
src/vm/util.cpp

diff --git a/src/ToolBox/superpmi/superpmi-shared/coreclrcommoncallbacks.h b/src/ToolBox/superpmi/superpmi-shared/coreclrcommoncallbacks.h
new file mode 100644 (file)
index 0000000..ca542fb
--- /dev/null
@@ -0,0 +1,20 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+#ifndef _CoreClrCommonCallbacks
+#define _CoreClrCommonCallbacks
+
+#include "runtimedetails.h"
+
+IExecutionEngine* IEE_t();
+HRESULT GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength);
+LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
+BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
+void* GetCLRFunction(LPCSTR functionName);
+
+typedef LPVOID (*pfnEEHeapAllocInProcessHeap)(DWORD dwFlags, SIZE_T dwBytes);
+typedef BOOL (*pfnEEHeapFreeInProcessHeap)(DWORD dwFlags, LPVOID lpMem);
+
+#endif
index e9a42d8..14a55b5 100644 (file)
@@ -7,14 +7,11 @@
 #include "coreclrcallbacks.h"
 #include "iexecutionengine.h"
 
-typedef LPVOID(__stdcall* pfnEEHeapAllocInProcessHeap)(DWORD dwFlags, SIZE_T dwBytes);
-typedef BOOL(__stdcall* pfnEEHeapFreeInProcessHeap)(DWORD dwFlags, LPVOID lpMem);
-
 CoreClrCallbacks*           original_CoreClrCallbacks         = nullptr;
 pfnEEHeapAllocInProcessHeap original_EEHeapAllocInProcessHeap = nullptr;
 pfnEEHeapFreeInProcessHeap  original_EEHeapFreeInProcessHeap  = nullptr;
 
-IExecutionEngine* STDMETHODCALLTYPE IEE_t()
+IExecutionEngine* IEE_t()
 {
     interceptor_IEE* iee = new interceptor_IEE();
     iee->original_IEE    = original_CoreClrCallbacks->m_pfnIEE();
@@ -29,21 +26,21 @@ HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer,
 }
 */
 
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
+LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
 {
     if (original_EEHeapAllocInProcessHeap == nullptr)
         __debugbreak();
     return original_EEHeapAllocInProcessHeap(dwFlags, dwBytes);
 }
 
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
+BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
 {
     if (original_EEHeapFreeInProcessHeap == nullptr)
         __debugbreak();
     return original_EEHeapFreeInProcessHeap(dwFlags, lpMem);
 }
 
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
+void* GetCLRFunction(LPCSTR functionName)
 {
     if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0)
     {
index 1d4b801..a525742 100644 (file)
@@ -6,14 +6,8 @@
 #ifndef _CoreClrCallbacks
 #define _CoreClrCallbacks
 
-#include "runtimedetails.h"
-
-IExecutionEngine* STDMETHODCALLTYPE IEE_t();
-HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength);
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName);
+#include "coreclrcommoncallbacks.h"
 
 extern CoreClrCallbacks* original_CoreClrCallbacks;
 
-#endif
\ No newline at end of file
+#endif
index e9a42d8..14a55b5 100644 (file)
@@ -7,14 +7,11 @@
 #include "coreclrcallbacks.h"
 #include "iexecutionengine.h"
 
-typedef LPVOID(__stdcall* pfnEEHeapAllocInProcessHeap)(DWORD dwFlags, SIZE_T dwBytes);
-typedef BOOL(__stdcall* pfnEEHeapFreeInProcessHeap)(DWORD dwFlags, LPVOID lpMem);
-
 CoreClrCallbacks*           original_CoreClrCallbacks         = nullptr;
 pfnEEHeapAllocInProcessHeap original_EEHeapAllocInProcessHeap = nullptr;
 pfnEEHeapFreeInProcessHeap  original_EEHeapFreeInProcessHeap  = nullptr;
 
-IExecutionEngine* STDMETHODCALLTYPE IEE_t()
+IExecutionEngine* IEE_t()
 {
     interceptor_IEE* iee = new interceptor_IEE();
     iee->original_IEE    = original_CoreClrCallbacks->m_pfnIEE();
@@ -29,21 +26,21 @@ HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer,
 }
 */
 
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
+LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
 {
     if (original_EEHeapAllocInProcessHeap == nullptr)
         __debugbreak();
     return original_EEHeapAllocInProcessHeap(dwFlags, dwBytes);
 }
 
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
+BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
 {
     if (original_EEHeapFreeInProcessHeap == nullptr)
         __debugbreak();
     return original_EEHeapFreeInProcessHeap(dwFlags, lpMem);
 }
 
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
+void* GetCLRFunction(LPCSTR functionName)
 {
     if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0)
     {
index 1d4b801..a525742 100644 (file)
@@ -6,14 +6,8 @@
 #ifndef _CoreClrCallbacks
 #define _CoreClrCallbacks
 
-#include "runtimedetails.h"
-
-IExecutionEngine* STDMETHODCALLTYPE IEE_t();
-HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength);
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName);
+#include "coreclrcommoncallbacks.h"
 
 extern CoreClrCallbacks* original_CoreClrCallbacks;
 
-#endif
\ No newline at end of file
+#endif
index 60018b8..85ceaa2 100644 (file)
@@ -7,14 +7,11 @@
 #include "coreclrcallbacks.h"
 #include "iexecutionengine.h"
 
-typedef LPVOID(__stdcall* pfnEEHeapAllocInProcessHeap)(DWORD dwFlags, SIZE_T dwBytes);
-typedef BOOL(__stdcall* pfnEEHeapFreeInProcessHeap)(DWORD dwFlags, LPVOID lpMem);
-
 CoreClrCallbacks*           original_CoreClrCallbacks         = nullptr;
 pfnEEHeapAllocInProcessHeap original_EEHeapAllocInProcessHeap = nullptr;
 pfnEEHeapFreeInProcessHeap  original_EEHeapFreeInProcessHeap  = nullptr;
 
-IExecutionEngine* STDMETHODCALLTYPE IEE_t()
+IExecutionEngine* IEE_t()
 {
     interceptor_IEE* iee = new interceptor_IEE();
     iee->original_IEE    = original_CoreClrCallbacks->m_pfnIEE();
@@ -29,17 +26,17 @@ HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer,
 }
 */
 
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
+LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
 {
     return original_EEHeapAllocInProcessHeap(dwFlags, dwBytes);
 }
 
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
+BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
 {
     return original_EEHeapFreeInProcessHeap(dwFlags, lpMem);
 }
 
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
+void* GetCLRFunction(LPCSTR functionName)
 {
     if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0)
     {
index 3207bbe..6c4a054 100644 (file)
@@ -6,15 +6,9 @@
 #ifndef _CoreClrCallbacks
 #define _CoreClrCallbacks
 
-#include "runtimedetails.h"
-
-IExecutionEngine* STDMETHODCALLTYPE IEE_t();
-HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength);
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName);
+#include "coreclrcommoncallbacks.h"
 
 // Added to allow us to persist a copy of the original callbacks
 extern CoreClrCallbacks* original_CoreClrCallbacks;
 
-#endif
\ No newline at end of file
+#endif
index d96e2be..98fbe69 100644 (file)
@@ -8,7 +8,7 @@
 #include "coreclrcallbacks.h"
 #include "iexecutionengine.h"
 
-IExecutionEngine* STDMETHODCALLTYPE IEE_t()
+IExecutionEngine* IEE_t()
 {
     MyIEE* iee = InitIExecutionEngine();
     return iee;
@@ -24,7 +24,7 @@ HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer,
 
 HANDLE ourHeap = nullptr;
 
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
+LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
 {
     if (ourHeap == nullptr)
         ourHeap = HeapCreate(0, 4096, 0);
@@ -39,13 +39,13 @@ LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
     return result;
 }
 
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
+BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
 {
     //  return true;
     return HeapFree(ourHeap, dwFlags, lpMem);
 }
 
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
+void* GetCLRFunction(LPCSTR functionName)
 {
     if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0)
         return (void*)EEHeapAllocInProcessHeap;
index e43267c..3305779 100644 (file)
@@ -6,13 +6,8 @@
 #ifndef _CoreClrCallbacks
 #define _CoreClrCallbacks
 
-#include "runtimedetails.h"
+#include "coreclrcommoncallbacks.h"
 
-IExecutionEngine* STDMETHODCALLTYPE IEE_t();
-HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength);
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName);
 CoreClrCallbacks* InitCoreClrCallbacks();
 
-#endif
\ No newline at end of file
+#endif
index f33f095..f3e22da 100644 (file)
@@ -48,7 +48,7 @@ HINSTANCE g_hThisInst;  // This library.
 
 #include <process.h> // for __security_init_cookie()
 
-extern "C" IExecutionEngine* __stdcall IEE();
+extern "C" IExecutionEngine* IEE();
 
 #ifdef NO_CRT_INIT
 #define _CRT_INIT(hInstance, dwReason, lpReserved) (TRUE)
index 06133cf..78dbf69 100644 (file)
@@ -5109,9 +5109,9 @@ BOOL IsIPInModule(HMODULE_TGT hModule, PCODE ip);
 //----------------------------------------------------------------------------------------
 struct CoreClrCallbacks
 {
-    typedef IExecutionEngine* (__stdcall * pfnIEE_t)();
-    typedef HRESULT (__stdcall * pfnGetCORSystemDirectory_t)(SString& pbuffer);
-    typedef void* (__stdcall * pfnGetCLRFunction_t)(LPCSTR functionName);
+    typedef IExecutionEngine* (* pfnIEE_t)();
+    typedef HRESULT (* pfnGetCORSystemDirectory_t)(SString& pbuffer);
+    typedef void* (* pfnGetCLRFunction_t)(LPCSTR functionName);
 
     HINSTANCE                   m_hmodCoreCLR;
     pfnIEE_t                    m_pfnIEE;
@@ -5516,6 +5516,6 @@ extern SpinConstants g_SpinConstants;
 
 // ======================================================================================
 
-void* __stdcall GetCLRFunction(LPCSTR FunctionName);
+void* GetCLRFunction(LPCSTR FunctionName);
 
 #endif // __UtilCode_h__
index 51f90b9..d1c2209 100644 (file)
@@ -252,7 +252,7 @@ inline void *__cdecl operator new(size_t, void *_P)
 #define STDMETHODCALLTYPE    __stdcall
 #define STDMETHODVCALLTYPE   __cdecl
 
-#define STDAPICALLTYPE       __stdcall
+#define STDAPICALLTYPE       __cdecl
 #define STDAPIVCALLTYPE      __cdecl
 
 #define STDMETHODIMP         HRESULT STDMETHODCALLTYPE
index b02cde3..2b9b4b8 100644 (file)
@@ -39,15 +39,15 @@ FunctionPointer ApiShim(LPCSTR szApiName)
 // Shim APIs, passing off into the desktop VM
 //
 
-IExecutionEngine * __stdcall SnIEE()
+IExecutionEngine* SnIEE()
 {
-    typedef IExecutionEngine * ( __stdcall *IEEFn_t)();
+    typedef IExecutionEngine* (* IEEFn_t)();
     return ApiShim<IEEFn_t>("IEE")();
 }
 
-STDAPI SnGetCorSystemDirectory(SString&  pbuffer)
+HRESULT SnGetCorSystemDirectory(SString&  pbuffer)
 {
-    typedef HRESULT (__stdcall *GetCorSystemDirectoryFn_t)(SString&);
+    typedef HRESULT (*GetCorSystemDirectoryFn_t)(SString&);
     return ApiShim<GetCorSystemDirectoryFn_t>("GetCORSystemDirectory")(pbuffer);
 }
 
index 22f1152..9cce46d 100644 (file)
@@ -2386,7 +2386,7 @@ BOOL CanRunManagedCode(LoaderLockCheck::kind checkKind, HINSTANCE hInst /*= 0*/)
 //  no longer maintains a ref count since the EE doesn't support being
 //  unloaded and re-loaded. It simply ensures the EE has been started.
 // ---------------------------------------------------------------------------
-HRESULT STDMETHODCALLTYPE CoInitializeEE(DWORD fFlags)
+HRESULT STDAPICALLTYPE CoInitializeEE(DWORD fFlags)
 {
     CONTRACTL
     {
@@ -2417,7 +2417,7 @@ HRESULT STDMETHODCALLTYPE CoInitializeEE(DWORD fFlags)
 // Description:
 //  Must be called by client on shut down in order to free up the system.
 // ---------------------------------------------------------------------------
-void STDMETHODCALLTYPE CoUninitializeEE(BOOL fIsDllUnloading)
+void STDAPICALLTYPE CoUninitializeEE(BOOL fIsDllUnloading)
 {
     LIMITED_METHOD_CONTRACT;
     //BEGIN_ENTRYPOINT_VOIDRET;
index d935ddd..fd27a7a 100644 (file)
@@ -75,7 +75,7 @@ SVAL_IMPL_INIT(ECustomDumpFlavor, CCLRErrorReportingManager, g_ECustomDumpFlavor
 #ifndef DACCESS_COMPILE
 
 extern void STDMETHODCALLTYPE EEShutDown(BOOL fIsDllUnloading);
-extern HRESULT STDMETHODCALLTYPE CoInitializeEE(DWORD fFlags);
+extern HRESULT STDAPICALLTYPE CoInitializeEE(DWORD fFlags);
 extern void PrintToStdOutA(const char *pszString);
 extern void PrintToStdOutW(const WCHAR *pwzString);
 extern BOOL g_fEEHostedStartup;
index 620b9d6..d47bc28 100644 (file)
@@ -444,6 +444,11 @@ LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
     WRAPPER_NO_CONTRACT;
     STATIC_CONTRACT_SO_TOLERANT;
 
+#ifdef _DEBUG
+    // Check whether (indispensable) implicit casting in ClrAllocInProcessHeapBootstrap is safe.
+    static FastAllocInProcessHeapFunc pFunc = EEHeapAllocInProcessHeap;
+#endif
+
     static HANDLE ProcessHeap = NULL;
 
     // We need to guarentee a very small stack consumption in allocating.  And we can't allow
@@ -506,6 +511,11 @@ BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
     }
     CONTRACTL_END;
 
+#ifdef _DEBUG
+    // Check whether (indispensable) implicit casting in ClrFreeInProcessHeapBootstrap is safe.
+    static FastFreeInProcessHeapFunc pFunc = EEHeapFreeInProcessHeap;
+#endif
+
     // Take a look at comment in EEHeapFree and EEHeapAllocInProcessHeap, obviously someone
     // needs to take a little time to think more about this code.
     //CONTRACT_VIOLATION(SOToleranceViolation);
index 70ed0e2..da7d18c 100644 (file)
@@ -2525,12 +2525,12 @@ HMODULE CLRGetCurrentModuleHandle()
 
 #endif // !FEATURE_PAL
 
-extern LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
-extern BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
-extern void ShutdownRuntimeWithoutExiting(int exitCode);
-extern BOOL IsRuntimeStarted(DWORD *pdwStartupFlags);
+LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
+BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
+void ShutdownRuntimeWithoutExiting(int exitCode);
+BOOL IsRuntimeStarted(DWORD *pdwStartupFlags);
 
-void * __stdcall GetCLRFunction(LPCSTR FunctionName)
+void *GetCLRFunction(LPCSTR FunctionName)
 {
 
     void* func = NULL;