uml - tls support: hack to make it compile on any host

From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>

Copy the definition of struct user_desc (with another name) to make sure it
compiles.

Btw, the part commented with "XXX Hack" should be avoided - I should name the
defined type "user_desc_t" and define user_desc_t to be either the defined
struct or struct user_desc. I didn't use a typedef because I cannot create with
a typedef a name like "struct um_dup_user_desc" (that's why I suggest using
something like "user_desc_t", without struct).

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Index: linux-2.6.16/arch/um/include/os.h
===================================================================
--- linux-2.6.16.orig/arch/um/include/os.h	2006-03-23 20:28:46.000000000 -0500
+++ linux-2.6.16/arch/um/include/os.h	2006-03-23 20:32:29.000000000 -0500
@@ -10,6 +10,7 @@
 #include "asm/types.h"
 #include "../os/include/file.h"
 #include "sysdep/ptrace.h"
+#include "sysdep/tls.h"
 #include "kern_util.h"
 #include "skas/mm_id.h"
 #include "irq_user.h"
@@ -333,6 +334,6 @@ extern void user_signal(int sig, union u
 
 
 /* tls.c */
-extern int os_set_thread_area(void *data, int pid);
-extern int os_get_thread_area(void *data, int pid);
+extern int os_set_thread_area(struct um_dup_user_desc *info, int pid);
+extern int os_get_thread_area(struct um_dup_user_desc *info, int pid);
 #endif
Index: linux-2.6.16/arch/um/include/sysdep-i386/tls.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.16/arch/um/include/sysdep-i386/tls.h	2006-03-23 20:32:04.000000000 -0500
@@ -0,0 +1,27 @@
+#ifndef _SYSDEP_TLS_H
+#define _SYSDEP_TLS_H
+
+#ifndef __KERNEL__
+
+/* Change name to avoid conflicts with the original one from <asm/ldt.h>*/
+
+struct um_dup_user_desc {
+	unsigned int  entry_number;
+	unsigned long base_addr;
+	unsigned int  limit;
+	unsigned int  seg_32bit:1;
+	unsigned int  contents:2;
+	unsigned int  read_exec_only:1;
+	unsigned int  limit_in_pages:1;
+	unsigned int  seg_not_present:1;
+	unsigned int  useable:1;
+};
+#else /* __KERNEL__ */
+
+/*XXX Hack*/
+#define um_dup_user_desc user_desc
+#include <asm/ldt.h>
+
+#endif
+
+#endif
Index: linux-2.6.16/arch/um/include/sysdep-x86_64/tls.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.16/arch/um/include/sysdep-x86_64/tls.h	2006-03-23 20:32:04.000000000 -0500
@@ -0,0 +1,32 @@
+#ifndef _SYSDEP_TLS_H
+#define _SYSDEP_TLS_H
+
+/* Note on 64bit base and limit is ignored and you cannot set
+   DS/ES/CS not to the default values if you still want to do syscalls. This
+   call is more for 32bit mode therefore. */
+
+#ifndef __KERNEL__
+
+/* Change name to avoid conflicts with the original one from <asm/ldt.h>*/
+
+struct um_dup_user_desc {
+	unsigned int  entry_number;
+	unsigned int  base_addr;
+	unsigned int  limit;
+	unsigned int  seg_32bit:1;
+	unsigned int  contents:2;
+	unsigned int  read_exec_only:1;
+	unsigned int  limit_in_pages:1;
+	unsigned int  seg_not_present:1;
+	unsigned int  useable:1;
+	unsigned int  lm:1;
+};
+#else /* __KERNEL__ */
+
+/*XXX Hack*/
+#define um_dup_user_desc user_desc
+#include <asm/ldt.h>
+
+#endif
+
+#endif
Index: linux-2.6.16/arch/um/os-Linux/tls.c
===================================================================
--- linux-2.6.16.orig/arch/um/os-Linux/tls.c	2006-03-23 20:31:56.000000000 -0500
+++ linux-2.6.16/arch/um/os-Linux/tls.c	2006-03-23 20:32:04.000000000 -0500
@@ -1,6 +1,7 @@
 #include <errno.h>
 #include <sys/ptrace.h>
 #include <asm/ldt.h>
+#include "sysdep/tls.h"
 #include "uml-config.h"
 
 /* TLS support - we basically rely on the host's one.*/
@@ -18,9 +19,8 @@
 #define PTRACE_SET_THREAD_AREA 26
 #endif
 
-int os_set_thread_area(void *data, int pid)
+int os_set_thread_area(struct um_dup_user_desc *info, int pid)
 {
-	struct user_desc *info = data;
 	int ret;
 
 	ret = ptrace(PTRACE_SET_THREAD_AREA, pid, info->entry_number,
@@ -32,9 +32,8 @@ int os_set_thread_area(void *data, int p
 
 #ifdef UML_CONFIG_MODE_SKAS
 
-int os_get_thread_area(void *data, int pid)
+int os_get_thread_area(struct um_dup_user_desc *info, int pid)
 {
-	struct user_desc *info = data;
 	int ret;
 
 	ret = ptrace(PTRACE_GET_THREAD_AREA, pid, info->entry_number,
@@ -49,10 +48,10 @@ int os_get_thread_area(void *data, int p
 #ifdef UML_CONFIG_MODE_TT
 #include "asm/unistd.h"
 
-_syscall1(int, get_thread_area, struct user_desc *, u_info);
-_syscall1(int, set_thread_area, struct user_desc *, u_info);
+_syscall1(int, get_thread_area, struct um_dup_user_desc *, u_info);
+_syscall1(int, set_thread_area, struct um_dup_user_desc *, u_info);
 
-int do_set_thread_area_tt(struct user_desc *info)
+int do_set_thread_area_tt(struct um_dup_user_desc *info)
 {
 	int ret;
 
@@ -63,7 +62,7 @@ int do_set_thread_area_tt(struct user_de
 	return ret;
 }
 
-int do_get_thread_area_tt(struct user_desc *info)
+int do_get_thread_area_tt(struct um_dup_user_desc *info)
 {
 	int ret;
 
