@@ -22,6 +22,7 @@
#include "lib/graphics.h"
#include "lib/window.h"
#include "lib/decorations.h"
#include "lib/pthread.h"

#define FONT_SIZE 13

@@ -487,40 +488,6 @@ DEFN_SYSCALL0(mousedevice, 33);
DECL_SYSCALL2(dup2, int, int);
DECL_SYSCALL0(mkpipe);

DEFN_SYSCALL3(clone, 30, uintptr_t, uintptr_t, void *);
DEFN_SYSCALL0(gettid, 41);

int clone(uintptr_t,uintptr_t,void*) __attribute__((alias("syscall_clone")));
int gettid() __attribute__((alias("syscall_gettid")));

typedef struct {
uint32_t id;
char * stack;
void * ret_val;
} pthread_t;
typedef unsigned int pthread_attr_t;

#define PTHREAD_STACK_SIZE 10240

int pthread_create(pthread_t * thread, pthread_attr_t * attr, void *(*start_routine)(void *), void * arg) {
char * stack = malloc(PTHREAD_STACK_SIZE);
uintptr_t stack_top = (uintptr_t)stack + PTHREAD_STACK_SIZE;
thread->stack = stack;
thread->id = clone(stack_top, (uintptr_t)start_routine, arg);
return 0;
}

void pthread_exit(void * value) {
/* Perform nice cleanup */
#if 0
/* XXX: LOCK */
free(stack);
/* XXX: Return value!? */
#endif
__asm__ ("jmp 0xFFFFB00F"); /* Force thread exit */
}


uint16_t term_width = 0;
uint16_t term_height = 0;
uint16_t char_width = 8;