[PATCH] uml: eliminate anonymous union and clean up symlink lossage

This gives a name to the anonymous union introduced in skas-hold-own-ldt,
allowing to build on a wider range of gccs.

It also removes ldt.h, which somehow became real, and replaces it with a
symlink, and creates ldt-x86_64.h as a copy of ldt-i386.h for now.

Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
diff --git a/arch/um/Makefile b/arch/um/Makefile
index e55d32e..1b12fee 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -17,7 +17,7 @@
 
 # Have to precede the include because the included Makefiles reference them.
 SYMLINK_HEADERS := archparam.h system.h sigcontext.h processor.h ptrace.h \
-	module.h vm-flags.h elf.h
+	module.h vm-flags.h elf.h ldt.h
 SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header))
 
 # XXX: The "os" symlink is only used by arch/um/include/os.h, which includes
diff --git a/arch/um/sys-i386/ldt.c b/arch/um/sys-i386/ldt.c
index 6360f1c..17746b4 100644
--- a/arch/um/sys-i386/ldt.c
+++ b/arch/um/sys-i386/ldt.c
@@ -228,7 +228,7 @@
 		size = LDT_ENTRY_SIZE*LDT_DIRECT_ENTRIES;
 		if(size > bytecount)
 			size = bytecount;
-		if(copy_to_user(ptr, ldt->entries, size))
+		if(copy_to_user(ptr, ldt->u.entries, size))
 			err = -EFAULT;
 		bytecount -= size;
 		ptr += size;
@@ -239,7 +239,7 @@
 			size = PAGE_SIZE;
 			if(size > bytecount)
 				size = bytecount;
-			if(copy_to_user(ptr, ldt->pages[i], size)){
+			if(copy_to_user(ptr, ldt->u.pages[i], size)){
 				err = -EFAULT;
 				break;
 			}
@@ -321,10 +321,11 @@
 		    i*LDT_ENTRIES_PER_PAGE <= ldt_info.entry_number;
 		    i++){
 			if(i == 0)
-				memcpy(&entry0, ldt->entries, sizeof(entry0));
-			ldt->pages[i] = (struct ldt_entry *)
-					__get_free_page(GFP_KERNEL|__GFP_ZERO);
-			if(!ldt->pages[i]){
+				memcpy(&entry0, ldt->u.entries,
+				       sizeof(entry0));
+			ldt->u.pages[i] = (struct ldt_entry *)
+				__get_free_page(GFP_KERNEL|__GFP_ZERO);
+			if(!ldt->u.pages[i]){
 				err = -ENOMEM;
 				/* Undo the change in host */
 				memset(&ldt_info, 0, sizeof(ldt_info));
@@ -332,8 +333,9 @@
 				goto out_unlock;
 			}
 			if(i == 0) {
-				memcpy(ldt->pages[0], &entry0, sizeof(entry0));
-				memcpy(ldt->pages[0]+1, ldt->entries+1,
+				memcpy(ldt->u.pages[0], &entry0,
+				       sizeof(entry0));
+				memcpy(ldt->u.pages[0]+1, ldt->u.entries+1,
 				       sizeof(entry0)*(LDT_DIRECT_ENTRIES-1));
 			}
 			ldt->entry_count = (i + 1) * LDT_ENTRIES_PER_PAGE;
@@ -343,9 +345,9 @@
 		ldt->entry_count = ldt_info.entry_number + 1;
 
 	if(ldt->entry_count <= LDT_DIRECT_ENTRIES)
-		ldt_p = ldt->entries + ldt_info.entry_number;
+		ldt_p = ldt->u.entries + ldt_info.entry_number;
 	else
-		ldt_p = ldt->pages[ldt_info.entry_number/LDT_ENTRIES_PER_PAGE] +
+		ldt_p = ldt->u.pages[ldt_info.entry_number/LDT_ENTRIES_PER_PAGE] +
 			ldt_info.entry_number%LDT_ENTRIES_PER_PAGE;
 
 	if(ldt_info.base_addr == 0 && ldt_info.limit == 0 &&
@@ -501,8 +503,8 @@
 		 */
 		down(&from_mm->ldt.semaphore);
 		if(from_mm->ldt.entry_count <= LDT_DIRECT_ENTRIES){
-			memcpy(new_mm->ldt.entries, from_mm->ldt.entries,
-			       sizeof(new_mm->ldt.entries));
+			memcpy(new_mm->ldt.u.entries, from_mm->ldt.u.entries,
+			       sizeof(new_mm->ldt.u.entries));
 		}
 		else{
 			i = from_mm->ldt.entry_count / LDT_ENTRIES_PER_PAGE;
@@ -512,9 +514,10 @@
 					err = -ENOMEM;
 					break;
 				}
-				new_mm->ldt.pages[i] = (struct ldt_entry*)page;
-				memcpy(new_mm->ldt.pages[i],
-				       from_mm->ldt.pages[i], PAGE_SIZE);
+				new_mm->ldt.u.pages[i] =
+					(struct ldt_entry *) page;
+				memcpy(new_mm->ldt.u.pages[i],
+				       from_mm->ldt.u.pages[i], PAGE_SIZE);
 			}
 		}
 		new_mm->ldt.entry_count = from_mm->ldt.entry_count;
@@ -532,7 +535,7 @@
 	if(!ptrace_ldt && mm->ldt.entry_count > LDT_DIRECT_ENTRIES){
 		i = mm->ldt.entry_count / LDT_ENTRIES_PER_PAGE;
 		while(i-- > 0){
-			free_page((long )mm->ldt.pages[i]);
+			free_page((long )mm->ldt.u.pages[i]);
 		}
 	}
 	mm->ldt.entry_count = 0;
diff --git a/include/asm-um/ldt-i386.h b/include/asm-um/ldt-i386.h
index b426629..175722a 100644
--- a/include/asm-um/ldt-i386.h
+++ b/include/asm-um/ldt-i386.h
@@ -35,7 +35,7 @@
 	union {
 		struct ldt_entry * pages[LDT_PAGES_MAX];
 		struct ldt_entry entries[LDT_DIRECT_ENTRIES];
-	};
+	} u;
 } uml_ldt_t;
 
 /*
diff --git a/include/asm-um/ldt.h b/include/asm-um/ldt-x86_64.h
similarity index 95%
rename from include/asm-um/ldt.h
rename to include/asm-um/ldt-x86_64.h
index 4466ff6..175722a 100644
--- a/include/asm-um/ldt.h
+++ b/include/asm-um/ldt-x86_64.h
@@ -35,7 +35,7 @@
 	union {
 		struct ldt_entry * pages[LDT_PAGES_MAX];
 		struct ldt_entry entries[LDT_DIRECT_ENTRIES];
-	};
+	} u;
 } uml_ldt_t;
 
 /*
@@ -67,8 +67,3 @@
 	(info)->useable		== 0	)
 
 #endif
-#ifndef __UM_LDT_H
-#define __UM_LDT_H
-
-#include "asm/arch/ldt.h"
-#endif