Add cmake option to enable win32 fibers

This commit is contained in:
Marek Roszko 2021-03-04 21:31:53 -05:00
parent 4ddb942ec0
commit 2bf488e0c7
3 changed files with 30 additions and 10 deletions

View File

@ -135,6 +135,10 @@ cmake_dependent_option( KICAD_WIN32_DPI_AWARE
"Turn on DPI awareness for Windows builds only" "Turn on DPI awareness for Windows builds only"
OFF "WIN32" OFF ) OFF "WIN32" OFF )
cmake_dependent_option( KICAD_WIN32_CONTEXT_WINFIBER
"Use win32 fibers for libcontext"
OFF "WIN32" OFF )
option( KICAD_USE_EGL option( KICAD_USE_EGL
"Build KiCad with EGL backend support for Wayland." "Build KiCad with EGL backend support for Wayland."
OFF ) OFF )
@ -219,6 +223,13 @@ perform_feature_checks()
# Setup the compiler warnings # Setup the compiler warnings
include( ${CMAKE_MODULE_PATH}/Warnings.cmake ) 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 ) if( WIN32 )
# define UNICODE and_UNICODE definition on Windows. KiCad uses unicode. # define UNICODE and_UNICODE definition on Windows. KiCad uses unicode.
# Both definitions are required # Both definitions are required

View File

@ -16,16 +16,20 @@ list(APPEND LIBCONTEXT_SOURCES
if( MSVC ) if( MSVC )
enable_language(ASM_MASM) enable_language(ASM_MASM)
if ( NOT CMAKE_SIZEOF_VOID_P EQUAL 8 ) if( NOT LIBCONTEXT_USE_WINFIBER )
list(APPEND LIBCONTEXT_SOURCES if ( NOT CMAKE_SIZEOF_VOID_P EQUAL 8 )
make_i386_ms_pe_masm.asm list(APPEND LIBCONTEXT_SOURCES
jump_i386_ms_pe_masm.asm make_i386_ms_pe_masm.asm
) jump_i386_ms_pe_masm.asm
elseif( CMAKE_SIZEOF_VOID_P EQUAL 8 ) )
list(APPEND LIBCONTEXT_SOURCES elseif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
make_x86_64_ms_pe_masm.asm list(APPEND LIBCONTEXT_SOURCES
jump_x86_64_ms_pe_masm.asm make_x86_64_ms_pe_masm.asm
) jump_x86_64_ms_pe_masm.asm
)
endif()
else()
add_compile_definitions(LIBCONTEXT_USE_WINFIBER)
endif() endif()
endif() endif()

View File

@ -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 ) void LIBCONTEXT_CALL_CONVENTION release_fcontext( fcontext_t ctx )
{ {
if( ctx == nullptr )
return;
if( fiberParams.find( ctx ) != fiberParams.end() ) if( fiberParams.find( ctx ) != fiberParams.end() )
{ {
fiberParams.erase( ctx ); fiberParams.erase( ctx );
} }
DeleteFiber( ctx );
} }