diff --git a/headers/private/kernel/arch/thread.h b/headers/private/kernel/arch/thread.h index 787aea24ab..225f001c9b 100644 --- a/headers/private/kernel/arch/thread.h +++ b/headers/private/kernel/arch/thread.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. @@ -19,7 +19,7 @@ extern "C" { status_t arch_thread_init(struct kernel_args *args); status_t arch_team_init_team_struct(struct team *t, bool kernel); status_t arch_thread_init_thread_struct(struct thread *t); -void arch_thread_init_tls(struct thread *thread); +status_t arch_thread_init_tls(struct thread *thread); void arch_thread_context_switch(struct thread *t_from, struct thread *t_to); status_t arch_thread_init_kthread_stack(struct thread *t, int (*start_func)(void), void (*entry_func)(void), void (*exit_func)(void)); void arch_thread_dump_info(void *info); diff --git a/src/system/kernel/arch/ppc/arch_thread.c b/src/system/kernel/arch/ppc/arch_thread.c index 05f844eaac..903b1c37bf 100644 --- a/src/system/kernel/arch/ppc/arch_thread.c +++ b/src/system/kernel/arch/ppc/arch_thread.c @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006, Haiku Inc. All rights reserved. + * Copyright 2003-2007, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -160,10 +160,11 @@ arch_thread_init_kthread_stack(struct thread *t, int (*start_func)(void), } -void +status_t arch_thread_init_tls(struct thread *thread) { -// TODO: Implement! + // TODO: Implement! + return B_OK; } diff --git a/src/system/kernel/arch/x86/arch_thread.c b/src/system/kernel/arch/x86/arch_thread.c index d66f5b8b42..2f115c118f 100644 --- a/src/system/kernel/arch/x86/arch_thread.c +++ b/src/system/kernel/arch/x86/arch_thread.c @@ -1,5 +1,5 @@ /* - * Copyright 2002-2005, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * * Copyright 2001, Travis Geiselbrecht. All rights reserved. @@ -229,17 +229,19 @@ arch_thread_init_kthread_stack(struct thread *t, int (*start_func)(void), void ( * Is called from _create_user_thread_kentry(). */ -void +status_t arch_thread_init_tls(struct thread *thread) { - uint32 *tls; + uint32 tls[TLS_THREAD_ID_SLOT + 1]; + int32 i; thread->user_local_storage = thread->user_stack_base + thread->user_stack_size; - tls = (uint32 *)thread->user_local_storage; + // initialize default TLS fields tls[TLS_BASE_ADDRESS_SLOT] = thread->user_local_storage; tls[TLS_THREAD_ID_SLOT] = thread->id; - tls[TLS_ERRNO_SLOT] = 0; + + return user_memcpy((void *)thread->user_local_storage, tls, sizeof(tls)); }