diff --git a/cpu/native/mtarch.c b/cpu/native/mtarch.c index 6121ae8ba..5bb01a0cc 100644 --- a/cpu/native/mtarch.c +++ b/cpu/native/mtarch.c @@ -40,7 +40,7 @@ static void *main_fiber; -#else /* _WIN32 || __CYGWIN__ */ +#elif defined(__linux) #include #include @@ -54,7 +54,7 @@ struct mtarch_t { static ucontext_t main_context; static ucontext_t *running_context; -#endif /* _WIN32 || __CYGWIN__ */ +#endif /* _WIN32 || __CYGWIN__ || __linux */ #include "mtarch.h" @@ -88,7 +88,7 @@ mtarch_start(struct mtarch_thread *thread, thread->mt_thread = CreateFiber(0, (LPFIBER_START_ROUTINE)function, data); -#else /* _WIN32 || __CYGWIN__ */ +#elif defined(__linux) thread->mt_thread = malloc(sizeof(struct mtarch_t)); @@ -118,7 +118,7 @@ mtarch_start(struct mtarch_thread *thread, makecontext(&((struct mtarch_t *)thread->mt_thread)->context, (void (*)(void))function, 1, data); -#endif /* _WIN32 || __CYGWIN__ */ +#endif /* _WIN32 || __CYGWIN__ || __linux */ } /*--------------------------------------------------------------------------*/ void @@ -128,11 +128,11 @@ mtarch_yield(void) SwitchToFiber(main_fiber); -#else /* _WIN32 || __CYGWIN__ */ +#elif defined(__linux) swapcontext(running_context, &main_context); -#endif /* _WIN32 || __CYGWIN__ */ +#endif /* _WIN32 || __CYGWIN__ || __linux */ } /*--------------------------------------------------------------------------*/ void @@ -142,13 +142,13 @@ mtarch_exec(struct mtarch_thread *thread) SwitchToFiber(thread->mt_thread); -#else /* _WIN32 || __CYGWIN__ */ +#elif defined(__linux) running_context = &((struct mtarch_t *)thread->mt_thread)->context; swapcontext(&main_context, running_context); running_context = NULL; -#endif /* _WIN32 || __CYGWIN__ */ +#endif /* _WIN32 || __CYGWIN__ || __linux */ } /*--------------------------------------------------------------------------*/ void @@ -158,11 +158,11 @@ mtarch_stop(struct mtarch_thread *thread) DeleteFiber(thread->mt_thread); -#else /* _WIN32 || __CYGWIN__ */ +#elif defined(linux) || defined(__linux) free(thread->mt_thread); -#endif /* _WIN32 || __CYGWIN__ */ +#endif /* _WIN32 || __CYGWIN__ || __linux */ } /*--------------------------------------------------------------------------*/ void