22//  The .NET Foundation licenses this file to you under the MIT license.
33
44#include  < stdint.h> 
5- #include  < stdlib.h> 
5+ 
6+ #if  defined(DEBUG) && defined(_WIN32)
7+ #include  < process.h> 
8+ #include  < windows.h> 
9+ #endif 
610
711// 
812//  This is the mechanism whereby multiple linked modules contribute their global data for initialization at
@@ -107,16 +111,16 @@ void* PalGetModuleHandleFromPointer(void* pointer);
107111#if  defined(HOST_X86) && defined(HOST_WINDOWS)
108112#define  STRINGIFY (s ) #s
109113#define  MANAGED_RUNTIME_EXPORT_ALTNAME (_method ) STRINGIFY(/alternatename:_##_method=_method)
114+ #define  MANAGED_RUNTIME_EXPORT_CALLCONV  __cdecl
110115#define  MANAGED_RUNTIME_EXPORT (_name ) \
111116    __pragma (comment (linker, MANAGED_RUNTIME_EXPORT_ALTNAME(_name))) \
112-     extern "C" void __cdecl  _name();
117+     extern "C" void MANAGED_RUNTIME_EXPORT_CALLCONV  _name();
113118#define  MANAGED_RUNTIME_EXPORT_NAME (_name ) _name
114- #define  CDECL  __cdecl
115119#else 
120+ #define  MANAGED_RUNTIME_EXPORT_CALLCONV 
116121#define  MANAGED_RUNTIME_EXPORT (_name ) \
117122    extern  " C" void  _name ();
118123#define  MANAGED_RUNTIME_EXPORT_NAME (_name ) _name
119- #define  CDECL 
120124#endif 
121125
122126MANAGED_RUNTIME_EXPORT (GetRuntimeException)
@@ -132,7 +136,7 @@ MANAGED_RUNTIME_EXPORT(ObjectiveCMarshalGetOnEnteredFinalizerQueueCallback)
132136MANAGED_RUNTIME_EXPORT(ObjectiveCMarshalGetUnhandledExceptionPropagationHandler)
133137#endif 
134138
135- typedef  void  (CDECL  *pfn)();
139+ typedef  void  (MANAGED_RUNTIME_EXPORT_CALLCONV  *pfn)();
136140
137141static  const  pfn c_classlibFunctions[] = {
138142    &MANAGED_RUNTIME_EXPORT_NAME (GetRuntimeException),
@@ -210,7 +214,7 @@ static int InitializeRuntime()
210214#ifndef  NATIVEAOT_DLL
211215
212216#if  defined(_WIN32)
213- int  CDECL  wmain (int  argc, wchar_t * argv[])
217+ int  __cdecl  wmain (int  argc, wchar_t * argv[])
214218#else 
215219int  main (int  argc, char * argv[])
216220#endif 
@@ -220,8 +224,10 @@ int main(int argc, char* argv[])
220224        return  initval;
221225
222226#if  defined(DEBUG) && defined(_WIN32)
223-     //  quick_exit works around Debug UCRT shutdown issues: https://github.com/dotnet/runtime/issues/108640
224-     quick_exit (__managed__Main (argc, argv));
227+     //  work around Debug UCRT shutdown issues: https://github.com/dotnet/runtime/issues/108640
228+     int  exitCode = __managed__Main (argc, argv);
229+     _cexit ();
230+     ExitProcess (exitCode);
225231#else 
226232    return  __managed__Main (argc, argv);
227233#endif 
0 commit comments