/uspace/trunk/libc/generic/thread.c |
---|
28,39 → 28,13 |
#include <thread.h> |
#include <libc.h> |
#include <stdlib.h> |
#include <arch/faddr.h> |
#include <kernel/proc/uarg.h> |
void thread_main(uspace_arg_t *uarg) |
{ |
uarg->uspace_thread_function(uarg->uspace_thread_arg); |
free(uarg->uspace_stack); |
free(uarg); |
thread_exit(0); |
} |
typedef void (* voidfunc_t)(void); |
int thread_create(void (* function)(void *), void *arg, char *name) |
int thread_create(void (* function)(void *), void *arg, void *stack, char *name) |
{ |
char *stack; |
uspace_arg_t *uarg; |
stack = (char *) malloc(getpagesize()); |
if (!stack) |
return -1; |
uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t)); |
if (!uarg) { |
free(stack); |
return -1; |
} |
uarg->uspace_entry = (void *) FADDR(__thread_entry); |
uarg->uspace_stack = (void *) stack; |
uarg->uspace_thread_function = (void *) FADDR(function); |
uarg->uspace_thread_arg = arg; |
uarg->uspace_uarg = uarg; |
return __SYSCALL2(SYS_THREAD_CREATE, (sysarg_t) uarg, (sysarg_t) name); |
return __SYSCALL4(SYS_THREAD_CREATE, (sysarg_t) FADDR((voidfunc_t) function), (sysarg_t) arg, (sysarg_t) stack, (sysarg_t) name); |
} |
void thread_exit(int status) |
67,3 → 41,4 |
{ |
__SYSCALL1(SYS_THREAD_EXIT, (sysarg_t) status); |
} |
/uspace/trunk/libc/Makefile |
---|
51,8 → 51,7 |
malloc/malloc.c |
ARCH_SOURCES += \ |
arch/$(ARCH)/src/entry.s \ |
arch/$(ARCH)/src/thread_entry.s |
arch/$(ARCH)/src/entry.s |
GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES))) |
ARCH_OBJECTS := $(addsuffix .o,$(basename $(ARCH_SOURCES))) |
/uspace/trunk/libc/include/thread.h |
---|
29,12 → 29,7 |
#ifndef __LIBC__THREAD_H__ |
#define __LIBC__THREAD_H__ |
#include <kernel/proc/uarg.h> |
int thread_create(void (* function)(void *arg), void *arg, void *stack, char *name); |
void thread_exit(int status); |
extern void __thread_entry(void); |
extern void thread_main(uspace_arg_t *uarg); |
extern int thread_create(void (* function)(void *arg), void *arg, char *name); |
extern void thread_exit(int status); |
#endif |
/uspace/trunk/libc/arch/mips32/src/thread_entry.s |
---|
File deleted |
/uspace/trunk/libc/arch/ia64/src/thread_entry.s |
---|
File deleted |
/uspace/trunk/libc/arch/ia64/src/entry.s |
---|
36,7 → 36,6 |
# |
# |
__entry: |
alloc loc0 = ar.pfs, 0, 1, 2, 0 |
mov r1 = _gp |
{ br.call.sptk.many b0 = main } |
{ br.call.sptk.many b0 = __exit } |
/uspace/trunk/libc/arch/amd64/src/thread_entry.s |
---|
File deleted |
/uspace/trunk/libc/arch/ia32/src/thread_entry.s |
---|
File deleted |