Use CreateFiberEx instead of CreateFiber, ConvertThreadToFiberEx instead of ConvertThreadToFiber

- Allows specifying FIBER_FLAG_FLOAT_SWITCH to save FP registers (it doesnt by default on win32 but does on win64)
- Specify a commit stack size one byte less than the reserve stack size or else Windows rounds up to the nearest allocation size above the desired size
This commit is contained in:
Marek Roszko 2020-08-24 21:07:26 -04:00 committed by Mark Roszko
parent 46cb760641
commit 3b1f1f7b6a
1 changed files with 2 additions and 2 deletions

View File

@ -1284,11 +1284,11 @@ fcontext_t LIBCONTEXT_CALL_CONVENTION make_fcontext(void* sp, size_t size, void(
{
if (!threadHasFibers)
{
ConvertThreadToFiber(nullptr);
ConvertThreadToFiberEx(nullptr, FIBER_FLAG_FLOAT_SWITCH);
threadHasFibers = 1;
}
fcontext_t ctx = CreateFiber(size, (LPFIBER_START_ROUTINE) fiberEntry, nullptr );
fcontext_t ctx = CreateFiberEx(size - 1, size, FIBER_FLAG_FLOAT_SWITCH, (LPFIBER_START_ROUTINE) fiberEntry, nullptr );
fiberParams[ctx].entry = fn;
return ctx;