Index: arch/amd64/Makefile.inc
===================================================================
--- arch/amd64/Makefile.inc	(revision a84af84b414d895aeccb89cb23f05172505dd693)
+++ arch/amd64/Makefile.inc	(revision 3fa424a9f62d07df3b6495800f6c4694d1504908)
@@ -104,4 +104,5 @@
 	arch/$(ARCH)/src/cpu/cpu.c \
 	arch/$(ARCH)/src/proc/scheduler.c \
+	arch/$(ARCH)/src/proc/thread.c \
 	arch/$(ARCH)/src/userspace.c \
 	arch/$(ARCH)/src/syscall.c \
Index: arch/amd64/src/proc/thread.c
===================================================================
--- arch/amd64/src/proc/thread.c	(revision 3fa424a9f62d07df3b6495800f6c4694d1504908)
+++ arch/amd64/src/proc/thread.c	(revision 3fa424a9f62d07df3b6495800f6c4694d1504908)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2006 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <proc/thread.h>
+
+/** Perform amd64 specific thread initialization.
+ *
+ * @param t Thread to be initialized.
+ */
+void thread_create_arch(thread_t *t)
+{
+	t->tls = 0;
+}
Index: arch/ia32/Makefile.inc
===================================================================
--- arch/ia32/Makefile.inc	(revision a84af84b414d895aeccb89cb23f05172505dd693)
+++ arch/ia32/Makefile.inc	(revision 3fa424a9f62d07df3b6495800f6c4694d1504908)
@@ -109,4 +109,5 @@
 	arch/$(ARCH)/src/asm.S \
 	arch/$(ARCH)/src/proc/scheduler.c \
+	arch/$(ARCH)/src/proc/thread.c \
 	arch/$(ARCH)/src/bios/bios.c \
 	arch/$(ARCH)/src/smp/ap.S \
Index: arch/ia32/src/proc/thread.c
===================================================================
--- arch/ia32/src/proc/thread.c	(revision 3fa424a9f62d07df3b6495800f6c4694d1504908)
+++ arch/ia32/src/proc/thread.c	(revision 3fa424a9f62d07df3b6495800f6c4694d1504908)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2006 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <proc/thread.h>
+
+/** Perform ia32 specific thread initialization.
+ *
+ * @param t Thread to be initialized.
+ */
+void thread_create_arch(thread_t *t)
+{
+	t->tls = 0;
+}
Index: arch/ia64/include/thread.h
===================================================================
--- arch/ia64/include/thread.h	(revision a84af84b414d895aeccb89cb23f05172505dd693)
+++ arch/ia64/include/thread.h	(revision 3fa424a9f62d07df3b6495800f6c4694d1504908)
@@ -32,3 +32,5 @@
 #define ARCH_THREAD_DATA struct { } arch_thread_data;
 
+#define thread_create_arch(t)
+
 #endif
Index: arch/mips32/include/thread.h
===================================================================
--- arch/mips32/include/thread.h	(revision a84af84b414d895aeccb89cb23f05172505dd693)
+++ arch/mips32/include/thread.h	(revision 3fa424a9f62d07df3b6495800f6c4694d1504908)
@@ -34,3 +34,5 @@
 #define ARCH_THREAD_DATA
 
+#define thread_create_arch(t)
+
 #endif
Index: arch/ppc32/include/thread.h
===================================================================
--- arch/ppc32/include/thread.h	(revision a84af84b414d895aeccb89cb23f05172505dd693)
+++ arch/ppc32/include/thread.h	(revision 3fa424a9f62d07df3b6495800f6c4694d1504908)
@@ -32,3 +32,5 @@
 #define ARCH_THREAD_DATA
 
+#define thread_create_arch(t)
+
 #endif
Index: arch/ppc64/include/thread.h
===================================================================
--- arch/ppc64/include/thread.h	(revision a84af84b414d895aeccb89cb23f05172505dd693)
+++ arch/ppc64/include/thread.h	(revision 3fa424a9f62d07df3b6495800f6c4694d1504908)
@@ -32,3 +32,5 @@
 #define ARCH_THREAD_DATA
 
+#define thread_create_arch(t)
+
 #endif
Index: arch/sparc64/include/thread.h
===================================================================
--- arch/sparc64/include/thread.h	(revision a84af84b414d895aeccb89cb23f05172505dd693)
+++ arch/sparc64/include/thread.h	(revision 3fa424a9f62d07df3b6495800f6c4694d1504908)
@@ -32,3 +32,5 @@
 #define ARCH_THREAD_DATA
 
+#define thread_create_arch(t)
+
 #endif
Index: generic/include/proc/thread.h
===================================================================
--- generic/include/proc/thread.h	(revision a84af84b414d895aeccb89cb23f05172505dd693)
+++ generic/include/proc/thread.h	(revision 3fa424a9f62d07df3b6495800f6c4694d1504908)
@@ -138,4 +138,8 @@
 extern void thread_exit(void);
 
+#ifndef thread_create_arch
+extern void thread_create_arch(thread_t *t);
+#endif
+
 extern void thread_sleep(__u32 sec);
 extern void thread_usleep(__u32 usec);
Index: generic/src/proc/thread.c
===================================================================
--- generic/src/proc/thread.c	(revision a84af84b414d895aeccb89cb23f05172505dd693)
+++ generic/src/proc/thread.c	(revision 3fa424a9f62d07df3b6495800f6c4694d1504908)
@@ -264,4 +264,6 @@
 	if (!t)
 		return NULL;
+
+	thread_create_arch(t);
 	
 	/* Not needed, but good for debugging */
