2013-06-03 19:15:09 +02:00
|
|
|
#include <newlib.h>
|
|
|
|
|
|
|
|
void init_reent();
|
|
|
|
|
|
|
|
void __attribute__((noreturn))
|
|
|
|
__thread_startup (int (*entry)(void*), void *param,
|
|
|
|
void *stacklow, void *stackhigh)
|
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
__asm__ __volatile__( // save stack limits
|
2013-07-10 21:26:24 +02:00
|
|
|
"movl %0, %%fs:8 \n\t" // use TLS
|
|
|
|
"movl %1, %%fs:12 \n\t"
|
2013-06-03 19:15:09 +02:00
|
|
|
::"r"(stacklow), "r"(stackhigh));
|
|
|
|
|
|
|
|
init_reent(); // initialize thread reentry structure
|
|
|
|
|
|
|
|
retval = entry(param); // call user thread function
|
|
|
|
|
|
|
|
_exit(retval);
|
|
|
|
};
|
|
|
|
|