Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/coreclr/nativeaot/Bootstrap/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.

#include <stdint.h>
#include <stdlib.h>

#if defined(DEBUG) && defined(_WIN32)
#include <process.h>
#include <windows.h>
#endif

//
// This is the mechanism whereby multiple linked modules contribute their global data for initialization at
Expand Down Expand Up @@ -107,16 +111,16 @@ void* PalGetModuleHandleFromPointer(void* pointer);
#if defined(HOST_X86) && defined(HOST_WINDOWS)
#define STRINGIFY(s) #s
#define MANAGED_RUNTIME_EXPORT_ALTNAME(_method) STRINGIFY(/alternatename:_##_method=_method)
#define MANAGED_RUNTIME_EXPORT_CALLCONV __cdecl
#define MANAGED_RUNTIME_EXPORT(_name) \
__pragma(comment (linker, MANAGED_RUNTIME_EXPORT_ALTNAME(_name))) \
extern "C" void __cdecl _name();
extern "C" void MANAGED_RUNTIME_EXPORT_CALLCONV _name();
#define MANAGED_RUNTIME_EXPORT_NAME(_name) _name
#define CDECL __cdecl
#else
#define MANAGED_RUNTIME_EXPORT_CALLCONV
#define MANAGED_RUNTIME_EXPORT(_name) \
extern "C" void _name();
#define MANAGED_RUNTIME_EXPORT_NAME(_name) _name
#define CDECL
#endif

MANAGED_RUNTIME_EXPORT(GetRuntimeException)
Expand All @@ -134,7 +138,7 @@ MANAGED_RUNTIME_EXPORT(ObjectiveCMarshalGetOnEnteredFinalizerQueueCallback)
MANAGED_RUNTIME_EXPORT(ObjectiveCMarshalGetUnhandledExceptionPropagationHandler)
#endif

typedef void (CDECL *pfn)();
typedef void (MANAGED_RUNTIME_EXPORT_CALLCONV *pfn)();

static const pfn c_classlibFunctions[] = {
&MANAGED_RUNTIME_EXPORT_NAME(GetRuntimeException),
Expand Down Expand Up @@ -214,7 +218,7 @@ static int InitializeRuntime()
#ifndef NATIVEAOT_DLL

#if defined(_WIN32)
int CDECL wmain(int argc, wchar_t* argv[])
int __cdecl wmain(int argc, wchar_t* argv[])
#else
int main(int argc, char* argv[])
#endif
Expand All @@ -224,8 +228,10 @@ int main(int argc, char* argv[])
return initval;

#if defined(DEBUG) && defined(_WIN32)
// quick_exit works around Debug UCRT shutdown issues: https://github.com/dotnet/runtime/issues/108640
quick_exit(__managed__Main(argc, argv));
// work around Debug UCRT shutdown issues: https://github.com/dotnet/runtime/issues/108640
int exitCode = __managed__Main(argc, argv);
_cexit();
ExitProcess(exitCode);
#else
return __managed__Main(argc, argv);
#endif
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/nativeaot/Runtime/startup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,6 @@ extern "C" bool RhInitialize(bool isDll)
#endif

#if defined(HOST_WINDOWS) || defined(FEATURE_PERFTRACING)
#if defined(DEBUG) && defined(HOST_WINDOWS)
// quick_exit works around Debug UCRT shutdown issues: https://github.com/dotnet/runtime/issues/108640
at_quick_exit(&OnProcessExit);
#endif
atexit(&OnProcessExit);
#endif

Expand Down
Loading