diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2013-12-20 01:34:09 -0800 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2013-12-20 01:34:09 -0800 |
commit | 3a91332a70abfc777a352c46727f54426c982371 (patch) | |
tree | e2ea6da7b045af8daf749c957b70bdf721864a1e /src/Task.cc | |
parent | 28e250cda01038c91fb9b69206c6f61f24764469 (diff) |
A few more Win32 / VisualStudio fixes.
Diffstat (limited to 'src/Task.cc')
-rw-r--r-- | src/Task.cc | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/src/Task.cc b/src/Task.cc index 9bf7c5b..c97077b 100644 --- a/src/Task.cc +++ b/src/Task.cc @@ -1,8 +1,43 @@ +#ifdef _MSC_VER +#include <windows.h> // for CALLBACK +#endif +#ifndef _WIN32 +#define CALLBACK +#endif + #include "Task.h" #include "TaskMan.h" #include "Exceptions.h" #include "Printer.h" #include "Local.h" +#include "Main.h" + +typedef void (*trampoline_t)(void *); + +static trampoline_t s_trampoline = NULL; + +namespace { + +class RegisterTrampoline : public Balau::AtStart { + public: + RegisterTrampoline() : AtStart(0) { } + void doStart() { + Balau::Task::registerTrampoline(); + } +}; + +static RegisterTrampoline registerTrampoline; + +} + +static void CALLBACK trampoline(void * arg) { + s_trampoline(arg); +} + +void Balau::Task::registerTrampoline() { + AAssert(s_trampoline == NULL, "Don't call registerTrampoline directly"); + s_trampoline = coroutineTrampoline; +} static Balau::LocalTmpl<Balau::Task> localTask; @@ -28,11 +63,11 @@ 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, coroutineTrampoline, this, m_stack, size); + coro_create(&m_ctx, trampoline, this, m_stack, size); #else IAssert(!stack, "We shouldn't allocate stacks with Fibers"); m_stack = NULL; - m_fiber = CreateFiber(size, coroutineTrampoline, this); + m_fiber = CreateFiber(size, trampoline, this); #endif } |