diff --git a/CMakeLists.txt b/CMakeLists.txt index ffbcb7a92c..3e20bc7615 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,6 +135,10 @@ cmake_dependent_option( KICAD_WIN32_DPI_AWARE "Turn on DPI awareness for Windows builds only" OFF "WIN32" OFF ) +cmake_dependent_option( KICAD_WIN32_CONTEXT_WINFIBER + "Use win32 fibers for libcontext" + OFF "WIN32" OFF ) + option( KICAD_USE_EGL "Build KiCad with EGL backend support for Wayland." OFF ) @@ -219,6 +223,13 @@ perform_feature_checks() # Setup the compiler warnings include( ${CMAKE_MODULE_PATH}/Warnings.cmake ) +if( KICAD_WIN32_CONTEXT_WINFIBER ) + set(LIBCONTEXT_USE_WINFIBER true) + add_compile_definitions(LIBCONTEXT_USE_WINFIBER) +else() + set(LIBCONTEXT_USE_WINFIBER false) +endif() + if( WIN32 ) # define UNICODE and_UNICODE definition on Windows. KiCad uses unicode. # Both definitions are required diff --git a/thirdparty/libcontext/CMakeLists.txt b/thirdparty/libcontext/CMakeLists.txt index 5846a19f2a..c908ef8342 100644 --- a/thirdparty/libcontext/CMakeLists.txt +++ b/thirdparty/libcontext/CMakeLists.txt @@ -16,16 +16,20 @@ list(APPEND LIBCONTEXT_SOURCES if( MSVC ) enable_language(ASM_MASM) - if ( NOT CMAKE_SIZEOF_VOID_P EQUAL 8 ) - list(APPEND LIBCONTEXT_SOURCES - make_i386_ms_pe_masm.asm - jump_i386_ms_pe_masm.asm - ) - elseif( CMAKE_SIZEOF_VOID_P EQUAL 8 ) - list(APPEND LIBCONTEXT_SOURCES - make_x86_64_ms_pe_masm.asm - jump_x86_64_ms_pe_masm.asm - ) + if( NOT LIBCONTEXT_USE_WINFIBER ) + if ( NOT CMAKE_SIZEOF_VOID_P EQUAL 8 ) + list(APPEND LIBCONTEXT_SOURCES + make_i386_ms_pe_masm.asm + jump_i386_ms_pe_masm.asm + ) + elseif( CMAKE_SIZEOF_VOID_P EQUAL 8 ) + list(APPEND LIBCONTEXT_SOURCES + make_x86_64_ms_pe_masm.asm + jump_x86_64_ms_pe_masm.asm + ) + endif() + else() + add_compile_definitions(LIBCONTEXT_USE_WINFIBER) endif() endif() diff --git a/thirdparty/libcontext/libcontext.cpp b/thirdparty/libcontext/libcontext.cpp index 5ae8d47f7d..ee49da915a 100644 --- a/thirdparty/libcontext/libcontext.cpp +++ b/thirdparty/libcontext/libcontext.cpp @@ -1398,10 +1398,15 @@ intptr_t LIBCONTEXT_CALL_CONVENTION jump_fcontext( fcontext_t* ofc, fcontext_t n void LIBCONTEXT_CALL_CONVENTION release_fcontext( fcontext_t ctx ) { + if( ctx == nullptr ) + return; + if( fiberParams.find( ctx ) != fiberParams.end() ) { fiberParams.erase( ctx ); } + + DeleteFiber( ctx ); }