diff --git a/.mapping.json b/.mapping.json index e021f99f86a4..5e4339230c57 100644 --- a/.mapping.json +++ b/.mapping.json @@ -3950,6 +3950,7 @@ "third_party/uboost_coro/src/context/asm/ontop_x86_64_sysv_macho_gas.S":"taxi/uservices/userver/third_party/uboost_coro/src/context/asm/ontop_x86_64_sysv_macho_gas.S", "third_party/uboost_coro/src/context/continuation.cpp":"taxi/uservices/userver/third_party/uboost_coro/src/context/continuation.cpp", "third_party/uboost_coro/src/context/dummy.cpp":"taxi/uservices/userver/third_party/uboost_coro/src/context/dummy.cpp", + "third_party/uboost_coro/src/context/fcontext.cpp":"taxi/uservices/userver/third_party/uboost_coro/src/context/fcontext.cpp", "third_party/uboost_coro/src/context/fiber.cpp":"taxi/uservices/userver/third_party/uboost_coro/src/context/fiber.cpp", "third_party/uboost_coro/src/context/posix/stack_traits.cpp":"taxi/uservices/userver/third_party/uboost_coro/src/context/posix/stack_traits.cpp", "third_party/uboost_coro/src/context/untested.cpp":"taxi/uservices/userver/third_party/uboost_coro/src/context/untested.cpp", diff --git a/third_party/uboost_coro/CMakeLists.txt b/third_party/uboost_coro/CMakeLists.txt index 4a70f0b08014..0da3da20ce0d 100644 --- a/third_party/uboost_coro/CMakeLists.txt +++ b/third_party/uboost_coro/CMakeLists.txt @@ -14,6 +14,7 @@ endif() set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/context/posix/stack_traits.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/context/fcontext.cpp ) enable_language(ASM) diff --git a/third_party/uboost_coro/README.md b/third_party/uboost_coro/README.md index 9b75bd1013f0..3c93fd445afe 100644 --- a/third_party/uboost_coro/README.md +++ b/third_party/uboost_coro/README.md @@ -1,5 +1,5 @@ # userver: Boost.Coro -Subset of [Boost C++ Libraries](https://www.boost.org) 1.83.0, that includes Coroutine2 and Context. +Subset of [Boost C++ Libraries](https://www.boost.org) 1.87.0, that includes Coroutine2 and Context. `CMakeLists.txt` is based on [boost-cmake](https://github.com/Orphis/boost-cmake). Sanitizers could be enabled via [USERVER_SANITIZE](https://userver.tech/d3/da9/md_en_2userver_2tutorial_2build.html). diff --git a/third_party/uboost_coro/include/uboost_coro/context/continuation_ucontext.hpp b/third_party/uboost_coro/include/uboost_coro/context/continuation_ucontext.hpp index 2b25d96a6854..601ddfd2e2ec 100644 --- a/third_party/uboost_coro/include/uboost_coro/context/continuation_ucontext.hpp +++ b/third_party/uboost_coro/include/uboost_coro/context/continuation_ucontext.hpp @@ -62,7 +62,7 @@ namespace detail { // entered if the execution context // is resumed for the first time template -#ifdef BOOST_OS_MACOS +#if BOOST_OS_MACOS static void entry_func(std::uint32_t data_high, std::uint32_t data_low) noexcept { auto data = @@ -306,7 +306,7 @@ static activation_record * create_context1( StackAlloc && salloc, Fn && fn) { record->uctx.uc_stack.ss_size = reinterpret_cast< uintptr_t >( storage) - reinterpret_cast< uintptr_t >( stack_bottom) - static_cast< uintptr_t >( 64); record->uctx.uc_link = nullptr; -#ifdef BOOST_OS_MACOS +#if BOOST_OS_MACOS const auto integer = std::uint64_t(record); ::makecontext(&record->uctx, (void (*)()) & entry_func, 2, std::uint32_t((integer >> 32) & 0xFFFFFFFF), @@ -349,7 +349,7 @@ static activation_record * create_context2( preallocated palloc, StackAlloc && s record->uctx.uc_stack.ss_size = reinterpret_cast< uintptr_t >( storage) - reinterpret_cast< uintptr_t >( stack_bottom) - static_cast< uintptr_t >( 64); record->uctx.uc_link = nullptr; -#ifdef BOOST_OS_MACOS +#if BOOST_OS_MACOS const auto integer = std::uint64_t(record); ::makecontext(&record->uctx, (void (*)()) & entry_func, 2, std::uint32_t((integer >> 32) & 0xFFFFFFFF), diff --git a/third_party/uboost_coro/include/uboost_coro/context/detail/fcontext.hpp b/third_party/uboost_coro/include/uboost_coro/context/detail/fcontext.hpp index 4360d1b3f911..070c3a82a54e 100644 --- a/third_party/uboost_coro/include/uboost_coro/context/detail/fcontext.hpp +++ b/third_party/uboost_coro/include/uboost_coro/context/detail/fcontext.hpp @@ -27,14 +27,11 @@ struct transfer_t { void * data; }; -extern "C" BOOST_CONTEXT_DECL -transfer_t BOOST_CONTEXT_CALLDECL jump_fcontext( fcontext_t const to, void * vp); -extern "C" BOOST_CONTEXT_DECL -fcontext_t BOOST_CONTEXT_CALLDECL make_fcontext( void * sp, std::size_t size, void (* fn)( transfer_t) ); +BOOST_CONTEXT_DECL transfer_t jump_fcontext( fcontext_t const to, void * vp); +BOOST_CONTEXT_DECL fcontext_t make_fcontext( void * sp, std::size_t size, void (* fn)( transfer_t) ); // based on an idea of Giovanni Derreta -extern "C" BOOST_CONTEXT_DECL -transfer_t BOOST_CONTEXT_CALLDECL ontop_fcontext( fcontext_t const to, void * vp, transfer_t (* fn)( transfer_t) ); +BOOST_CONTEXT_DECL transfer_t ontop_fcontext( fcontext_t const to, void * vp, transfer_t (* fn)( transfer_t) ); }}} diff --git a/third_party/uboost_coro/include/uboost_coro/context/fiber_ucontext.hpp b/third_party/uboost_coro/include/uboost_coro/context/fiber_ucontext.hpp index c00ec82051e2..2da686fb3bcd 100644 --- a/third_party/uboost_coro/include/uboost_coro/context/fiber_ucontext.hpp +++ b/third_party/uboost_coro/include/uboost_coro/context/fiber_ucontext.hpp @@ -67,7 +67,7 @@ namespace detail { // entered if the execution context // is resumed for the first time template -#ifdef BOOST_OS_MACOS +#if BOOST_OS_MACOS static void fiber_entry_func(std::uint32_t data_high, std::uint32_t data_low) noexcept { auto data = @@ -336,7 +336,7 @@ static fiber_activation_record * create_fiber1( StackAlloc && salloc, Fn && fn) record->uctx.uc_stack.ss_size = reinterpret_cast< uintptr_t >( storage) - reinterpret_cast< uintptr_t >( stack_bottom) - static_cast< uintptr_t >( 64); record->uctx.uc_link = nullptr; -#ifdef BOOST_OS_MACOS +#if BOOST_OS_MACOS const auto integer = std::uint64_t(record); ::makecontext(&record->uctx, (void (*)()) & fiber_entry_func, 2, std::uint32_t((integer >> 32) & 0xFFFFFFFF), @@ -387,7 +387,7 @@ static fiber_activation_record * create_fiber2( preallocated palloc, StackAlloc record->uctx.uc_stack.ss_size = reinterpret_cast< uintptr_t >( storage) - reinterpret_cast< uintptr_t >( stack_bottom) - static_cast< uintptr_t >( 64); record->uctx.uc_link = nullptr; -#ifdef BOOST_OS_MACOS +#if BOOST_OS_MACOS const auto integer = std::uint64_t(record); ::makecontext(&record->uctx, (void (*)()) & fiber_entry_func, 2, std::uint32_t((integer >> 32) & 0xFFFFFFFF), diff --git a/third_party/uboost_coro/include/uboost_coro/coroutine2/detail/pull_control_block_cc.hpp b/third_party/uboost_coro/include/uboost_coro/coroutine2/detail/pull_control_block_cc.hpp index 257a59b56d32..7c59c2020d41 100644 --- a/third_party/uboost_coro/include/uboost_coro/coroutine2/detail/pull_control_block_cc.hpp +++ b/third_party/uboost_coro/include/uboost_coro/coroutine2/detail/pull_control_block_cc.hpp @@ -30,7 +30,7 @@ struct pull_coroutine< T >::control_block { state_t state; std::exception_ptr except; bool bvalid; - typename std::aligned_storage< sizeof( T), alignof( T) >::type storage; + alignas(T) unsigned char storage[sizeof(T)]; static void destroy( control_block * cb) noexcept; @@ -71,7 +71,7 @@ struct pull_coroutine< T & >::control_block { state_t state; std::exception_ptr except; bool bvalid; - typename std::aligned_storage< sizeof( holder), alignof( holder) >::type storage; + alignas(holder) unsigned char storage[sizeof(holder)]; static void destroy( control_block * cb) noexcept; diff --git a/third_party/uboost_coro/src/context/asm/jump_arm64_aapcs_elf_gas.S b/third_party/uboost_coro/src/context/asm/jump_arm64_aapcs_elf_gas.S index cefd1830d718..7c1f07535597 100644 --- a/third_party/uboost_coro/src/context/asm/jump_arm64_aapcs_elf_gas.S +++ b/third_party/uboost_coro/src/context/asm/jump_arm64_aapcs_elf_gas.S @@ -55,6 +55,7 @@ .text .align 2 .global jump_fcontext +.hidden jump_fcontext .type jump_fcontext, %function jump_fcontext: # prepare stack for GP + FPU diff --git a/third_party/uboost_coro/src/context/asm/jump_arm64_aapcs_macho_gas.S b/third_party/uboost_coro/src/context/asm/jump_arm64_aapcs_macho_gas.S index 31738f745314..12cc02158685 100644 --- a/third_party/uboost_coro/src/context/asm/jump_arm64_aapcs_macho_gas.S +++ b/third_party/uboost_coro/src/context/asm/jump_arm64_aapcs_macho_gas.S @@ -52,6 +52,7 @@ *******************************************************/ .text +.private_extern _jump_fcontext .globl _jump_fcontext .balign 16 _jump_fcontext: diff --git a/third_party/uboost_coro/src/context/asm/jump_arm_aapcs_elf_gas.S b/third_party/uboost_coro/src/context/asm/jump_arm_aapcs_elf_gas.S index 86efe9d82146..9934c0897c8a 100644 --- a/third_party/uboost_coro/src/context/asm/jump_arm_aapcs_elf_gas.S +++ b/third_party/uboost_coro/src/context/asm/jump_arm_aapcs_elf_gas.S @@ -41,6 +41,7 @@ .file "jump_arm_aapcs_elf_gas.S" .text .globl jump_fcontext +.hidden jump_fcontext .align 2 .type jump_fcontext,%function .syntax unified diff --git a/third_party/uboost_coro/src/context/asm/jump_i386_sysv_elf_gas.S b/third_party/uboost_coro/src/context/asm/jump_i386_sysv_elf_gas.S index 47be9e77822e..d00ac4fffd42 100644 --- a/third_party/uboost_coro/src/context/asm/jump_i386_sysv_elf_gas.S +++ b/third_party/uboost_coro/src/context/asm/jump_i386_sysv_elf_gas.S @@ -24,9 +24,14 @@ * * ****************************************************************************************/ +#ifdef __x86_64__ +#include "jump_x86_64_sysv_elf_gas.S" +#else + .file "jump_i386_sysv_elf_gas.S" .text .globl jump_fcontext +.hidden jump_fcontext .align 2 .type jump_fcontext,@function jump_fcontext: @@ -91,3 +96,5 @@ jump_fcontext: /* Mark that we don't need executable stack. */ .section .note.GNU-stack,"",%progbits + +#endif diff --git a/third_party/uboost_coro/src/context/asm/jump_x86_64_sysv_elf_gas.S b/third_party/uboost_coro/src/context/asm/jump_x86_64_sysv_elf_gas.S index 58f0e241d70f..2eff59a380cb 100644 --- a/third_party/uboost_coro/src/context/asm/jump_x86_64_sysv_elf_gas.S +++ b/third_party/uboost_coro/src/context/asm/jump_x86_64_sysv_elf_gas.S @@ -31,16 +31,20 @@ * * ****************************************************************************************/ -# if defined __CET__ -# include -# define SHSTK_ENABLED (__CET__ & 0x2) -# define BOOST_CONTEXT_SHADOW_STACK (SHSTK_ENABLED && SHADOW_STACK_SYSCALL) +# ifdef __i386__ +# include "jump_i386_sysv_elf_gas.S" # else -# define _CET_ENDBR -# endif +# if defined __CET__ +# include +# define SHSTK_ENABLED (__CET__ & 0x2) +# define BOOST_CONTEXT_SHADOW_STACK (SHSTK_ENABLED && SHADOW_STACK_SYSCALL) +# else +# define _CET_ENDBR +# endif .file "jump_x86_64_sysv_elf_gas.S" .text .globl jump_fcontext +.hidden jump_fcontext .type jump_fcontext,@function .align 16 jump_fcontext: @@ -70,7 +74,7 @@ jump_fcontext: /* read the current SSP and store it */ rdsspq %rcx movq %rcx, (%rsp) -#endif +# endif /* store RSP (pointing to context-data) in RAX */ movq %rsp, %rax @@ -140,3 +144,4 @@ jump_fcontext: /* Mark that we don't need executable stack. */ .section .note.GNU-stack,"",%progbits +# endif diff --git a/third_party/uboost_coro/src/context/asm/jump_x86_64_sysv_macho_gas.S b/third_party/uboost_coro/src/context/asm/jump_x86_64_sysv_macho_gas.S index afc3e5c126f9..673daa61dfaa 100644 --- a/third_party/uboost_coro/src/context/asm/jump_x86_64_sysv_macho_gas.S +++ b/third_party/uboost_coro/src/context/asm/jump_x86_64_sysv_macho_gas.S @@ -25,6 +25,7 @@ ****************************************************************************************/ .text +.private_extern _jump_fcontext .globl _jump_fcontext .align 8 _jump_fcontext: diff --git a/third_party/uboost_coro/src/context/asm/make_arm64_aapcs_elf_gas.S b/third_party/uboost_coro/src/context/asm/make_arm64_aapcs_elf_gas.S index 66cfb2da17ea..8ac825bf546f 100644 --- a/third_party/uboost_coro/src/context/asm/make_arm64_aapcs_elf_gas.S +++ b/third_party/uboost_coro/src/context/asm/make_arm64_aapcs_elf_gas.S @@ -55,6 +55,7 @@ .text .align 2 .global make_fcontext +.hidden make_fcontext .type make_fcontext, %function make_fcontext: # shift address in x0 (allocated stack) to lower 16 byte boundary diff --git a/third_party/uboost_coro/src/context/asm/make_arm64_aapcs_macho_gas.S b/third_party/uboost_coro/src/context/asm/make_arm64_aapcs_macho_gas.S index b30b1e3e5bbb..a6a1314c0dcd 100644 --- a/third_party/uboost_coro/src/context/asm/make_arm64_aapcs_macho_gas.S +++ b/third_party/uboost_coro/src/context/asm/make_arm64_aapcs_macho_gas.S @@ -52,6 +52,7 @@ *******************************************************/ .text +.private_extern _make_fcontext .globl _make_fcontext .balign 16 diff --git a/third_party/uboost_coro/src/context/asm/make_arm_aapcs_elf_gas.S b/third_party/uboost_coro/src/context/asm/make_arm_aapcs_elf_gas.S index 98ae64b43f9d..9616e566af62 100644 --- a/third_party/uboost_coro/src/context/asm/make_arm_aapcs_elf_gas.S +++ b/third_party/uboost_coro/src/context/asm/make_arm_aapcs_elf_gas.S @@ -41,6 +41,7 @@ .file "make_arm_aapcs_elf_gas.S" .text .globl make_fcontext +.hidden make_fcontext .align 2 .type make_fcontext,%function .syntax unified diff --git a/third_party/uboost_coro/src/context/asm/make_i386_sysv_elf_gas.S b/third_party/uboost_coro/src/context/asm/make_i386_sysv_elf_gas.S index 9261e566c0d4..992bae019af2 100644 --- a/third_party/uboost_coro/src/context/asm/make_i386_sysv_elf_gas.S +++ b/third_party/uboost_coro/src/context/asm/make_i386_sysv_elf_gas.S @@ -24,9 +24,14 @@ * * ****************************************************************************************/ +#ifdef __x86_64__ +#include "make_x86_64_sysv_elf_gas.S" +#else + .file "make_i386_sysv_elf_gas.S" .text .globl make_fcontext +.hidden make_fcontext .align 2 .type make_fcontext,@function make_fcontext: @@ -111,3 +116,5 @@ finish: /* Mark that we don't need executable stack. */ .section .note.GNU-stack,"",%progbits + +#endif diff --git a/third_party/uboost_coro/src/context/asm/make_x86_64_sysv_elf_gas.S b/third_party/uboost_coro/src/context/asm/make_x86_64_sysv_elf_gas.S index 4294398a2edc..7561c0896baa 100644 --- a/third_party/uboost_coro/src/context/asm/make_x86_64_sysv_elf_gas.S +++ b/third_party/uboost_coro/src/context/asm/make_x86_64_sysv_elf_gas.S @@ -31,20 +31,25 @@ * * ****************************************************************************************/ -# if defined __CET__ -# include -# define SHSTK_ENABLED (__CET__ & 0x2) -# define BOOST_CONTEXT_SHADOW_STACK (SHSTK_ENABLED && SHADOW_STACK_SYSCALL) +# ifdef __i386__ +# include "make_i386_sysv_elf_gas.S" # else -# define _CET_ENDBR -# endif +# if defined __CET__ +# include +# define SHSTK_ENABLED (__CET__ & 0x2) +# define BOOST_CONTEXT_SHADOW_STACK (SHSTK_ENABLED && SHADOW_STACK_SYSCALL) +# else +# define _CET_ENDBR +# endif .file "make_x86_64_sysv_elf_gas.S" .text .globl make_fcontext +.hidden make_fcontext .type make_fcontext,@function .align 16 make_fcontext: _CET_ENDBR + #if BOOST_CONTEXT_SHADOW_STACK /* the new shadow stack pointer (SSP) */ movq -0x8(%rdi), %r9 @@ -88,7 +93,8 @@ make_fcontext: movq %rcx, 0x38(%rax) #if BOOST_CONTEXT_SHADOW_STACK - /* Populate the shadow stack and normal stack */ + /* Populate the shadow stack */ + /* get original SSP */ rdsspq %r8 /* restore new shadow stack */ @@ -110,6 +116,14 @@ make_fcontext: /* save the restore token on the new shadow stack. */ saveprevssp + /* now the new shadow stack looks like: + base-> +------------------------------+ + | address of "jmp trampoline" | + SSP-> +------------------------------+ + | restore token | + +------------------------------+ + */ + /* reserve space for the new SSP */ leaq -0x8(%rax), %rax /* save the new SSP to this fcontext */ @@ -119,9 +133,9 @@ make_fcontext: ret /* return pointer to context-data */ trampoline: - _CET_ENDBR /* store return address on stack */ /* fix stack alignment */ + _CET_ENDBR #if BOOST_CONTEXT_SHADOW_STACK /* save address of "jmp *%rbp" as return-address */ /* on stack and shadow stack */ @@ -145,3 +159,4 @@ finish: /* Mark that we don't need executable stack. */ .section .note.GNU-stack,"",%progbits +# endif diff --git a/third_party/uboost_coro/src/context/asm/make_x86_64_sysv_macho_gas.S b/third_party/uboost_coro/src/context/asm/make_x86_64_sysv_macho_gas.S index 5d6c5431c598..06357f678ac9 100644 --- a/third_party/uboost_coro/src/context/asm/make_x86_64_sysv_macho_gas.S +++ b/third_party/uboost_coro/src/context/asm/make_x86_64_sysv_macho_gas.S @@ -25,6 +25,7 @@ ****************************************************************************************/ .text +.private_extern _make_fcontext .globl _make_fcontext .align 8 _make_fcontext: diff --git a/third_party/uboost_coro/src/context/asm/ontop_arm64_aapcs_elf_gas.S b/third_party/uboost_coro/src/context/asm/ontop_arm64_aapcs_elf_gas.S index 665ca5a2c118..8e40fc7d365a 100644 --- a/third_party/uboost_coro/src/context/asm/ontop_arm64_aapcs_elf_gas.S +++ b/third_party/uboost_coro/src/context/asm/ontop_arm64_aapcs_elf_gas.S @@ -55,6 +55,7 @@ .text .align 2 .global ontop_fcontext +.hidden ontop_fcontext .type ontop_fcontext, %function ontop_fcontext: # prepare stack for GP + FPU diff --git a/third_party/uboost_coro/src/context/asm/ontop_arm64_aapcs_macho_gas.S b/third_party/uboost_coro/src/context/asm/ontop_arm64_aapcs_macho_gas.S index a387d06dd298..8babe470233b 100644 --- a/third_party/uboost_coro/src/context/asm/ontop_arm64_aapcs_macho_gas.S +++ b/third_party/uboost_coro/src/context/asm/ontop_arm64_aapcs_macho_gas.S @@ -52,6 +52,7 @@ *******************************************************/ .text +.private_extern _ontop_fcontext .global _ontop_fcontext .balign 16 _ontop_fcontext: diff --git a/third_party/uboost_coro/src/context/asm/ontop_arm_aapcs_elf_gas.S b/third_party/uboost_coro/src/context/asm/ontop_arm_aapcs_elf_gas.S index 59ad5ca9ce77..8c6c9020de84 100644 --- a/third_party/uboost_coro/src/context/asm/ontop_arm_aapcs_elf_gas.S +++ b/third_party/uboost_coro/src/context/asm/ontop_arm_aapcs_elf_gas.S @@ -41,6 +41,7 @@ .file "ontop_arm_aapcs_elf_gas.S" .text .globl ontop_fcontext +.hidden ontop_fcontext .align 2 .type ontop_fcontext,%function .syntax unified diff --git a/third_party/uboost_coro/src/context/asm/ontop_i386_sysv_elf_gas.S b/third_party/uboost_coro/src/context/asm/ontop_i386_sysv_elf_gas.S index 0cb6168fab76..ea7a75b90f44 100644 --- a/third_party/uboost_coro/src/context/asm/ontop_i386_sysv_elf_gas.S +++ b/third_party/uboost_coro/src/context/asm/ontop_i386_sysv_elf_gas.S @@ -24,9 +24,14 @@ * * ****************************************************************************************/ +#ifdef __x86_64__ +#include "ontop_x86_64_sysv_elf_gas.S" +#else + .file "ontop_i386_sysv_elf_gas.S" .text .globl ontop_fcontext +.hidden ontop_fcontext .align 2 .type ontop_fcontext,@function ontop_fcontext: @@ -98,3 +103,5 @@ ontop_fcontext: /* Mark that we don't need executable stack. */ .section .note.GNU-stack,"",%progbits + +#endif diff --git a/third_party/uboost_coro/src/context/asm/ontop_x86_64_sysv_elf_gas.S b/third_party/uboost_coro/src/context/asm/ontop_x86_64_sysv_elf_gas.S index c3892b8ba0a7..e3e4bdf870a4 100644 --- a/third_party/uboost_coro/src/context/asm/ontop_x86_64_sysv_elf_gas.S +++ b/third_party/uboost_coro/src/context/asm/ontop_x86_64_sysv_elf_gas.S @@ -40,6 +40,7 @@ .file "ontop_x86_64_sysv_elf_gas.S" .text .globl ontop_fcontext +.hidden ontop_fcontext .type ontop_fcontext,@function .align 16 ontop_fcontext: diff --git a/third_party/uboost_coro/src/context/asm/ontop_x86_64_sysv_macho_gas.S b/third_party/uboost_coro/src/context/asm/ontop_x86_64_sysv_macho_gas.S index 49755c69b071..7d15b5ba2435 100644 --- a/third_party/uboost_coro/src/context/asm/ontop_x86_64_sysv_macho_gas.S +++ b/third_party/uboost_coro/src/context/asm/ontop_x86_64_sysv_macho_gas.S @@ -25,6 +25,7 @@ ****************************************************************************************/ .text +.private_extern _ontop_fcontext .globl _ontop_fcontext .align 8 _ontop_fcontext: diff --git a/third_party/uboost_coro/src/context/fcontext.cpp b/third_party/uboost_coro/src/context/fcontext.cpp new file mode 100644 index 000000000000..045c862f36ad --- /dev/null +++ b/third_party/uboost_coro/src/context/fcontext.cpp @@ -0,0 +1,39 @@ +// SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its affiliates +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// This code wraps the plain C asm symbols into properly +// namespaced and mangled C++ symbols that are safe to +// export from a library. + +#include + +extern "C" +boost::context::detail::transfer_t BOOST_CONTEXT_CALLDECL jump_fcontext( boost::context::detail::fcontext_t const to, void * vp); +extern "C" +boost::context::detail::fcontext_t BOOST_CONTEXT_CALLDECL make_fcontext( void * sp, std::size_t size, void (* fn)( boost::context::detail::transfer_t) ); + +// based on an idea of Giovanni Derreta +extern "C" +boost::context::detail::transfer_t BOOST_CONTEXT_CALLDECL ontop_fcontext( boost::context::detail::fcontext_t const to, void * vp, boost::context::detail::transfer_t (* fn)( boost::context::detail::transfer_t) ); + +namespace boost { +namespace context { +namespace detail { + +transfer_t jump_fcontext( fcontext_t const to, void * vp) +{ + return ::jump_fcontext(to, vp); +} + +fcontext_t make_fcontext( void * sp, std::size_t size, void (* fn)( transfer_t) ) +{ + return ::make_fcontext(sp, size, fn); +} + +transfer_t ontop_fcontext( fcontext_t const to, void * vp, transfer_t (* fn)( transfer_t) ) +{ + return ::ontop_fcontext(to, vp, fn); +} +}}} diff --git a/third_party/uboost_coro/src/context/posix/stack_traits.cpp b/third_party/uboost_coro/src/context/posix/stack_traits.cpp index cf6d5fd0a533..2cb235318af1 100644 --- a/third_party/uboost_coro/src/context/posix/stack_traits.cpp +++ b/third_party/uboost_coro/src/context/posix/stack_traits.cpp @@ -39,7 +39,7 @@ namespace { std::size_t pagesize() BOOST_NOEXCEPT_OR_NOTHROW { // conform to POSIX.1-2001 - return ::sysconf( _SC_PAGESIZE); + return static_cast(::sysconf( _SC_PAGESIZE)); } rlim_t stacksize_limit_() BOOST_NOEXCEPT_OR_NOTHROW { @@ -77,7 +77,7 @@ stack_traits::default_size() BOOST_NOEXCEPT_OR_NOTHROW { std::size_t stack_traits::minimum_size() BOOST_NOEXCEPT_OR_NOTHROW { - return MINSIGSTKSZ; + return static_cast(MINSIGSTKSZ); } std::size_t