121 lines
3.0 KiB
Diff
121 lines
3.0 KiB
Diff
--- a/utils/wvtask.cc.old 2015-09-22 05:49:32.911132004 -0400
|
|
+++ b/utils/wvtask.cc 2015-09-22 06:48:44.627809854 -0400
|
|
@@ -200,7 +200,9 @@
|
|
stacktop = (char *)alloca(0);
|
|
|
|
context_return = 0;
|
|
+#ifdef __GLIBC__
|
|
assert(getcontext(&get_stack_return) == 0);
|
|
+#endif
|
|
if (context_return == 0)
|
|
{
|
|
// initial setup - start the stackmaster() task (never returns!)
|
|
@@ -266,13 +268,17 @@
|
|
state = &old_task->mystate;
|
|
|
|
context_return = 0;
|
|
+#ifdef __GLIBC__
|
|
assert(getcontext(state) == 0);
|
|
+#endif
|
|
int newval = context_return;
|
|
if (newval == 0)
|
|
{
|
|
// saved the state, now run the task.
|
|
context_return = val;
|
|
+#ifdef __GLIBC__
|
|
setcontext(&task.mystate);
|
|
+#endif
|
|
return -1;
|
|
}
|
|
else
|
|
@@ -320,13 +326,17 @@
|
|
#endif
|
|
|
|
context_return = 0;
|
|
+#ifdef __GLIBC__
|
|
assert(getcontext(¤t_task->mystate) == 0);
|
|
+#endif
|
|
int newval = context_return;
|
|
if (newval == 0)
|
|
{
|
|
// saved the task state; now yield to the toplevel.
|
|
context_return = val;
|
|
+#ifdef __GLIBC__
|
|
setcontext(&toplevel);
|
|
+#endif
|
|
return -1;
|
|
}
|
|
else
|
|
@@ -342,7 +352,9 @@
|
|
void WvTaskMan::get_stack(WvTask &task, size_t size)
|
|
{
|
|
context_return = 0;
|
|
+#ifdef __GLIBC__
|
|
assert(getcontext(&get_stack_return) == 0);
|
|
+#endif
|
|
if (context_return == 0)
|
|
{
|
|
assert(magic_number == -WVTASK_MAGIC);
|
|
@@ -372,7 +384,9 @@
|
|
// initial setup
|
|
stack_target = &task;
|
|
context_return = size/1024 + (size%1024 > 0);
|
|
+#ifdef __GLIBC__
|
|
setcontext(&stackmaster_task);
|
|
+#endif
|
|
}
|
|
else
|
|
{
|
|
@@ -410,7 +424,9 @@
|
|
assert(magic_number == -WVTASK_MAGIC);
|
|
|
|
context_return = 0;
|
|
+#ifdef __GLIBC__
|
|
assert(getcontext(&stackmaster_task) == 0);
|
|
+#endif
|
|
val = context_return;
|
|
if (val == 0)
|
|
{
|
|
@@ -420,7 +436,9 @@
|
|
// all current stack allocations) and go back to get_stack
|
|
// (or the constructor, if that's what called us)
|
|
context_return = 1;
|
|
+#ifdef __GLIBC__
|
|
setcontext(&get_stack_return);
|
|
+#endif
|
|
}
|
|
else
|
|
{
|
|
@@ -475,7 +493,9 @@
|
|
|
|
// back here from longjmp; someone wants stack space.
|
|
context_return = 0;
|
|
+#ifdef __GLIBC__
|
|
assert(getcontext(&task->mystate) == 0);
|
|
+#endif
|
|
if (context_return == 0)
|
|
{
|
|
// done the setjmp; that means the target task now has
|
|
@@ -511,7 +531,9 @@
|
|
}
|
|
else
|
|
{
|
|
+#ifdef __GLIBC__
|
|
assert(getcontext(&task->func_call) == 0);
|
|
+#endif
|
|
task->func_call.uc_stack.ss_size = task->stacksize;
|
|
task->func_call.uc_stack.ss_sp = task->stack;
|
|
task->func_call.uc_stack.ss_flags = 0;
|
|
@@ -522,9 +544,11 @@
|
|
(void (*)(void))call_func, 1, task);
|
|
|
|
context_return = 0;
|
|
+#ifdef __GLIBC__
|
|
assert(getcontext(&task->func_return) == 0);
|
|
if (context_return == 0)
|
|
setcontext(&task->func_call);
|
|
+#endif
|
|
}
|
|
|
|
// the task's function terminated.
|