Permalink
Browse files

another go at the WINFIBER stack handling

  • Loading branch information...
1 parent 569883b commit cebed2913aff114d7b1e84c62333a96e0dff2340 @japj japj committed Apr 29, 2012
Showing with 6 additions and 5 deletions.
  1. +5 −4 src/coroutine.cc
  2. +1 −1 src/coroutine.h
View
@@ -70,15 +70,16 @@ void Coroutine::trampoline(void* that) {
pthread_setspecific(ceil_thread_key, that);
#endif
#ifdef USE_WINFIBER
- int tmp;
- static_cast<Coroutine*>(that)->stack_bottom = &tmp; // hack for getting "bottom" of the stack.
+ static_cast<Coroutine*>(that)->stack_top = _AddressOfReturnAddress(); // hack for getting "bottom" of the stack.
#endif
while (true) {
static_cast<Coroutine*>(that)->entry(const_cast<void*>(static_cast<Coroutine*>(that)->arg));
}
}
-Coroutine::Coroutine() : entry(NULL) {
+Coroutine::Coroutine() :
+ entry(NULL),
+ arg(NULL) {
#ifdef USE_CORO
coro_create(&context, NULL, NULL, NULL, NULL);
#endif
@@ -203,7 +204,7 @@ void* Coroutine::bottom() const {
#ifndef USE_WINFIBER
return (char*)&stack[0];
#else
- return stack_bottom;
+ return (void *)(size_t(stack_top) + stack_size);
#endif
}
View
@@ -34,7 +34,7 @@ class Coroutine {
#ifndef USE_WINFIBER
std::vector<char> stack;
#else
- void* stack_bottom;
+ void* stack_top;
#endif
#endif
std::vector<void*> fls_data;

0 comments on commit cebed29

Please sign in to comment.