Skip to content

Commit f44b36e

Browse files
committed
feat core: update Boost.Context and Boost.Coroutine2 to 1.87
Fixes: #620 Tests: протестировано CI commit_hash:676dd740ba452798dfb84df2a8731e6444110489
1 parent 65806bf commit f44b36e

27 files changed

+124
-32
lines changed

.mapping.json

+1
Original file line numberDiff line numberDiff line change
@@ -3950,6 +3950,7 @@
39503950
"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",
39513951
"third_party/uboost_coro/src/context/continuation.cpp":"taxi/uservices/userver/third_party/uboost_coro/src/context/continuation.cpp",
39523952
"third_party/uboost_coro/src/context/dummy.cpp":"taxi/uservices/userver/third_party/uboost_coro/src/context/dummy.cpp",
3953+
"third_party/uboost_coro/src/context/fcontext.cpp":"taxi/uservices/userver/third_party/uboost_coro/src/context/fcontext.cpp",
39533954
"third_party/uboost_coro/src/context/fiber.cpp":"taxi/uservices/userver/third_party/uboost_coro/src/context/fiber.cpp",
39543955
"third_party/uboost_coro/src/context/posix/stack_traits.cpp":"taxi/uservices/userver/third_party/uboost_coro/src/context/posix/stack_traits.cpp",
39553956
"third_party/uboost_coro/src/context/untested.cpp":"taxi/uservices/userver/third_party/uboost_coro/src/context/untested.cpp",

third_party/uboost_coro/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ endif()
1414

1515
set(SOURCES
1616
${CMAKE_CURRENT_SOURCE_DIR}/src/context/posix/stack_traits.cpp
17+
${CMAKE_CURRENT_SOURCE_DIR}/src/context/fcontext.cpp
1718
)
1819

1920
enable_language(ASM)

