mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Added NoThreadExitWait Rt option for DLLs
This commit is contained in:
parent
177b5b7254
commit
b2ab1b1f62
7 changed files with 36 additions and 5 deletions
|
@ -118,6 +118,11 @@ namespace System
|
||||||
{
|
{
|
||||||
sModuleHandle = handle;
|
sModuleHandle = handle;
|
||||||
}
|
}
|
||||||
|
[AlwaysInclude]
|
||||||
|
static void AddRtFlags(int32 flags)
|
||||||
|
{
|
||||||
|
Runtime.[Friend]sExtraFlags |= (.)flags;
|
||||||
|
}
|
||||||
|
|
||||||
public static T* AllocRawArrayUnmarked<T>(int size)
|
public static T* AllocRawArrayUnmarked<T>(int size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -279,14 +279,17 @@ namespace System
|
||||||
ObjectHasDebugFlags = 1,
|
ObjectHasDebugFlags = 1,
|
||||||
LeakCheck = 2,
|
LeakCheck = 2,
|
||||||
SilentCrash = 4,
|
SilentCrash = 4,
|
||||||
DebugAlloc = 8
|
DebugAlloc = 8,
|
||||||
|
NoThreadExitWait = 0x10
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static RtFlags sExtraFlags;
|
||||||
|
|
||||||
public static this()
|
public static this()
|
||||||
{
|
{
|
||||||
BfRtCallbacks.sCallbacks.Init();
|
BfRtCallbacks.sCallbacks.Init();
|
||||||
|
|
||||||
RtFlags flags = default;
|
RtFlags flags = sExtraFlags;
|
||||||
#if BF_ENABLE_OBJECT_DEBUG_FLAGS
|
#if BF_ENABLE_OBJECT_DEBUG_FLAGS
|
||||||
flags |= .ObjectHasDebugFlags;
|
flags |= .ObjectHasDebugFlags;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -35,7 +35,8 @@ enum BfRtFlags
|
||||||
BfRtFlags_ObjectHasDebugFlags = 1,
|
BfRtFlags_ObjectHasDebugFlags = 1,
|
||||||
BfRtFlags_LeakCheck = 2,
|
BfRtFlags_LeakCheck = 2,
|
||||||
BfRtFlags_SilentCrash = 4,
|
BfRtFlags_SilentCrash = 4,
|
||||||
BfRtFlags_DebugAlloc = 8
|
BfRtFlags_DebugAlloc = 8,
|
||||||
|
BfRtFlags_NoThreadExitWait = 0x10,
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace bf
|
namespace bf
|
||||||
|
|
|
@ -159,6 +159,9 @@ static void BF_CALLTYPE CStartProc(void* threadParam)
|
||||||
|
|
||||||
void BfInternalThread::WaitForAllDone()
|
void BfInternalThread::WaitForAllDone()
|
||||||
{
|
{
|
||||||
|
if ((gBfRtFlags & BfRtFlags_NoThreadExitWait) != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
while (gLiveThreadCount != 0)
|
while (gLiveThreadCount != 0)
|
||||||
{
|
{
|
||||||
// Clear out any old done events
|
// Clear out any old done events
|
||||||
|
|
|
@ -107,6 +107,11 @@ namespace System
|
||||||
{
|
{
|
||||||
sModuleHandle = handle;
|
sModuleHandle = handle;
|
||||||
}
|
}
|
||||||
|
[AlwaysInclude]
|
||||||
|
static void AddRtFlags(int32 flags)
|
||||||
|
{
|
||||||
|
Runtime.[Friend]sExtraFlags |= (.)flags;
|
||||||
|
}
|
||||||
|
|
||||||
public static Object ObjectAlloc(TypeInstance typeInst, int size)
|
public static Object ObjectAlloc(TypeInstance typeInst, int size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1634,6 +1634,8 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
||||||
// Generate "main"
|
// Generate "main"
|
||||||
if (!IsHotCompile())
|
if (!IsHotCompile())
|
||||||
{
|
{
|
||||||
|
int rtFlags = 0;
|
||||||
|
|
||||||
BfIRFunctionType mainFuncType;
|
BfIRFunctionType mainFuncType;
|
||||||
BfIRFunction mainFunc;
|
BfIRFunction mainFunc;
|
||||||
if ((targetType == BfTargetType_BeefConsoleApplication) || (targetType == BfTargetType_BeefTest))
|
if ((targetType == BfTargetType_BeefConsoleApplication) || (targetType == BfTargetType_BeefTest))
|
||||||
|
@ -1656,6 +1658,7 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
||||||
if (mOptions.mMachineType == BfMachineType_x86)
|
if (mOptions.mMachineType == BfMachineType_x86)
|
||||||
bfModule->mBfIRBuilder->SetFuncCallingConv(mainFunc, BfIRCallingConv_StdCall);
|
bfModule->mBfIRBuilder->SetFuncCallingConv(mainFunc, BfIRCallingConv_StdCall);
|
||||||
bfModule->SetupIRMethod(NULL, mainFunc, false);
|
bfModule->SetupIRMethod(NULL, mainFunc, false);
|
||||||
|
rtFlags = 0x10; // BfRtFlags_NoThreadExitWait
|
||||||
}
|
}
|
||||||
else if (targetType == BfTargetType_BeefWindowsApplication)
|
else if (targetType == BfTargetType_BeefWindowsApplication)
|
||||||
{
|
{
|
||||||
|
@ -1687,6 +1690,17 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
||||||
auto entryBlock = bfModule->mBfIRBuilder->CreateBlock("entry", true);
|
auto entryBlock = bfModule->mBfIRBuilder->CreateBlock("entry", true);
|
||||||
bfModule->mBfIRBuilder->SetInsertPoint(entryBlock);
|
bfModule->mBfIRBuilder->SetInsertPoint(entryBlock);
|
||||||
|
|
||||||
|
if (rtFlags != 0)
|
||||||
|
{
|
||||||
|
auto addRtFlagMethod = bfModule->GetInternalMethod("AddRtFlags", 1);
|
||||||
|
if (addRtFlagMethod)
|
||||||
|
{
|
||||||
|
SmallVector<BfIRValue, 1> args;
|
||||||
|
args.push_back(bfModule->mBfIRBuilder->CreateConst(BfTypeCode_Int32, rtFlags));
|
||||||
|
bfModule->mBfIRBuilder->CreateCall(addRtFlagMethod.mFunc, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((mOptions.mPlatformType != BfPlatformType_Windows) &&
|
if ((mOptions.mPlatformType != BfPlatformType_Windows) &&
|
||||||
((targetType == BfTargetType_BeefConsoleApplication) || (targetType == BfTargetType_BeefTest)))
|
((targetType == BfTargetType_BeefConsoleApplication) || (targetType == BfTargetType_BeefTest)))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue