#include <init.hpp>
#include <api/dll.h>
#if defined(_WIN32) || defined(USES_DLLMAIN)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#endif
#ifdef _MANAGED
#pragma managed(push, off)
#endif
#if defined(_WIN32) || defined(USES_DLLMAIN)
extern "C" BOOL APIENTRY DllMain(
[[maybe_unused]] HMODULE hModule,
DWORD ul_reason_for_call,
[[maybe_unused]] LPVOID lpReserved);
extern "C" BOOL APIENTRY DllMain(
HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved)
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
SetMaxThreads(0);
else if (ul_reason_for_call == DLL_PROCESS_DETACH)
{
CloseDebugFiles();
FreeMemory();
#ifdef DDS_MEMORY_LEAKS_WIN32
_CrtDumpMemoryLeaks();
#endif
}
hModule;
lpReserved;
return 1;
}
#elif (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) || defined(__MAC_OS_X_VERSION_MAX_ALLOWED))
void DDSInitialize(), DDSFinalize();
void DDSInitialize(void)
{
SetMaxThreads(0);
}
void DDSFinalize(void)
{
CloseDebugFiles();
FreeMemory();
}
#elif defined(USES_CONSTRUCTOR)
static void __attribute__ ((constructor)) libInit(void)
{
SetMaxThreads(0);
}
static void __attribute__ ((destructor)) libEnd(void)
{
CloseDebugFiles();
}
#endif
#ifdef _MANAGED
#pragma managed(pop)
#endif