third_party/uboost_coro/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# userver: Boost.Coro
2-
Subset of [Boost C++ Libraries](https://www.boost.org) 1.83.0, that includes Coroutine2 and Context.
2+
Subset of [Boost C++ Libraries](https://www.boost.org) 1.87.0, that includes Coroutine2 and Context.
33
`CMakeLists.txt` is based on [boost-cmake](https://github.com/Orphis/boost-cmake).
44

55
Sanitizers could be enabled via [USERVER_SANITIZE](https://userver.tech/d3/da9/md_en_2userver_2tutorial_2build.html).

third_party/uboost_coro/include/uboost_coro/context/continuation_ucontext.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace detail {
6262
// entered if the execution context
6363
// is resumed for the first time
6464
template <typename Record>
65-
#ifdef BOOST_OS_MACOS
65+
#if BOOST_OS_MACOS
6666
static void entry_func(std::uint32_t data_high,
6767
std::uint32_t data_low) noexcept {
6868
auto data =
@@ -306,7 +306,7 @@ static activation_record * create_context1( StackAlloc && salloc, Fn && fn) {
306306
record->uctx.uc_stack.ss_size = reinterpret_cast< uintptr_t >( storage) -
307307
reinterpret_cast< uintptr_t >( stack_bottom) - static_cast< uintptr_t >( 64);
308308
record->uctx.uc_link = nullptr;
309-
#ifdef BOOST_OS_MACOS
309+
#if BOOST_OS_MACOS
310310
const auto integer = std::uint64_t(record);
311311
::makecontext(&record->uctx, (void (*)()) & entry_func<capture_t>, 2,
312312
std::uint32_t((integer >> 32) & 0xFFFFFFFF),
@@ -349,7 +349,7 @@ static activation_record * create_context2( preallocated palloc, StackAlloc && s
349349
record->uctx.uc_stack.ss_size = reinterpret_cast< uintptr_t >( storage) -
350350
reinterpret_cast< uintptr_t >( stack_bottom) - static_cast< uintptr_t >( 64);
351351
record->uctx.uc_link = nullptr;
352-
#ifdef BOOST_OS_MACOS
352+
#if BOOST_OS_MACOS
353353
const auto integer = std::uint64_t(record);
354354
::makecontext(&record->uctx, (void (*)()) & entry_func<capture_t>, 2,
355355
std::uint32_t((integer >> 32) & 0xFFFFFFFF),

third_party/uboost_coro/include/uboost_coro/context/detail/fcontext.hpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,11 @@ struct transfer_t {
2727
void * data;
2828
};
2929

30-
extern "C" BOOST_CONTEXT_DECL
31-
transfer_t BOOST_CONTEXT_CALLDECL jump_fcontext( fcontext_t const to, void * vp);
32-
extern "C" BOOST_CONTEXT_DECL
33-
fcontext_t BOOST_CONTEXT_CALLDECL make_fcontext( void * sp, std::size_t size, void (* fn)( transfer_t) );
30+
BOOST_CONTEXT_DECL transfer_t jump_fcontext( fcontext_t const to, void * vp);
31+
BOOST_CONTEXT_DECL fcontext_t make_fcontext( void * sp, std::size_t size, void (* fn)( transfer_t) );
3432

3533
// based on an idea of Giovanni Derreta
36-
extern "C" BOOST_CONTEXT_DECL
37-
transfer_t BOOST_CONTEXT_CALLDECL ontop_fcontext( fcontext_t const to, void * vp, transfer_t (* fn)( transfer_t) );
34+
BOOST_CONTEXT_DECL transfer_t ontop_fcontext( fcontext_t const to, void * vp, transfer_t (* fn)( transfer_t) );
3835

3936
}}}
4037

third_party/uboost_coro/include/uboost_coro/context/fiber_ucontext.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ namespace detail {
6767
// entered if the execution context
6868
// is resumed for the first time
6969
template <typename Record>
70-
#ifdef BOOST_OS_MACOS
70+
#if BOOST_OS_MACOS
7171
static void fiber_entry_func(std::uint32_t data_high,
7272
std::uint32_t data_low) noexcept {
7373
auto data =
@@ -336,7 +336,7 @@ static fiber_activation_record * create_fiber1( StackAlloc && salloc, Fn && fn)
336336
record->uctx.uc_stack.ss_size = reinterpret_cast< uintptr_t >( storage) -
337337
reinterpret_cast< uintptr_t >( stack_bottom) - static_cast< uintptr_t >( 64);
338338
record->uctx.uc_link = nullptr;
339-
#ifdef BOOST_OS_MACOS
339+
#if BOOST_OS_MACOS
340340
const auto integer = std::uint64_t(record);
341341
::makecontext(&record->uctx, (void (*)()) & fiber_entry_func<capture_t>, 2,
342342
std::uint32_t((integer >> 32) & 0xFFFFFFFF),
@@ -387,7 +387,7 @@ static fiber_activation_record * create_fiber2( preallocated palloc, StackAlloc
387387
record->uctx.uc_stack.ss_size = reinterpret_cast< uintptr_t >( storage) -
388388
reinterpret_cast< uintptr_t >( stack_bottom) - static_cast< uintptr_t >( 64);
389389
record->uctx.uc_link = nullptr;
390-
#ifdef BOOST_OS_MACOS
390+
#if BOOST_OS_MACOS
391391
const auto integer = std::uint64_t(record);
392392
::makecontext(&record->uctx, (void (*)()) & fiber_entry_func<capture_t>, 2,
393393
std::uint32_t((integer >> 32) & 0xFFFFFFFF),

third_party/uboost_coro/include/uboost_coro/coroutine2/detail/pull_control_block_cc.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct pull_coroutine< T >::control_block {
3030
state_t state;
3131
std::exception_ptr except;
3232
bool bvalid;
33-
typename std::aligned_storage< sizeof( T), alignof( T) >::type storage;
33+
alignas(T) unsigned char storage[sizeof(T)];
3434

3535
static void destroy( control_block * cb) noexcept;
3636

@@ -71,7 +71,7 @@ struct pull_coroutine< T & >::control_block {
7171
state_t state;
7272
std::exception_ptr except;
7373
bool bvalid;
74-
typename std::aligned_storage< sizeof( holder), alignof( holder) >::type storage;
74+
alignas(holder) unsigned char storage[sizeof(holder)];
7575

7676
static void destroy( control_block * cb) noexcept;
7777

third_party/uboost_coro/src/context/asm/jump_arm64_aapcs_elf_gas.S

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
.text
5656
.align 2
5757
.global jump_fcontext
58+
.hidden jump_fcontext
5859
.type jump_fcontext, %function
5960
jump_fcontext:
6061
# prepare stack for GP + FPU

third_party/uboost_coro/src/context/asm/jump_arm64_aapcs_macho_gas.S

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
*******************************************************/
5353

5454
.text
55+
.private_extern _jump_fcontext
5556
.globl _jump_fcontext
5657
.balign 16
5758
_jump_fcontext:

third_party/uboost_coro/src/context/asm/jump_arm_aapcs_elf_gas.S

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
.file "jump_arm_aapcs_elf_gas.S"
4242
.text
4343
.globl jump_fcontext
44+
.hidden jump_fcontext
4445
.align 2
4546
.type jump_fcontext,%function
4647
.syntax unified

third_party/uboost_coro/src/context/asm/jump_i386_sysv_elf_gas.S

+7
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@
2424
* *
2525
****************************************************************************************/
2626

27+
#ifdef __x86_64__
28+
#include "jump_x86_64_sysv_elf_gas.S"
29+
#else
30+
2731
.file "jump_i386_sysv_elf_gas.S"
2832
.text
2933
.globl jump_fcontext
34+
.hidden jump_fcontext
3035
.align 2
3136
.type jump_fcontext,@function
3237
jump_fcontext:
@@ -91,3 +96,5 @@ jump_fcontext:
9196

9297
/* Mark that we don't need executable stack. */
9398
.section .note.GNU-stack,"",%progbits
99+
100+
#endif

third_party/uboost_coro/src/context/asm/jump_x86_64_sysv_elf_gas.S

+12-7
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,20 @@
3131
* *
3232
****************************************************************************************/
3333

34-
# if defined __CET__
35-
# include <cet.h>
36-
# define SHSTK_ENABLED (__CET__ & 0x2)
37-
# define BOOST_CONTEXT_SHADOW_STACK (SHSTK_ENABLED && SHADOW_STACK_SYSCALL)
34+
# ifdef __i386__
35+
# include "jump_i386_sysv_elf_gas.S"
3836
# else
39-
# define _CET_ENDBR
40-
# endif
37+
# if defined __CET__
38+
# include <cet.h>
39+
# define SHSTK_ENABLED (__CET__ & 0x2)
40+
# define BOOST_CONTEXT_SHADOW_STACK (SHSTK_ENABLED && SHADOW_STACK_SYSCALL)
41+
# else
42+
# define _CET_ENDBR
43+
# endif
4144
.file "jump_x86_64_sysv_elf_gas.S"
4245
.text
4346
.globl jump_fcontext
47+
.hidden jump_fcontext
4448
.type jump_fcontext,@function
4549
.align 16
4650
jump_fcontext:
@@ -70,7 +74,7 @@ jump_fcontext:
7074
/* read the current SSP and store it */
7175
rdsspq %rcx
7276
movq %rcx, (%rsp)
73-
#endif
77+
# endif
7478

7579
/* store RSP (pointing to context-data) in RAX */
7680
movq %rsp, %rax
@@ -140,3 +144,4 @@ jump_fcontext:
140144

141145
/* Mark that we don't need executable stack. */
142146
.section .note.GNU-stack,"",%progbits
147+
# endif

third_party/uboost_coro/src/context/asm/jump_x86_64_sysv_macho_gas.S

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
****************************************************************************************/
2626

2727
.text
28+
.private_extern _jump_fcontext
2829
.globl _jump_fcontext
2930
.align 8
3031
_jump_fcontext:

third_party/uboost_coro/src/context/asm/make_arm64_aapcs_elf_gas.S

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
.text
5656
.align 2
5757
.global make_fcontext
58+
.hidden make_fcontext
5859
.type make_fcontext, %function
5960
make_fcontext:
6061
# shift address in x0 (allocated stack) to lower 16 byte boundary

third_party/uboost_coro/src/context/asm/make_arm64_aapcs_macho_gas.S

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
*******************************************************/
5353

5454
.text
55+
.private_extern _make_fcontext
5556
.globl _make_fcontext
5657
.balign 16
5758

third_party/uboost_coro/src/context/asm/make_arm_aapcs_elf_gas.S

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
.file "make_arm_aapcs_elf_gas.S"
4242
.text
4343
.globl make_fcontext
44+
.hidden make_fcontext
4445
.align 2
4546
.type make_fcontext,%function
4647
.syntax unified

third_party/uboost_coro/src/context/asm/make_i386_sysv_elf_gas.S

+7
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@
2424
* *
2525
****************************************************************************************/
2626

27+
#ifdef __x86_64__
28+
#include "make_x86_64_sysv_elf_gas.S"
29+
#else
30+
2731
.file "make_i386_sysv_elf_gas.S"
2832
.text
2933
.globl make_fcontext
34+
.hidden make_fcontext
3035
.align 2
3136
.type make_fcontext,@function
3237
make_fcontext:
@@ -111,3 +116,5 @@ finish:
111116

112117
/* Mark that we don't need executable stack. */
113118
.section .note.GNU-stack,"",%progbits
119+
120+
#endif

third_party/uboost_coro/src/context/asm/make_x86_64_sysv_elf_gas.S

+23-8
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,25 @@
3131
* *
3232
****************************************************************************************/
3333

34-
# if defined __CET__
35-
# include <cet.h>
36-
# define SHSTK_ENABLED (__CET__ & 0x2)
37-
# define BOOST_CONTEXT_SHADOW_STACK (SHSTK_ENABLED && SHADOW_STACK_SYSCALL)
34+
# ifdef __i386__
35+
# include "make_i386_sysv_elf_gas.S"
3836
# else
39-
# define _CET_ENDBR
40-
# endif
37+
# if defined __CET__
38+
# include <cet.h>
39+
# define SHSTK_ENABLED (__CET__ & 0x2)
40+
# define BOOST_CONTEXT_SHADOW_STACK (SHSTK_ENABLED && SHADOW_STACK_SYSCALL)
41+
# else
42+
# define _CET_ENDBR
43+
# endif
4144
.file "make_x86_64_sysv_elf_gas.S"
4245
.text
4346
.globl make_fcontext
47+
.hidden make_fcontext
4448
.type make_fcontext,@function
4549
.align 16
4650
make_fcontext:
4751
_CET_ENDBR
52+
4853
#if BOOST_CONTEXT_SHADOW_STACK
4954
/* the new shadow stack pointer (SSP) */
5055
movq -0x8(%rdi), %r9
@@ -88,7 +93,8 @@ make_fcontext:
8893
movq %rcx, 0x38(%rax)
8994

9095
#if BOOST_CONTEXT_SHADOW_STACK
91-
/* Populate the shadow stack and normal stack */
96+
/* Populate the shadow stack */
97+
9298
/* get original SSP */
9399
rdsspq %r8
94100
/* restore new shadow stack */
@@ -110,6 +116,14 @@ make_fcontext:
110116
/* save the restore token on the new shadow stack. */
111117
saveprevssp
112118

119+
/* now the new shadow stack looks like:
120+
base-> +------------------------------+
121+
| address of "jmp trampoline" |
122+
SSP-> +------------------------------+
123+
| restore token |
124+
+------------------------------+
125+
*/
126+
113127
/* reserve space for the new SSP */
114128
leaq -0x8(%rax), %rax
115129
/* save the new SSP to this fcontext */
@@ -119,9 +133,9 @@ make_fcontext:
119133
ret /* return pointer to context-data */
120134

121135
trampoline:
122-
_CET_ENDBR
123136
/* store return address on stack */
124137
/* fix stack alignment */
138+
_CET_ENDBR
125139
#if BOOST_CONTEXT_SHADOW_STACK
126140
/* save address of "jmp *%rbp" as return-address */
127141
/* on stack and shadow stack */
@@ -145,3 +159,4 @@ finish:
145159

146160
/* Mark that we don't need executable stack. */
147161
.section .note.GNU-stack,"",%progbits
162+
# endif

third_party/uboost_coro/src/context/asm/make_x86_64_sysv_macho_gas.S

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
****************************************************************************************/
2626

2727
.text
28+
.private_extern _make_fcontext
2829
.globl _make_fcontext
2930
.align 8
3031
_make_fcontext:

third_party/uboost_coro/src/context/asm/ontop_arm64_aapcs_elf_gas.S

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
.text
5656
.align 2
5757
.global ontop_fcontext
58+
.hidden ontop_fcontext
5859
.type ontop_fcontext, %function
5960
ontop_fcontext:
6061
# prepare stack for GP + FPU

third_party/uboost_coro/src/context/asm/ontop_arm64_aapcs_macho_gas.S

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
*******************************************************/
5353

5454
.text
55+
.private_extern _ontop_fcontext
5556
.global _ontop_fcontext
5657
.balign 16
5758
_ontop_fcontext:

third_party/uboost_coro/src/context/asm/ontop_arm_aapcs_elf_gas.S

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
.file "ontop_arm_aapcs_elf_gas.S"
4242
.text
4343
.globl ontop_fcontext
44+
.hidden ontop_fcontext
4445
.align 2
4546
.type ontop_fcontext,%function
4647
.syntax unified

third_party/uboost_coro/src/context/asm/ontop_i386_sysv_elf_gas.S

+7
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@
2424
* *
2525
****************************************************************************************/
2626

27+
#ifdef __x86_64__
28+
#include "ontop_x86_64_sysv_elf_gas.S"
29+
#else
30+
2731
.file "ontop_i386_sysv_elf_gas.S"
2832
.text
2933
.globl ontop_fcontext
34+
.hidden ontop_fcontext
3035
.align 2
3136
.type ontop_fcontext,@function
3237
ontop_fcontext:
@@ -98,3 +103,5 @@ ontop_fcontext:
98103

99104
/* Mark that we don't need executable stack. */
100105
.section .note.GNU-stack,"",%progbits
106+
107+
#endif

third_party/uboost_coro/src/context/asm/ontop_x86_64_sysv_elf_gas.S

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
.file "ontop_x86_64_sysv_elf_gas.S"
4141
.text
4242
.globl ontop_fcontext
43+
.hidden ontop_fcontext
4344
.type ontop_fcontext,@function
4445
.align 16
4546
ontop_fcontext:

third_party/uboost_coro/src/context/asm/ontop_x86_64_sysv_macho_gas.S

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
****************************************************************************************/
2626

2727
.text
28+
.private_extern _ontop_fcontext
2829
.globl _ontop_fcontext
2930
.align 8
3031
_ontop_fcontext:

0 commit comments

Comments
 (0)