summaryrefslogtreecommitdiff
path: root/src/Task.cc
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2015-04-04 11:18:21 +0200
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2015-04-04 11:18:21 +0200
commit7b3f9f74fb9bd764c1382849b9d66eb50ccf4e17 (patch)
treefbfc14b788b3d0d0635b54a6e295fefb1c4ab830 /src/Task.cc
parentb384e35959a17fc5b85655184534b96add5904b5 (diff)
Removing libcoro.HEADmaster
Diffstat (limited to 'src/Task.cc')
-rw-r--r--src/Task.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/Task.cc b/src/Task.cc
index fe4d97a..949f6de 100644
--- a/src/Task.cc
+++ b/src/Task.cc
@@ -63,7 +63,12 @@ void Balau::Task::setup(TaskMan * taskMan, void * stack) {
#ifndef _WIN32
IAssert(stack, "Can't setup a coroutine without a stack");
m_stack = stack;
- coro_create(&m_ctx, trampoline, this, m_stack, size);
+ int r = getcontext(&m_ctx);
+ RAssert(r == 0, "Unable to get current context: errno = %i", errno);
+ m_ctx.uc_stack.ss_sp = stack;
+ m_ctx.uc_stack.ss_size = size;
+ m_ctx.uc_link = &m_taskMan->m_returnContext;
+ makecontext(&m_ctx, (void(*)()) trampoline, 1, this);
#else
IAssert(!stack, "We shouldn't allocate stacks with Fibers");
m_stack = NULL;
@@ -156,7 +161,7 @@ void Balau::Task::coroutine() {
}
if (!m_stackless) {
#ifndef _WIN32
- coro_transfer(&m_ctx, &m_taskMan->m_returnContext);
+ swapcontext(&m_ctx, &m_taskMan->m_returnContext);
#else
SwitchToFiber(m_taskMan->m_fiber);
#endif
@@ -174,7 +179,7 @@ void Balau::Task::switchTo() {
coroutine();
} else {
#ifndef _WIN32
- coro_transfer(&m_taskMan->m_returnContext, &m_ctx);
+ swapcontext(&m_taskMan->m_returnContext, &m_ctx);
#else
SwitchToFiber(m_fiber);
#endif
@@ -193,7 +198,7 @@ bool Balau::Task::yield(bool stillRunning) {
return true;
} else {
#ifndef _WIN32
- coro_transfer(&m_ctx, &m_taskMan->m_returnContext);
+ swapcontext(&m_ctx, &m_taskMan->m_returnContext);
#else
SwitchToFiber(m_taskMan->m_fiber);
#endif