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

To merge in tls/copy-user-desc when merging into stable.

Index: linux-2.6.16/arch/um/include/os.h
===================================================================
--- linux-2.6.16.orig/arch/um/include/os.h	2006-03-23 20:32:29.000000000 -0500
+++ linux-2.6.16/arch/um/include/os.h	2006-03-23 20:32:46.000000000 -0500
@@ -334,6 +334,6 @@ extern void user_signal(int sig, union u
 
 
 /* tls.c */
-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);
+extern int os_set_thread_area(user_desc_t *info, int pid);
+extern int os_get_thread_area(user_desc_t *info, int pid);
 #endif
Index: linux-2.6.16/arch/um/include/sysdep-i386/tls.h
===================================================================
--- linux-2.6.16.orig/arch/um/include/sysdep-i386/tls.h	2006-03-23 20:32:04.000000000 -0500
+++ linux-2.6.16/arch/um/include/sysdep-i386/tls.h	2006-03-23 20:32:46.000000000 -0500
@@ -1,13 +1,15 @@
 #ifndef _SYSDEP_TLS_H
 #define _SYSDEP_TLS_H
 
-#ifndef __KERNEL__
+# ifndef __KERNEL__
 
-/* Change name to avoid conflicts with the original one from <asm/ldt.h>*/
+/* Change name to avoid conflicts with the original one from <asm/ldt.h>, which
+ * may be named user_desc (but in 2.4 and in header matching its API was named
+ * modify_ldt_ldt_s). */
 
-struct um_dup_user_desc {
+typedef struct um_dup_user_desc {
 	unsigned int  entry_number;
-	unsigned long base_addr;
+	unsigned int  base_addr;
 	unsigned int  limit;
 	unsigned int  seg_32bit:1;
 	unsigned int  contents:2;
@@ -15,13 +17,12 @@ struct um_dup_user_desc {
 	unsigned int  limit_in_pages:1;
 	unsigned int  seg_not_present:1;
 	unsigned int  useable:1;
-};
-#else /* __KERNEL__ */
+} user_desc_t;
 
-/*XXX Hack*/
-#define um_dup_user_desc user_desc
-#include <asm/ldt.h>
+# else /* __KERNEL__ */
 
-#endif
+#  include <asm/ldt.h>
+typedef struct user_desc user_desc_t;
 
-#endif
+# endif /* __KERNEL__ */
+#endif /* _SYSDEP_TLS_H */
Index: linux-2.6.16/arch/um/include/sysdep-x86_64/tls.h
===================================================================
--- linux-2.6.16.orig/arch/um/include/sysdep-x86_64/tls.h	2006-03-23 20:32:04.000000000 -0500
+++ linux-2.6.16/arch/um/include/sysdep-x86_64/tls.h	2006-03-23 20:32:46.000000000 -0500
@@ -1,15 +1,13 @@
 #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__
 
-#ifndef __KERNEL__
+/* Change name to avoid conflicts with the original one from <asm/ldt.h>, which
+ * may be named user_desc (but in 2.4 and in header matching its API was named
+ * modify_ldt_ldt_s). */
 
-/* Change name to avoid conflicts with the original one from <asm/ldt.h>*/
-
-struct um_dup_user_desc {
+typedef struct um_dup_user_desc {
 	unsigned int  entry_number;
 	unsigned int  base_addr;
 	unsigned int  limit;
@@ -20,13 +18,12 @@ struct um_dup_user_desc {
 	unsigned int  seg_not_present:1;
 	unsigned int  useable:1;
 	unsigned int  lm:1;
-};
-#else /* __KERNEL__ */
+} user_desc_t;
 
-/*XXX Hack*/
-#define um_dup_user_desc user_desc
-#include <asm/ldt.h>
+# else /* __KERNEL__ */
 
-#endif
+#  include <asm/ldt.h>
+typedef struct user_desc user_desc_t;
 
-#endif
+# endif /* __KERNEL__ */
+#endif /* _SYSDEP_TLS_H */
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:32:04.000000000 -0500
+++ linux-2.6.16/arch/um/os-Linux/tls.c	2006-03-23 20:32:46.000000000 -0500
@@ -19,7 +19,7 @@
 #define PTRACE_SET_THREAD_AREA 26
 #endif
 
-int os_set_thread_area(struct um_dup_user_desc *info, int pid)
+int os_set_thread_area(user_desc_t *info, int pid)
 {
 	int ret;
 
@@ -32,7 +32,7 @@ int os_set_thread_area(struct um_dup_use
 
 #ifdef UML_CONFIG_MODE_SKAS
 
-int os_get_thread_area(struct um_dup_user_desc *info, int pid)
+int os_get_thread_area(user_desc_t *info, int pid)
 {
 	int ret;
 
@@ -48,10 +48,10 @@ int os_get_thread_area(struct um_dup_use
 #ifdef UML_CONFIG_MODE_TT
 #include "asm/unistd.h"
 
-_syscall1(int, get_thread_area, struct um_dup_user_desc *, u_info);
-_syscall1(int, set_thread_area, struct um_dup_user_desc *, u_info);
+_syscall1(int, get_thread_area, user_desc_t *, u_info);
+_syscall1(int, set_thread_area, user_desc_t *, u_info);
 
-int do_set_thread_area_tt(struct um_dup_user_desc *info)
+int do_set_thread_area_tt(user_desc_t *info)
 {
 	int ret;
 
@@ -62,7 +62,7 @@ int do_set_thread_area_tt(struct um_dup_
 	return ret;
 }
 
-int do_get_thread_area_tt(struct um_dup_user_desc *info)
+int do_get_thread_area_tt(user_desc_t *info)
 {
 	int ret;
 
