mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 03:59:36 +00:00
EOL fixes
This commit is contained in:
@@ -1,56 +1,56 @@
|
|||||||
#include "GpFiberStarter.h"
|
#include "GpFiberStarter.h"
|
||||||
#include "GpFiber_Win32.h"
|
#include "GpFiber_Win32.h"
|
||||||
#include "GpWindows.h"
|
#include "GpWindows.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
namespace GpFiberStarter_Win32
|
namespace GpFiberStarter_Win32
|
||||||
{
|
{
|
||||||
struct FiberStartState
|
struct FiberStartState
|
||||||
{
|
{
|
||||||
GpFiberStarter::ThreadFunc_t m_threadFunc;
|
GpFiberStarter::ThreadFunc_t m_threadFunc;
|
||||||
IGpFiber *m_creatingFiber;
|
IGpFiber *m_creatingFiber;
|
||||||
void *m_context;
|
void *m_context;
|
||||||
};
|
};
|
||||||
|
|
||||||
static VOID WINAPI FiberStartRoutine(LPVOID lpThreadParameter)
|
static VOID WINAPI FiberStartRoutine(LPVOID lpThreadParameter)
|
||||||
{
|
{
|
||||||
const FiberStartState *tss = static_cast<const FiberStartState*>(lpThreadParameter);
|
const FiberStartState *tss = static_cast<const FiberStartState*>(lpThreadParameter);
|
||||||
|
|
||||||
GpFiberStarter::ThreadFunc_t threadFunc = tss->m_threadFunc;
|
GpFiberStarter::ThreadFunc_t threadFunc = tss->m_threadFunc;
|
||||||
IGpFiber *creatingFiber = tss->m_creatingFiber;
|
IGpFiber *creatingFiber = tss->m_creatingFiber;
|
||||||
void *context = tss->m_context;
|
void *context = tss->m_context;
|
||||||
creatingFiber->YieldTo();
|
creatingFiber->YieldTo();
|
||||||
|
|
||||||
threadFunc(context);
|
threadFunc(context);
|
||||||
|
|
||||||
assert(!"Fiber function exited");
|
assert(!"Fiber function exited");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IGpFiber *GpFiberStarter::StartFiber(ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber)
|
IGpFiber *GpFiberStarter::StartFiber(ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber)
|
||||||
{
|
{
|
||||||
ULONG_PTR lowLimit;
|
ULONG_PTR lowLimit;
|
||||||
ULONG_PTR highLimit;
|
ULONG_PTR highLimit;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
GetCurrentThreadStackLimits(&lowLimit, &highLimit);
|
||||||
|
|
||||||
#if 0
|
|
||||||
GetCurrentThreadStackLimits(&lowLimit, &highLimit);
|
|
||||||
|
|
||||||
ULONG_PTR stackSize = highLimit - lowLimit;
|
ULONG_PTR stackSize = highLimit - lowLimit;
|
||||||
#else
|
#else
|
||||||
ULONG_PTR stackSize = 1024 * 1024;
|
ULONG_PTR stackSize = 1024 * 1024;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GpFiberStarter_Win32::FiberStartState startState;
|
GpFiberStarter_Win32::FiberStartState startState;
|
||||||
startState.m_context = context;
|
startState.m_context = context;
|
||||||
startState.m_creatingFiber = creatingFiber;
|
startState.m_creatingFiber = creatingFiber;
|
||||||
startState.m_threadFunc = threadFunc;
|
startState.m_threadFunc = threadFunc;
|
||||||
|
|
||||||
void *fiber = CreateFiber(static_cast<SIZE_T>(stackSize), GpFiberStarter_Win32::FiberStartRoutine, &startState);
|
void *fiber = CreateFiber(static_cast<SIZE_T>(stackSize), GpFiberStarter_Win32::FiberStartRoutine, &startState);
|
||||||
if (!fiber)
|
if (!fiber)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
SwitchToFiber(fiber);
|
SwitchToFiber(fiber);
|
||||||
|
|
||||||
return GpFiber_Win32::Create(fiber);
|
return GpFiber_Win32::Create(fiber);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user