The dependency on the ucontext functions has the potential to keep others from successfully using cpu/native for other platforms. As the Contiki multithreading library typically isn't used at all it's not worth the trouble. So we just limit it to Windows and Linux - where it is known to not only build but actually work. If someone needs the Contiki cpu/native multithreading library on another platform he's certainly welcome to add that platform - hopefully by just activating the codepath that we now made exclusive for Linux for his platform.
This commit is contained in:
parent
8edd86da5e
commit
e38f008b9b
@ -40,7 +40,7 @@
|
||||
|
||||
static void *main_fiber;
|
||||
|
||||
#else /* _WIN32 || __CYGWIN__ */
|
||||
#elif defined(__linux)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user