11 #define ON_64BIT_ARCH 1
13 #define ON_64BIT_ARCH 0
36 unsigned long retaddr;
37 unsigned long retaddr2;
48 void (*
function)(
void *),
void *data)
50 struct frame *f = (
struct frame *)&t->stack[MTARCH_STACKSIZE -
sizeof(
struct frame)/
sizeof(
unsigned long)];
53 for(i = 0; i < MTARCH_STACKSIZE; ++i) {
57 memset(f, 0,
sizeof(
struct frame));
58 f->retaddr = (
unsigned long)
function;
59 f->data = (
unsigned long)data;
60 t->sp = (
unsigned long)&f->flags;
62 f->rbp = (
unsigned long)&f->rax;
64 f->ebp = (
unsigned long)&f->eax;
68 static struct mtarch_thread *running_thread;
98 __asm__ (
"movq %0, %%rax\n\t" : :
"m" (running_thread));
100 "movq (%rax), %rbx\n\t"
101 "movq %rsp, (%rax)\n\t"
102 "movq %rbx, %rsp\n\t"
105 __asm__ (
"movl %0, %%eax\n\t" : :
"m" (running_thread));
107 "movl (%eax), %ebx\n\t"
108 "movl %esp, (%eax)\n\t"
109 "movl %ebx, %esp\n\t"
152 running_thread =
NULL;
177 mtarch_stack_usage(
struct mt_thread *t)
180 for(i = 0; i < MTARCH_STACKSIZE; ++i) {
181 if(t->thread.stack[i] != i) {
182 return MTARCH_STACKSIZE - i;