From 3b1f1f7b6ac890190538d98ec7901d95258d14c3 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Mon, 24 Aug 2020 21:07:26 -0400 Subject: [PATCH] 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 --- thirdparty/libcontext/libcontext.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/thirdparty/libcontext/libcontext.cpp b/thirdparty/libcontext/libcontext.cpp index 661e966497..7de0e20e3e 100644 --- a/thirdparty/libcontext/libcontext.cpp +++ b/thirdparty/libcontext/libcontext.cpp @@ -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;