105 lines
4.0 KiB
Diff
105 lines
4.0 KiB
Diff
Subject: boost::context ucontext implementation for e2k
|
|
Bug: 111271
|
|
Tags: e2k
|
|
|
|
diff -rupN a/boost/context/continuation_ucontext.hpp b/boost/context/continuation_ucontext.hpp
|
|
--- a/boost/context/continuation_ucontext.hpp 2023-11-16 14:59:08.850022763 +0300
|
|
+++ b/boost/context/continuation_ucontext.hpp 2023-11-16 15:34:59.644959040 +0300
|
|
@@ -233,6 +233,12 @@ private:
|
|
static void destroy( capture_record * p) noexcept {
|
|
typename std::decay< StackAlloc >::type salloc = std::move( p->salloc_);
|
|
stack_context sctx = p->sctx;
|
|
+
|
|
+ // deallocate the created context
|
|
+#ifdef __e2k__
|
|
+ freecontext_e2k(& p->uctx);
|
|
+#endif
|
|
+
|
|
// deallocate activation record
|
|
p->~capture_record();
|
|
// destroy stack with stack allocator
|
|
@@ -312,9 +318,13 @@ static activation_record * create_contex
|
|
std::uint32_t((integer >> 32) & 0xFFFFFFFF),
|
|
std::uint32_t(integer));
|
|
#else
|
|
+#ifdef __e2k__
|
|
+ ::makecontext_e2k(&record->uctx, (void (*)()) & entry_func<capture_t>, 1, record);
|
|
+#else
|
|
::makecontext(&record->uctx, (void (*)()) & entry_func<capture_t>, 1,
|
|
record);
|
|
#endif
|
|
+#endif
|
|
#if defined(BOOST_USE_ASAN)
|
|
record->stack_bottom = record->uctx.uc_stack.ss_sp;
|
|
record->stack_size = record->uctx.uc_stack.ss_size;
|
|
@@ -355,9 +365,13 @@ static activation_record * create_contex
|
|
std::uint32_t((integer >> 32) & 0xFFFFFFFF),
|
|
std::uint32_t(integer));
|
|
#else
|
|
+#ifdef __e2k__
|
|
+ ::makecontext_e2k(&record->uctx, (void (*)()) & entry_func<capture_t>, 1, record);
|
|
+#else
|
|
::makecontext(&record->uctx, (void (*)()) & entry_func<capture_t>, 1,
|
|
record);
|
|
#endif
|
|
+#endif
|
|
#if defined(BOOST_USE_ASAN)
|
|
record->stack_bottom = record->uctx.uc_stack.ss_sp;
|
|
record->stack_size = record->uctx.uc_stack.ss_size;
|
|
diff -rupN a/boost/context/detail/config.hpp b/boost/context/detail/config.hpp
|
|
--- a/boost/context/detail/config.hpp 2023-11-16 20:34:09.686362792 +0300
|
|
+++ b/boost/context/detail/config.hpp 2023-11-16 20:35:45.193052234 +0300
|
|
@@ -30,7 +30,7 @@
|
|
# define BOOST_CONTEXT_DECL
|
|
#endif
|
|
|
|
-#if ! defined(BOOST_USE_UCONTEXT) && defined(__CYGWIN__)
|
|
+#if ! defined(BOOST_USE_UCONTEXT) && (defined(__CYGWIN__) || defined(__e2k__))
|
|
# define BOOST_USE_UCONTEXT
|
|
#endif
|
|
|
|
diff -rupN a/boost/context/fiber_ucontext.hpp b/boost/context/fiber_ucontext.hpp
|
|
--- a/boost/context/fiber_ucontext.hpp 2023-11-16 14:59:24.476208382 +0300
|
|
+++ b/boost/context/fiber_ucontext.hpp 2023-11-16 15:39:09.653954662 +0300
|
|
@@ -258,6 +258,12 @@ private:
|
|
static void destroy( fiber_capture_record * p) noexcept {
|
|
typename std::decay< StackAlloc >::type salloc = std::move( p->salloc_);
|
|
stack_context sctx = p->sctx;
|
|
+
|
|
+ // deallocate the created context
|
|
+#ifdef __e2k__
|
|
+ freecontext_e2k(& p->uctx);
|
|
+#endif
|
|
+
|
|
// deallocate activation record
|
|
p->~fiber_capture_record();
|
|
// destroy stack with stack allocator
|
|
@@ -342,9 +348,13 @@ static fiber_activation_record * create_
|
|
std::uint32_t((integer >> 32) & 0xFFFFFFFF),
|
|
std::uint32_t(integer));
|
|
#else
|
|
+#ifdef __e2k__
|
|
+ ::makecontext_e2k(&record->uctx, (void (*)()) & fiber_entry_func<capture_t>, 1, record);
|
|
+#else
|
|
::makecontext(&record->uctx, (void (*)()) & fiber_entry_func<capture_t>, 1,
|
|
record);
|
|
#endif
|
|
+#endif
|
|
#if defined(BOOST_USE_ASAN)
|
|
record->stack_bottom = record->uctx.uc_stack.ss_sp;
|
|
record->stack_size = record->uctx.uc_stack.ss_size;
|
|
@@ -393,9 +403,13 @@ static fiber_activation_record * create_
|
|
std::uint32_t((integer >> 32) & 0xFFFFFFFF),
|
|
std::uint32_t(integer));
|
|
#else
|
|
+#ifdef __e2k__
|
|
+ ::makecontext_e2k(&record->uctx, (void (*)()) & fiber_entry_func<capture_t>, 1, record);
|
|
+#else
|
|
::makecontext(&record->uctx, (void (*)()) & fiber_entry_func<capture_t>, 1,
|
|
record);
|
|
#endif
|
|
+#endif
|
|
#if defined(BOOST_USE_ASAN)
|
|
record->stack_bottom = record->uctx.uc_stack.ss_sp;
|
|
record->stack_size = record->uctx.uc_stack.ss_size;
|